Widget:A2Event: Unterschied zwischen den Versionen
Zur Navigation springen
Zur Suche springen
J* (Diskussion | Beiträge) |
J* (Diskussion | Beiträge) |
||
Zeile 2: | Zeile 2: | ||
function wait4a2 (f){ | function wait4a2 (f){ | ||
− | if (document.a2 && document.a2.parser) | + | if (document.a2 && document.a2.parser) { |
f(); | f(); | ||
− | else | + | } else { |
+ | if (window.importJS) { | ||
+ | importJS("MediaWiki:Skin/Projekt:Adventure2/lib.js"); | ||
+ | importJS("MediaWiki:Skin/Projekt:Adventure2/parser.js"); | ||
+ | } | ||
window.setTimeout(function() { wait4a2(f); }, 100); | window.setTimeout(function() { wait4a2(f); }, 100); | ||
+ | } | ||
} | } | ||
wait4a2(function () { | wait4a2(function () { | ||
− | + | ||
− | + | var event = {}; | |
− | + | var error = ""; | |
− | + | try { | |
− | + | var event = window.a2.parser.parse("<!--{$event|escape:'javascript'}-->"); | |
− | + | } catch (e) { | |
− | + | var error = e; | |
− | + | } | |
− | + | ||
− | + | if ("<!--{$action|escape:'javascript'}-->" == "render"){ | |
− | + | if (!error) | |
− | + | a2.registerEventHandler(event); | |
− | + | } else { | |
− | + | $pre = $("<pr"+"e/>"); | |
− | + | $pre.text("<!--{$event|escape:'javascript'}-->\n"+String(error)); | |
− | + | $("#bodyContent").append($pre); | |
− | + | } | |
− | + | }); | |
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
</script> | </script> |
Version vom 7. Juli 2012, 08:17 Uhr
<script type="text/javascript"> function wait4a2 (f){ if (document.a2 && document.a2.parser) { f(); } else { if (window.importJS) { importJS("MediaWiki:Skin/Projekt:Adventure2/lib.js"); importJS("MediaWiki:Skin/Projekt:Adventure2/parser.js"); } window.setTimeout(function() { wait4a2(f); }, 100); } } wait4a2(function () { var event = {}; var error = ""; try { var event = window.a2.parser.parse(""); } catch (e) { var error = e; } if ("" == "render"){ if (!error) a2.registerEventHandler(event); } else { $pre = $("<pr"+"e/>"); $pre.text("\n"+String(error)); $("#bodyContent").append($pre); } }); </script>