-
Notifications
You must be signed in to change notification settings - Fork 81
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #892 from peuter/feature-nosourcecache
re-enable the forceReload URL parameter to add random strings as quer…
- Loading branch information
Showing
2 changed files
with
242 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,224 @@ | ||
(function(){ | ||
|
||
if (!window.qx) window.qx = {}; | ||
|
||
qx.$$start = new Date(); | ||
|
||
if (!qx.$$environment) qx.$$environment = {}; | ||
var envinfo = %{EnvSettings}; | ||
for (var k in envinfo) qx.$$environment[k] = envinfo[k]; | ||
|
||
if (!qx.$$libraries) qx.$$libraries = {}; | ||
var libinfo = %{Libinfo}; | ||
for (var k in libinfo) qx.$$libraries[k] = libinfo[k]; | ||
|
||
qx.$$resources = %{Resources}; | ||
qx.$$translations = %{Translations}; | ||
qx.$$locales = %{Locales}; | ||
qx.$$packageData = {}; | ||
qx.$$g = {} | ||
|
||
qx.$$loader = { | ||
parts : %{Parts}, | ||
packages : %{Packages}, | ||
urisBefore : %{UrisBefore}, | ||
cssBefore : %{CssBefore}, | ||
boot : %{Boot}, | ||
closureParts : %{ClosureParts}, | ||
bootIsInline : %{BootIsInline}, | ||
addNoCacheParam : %{NoCacheParam}, | ||
delayDefer: false, | ||
|
||
decodeUris : function(compressedUris) | ||
{ | ||
var libs = qx.$$libraries; | ||
var uris = []; | ||
for (var i=0; i<compressedUris.length; i++) | ||
{ | ||
var uri = compressedUris[i].split(":"); | ||
var euri; | ||
if (uri.length==2 && uri[0] in libs) { | ||
var prefix = libs[uri[0]].sourceUri; | ||
euri = prefix + "/" + uri[1]; | ||
} else { | ||
euri = compressedUris[i]; | ||
} | ||
if (qx.$$loader.addNoCacheParam) { | ||
euri += "?nocache=" + Math.random(); | ||
} | ||
%{DecodeUrisPlug} | ||
uris.push(euri); | ||
} | ||
return uris; | ||
} | ||
}; | ||
|
||
if (window.location.search.length > 0) { | ||
window.location.search.substring(1).split('&').some(function (qs) { | ||
var parts = qs.split('='); | ||
if (parts[0] === 'forceReload' && (parts[1] === 'true' || parts[1] === '1')) { | ||
qx.$$loader.addNoCacheParam = true; | ||
} | ||
}); | ||
} | ||
|
||
var readyStateValue = {"complete" : true}; | ||
if (document.documentMode && document.documentMode < 10 || | ||
(typeof window.ActiveXObject !== "undefined" && !document.documentMode)) { | ||
readyStateValue["loaded"] = true; | ||
} | ||
|
||
function loadScript(uri, callback) { | ||
var elem = document.createElement("script"); | ||
elem.charset = "utf-8"; | ||
elem.src = uri; | ||
elem.onreadystatechange = elem.onload = function() { | ||
if (!this.readyState || readyStateValue[this.readyState]) { | ||
elem.onreadystatechange = elem.onload = null; | ||
if (typeof callback === "function") { | ||
callback(); | ||
} | ||
} | ||
}; | ||
|
||
if (isLoadParallel) { | ||
elem.async = null; | ||
} | ||
|
||
var head = document.getElementsByTagName("head")[0]; | ||
head.appendChild(elem); | ||
} | ||
|
||
function loadCss(uri) { | ||
var elem = document.createElement("link"); | ||
elem.rel = "stylesheet"; | ||
elem.type= "text/css"; | ||
elem.href= uri; | ||
var head = document.getElementsByTagName("head")[0]; | ||
head.appendChild(elem); | ||
} | ||
|
||
var isWebkit = /AppleWebKit\/([^ ]+)/.test(navigator.userAgent); | ||
var isLoadParallel = 'async' in document.createElement('script'); | ||
|
||
function loadScriptList(list, callback) { | ||
if (list.length == 0) { | ||
callback(); | ||
return; | ||
} | ||
|
||
var item; | ||
|
||
if (isLoadParallel) { | ||
while (list.length) { | ||
item = list.shift(); | ||
if (list.length) { | ||
loadScript(item); | ||
} else { | ||
loadScript(item, callback); | ||
} | ||
} | ||
} else { | ||
item = list.shift(); | ||
loadScript(item, function() { | ||
if (isWebkit) { | ||
// force async, else Safari fails with a "maximum recursion depth exceeded" | ||
window.setTimeout(function() { | ||
loadScriptList(list, callback); | ||
}, 0); | ||
} else { | ||
loadScriptList(list, callback); | ||
} | ||
}); | ||
} | ||
} | ||
|
||
var fireContentLoadedEvent = function() { | ||
qx.$$domReady = true; | ||
document.removeEventListener('DOMContentLoaded', fireContentLoadedEvent, false); | ||
}; | ||
if (document.addEventListener) { | ||
document.addEventListener('DOMContentLoaded', fireContentLoadedEvent, false); | ||
} | ||
|
||
qx.$$loader.importPackageData = function (dataMap, callback) { | ||
if (dataMap["resources"]){ | ||
var resMap = dataMap["resources"]; | ||
for (var k in resMap) qx.$$resources[k] = resMap[k]; | ||
} | ||
if (dataMap["locales"]){ | ||
var locMap = dataMap["locales"]; | ||
var qxlocs = qx.$$locales; | ||
for (var lang in locMap){ | ||
if (!qxlocs[lang]) qxlocs[lang] = locMap[lang]; | ||
else | ||
for (var k in locMap[lang]) qxlocs[lang][k] = locMap[lang][k]; | ||
} | ||
} | ||
if (dataMap["translations"]){ | ||
var trMap = dataMap["translations"]; | ||
var qxtrans = qx.$$translations; | ||
for (var lang in trMap){ | ||
if (!qxtrans[lang]) qxtrans[lang] = trMap[lang]; | ||
else | ||
for (var k in trMap[lang]) qxtrans[lang][k] = trMap[lang][k]; | ||
} | ||
} | ||
if (callback){ | ||
callback(dataMap); | ||
} | ||
} | ||
|
||
qx.$$loader.signalStartup = function () | ||
{ | ||
qx.Bootstrap.executePendingDefers(); | ||
qx.$$loader.delayDefer = false; | ||
qx.$$loader.scriptLoaded = true; | ||
if (window.qx && qx.event && qx.event.handler && qx.event.handler.Application) { | ||
qx.event.handler.Application.onScriptLoaded(); | ||
qx.$$loader.applicationHandlerReady = true; | ||
} else { | ||
qx.$$loader.applicationHandlerReady = false; | ||
} | ||
} | ||
|
||
// Load all stuff | ||
qx.$$loader.init = function(){ | ||
var l=qx.$$loader; | ||
if (l.cssBefore.length>0) { | ||
for (var i=0, m=l.cssBefore.length; i<m; i++) { | ||
loadCss(l.cssBefore[i]); | ||
} | ||
} | ||
if (l.urisBefore.length>0){ | ||
loadScriptList(l.urisBefore, function(){ | ||
l.initUris(); | ||
}); | ||
} else { | ||
l.initUris(); | ||
} | ||
} | ||
|
||
// Load qooxdoo boot stuff | ||
qx.$$loader.initUris = function(){ | ||
var l=qx.$$loader; | ||
var bootPackageHash=l.parts[l.boot][0]; | ||
if (l.bootIsInline){ | ||
l.importPackageData(qx.$$packageData[bootPackageHash]); | ||
l.signalStartup(); | ||
} else { | ||
loadScriptList(l.decodeUris(l.packages[l.parts[l.boot][0]].uris), function(){ | ||
// Opera needs this extra time to parse the scripts | ||
window.setTimeout(function(){ | ||
l.importPackageData(qx.$$packageData[bootPackageHash] || {}); | ||
l.signalStartup(); | ||
}, 0); | ||
}); | ||
} | ||
} | ||
})(); | ||
|
||
%{BootPart} | ||
|
||
qx.$$loader.init(); | ||
|