summary |
shortlog | log |
commit |
commitdiff |
tree
first ⋅ prev ⋅ next
Kai Moritz [Mon, 24 Sep 2012 12:19:28 +0000 (14:19 +0200)]
Simplified code
* Improved method-naming.
* Simplified code in function render_ads(): instead of a recursive call,
a while-loop is used now.
Kai Moritz [Mon, 24 Sep 2012 11:53:40 +0000 (13:53 +0200)]
Minimized JavaScript: keyword "var" only once per scope
Kai Moritz [Thu, 20 Sep 2012 12:42:54 +0000 (14:42 +0200)]
Fix for two errors, that only appear under IE 8
* The Internet-Explorer stumbles, when feeded with JavaScript-code that
includes the leading "<!--", that is often used to deter older browsers
from executing the code. Therefore this markup is filtered from the code
before it is executed via jQuery.globalEval(). The trailing "//-->" does
not have to be filtered, because it is a valid JavaScript-comment.
* A global variable "OA_output" is defined, because IE 8 would complain
loudly otherwise.
Kai Moritz [Wed, 19 Sep 2012 11:00:50 +0000 (13:00 +0200)]
Script-Code is now loaded and executed via $.getScript() and $.globalEval()
The script now utilizes jQuery.getScript(url,callback) and
jQuery.globalEval(code) when loading or executing the code of the detected
script-tags, because these functions work around several issues in older
browsers like IE 8 and Co.
TODO:
* The gloabal variable OA_output, in which the OpenX-scirpt spc places the
fetched banner-codes, is not defined under IE8, when the callback is
called after loading the script. Does the jQuery-function getScript()
not wait for the script, like suggested by the function-name?
Kai Moritz [Tue, 26 Feb 2013 12:58:33 +0000 (13:58 +0100)]
The script overwrites document.write in order to serialize all rendering
The first version of openx.js had sometimes freezed the IE 8. The cause of
this probably was a race-condition while moving the nodes with the banner
to their final destination.
Because of that, the script serializes all modifications of the DOM
strictly now. Implementation-Details:
* The HTML delivered by OpenX is parsed, in order to detect included
script-tags.
* HTML-code is written to the destination-node directly.
* script-tags, that load additional code are loaded via a script-node,
that is appended to the end of the page. The script waits, until the
additional code is loaded, by adding an onload-event to the appended
script-node.
* script-tags with inline-code are executed directly via eval().
* Calls to document.write() in the additional scripts are catched. To
achieve that, openx.js overwrites document.write with its own
implementation, that simply adds the code to an execution-queue, that
is processed, when the onload-event fires or when the eval()-call
returns.
TODO:
* Not tested with IE!
Kai Moritz [Tue, 26 Feb 2013 10:35:54 +0000 (11:35 +0100)]
Initial version of the script for asynchronous ad-fetching from OpenX
openx.js replaces the OpenX-script spcjs.php. It is modified in such a
way, that it can be called at the bottom of the HTML-page, just before the
closing </body>-tag, so that the ads are loaded, when the rendering of the
page is already completed and, thus, do not block the rendering of the
page.
Implementation-details:
* openx.js searches via jQery for DOM-elements, that are marked with the
CSS-class "oa". It fetches banners for all found elements (which banners
are to fetch is encoded in a second CSS-class).
* openx.js takes seperate steps to
1. fetch the banners,
2. render them in the page and
3. show them.
This is necessary, because most of the second-party ad-scripts work
with document.write(), so that the created banners first become
accessable via the DOM, when the script returns.
* Banners are rendert first into a div-block marked with "display:none".
They are moved to their final destination afterwards. This is necessary,
because "document.write()" always writes to the actual position of the
HTML-document, that is the position, where the browser found the
openx.js-script he is just executing. Hence, all ad-scripts that call
"document.write()" itself, would render their banner at the bottom of
the page, albeit the script itself was appended to the right DOM
-element. The Banners are renderd in a hidden div-block, because it has
shown, that some ad-scripts produce errors, when they are moved, so that
the ad was visible in two places afterwards: the div-block at the end of
the page and at the intended position.
TODO:
* Not tested with IE yet!