Hi Tim,
thanks for your code, I will look at it and try to make it officially
working, but I don't know if there is not problem also in Qooxdoo.
Some time ago when I tried qxbuild there was problem that when qooxdoo
detected page load (some kind of load event, unfortunately when only
first script was loaded) qooxdoo tried to create an application (based
on qxsettings). But at his time application script wasn't loaded yet.
This all is related to "manual initialization" already in bugzilla.
I don't know if you are not using older qxbuild, I also figured that
files must be loaded one-by-one
This is my new version, are you used something similar to this?
// qxloader v0.1, (c) Petr Kobalicek 2009, no licence (public domain).
qxloader =
{
//! @brief Main method called to load the scripts
//! @param params {Object} Map of parameters.
load: function(params)
{
// Event handlers
qxloader.$$start = params.start;
qxloader.$$finish = params.finish;
qxloader.$$progress = params.progress;
// Start handler
if (qxloader.$$start) qxloader.$$start();
// Add scripts to document
var scripts = params.scripts;
var i;
for (i = 0; i < scripts.length; i++)
{
if (qxloader.$$done[scripts[i]]) continue;
qxloader.$$tasks.push(scripts[i]);
qxloader.$$nTotal++;
}
qxloader.$$next();
},
$$next: function()
{
if (qxloader.$$tasks.length)
{
var script = qxloader.$$tasks[0];
qxloader.$$tasks.splice(0, 1);
var e = document.createElement("script");
e.setAttribute("src", script);
e.setAttribute("type", "text/javascript");
// Special workaround for IE
if (qxloader.$$IE)
{
e.onreadystatechange = function()
{
if (e.readyState == "loaded" || e.readyState == "complete")
{
e.onreadystatechange = null;
qxloader.$$onLoad(script);
}
}
}
else
{
e.onload = function()
{
qxloader.$$onLoad(script);
}
}
var p = document.getElementsByTagName("head")[0] || document.body;
p.appendChild(e);
}
},
$$onLoad: function(script)
{
// Remove script from pending map
qxloader.$$done[script] = true;
var nLoaded = ++qxloader.$$nLoaded;
// Calculate count of pending scripts
var nTotal = qxloader.$$nTotal;
// Update progress
if (qxloader.$$progress)
{
qxloader.$$progress(nLoaded / nTotal, script);
}
qxloader.$$next();
// If there are no pending scripts, run finish handler
if (nLoaded >= nTotal)
{
if (qxloader.$$finish) qxloader.$$finish();
}
},
$$onFail: function()
{
},
//! @brief Start function.
$$start: null,
//! @brief Called when all scripts are loaded (finish).
$$finish: null,
//! @brief Called when one script was load.
$$progress: null,
//! @brief Count of scripts loaded
$$nLoaded: 0,
//! @brief Count of scripts total
$$nTotal: 0,
//! @brief Scripts that are pending to complete
$$tasks: [],
//! @brief Loaded scripts by qxloader
$$done: {},
//! @brief IE detection for onload workaround
$$IE: !!(window.attachEvent && !window.opera)
};
I will look at your solution, thanks
- Petr
2009/9/10 Tim Demann <[email protected]>:
>
> Hi Petr,
>
> thanks for your response. In the meantime I fixed the IE problem by myself.
> The ScriptLoader can't cope with IE for two reasons:
>
> 1. The onload-event doesn't work for script tags in IE. So the progress bar
> doesn't show any progress and the application doesn't start. That means
> "loading process stucks".
>
> 2. IE doesn't guarantee the loading order. So it can happen, that
> application files are loaded and parsed before the qx-build.js file. In that
> case several execution errors occur.
>
> I replaced the ScriptLoader by my own implementation using the loading
> sequence from the original qooxdoo build result:
>
> ScriptLoaderNew =
> {
> init: function(scripts)
> {
> ScriptLoaderNew.loadScriptList(scripts, function(){
> // Opera needs this extra time to parse the scripts
> window.setTimeout(function(){
> if (window.qx && qx.event && qx.event.handler &&
> qx.event.handler.Application) {
> qx.event.handler.Application.onScriptLoaded();
> }
> }, 0);
> });
> },
>
> loadScriptList: function(list, callback) {
> if (list.length == 0) {
> callback();
> return;
> }
> ScriptLoaderNew.loadScript(list.shift(), function() {
> ScriptLoaderNew.loadScriptList(list, callback);
> });
> },
>
> loadScript: function(uri, callback) {
> var elem = document.createElement("script");
> elem.charset = "utf-8";
> elem.src = uri;
> elem.onreadystatechange = elem.onload = function()
> {
> if (!this.readyState || this.readyState == "loaded" || this.readyState
> == "complete")
> {
> elem.onreadystatechange = elem.onload = null;
> callback();
> }
> };
> var head = document.getElementsByTagName("head")[0];
> head.appendChild(elem);
> }
>
> };
>
> The files are loaded one by one (which is a little bit slower) and detecting
> successful loading for IE is done by the onreadystateevent.
>
> There is no progress bar yet, but adding the progress bar should be easy.
> The solution works for FF and IE.
>
> So that's my workflow now:
> - compiling qx-build.js with qx-build
> - manually removing the qooxdoo application start at the end of qx-build.js
> (qx.event.handler.Application.onScriptLoaded();)
> - loading and calling ScriptLoaderNew in the HTML file:
>
> qxscripts =
> [
> // Qooxdoo
> "./script/qx-build.js",
>
> // Add here your scripts to load
> "./trac/theme/Appearance.js",
> "./trac/Application.js",
> ...
> ];
> ScriptLoaderNew.init(qxscripts);
>
>
>
> Petr Kobalíček wrote:
>>
>>
>> And last thing,
>> you had problem with qx.bom.Vml ? I think I reported this issue
>> half year ago!:(
>>
>>
> The issue is still open.
>
> Cheers,
> Tim
> --
> View this message in context:
> http://www.nabble.com/qxbuild-for-0.8.2-ready-tp22386562p25378289.html
> Sent from the qooxdoo-devel mailing list archive at Nabble.com.
>
>
> ------------------------------------------------------------------------------
> Let Crystal Reports handle the reporting - Free Crystal Reports 2008 30-Day
> trial. Simplify your report design, integration and deployment - and focus on
> what you do best, core application coding. Discover what's new with
> Crystal Reports now. http://p.sf.net/sfu/bobj-july
> _______________________________________________
> qooxdoo-devel mailing list
> [email protected]
> https://lists.sourceforge.net/lists/listinfo/qooxdoo-devel
>
------------------------------------------------------------------------------
Let Crystal Reports handle the reporting - Free Crystal Reports 2008 30-Day
trial. Simplify your report design, integration and deployment - and focus on
what you do best, core application coding. Discover what's new with
Crystal Reports now. http://p.sf.net/sfu/bobj-july
_______________________________________________
qooxdoo-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/qooxdoo-devel