projects
/
openx
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Minimized JavaScript: keyword "var" only once per scope
[openx]
/
openx.js
diff --git
a/openx.js
b/openx.js
index
92c25bc
..
eb85805
100644
(file)
--- a/
openx.js
+++ b/
openx.js
@@
-4,30
+4,35
@@
(function( openx, $, undefined ) {
(function( openx, $, undefined ) {
- var id;
- var node;
+ var
- var count = 0;
- var slots = {};
- var ads = [];
+ id,
+ node,
+
+ count = 0,
+ slots = {},
+ ads = [];
openx.show_ads = function(server, zones) {
openx.show_ads = function(server, zones) {
+ var
+ domain = document.location.protocol == 'https:' ? 'https://' + server + ':8443':'http://' + server,
+ src = domain;
+
document.write = render;
document.writeln = render;
document.write = render;
document.writeln = render;
- var domain = document.location.protocol == 'https:' ? 'https://' + server + ':8443':'http://' + server;
-
- var src = domain;
src += "/www/delivery/spc.php?zones=";
/** Only fetch banners, that are really included in this page */
$('.oa').each(function() {
src += "/www/delivery/spc.php?zones=";
/** Only fetch banners, that are really included in this page */
$('.oa').each(function() {
- var node = $(this);
- for(var name in zones) {
+ var
+ node = $(this),
+ name, id;
+ for(name in zones) {
if (node.hasClass(name)) {
if (node.hasClass(name)) {
-
var
id = 'oa_' + ++count;
+ id = 'oa_' + ++count;
slots[id] = node;
src += escape(id + '=' + zones[name] + "|");
}
slots[id] = node;
src += escape(id + '=' + zones[name] + "|");
}
@@
-72,9
+77,7
@@
// node.append(id + ": " + node.attr('class'));
// node.append(id + ": " + node.attr('class'));
- var result;
- var src;
- var inline;
+ var result, src, inline;
while ((result = /<script/i.exec(OA_output[id])) != null) {
node.append(OA_output[id].slice(0,result.index));
while ((result = /<script/i.exec(OA_output[id])) != null) {
node.append(OA_output[id].slice(0,result.index));
@@
-96,6
+99,11
@@
result = /src\s*=\s*['"]([^'"]*)['"]/i.exec(src);
if (result == null) {
/** script-tag with inline-code: execute inline-code! */
result = /src\s*=\s*['"]([^'"]*)['"]/i.exec(src);
if (result == null) {
/** script-tag with inline-code: execute inline-code! */
+ result = /^\s*<.*$/m.exec(inline);
+ if (result != null) {
+ /** Remove leading HTML-comments, because IE will stumble otherwise */
+ inline = inline.slice(result[0].length,inline.length);
+ }
$.globalEval(inline);
}
else {
$.globalEval(inline);
}
else {
@@
-119,8
+127,11
@@
if (id == undefined)
return;
if (id == undefined)
return;
- var str = "";
- for (var i=0; i < arguments.length; i++)
+ var
+ str = "",
+ i;
+
+ for (i=0; i < arguments.length; i++)
str += arguments[i];
OA_output[id] = str + OA_output[id];
str += arguments[i];
OA_output[id] = str + OA_output[id];
@@
-128,3
+139,5
@@
}
} ( window.openx = window.openx || {}, jQuery ));
}
} ( window.openx = window.openx || {}, jQuery ));
+
+var OA_output = {}; // << Needed, because IE will complain loudly otherwise!