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 LOADER = {
var isDesktopPg = false; params: {},
var basePath = ''; 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 () { (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']; var sourceOptionList = ['local', 'devel', 'stable', 'none'];
...@@ -49,33 +38,15 @@ var basePath = ''; ...@@ -49,33 +38,15 @@ var basePath = '';
return params; return params;
} }
var params = getQueryParams(window.location.search); LOADER.params = getQueryParams(window.location.search);
LOADER.basePath = sourceOptions['stable'];
if (params['portal'] && params['portal'] === '1') var sourceName = LOADER.params['source'];
{
isPortal = true;
}
if (params['desktoppg'] && params['desktoppg'] === '1')
{
isDesktopPg = true;
}
var sourceName = params['source'];
basePath = sourceOptions['stable'];
if (sourceOptionList.indexOf(sourceName) !== -1) if (sourceOptionList.indexOf(sourceName) !== -1)
{ {
basePath = sourceOptions[sourceName]; LOADER.basePath = sourceOptions[sourceName];
} }
var body = document.getElementsByTagName('body')[0]; LOADER.loadFile('main.js');
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);
}
}()); }());
(function () (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. // 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"; var swfVersionStr = "11.1.0";
// To use express install, set to playerProductInstall.swf, otherwise the empty string. // To use express install, set to playerProductInstall.swf, otherwise the empty string.
...@@ -62,7 +106,7 @@ var swfVersionStr = "11.1.0"; ...@@ -62,7 +106,7 @@ var swfVersionStr = "11.1.0";
attributes.name = "flack"; attributes.name = "flack";
attributes.align = "middle"; attributes.align = "middle";
swfobject.embedSWF( swfobject.embedSWF(
basePath + "flack.swf", "flashContent", LOADER.basePath + "flack.swf", "flashContent",
"100%", "100%", "100%", "100%",
swfVersionStr, xiSwfUrlStr, swfVersionStr, xiSwfUrlStr,
flashvars, params, attributes); flashvars, params, attributes);
...@@ -133,11 +177,6 @@ function init(new_flash_id) ...@@ -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(); var clients = new Object();
function make_request(instance, host, path, sendData) function make_request(instance, host, path, sendData)
...@@ -262,8 +301,8 @@ function client_init(host) ...@@ -262,8 +301,8 @@ function client_init(host)
// optional cipher suites in order of preference // optional cipher suites in order of preference
caCerts : serverCerts, caCerts : serverCerts,
cipherSuites: [ cipherSuites: [
tls.CipherSuites.TLS_RSA_WITH_AES_128_CBC_SHA, forge.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_256_CBC_SHA],
verify: function(c, verified, depth, certs) verify: function(c, verified, depth, certs)
{ {
...@@ -289,7 +328,7 @@ function client_init(host) ...@@ -289,7 +328,7 @@ function client_init(host)
arg.getCertificate = function(c, request) { return clientCerts; }; arg.getCertificate = function(c, request) { return clientCerts; };
arg.getPrivateKey = function(c, cert) { return clientKey; }; arg.getPrivateKey = function(c, cert) { return clientKey; };
} }
result = http.createClient(arg); result = forge.http.createClient(arg);
} }
catch(ex) catch(ex)
{ {
...@@ -317,7 +356,7 @@ function client_send(client, path, data, instance) ...@@ -317,7 +356,7 @@ function client_send(client, path, data, instance)
requestArg.headers = [{'Content-Type': 'text/xml'}]; requestArg.headers = [{'Content-Type': 'text/xml'}];
requestArg.body = data; requestArg.body = data;
} }
var request = http.createRequest(requestArg); var request = forge.http.createRequest(requestArg);
client.send({ client.send({
request: request, request: request,
connected: function(e) 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