Commit 0b99e74e authored by Jonathon Duerig's avatar Jonathon Duerig

Pull as much code as possible out of loader.js. Less code == less bugs.

parent bbebaba0
var isPortal = false;
var isDesktopPg = false;
var basePath = '';
var LOADER = {
params: {},
basePath: '',
loadFile: function (relPath) {
var body = document.getElementsByTagName('body')[0];
var script = document.createElement('script');
script.src = this.basePath + relPath;
script.type = 'application/javascript';
script.async = false;
script.defer = false;
body.appendChild(script);
}
};
(function () {
var importList = [
'forge/debug.js',
'forge/util.js',
'forge/log.js',
'forge/socket.js',
'forge/md5.js',
'forge/sha1.js',
'forge/hmac.js',
'forge/aes.js',
'forge/asn1.js',
'forge/jsbn.js',
'forge/prng.js',
'forge/random.js',
'forge/oids.js',
'forge/rsa.js',
'forge/pki.js',
'forge/tls.js',
'forge/tlssocket.js',
'forge/http.js',
'main.js'
];
var sourceOptionList = ['local', 'devel', 'stable', 'none'];
......@@ -49,33 +38,15 @@ var basePath = '';
return params;
}
var params = getQueryParams(window.location.search);
LOADER.params = getQueryParams(window.location.search);
LOADER.basePath = sourceOptions['stable'];
if (params['portal'] && params['portal'] === '1')
{
isPortal = true;
}
if (params['desktoppg'] && params['desktoppg'] === '1')
{
isDesktopPg = true;
}
var sourceName = params['source'];
basePath = sourceOptions['stable'];
var sourceName = LOADER.params['source'];
if (sourceOptionList.indexOf(sourceName) !== -1)
{
basePath = sourceOptions[sourceName];
LOADER.basePath = sourceOptions[sourceName];
}
var body = document.getElementsByTagName('body')[0];
var i = 0;
for (i = 0; i < importList.length; i += 1)
{
var script = document.createElement('script');
script.src = basePath + importList[i];
script.type = 'application/javascript';
script.async = false;
script.defer = false;
body.appendChild(script);
}
LOADER.loadFile('main.js');
}());
(function ()
{
var importList = [
'forge/debug.js',
'forge/util.js',
'forge/log.js',
'forge/socket.js',
'forge/md5.js',
'forge/sha1.js',
'forge/hmac.js',
'forge/aes.js',
'forge/asn1.js',
'forge/jsbn.js',
'forge/prng.js',
'forge/random.js',
'forge/oids.js',
'forge/rsa.js',
'forge/pki.js',
'forge/tls.js',
'forge/tlssocket.js',
'forge/http.js',
];
for (var i = 0; i < importList.length; i += 1)
{
LOADER.loadFile(importList[i]);
}
if (window.isPortal === undefined)
{
window.isPortal = false;
if (LOADER.params['portal'] && LOADER.params['portal'] === '1')
{
window.isPortal = true;
}
}
if (window.isDesktopPg === undefined)
{
window.isDesktopPg = false;
if (LOADER.params['desktoppg'] && LOADER.params['desktoppg'] === '1')
{
window.isDesktopPg = true;
}
}
// For version detection, set to min. required Flash Player version, or 0 (or 0.0.0), for no version detection.
var swfVersionStr = "11.1.0";
// To use express install, set to playerProductInstall.swf, otherwise the empty string.
......@@ -62,7 +106,7 @@ var swfVersionStr = "11.1.0";
attributes.name = "flack";
attributes.align = "middle";
swfobject.embedSWF(
basePath + "flack.swf", "flashContent",
LOADER.basePath + "flack.swf", "flashContent",
"100%", "100%",
swfVersionStr, xiSwfUrlStr,
flashvars, params, attributes);
......@@ -133,11 +177,6 @@ function init(new_flash_id)
}
}
// local aliases
var tls = window.forge.tls;
var http = window.forge.http;
var util = window.forge.util;
var clients = new Object();
function make_request(instance, host, path, sendData)
......@@ -262,8 +301,8 @@ function client_init(host)
// optional cipher suites in order of preference
caCerts : serverCerts,
cipherSuites: [
tls.CipherSuites.TLS_RSA_WITH_AES_128_CBC_SHA,
tls.CipherSuites.TLS_RSA_WITH_AES_256_CBC_SHA],
forge.tls.CipherSuites.TLS_RSA_WITH_AES_128_CBC_SHA,
forge.tls.CipherSuites.TLS_RSA_WITH_AES_256_CBC_SHA],
verify: function(c, verified, depth, certs)
{
......@@ -289,7 +328,7 @@ function client_init(host)
arg.getCertificate = function(c, request) { return clientCerts; };
arg.getPrivateKey = function(c, cert) { return clientKey; };
}
result = http.createClient(arg);
result = forge.http.createClient(arg);
}
catch(ex)
{
......@@ -317,7 +356,7 @@ function client_send(client, path, data, instance)
requestArg.headers = [{'Content-Type': 'text/xml'}];
requestArg.body = data;
}
var request = http.createRequest(requestArg);
var request = forge.http.createRequest(requestArg);
client.send({
request: request,
connected: function(e)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment