Widget:A2Event: Unterschied zwischen den Versionen
Zur Navigation springen
Zur Suche springen
J* (Diskussion | Beiträge) |
J* (Diskussion | Beiträge) |
||
Zeile 36: | Zeile 36: | ||
var lineText = document.createTextNode(prefix + "│ " + lines[i]+"\n"); | var lineText = document.createTextNode(prefix + "│ " + lines[i]+"\n"); | ||
if (error.line && i+1 == error.line){ | if (error.line && i+1 == error.line){ | ||
− | var $ | + | var $node1 = $('<span style="color: red;" />').append(lineText); |
+ | $pre.append($node1); | ||
+ | |||
var c = " │"; | var c = " │"; | ||
while (c.length < error.column+4) | while (c.length < error.column+4) | ||
c += " "; | c += " "; | ||
− | $ | + | $node2 = $('<span style="color: blue;" />'); |
− | $ | + | $node2.append(document.createTextNode(c+"^\n")); |
+ | $node2.append(document.createTextNode(" │ " + error.message + "\n")); | ||
+ | $pre.append($node2); | ||
} else { | } else { | ||
− | + | $pre.append(lineText); | |
− | } | + | } |
− | |||
} | } | ||
Version vom 10. Juli 2012, 20:27 Uhr
<script type="text/javascript"> 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/>"); 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+"^\n"));
$node2.append(document.createTextNode(" │ " + error.message + "\n")); $pre.append($node2); } else { $pre.append(lineText); } }
if ($("#wikiPreview").length) $cont = $("#wikiPreview"); else $cont = $("#bodyContent");
$cont.append($pre);
return; }
if (error) return;
for (var i=0; i<list.length; i++) { var type = list[i][0]; var data = list[i][1];
if (type == "event"){ a2.registerEventHandler(data); } else { //FIXME: not yet implemented: declarations for item, page } } }); }); </script>