Removed base64-encoding from egw_instant_load.html, added code to egw_json which inserts script tags seperately when content is assigned to the innerHTML property

This commit is contained in:
Andreas Stöckel
2011-03-17 18:00:24 +00:00
parent 6a58d3c612
commit e19cc44fcb
3 changed files with 58 additions and 54 deletions

View File

@ -86,6 +86,57 @@ egw_seperateJavaScript = function(_html)
_html.html = html;
}
/**
* Inserts the script tags inside the given html into the dom tree
*/
function egw_insertJS(_html)
{
// Insert each script element seperately
if (_html)
{
var in_pos = -1;
var out_pos = -1;
do {
// Search in and out position
var in_pos = _html.search(/<script/im);
var out_pos = _html.search(/<\/script>/im);
// Copy the text inside the script tags...
if (in_pos > -1 && out_pos > -1)
{
if (out_pos > in_pos)
{
var scriptStart = _html.indexOf("\>", in_pos);
if (scriptStart > in_pos)
{
var script = _html.substring(scriptStart + 1,
out_pos);
try
{
// And insert them as real script tags
var tag = document.createElement("script");
tag.setAttribute("type", "text/javascript");
tag.text = script;
document.getElementsByTagName("head")[0].appendChild(tag);
}
catch (e)
{
if (typeof console != "undefined" && typeof console.log != "undefined")
{
console.log('Error while inserting JS code:', _e);
}
}
}
}
_html = _html.substr(out_pos + 9);
}
} while (in_pos > -1 && out_pos > -1)
}
}
/**
* Returns the top window which contains the current egw_instance, even for popup windows