Widget:A2Event: Unterschied zwischen den Versionen
Zur Navigation springen
Zur Suche springen
J* (Diskussion | Beiträge) (AZ: Die Seite wurde neu angelegt.) |
J* (Diskussion | Beiträge) (Änderung 515760 von J* (Diskussion) rückgängig gemacht.) |
||
| (70 dazwischenliegende Versionen desselben Benutzers werden nicht angezeigt) | |||
| Zeile 1: | Zeile 1: | ||
<script type="text/javascript"> | <script type="text/javascript"> | ||
| − | if ( | + | |
| − | + | $.fn.reverse = [].reverse; | |
| − | + | ||
| − | + | function wait4a2 (f){ | |
| − | + | if (window.a2 && window.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); | ||
| + | } | ||
| + | } | ||
| + | |||
| + | $(function () { | ||
| + | wait4a2(function () { | ||
| + | |||
| + | var text = "<!--{$event|escape:'javascript'}-->"; | ||
| + | var error = ""; | ||
| + | var list = []; | ||
| + | |||
| + | try { | ||
| + | list = window.a2.parser.parse(text); | ||
| + | } catch (e) { | ||
| + | error = e; | ||
| + | } | ||
| + | |||
| + | if ("<!--{$action|escape:'javascript'}-->" != "render"){ | ||
| + | $pre = $("<pr"+"e class='a2listing'/>"); | ||
| + | var lines = text.split("\n"); | ||
| + | for (var i=0; i<lines.length; i++) { | ||
| + | var prefix = String(i+1); | ||
| + | while (prefix.length < 3) | ||
| + | prefix = " "+prefix; | ||
| + | |||
| + | var lineText = document.createTextNode(prefix + "│ " + lines[i]+"\n"); | ||
| + | if (error.line && i+1 == error.line){ | ||
| + | var $node1 = $('<span style="color: red;" />').append(lineText); | ||
| + | $pre.append($node1); | ||
| + | |||
| + | var c = " │"; | ||
| + | while (c.length < error.column+4) | ||
| + | c += " "; | ||
| + | $node2 = $('<span style="color: blue;" />'); | ||
| + | $node2.append(document.createTextNode(c+"↑ ")); | ||
| + | $node2.append(document.createTextNode(error.message + "\n")); | ||
| + | $pre.append($node2); | ||
| + | } else { | ||
| + | $pre.append(lineText); | ||
| + | } | ||
| + | } | ||
| + | |||
| + | |||
| + | var linkedtext = $pre.html().replace(/goto\(([0-9]+)\)/g, "goto(<a href='/index.php/Projekt:Adventure_2.0/$1'>$1</a>)"); | ||
| + | $pre.html(linkedtext); | ||
| + | |||
| + | if ($("#wikiPreview").length) | ||
| + | $cont = $("#wikiPreview"); | ||
| + | else | ||
| + | $cont = $("#bodyContent"); | ||
| + | |||
| + | $cont.append($pre); | ||
| + | |||
| + | $("area").reverse().each(function(){ | ||
| + | var box = a2.ui.getAreaBox(this); | ||
| + | |||
| + | var par = $(".a2page img").parent().last(); | ||
| + | par.css("position","relative"); | ||
| + | par.css("width","550px"); | ||
| + | par.css("height","300px"); | ||
| + | |||
| + | var div = $('<div class="a2regionInfo">'); | ||
| + | var span = $('<span class="a2regionInfoText">'); | ||
| + | span.text(this.hash.substr(1)); | ||
| + | div.css("left",box.x1+"px"); | ||
| + | div.css("top",box.y1+"px"); | ||
| + | div.css("width",(box.x2-box.x1-2)+"px"); | ||
| + | div.css("height",(box.y2-box.y1-2)+"px"); | ||
| + | div.append(span); | ||
| + | par.append(div); | ||
| + | }); | ||
| + | |||
| + | $(".overlay:visible").each(function(){ | ||
| + | $(this).addClass("a2overlayInfoVisible"); | ||
| + | }); | ||
| + | |||
| + | $(".overlay").each(function(){ | ||
| + | $(this).addClass("a2overlayInfo").show(); | ||
| + | }); | ||
| + | |||
| + | $("#catlinks").remove().appendTo("#bodyContent"); | ||
| + | return; | ||
| + | } | ||
| + | |||
| + | // ab jetzt nur noch im Spiel und nicht mehr in der Seitenansicht | ||
| + | |||
| + | if (error) { | ||
| + | if (a2 && a2.debugError) | ||
| + | a2.debugError("Syntaxfehler in <!--{$scope|escape:'javascript'}-->."); | ||
| + | return; | ||
| + | } | ||
| + | |||
| + | for (var i=0; i<list.length; i++) { | ||
| + | |||
| + | var type = list[i][0]; | ||
| + | var data = list[i][1]; | ||
| + | |||
| + | if (type == "event"){ | ||
| + | data.scope = "<!--{$scope|escape:'javascript'}-->"; | ||
| + | a2.registerEventHandler(data); | ||
| + | } else { | ||
| + | a2.virtuals["<!--{$scope|escape:'javascript'}-->"] = data.virt; | ||
| + | } | ||
| + | } | ||
| + | |||
| + | |||
| + | }); | ||
| + | }); | ||
| + | |||
</script> | </script> | ||
Aktuelle Version vom 6. Mai 2013, 11:54 Uhr
<script type="text/javascript">
$.fn.reverse = [].reverse;
function wait4a2 (f){
if (window.a2 && window.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);
}
}
$(function () {
wait4a2(function () {
var text = "";
var error = "";
var list = [];
try {
list = window.a2.parser.parse(text);
} catch (e) {
error = e;
}
if ("" != "render"){
$pre = $("<pr"+"e class='a2listing'/>");
var lines = text.split("\n");
for (var i=0; i<lines.length; i++) {
var prefix = String(i+1);
while (prefix.length < 3)
prefix = " "+prefix;
var lineText = document.createTextNode(prefix + "│ " + lines[i]+"\n");
if (error.line && i+1 == error.line){
var $node1 = $('').append(lineText);
$pre.append($node1);
var c = " │"; while (c.length < error.column+4) c += " ";
$node2 = $('');
$node2.append(document.createTextNode(c+"↑ "));
$node2.append(document.createTextNode(error.message + "\n"));
$pre.append($node2);
} else {
$pre.append(lineText);
}
}
var linkedtext = $pre.html().replace(/goto\(([0-9]+)\)/g, "goto(<a href='/index.php/Projekt:Adventure_2.0/$1'>$1</a>)");
$pre.html(linkedtext);
if ($("#wikiPreview").length)
$cont = $("#wikiPreview");
else
$cont = $("#bodyContent");
$cont.append($pre);
$("area").reverse().each(function(){ var box = a2.ui.getAreaBox(this);
var par = $(".a2page img").parent().last(); par.css("position","relative"); par.css("width","550px"); par.css("height","300px");
var div = $('
');
var span = $('');
span.text(this.hash.substr(1)); div.css("left",box.x1+"px"); div.css("top",box.y1+"px"); div.css("width",(box.x2-box.x1-2)+"px"); div.css("height",(box.y2-box.y1-2)+"px");
div.append(span);
par.append(div); });
$(".overlay:visible").each(function(){
$(this).addClass("a2overlayInfoVisible"); });
$(".overlay").each(function(){
$(this).addClass("a2overlayInfo").show(); });
$("#catlinks").remove().appendTo("#bodyContent");
return;
}
// ab jetzt nur noch im Spiel und nicht mehr in der Seitenansicht
if (error) {
if (a2 && a2.debugError)
a2.debugError("Syntaxfehler in .");
return;
}
for (var i=0; i<list.length; i++) {
var type = list[i][0];
var data = list[i][1];
if (type == "event"){
data.scope = "";
a2.registerEventHandler(data);
} else {
a2.virtuals[""] = data.virt;
}
}
}); }); </script>