|
@@ -778,6 +778,16 @@ ${ smart_unicode(login_modal(request).content) | n,unicode }
|
|
|
loadedCss.push($(this).attr('href'));
|
|
loadedCss.push($(this).attr('href'));
|
|
|
});
|
|
});
|
|
|
|
|
|
|
|
|
|
+ var loadScript = function (scriptUrl) {
|
|
|
|
|
+ var deferred = $.Deferred();
|
|
|
|
|
+ $.get(scriptUrl).done(function (contents) {
|
|
|
|
|
+ loadedJs.push(scriptUrl);
|
|
|
|
|
+ deferred.resolve(contents);
|
|
|
|
|
+ }).fail(function () {
|
|
|
|
|
+ deferred.resolve('');
|
|
|
|
|
+ });
|
|
|
|
|
+ return deferred.promise();
|
|
|
|
|
+ };
|
|
|
|
|
|
|
|
var loadScripts = function (scriptUrls) {
|
|
var loadScripts = function (scriptUrls) {
|
|
|
var promises = [];
|
|
var promises = [];
|
|
@@ -786,15 +796,7 @@ ${ smart_unicode(login_modal(request).content) | n,unicode }
|
|
|
if (loadedJs.indexOf(scriptUrl) !== -1) {
|
|
if (loadedJs.indexOf(scriptUrl) !== -1) {
|
|
|
continue;
|
|
continue;
|
|
|
}
|
|
}
|
|
|
- var loadDeferred = $.Deferred();
|
|
|
|
|
- promises.push(loadDeferred.promise());
|
|
|
|
|
- loadDeferred.always(function () {
|
|
|
|
|
- loadedJs.push(scriptUrl);
|
|
|
|
|
- });
|
|
|
|
|
- $.get(scriptUrl).done(loadDeferred.resolve).fail(function () {
|
|
|
|
|
- // Ignore failed ones, they'll still appear as failed in the network tab as before
|
|
|
|
|
- loadDeferred.resolve('');
|
|
|
|
|
- });
|
|
|
|
|
|
|
+ promises.push(loadScript(scriptUrl));
|
|
|
}
|
|
}
|
|
|
return promises;
|
|
return promises;
|
|
|
};
|
|
};
|
|
@@ -827,8 +829,6 @@ ${ smart_unicode(login_modal(request).content) | n,unicode }
|
|
|
}).toArray();
|
|
}).toArray();
|
|
|
$allScripts.remove();
|
|
$allScripts.remove();
|
|
|
|
|
|
|
|
- var scriptPromises = loadScripts(scriptsToLoad);
|
|
|
|
|
-
|
|
|
|
|
$rawHtml.find('link[href]').each(function () {
|
|
$rawHtml.find('link[href]').each(function () {
|
|
|
addGlobalCss($(this)); // Also removes the elements;
|
|
addGlobalCss($(this)); // Also removes the elements;
|
|
|
});
|
|
});
|
|
@@ -850,13 +850,15 @@ ${ smart_unicode(login_modal(request).content) | n,unicode }
|
|
|
|
|
|
|
|
$rawHtml.unwrap('<span>');
|
|
$rawHtml.unwrap('<span>');
|
|
|
|
|
|
|
|
|
|
+ var scriptPromises = loadScripts(scriptsToLoad);
|
|
|
|
|
+
|
|
|
var evalScriptSync = function () {
|
|
var evalScriptSync = function () {
|
|
|
if (scriptPromises.length) {
|
|
if (scriptPromises.length) {
|
|
|
// Evaluate the scripts in the order they were defined in the page
|
|
// Evaluate the scripts in the order they were defined in the page
|
|
|
var nextScriptPromise = scriptPromises.shift();
|
|
var nextScriptPromise = scriptPromises.shift();
|
|
|
nextScriptPromise.done(function (contents) {
|
|
nextScriptPromise.done(function (contents) {
|
|
|
if (contents) {
|
|
if (contents) {
|
|
|
- eval(contents);
|
|
|
|
|
|
|
+ new Function(contents)();
|
|
|
}
|
|
}
|
|
|
evalScriptSync();
|
|
evalScriptSync();
|
|
|
});
|
|
});
|