Widget:A2debugger

aus Kamelopedia, der wüsten Enzyklopädie
Zur Navigation springen Zur Suche springen
<form>
  <select id="a2dbgSwitch">
    <option value="a2dbgState">Spielstand</option>
    <option value="a2dbgEventLog">Event-Log</option>
  </select>
</form>
    <form id="a2dbgGotoForm">
      <input type="text" id="a2dbgGoto" maxlength="3" style="width: 4em;"/><input type="submit" value="Los!" id="a2dbgGotoBtn">
    </form>
    <form id="a2dbgItemForm">
      <textarea id="a2dbgItems" style="width:80%; height: 200px;"></textarea><input type="submit" value="Setze!" id="a2dbgItemBtn">
    </form>


<script type="text/javascript">
$("#a2dbgSwitch").click(function(){
  $(".a2dbgWindow").hide();
  $("#"+$(this).val()).show();
  $("#a2dbgBottom:visible").scrollTop($("#a2dbgBottom")[0].scrollHeight);
});

$("#a2dbgSwitch").click();
$("#a2dbgGotoForm").submit( function(){
  try {
     a2.clearEventChain();
     a2.loadPage(parseInt($("#a2dbgGoto").val()));
  }
  catch (err) {
     a2.log(err);
  }
  return false;
});
$("#a2dbgItemForm").submit( function(){
  try {
     var d = "";
     var items = $("#a2dbgItems").val().split(/[\s\r\n]+/);
     for (var i=0; i<items.length; i++)
       if (!items[i].match(/^[\s\r\n]*$/))
          d += "|" + items[i]
     a2.stateDecode(a2.cpage+d);
  }
  catch (err) {
     a2.log(err);
  }
  return false;
});
</script>