mirror of
https://github.com/radareorg/radare2.git
synced 2024-12-28 16:53:36 +00:00
3 lines
22 KiB
JavaScript
3 lines
22 KiB
JavaScript
function _(e){return document.getElementById(e)}var Tiled=function(e){var t=document.getElementById(e);this.curframe=void 0,this.frames=[];var r=3,s=0;this.update_size=function(e,t){r=e||window.innerWidth,s=t||window.innerHeight},this.max_width=function(e){t=this.curframe[1];for(var t in this.frames)for(var r in this.frames[t])this.frames[t][r].mw=!1;this.curframe[0].mw=e},this.max_height=function(e){if(this.curframe){var t=this.curframe[1];for(var r in this.frames[t])this.frames[t][r].mh=!1;this.curframe[0].mh=e}},this.ctr2=0,this.tile=function(){if(this.maximize&&this.curframe){var e=0,t=r,i=s-(f=20);return(l=this.curframe[0]).obj.style.position="absolute",l.obj.style.top=f,l.obj.style.left=e,l.obj.style.zIndex=99999+this.ctr2++,l.obj.style.width=t,l.obj.style.height=i,void(l.update&&l.update(l.obj))}var a=this.frames.length,e=0;for(var h in this.frames){var n=this.frames[h].length,f=20,a=this.frames.length,m=function(e,t){if(e.frames[t])for(var r in e.frames[t]){var s=e.frames[t][r];if(s&&(s.mh||s.selected))return!0}return!1}(this,h),t=r/a,i=(s-20)/n;this.curframe&&this.frames.length>1&&(t=h==this.curframe[1]?r/2:r/2/(a-1));for(var c in this.frames[h]){var l=this.frames[h][c];i=m&&this.frames[h].length>1?l.selected?(s-20)/n*1.7:(s-1.7*(s-20)/n)/(n-1):(s-20)/n,i|=0,l.obj.style.position="absolute",l.obj.style.top=f,l.obj.style.left=e,l.obj.style.width=t,0==c&&(i-=22),l.obj.style.height=i,l.update&&l.update(l.obj),f+=i}e+=t}},this.num=0,this.defname=function(e){return e=e||"noname",this.num++,e+"_"+this.num},this.unselect_frames=function(){for(var e in this.frames)for(var t in this.frames[e])this.frames[e][t].selected=!1},this.move_frame=function(e){if(this.curframe){var t=this.curframe[1];switch(e){case"up":case"down":break;case"right":if(t==this.frames.length-1)return!1;alert("moveright Col is "+t);var r,s,i;r=this.frames[t],i=(s=this.frames.splice(t)).splice(1).slice(1),alert("AAAA "+this.frames.length),alert("C "+s.length),alert("D "+i.length),r&&this.frames.push(r),s.length>0&&(alert("SET COL "+this.frames.length),this.frames.push(s));for(var a=0;a<i.length;a++)this.frames.push(i[a]);this.tile()}}},this.other_frame=function(e){if(this.curframe)switch(e){case"up":r=+this.curframe[1];if((s=+this.curframe[2])>0){s--;var t=this.frames[r][s];this.select_frame(t.name),this.curframe=[t,r,s],this.run()}break;case"down":var r=+this.curframe[1],s=+this.curframe[2];s<=this.frames[r].length&&(s++,(t=this.frames[r][s])&&(this.select_frame(t.name),this.curframe=[t,r,s],this.run()));break;case"left":(r=+this.curframe[1])>0&&(r--,(t=this.frames[r][0])&&(this.select_frame(t.name),this.curframe=[t,r,0],this.run()));break;case"right":(r=+this.curframe[1])>=this.frames.length-1&&(r=-1),r<this.frames.length&&(r++,(t=this.frames[r])&&(t=t[0]),t&&(this.select_frame(t.name),this.curframe=[t,r,0],this.run()))}},this.select_frame=function(e){var t=void 0;!e&&this.curframe&&(e=this.curframe[0].name),this.oldframe=this.curframe;for(var r in this.frames)for(var s in this.frames[r]){var i=this.frames[r][s];i.name===e?(_("frame_"+i.name).style.backgroundColor="black",i.selected=!0,i.mw=!0,t=this.curframe=[i,r,s]):(_("frame_"+i.name).style.backgroundColor="#c0c0c0",i.mw=!1,i.selected=!1)}return this.tile(),t},this.new_frame=function(e,r,s,i,a){var h={};h.name=e=e||this.defname();var n=document.createElement("div");n.className="frame_title",n.id="frame_"+e;var f=document.createElement("div");f.style.backgroundColor="#c0c0c0",f.style["overflow-x"]="hidden";var m=document.createElement("a");m.innerHTML="[x]",m.href="#",function(e,t){m.onclick=function(){e.del_frame(t)}}(this,e),f.appendChild(m);var c=document.createElement("a");c.innerHTML="[r]",c.href="#",c.ival=null;var l=this;c.onclick=function(){c.ival?(clearInterval(c.ival),c.ival=null,c.innerHTML="[r]"):(c.innerHTML="[R]",a&&(a(l,h),c.ival=setInterval(function(){a(l,h)},1e3)))},f.appendChild(c),(v=document.createElement("a")).innerHTML="[@] ",v.href="#",v.onclick=h.refresh=function(){a&&a(l,h)},f.appendChild(v),(d=document.createElement("a")).innerHTML=e,d.href="#",f.appendChild(d),n.appendChild(f),function(){d.onclick=function(){prompt("title")}}(),"string"==typeof s&&(i=s,s=void 0),h.update=s,h.obj=document.createElement("div");n.outerHTML;switch(h.obj.className="frame",h.obj.id=h.name,h.obj.appendChild(n),(m=document.createElement("p")).innerHTML=r,h.obj.appendChild(n),h.obj.appendChild(m),t.appendChild(h.obj),i){case"bottom":var o=this.curframe?this.curframe[1]:0;this.frames.push([h]),this.frames[o].push(this.frames.pop()[0]);break;case"right":var u=this.curframe?this.curframe[1]:0,d=this.frames.slice(0,u+1),v=this.frames.slice(u+1);d.push([h]),this.frames=d.concat(v);break;default:this.frames.push([h])}return this.select_frame(e),a&&a(l,h),function(e,t){_("frame_"+t).onmouseup=function(){e.select_frame(t)||alert("Cant find frame for "+t)}}(this,e),h},this.update_all=function(){for(var e in this.frames)for(var t in this.frames[e])this.frames[e][t].refresh()},this.del_frame=function(e){var r=void 0;!e&&this.curframe&&(e=this.curframe[0].name);for(var s in this.frames)for(var i in this.frames[s]){var a=this.frames[s][i];if(a.name==e){if(a!=this.curframe[0])return;if(this.curframe[0]!=this.oldframe[0])return;if(this.frames[s].length>1)for(var h=this.frames[s].splice(i).slice(1),n=0;n<h.length;n++)this.frames[s].push(h[n]);else for(var h=this.frames.splice(s).slice(1),n=0;n<h.length;n++)this.frames.push(h[n]);if(t.removeChild(a.obj),!r)for(var s in this.frames)for(var i in this.frames[s]){r=this.frames[s][i];break}return this.select_frame(r),a}r=a.name}this.tile()},this.run=function(){this.update_size(),t.style.position="absolute",t.style.top=0,t.style.left=0,t.style.width=r,t.style.height=s,t.style.backgroundColor="#202020",this.tile()}};
|
|
function isFirefoxOS(){return"undefined"!=typeof locationbar&&!locationbar.visible&&navigator.userAgent.indexOf("Firefox")>-1&&navigator.userAgent.indexOf("Mobile")>-1&&"mozApps"in navigator}function asyncLoop(r,n,e){var t=0,o=!1,a={next:function(){o||(t<r?(t++,n(a)):(o=!0,e()))},iteration:function(){return t-1},break:function(){o=!0,e()}};return a.next(),a}function dump(r){var n="";for(var e in r)n+=e+"\n";alert(n)}function objtostr(r){var n="";for(var e in r)n+=e+": "+r[e]+",\n";return n}function Ajax(r,n,e,t,o){if("undefined"==typeof XMLHttpRequest)return!1;if("fake"==r2.asyncMode)return t&&t("{}"),!0;if("sasync"==r2.asyncMode&&(console.log("async waiting"),ajax_in_process))return setTimeout(function(){Ajax(r,n,e,t)},100),!1;a=void 0;if(isFirefoxOS())a=new XMLHttpRequest({mozSystem:!0});else var a=new XMLHttpRequest;if(!a)return!1;ajax_in_process=!0,"sync"==r2.asyncMode?a.open(r,n,!1):a.open(r,n,!0),a.setRequestHeader("Accept","text/plain"),a.setRequestHeader("Content-Type","application/x-ww-form-urlencoded; charset=UTF-8"),a.onreadystatechange=function(){ajax_in_process=!1,200==a.status?t?t(a.responseText):console.error("missing ajax callback"):((o||r2.err)("connection refused"),console.error("ajax "+a.status))};try{a.send(e)}catch(r){"NetworkError"==r.name&&(o||r2.err)("connection error")}return!0}function _internal_cmd(r,n,e){if("undefined"!=typeof r2cmd&&(hascmd=r2cmd),hascmd)return"undefined"!=typeof r2plugin?n(r2cmd(r)):hascmd(r,n);Ajax("GET",r2.root+"/cmd/"+encodeURI(r),"",function(r){n&&n(r)},e)}var r2={},backward=!1,next_curoff=0,next_lastoff=0,prev_curoff=0,prev_lastoff=0,hascmd=!1;r2.asyncMode="sync",r2.err=null,isFirefoxOS()?r2.root="http://cloud.radare.org":r2.root="","undefined"!=typeof module&&(module.exports=function(r){return hascmd="function"==typeof r?r:r.cmd,r2}),r2.project_name="",r2.plugin=function(){console.error("r2.plugin is not available in this environment")};try{r2plugin&&(r2.plugin=r2plugin)}catch(r){}r2.root="",r2.analAll=function(){r2.cmd("aa",function(){})},r2.analOp=function(r,n){r2.cmd("aoj 1 @ "+r,function(r){try{n(JSON.parse(r)[0])}catch(e){console.error(e),n(r)}})},r2.varMap=[],r2.argMap=[];var ajax_in_process=!1;r2.assemble=function(r,n,e){var t=r?"@"+r:"";r2.cmd('"pa '+n+'"'+t,e)},r2.disassemble=function(r,n,e){var t="pi @b:"+n+(r?"@"+r:"");r2.cmd(t,e)},r2.get_hexdump=function(r,n,e){r2.cmd("px "+n+"@"+r,e)},r2.get_disasm=function(r,n,e){r2.cmd("pD "+n+"@"+r,e)},r2.get_disasm_before=function(r,n,e){var t=[];r2.cmd("pdj -"+n+"@"+r+"|",function(r){t=JSON.parse(r)}),e(t)},r2.get_disasm_after=function(r,n,e){var t=[];r2.cmd("pdj "+n+"@"+r+"|",function(r){t=JSON.parse(r)}),e(t)},r2.get_disasm_before_after=function(r,n,e,t){var o=[],a=[];r2.cmd("pdj "+n+" @"+r+"|",function(r){o=JSON.parse(r)}),r2.cmd("pdj "+e+"@"+r+"|",function(r){a=JSON.parse(r)}),t(o.concat(a))},r2.Config=function(r,n,e){return"function"!=typeof n&&n?r2.cmd("e "+r+"="+n,e):r2.cmd("e "+r+"|",e||n),r2},r2.sections={},r2.load_mmap=function(){r2.cmdj("iSj|",function(r){void 0!==r&&null!==r&&(r2.sections=r)})},r2.get_address_type=function(r){var n=parseInt(r,16);for(var e in r2.sections)if(n>=r2.sections[e].addr&&n<r2.sections[e].addr+r2.sections[e].size)return r2.sections[e].flags.indexOf("x")>-1?"instruction":"memory";return""},r2.settings={},r2.load_settings=function(){r2.cmd("e asm.arch",function(r){r2.settings["asm.arch"]=r.trim()}),r2.cmd("e asm.bits",function(r){r2.settings["asm.bits"]=r.trim()}),r2.cmd("e asm.bytes",function(r){r2.settings["asm.bytes"]=toBoolean(r.trim())}),r2.cmd("e asm.flags",function(r){r2.settings["asm.flags"]=toBoolean(r.trim())}),r2.cmd("e asm.offset",function(r){r2.settings["asm.offset"]=toBoolean(r.trim())}),r2.cmd("e asm.lines",function(r){r2.settings["asm.lines"]=toBoolean(r.trim())}),r2.cmd("e asm.xrefs",function(r){r2.settings["asm.xrefs"]=toBoolean(r.trim())}),r2.cmd("e asm.cmtright",function(r){r2.settings["asm.cmtright"]=toBoolean(r.trim())}),r2.cmd("e asm.pseudo",function(r){r2.settings["asm.pseudo"]=toBoolean(r.trim())})},r2.flags={},r2.update_flags=function(){r2.cmd("fs *;fj|",function(r){var n=JSON.parse(r);if(void 0!==n&&null!==n){r2.flags={};for(var e in n){var t="0x"+n[e].offset.toString(16);if((t=address_canonicalize(t))in r2.flags){var o=r2.flags[t];o[o.length]={name:n[e].name,size:n[e].size},r2.flags[t]=o}else r2.flags[t]=[{name:n[e].name,size:n[e].size}]}}})},r2.get_flag_address=function(r){for(var n in r2.flags)for(var e in r2.flags[n])if(r==r2.flags[n][e].name)return n;return null},r2.get_flag_names=function(r){var n=[];for(var e in r2.flags[r])n[n.length]=r2.flags[r][e].name;return n},r2.set_flag_space=function(r,n){r2.cmd("fs "+r,n)},r2.get_flags=function(r){r2.cmd("fj|",function(n){r(n?JSON.parse(n):[])})},r2.get_opcodes=function(r,n,e){r2.cmd("pdj @"+r+"!"+n+"|",function(r){e(JSON.parse(r))})},r2.get_bytes=function(r,n,e){r2.cmd("pcj @"+r+"!"+n+"|",function(r){e(JSON.parse(r))})},r2.asm_config={},r2.store_asm_config=function(){config={},r2.cmd("e",function(r){conf=r.split("\n");for(var n in conf){var e=conf[n].split(" ");3==e.length&&0==e[0].trim().indexOf("asm.")&&(config[e[0].trim()]=e[2].trim())}r2.asm_config=config})},r2.restore_asm_config=function(){cmd="";for(var r in r2.asm_config)cmd+="e "+r+"="+r2.asm_config[r]+";";r2.cmd(cmd,function(){})},r2.get_info=function(r){r2.cmd("ij|",function(n){r(JSON.parse(n))})},r2.bin_relocs=function(r){r2.cmd("irj|",function(n){r(JSON.parse(n))})},r2.bin_imports=function(r){r2.cmd("iij|",function(n){r(JSON.parse(n))})},r2.bin_symbols=function(r){r2.cmd("isj|",function(n){r(JSON.parse(n))})},r2.bin_sections=function(r){r2.cmd("iSj|",function(n){r(JSON.parse(n))})},r2.cmds=function(r,n){function e(){void 0!=t&&0!=r.length&&(t=r[0],r=r.splice(1),r2.cmd(t,e),n&&n())}if(0!=r.length){var t=r[0];r=r.splice(1),r2.cmd(t,e)}},r2.cmd=function(r,n,e){if(Array.isArray(r)){var t=[],o=0;asyncLoop(r.length,function(n){_internal_cmd(r[o],function(r){o=n.iteration(),t[o]=r.replace(/\n$/,""),o++,n.next()},e)},function(){n(t)})}else _internal_cmd(r,n,e)},r2.cmdj=function(r,n){r2.cmd(r,function(r){try{n(JSON.parse(r))}catch(r){n(null)}})},r2.alive=function(r){r2.cmd("b",function(n){n&&n.length(),r&&r(n)})},r2.getTextLogger=function(r){return"object"!=typeof r&&(r={}),r.last=0,r.events={},r.interval=null,r2.cmd("Tl",function(n){r.last=+n}),r.load=function(n){r2.cmd('"Tj '+(r.last+1)+'"',function(r){n&&n(JSON.parse(r))})},r.clear=function(r){r2.cmd("T-",r)},r.send=function(r,n){r2.cmd('"T '+r+'"',n)},r.refresh=function(n){r.load(function(e){for(var t=0;t<e.length;t++){var o=e[t];r.events.message({id:o[0],text:o[1]}),o[0]>r.last&&(r.last=o[0])}n&&n()})},r.autorefresh=function(n){function e(){return r.refresh(function(){}),"Logs"===r2ui.selected_panel?setTimeout(e,1e3*n):console.log("Not in logs :("),!0}n?r.interval=setTimeout(e,1e3*n):r.interval&&r.interval.stop()},r.on=function(n,e){return r.events[n]=e,r},r},r2.filter_asm=function(r,n){var e=backward?prev_curoff:next_curoff,t=backward?prev_lastoff:next_lastoff,o=r.split(/\n/g);r2.cmd("s",function(r){e=r});for(c=o.length-1;c>0;c--){var a=o[c].match(/0x([a-fA-F0-9]+)/);if(a&&a.length>0){t=a[0].replace(/:/g,"");break}}if("afl"==n){for(var i="",c=0;c<o.length;c++)i+=(s=o[c].replace(/\ +/g," ").split(/ /g))[0]+" "+s[3]+"\n";r=i}else if("f"==n[0]){if("s"==n[1]){for(var i="",c=0;c<o.length;c++){var s=o[c].replace(/\ +/g," ").split(/ /g),f="*"==s[1]?"*":" ",l=s[2]?s[2]:s[1];l&&(i+=s[0]+" "+f+" <a href=\"javascript:runcmd('fs "+l+"')\">"+l+"</a>\n")}r=i}}else if("i"==n[0]&&n[1]){for(var i="",c=0;c<o.length;c++){for(var u=o[c].split(/ /g),d="",m="",p=0;p<u.length;p++){var g=u[p].split(/=/);"addr"==g[0]&&(m=g[1]),"name"==g[0]&&(d=g[1]),"string"==g[0]&&(d=g[1])}i+=m+" "+d+"\n"}r=i}return function(r){return"p"==r[0]&&"d"==r[1]||-1!=r.indexOf(";pd")}(n)&&(r=(r=(r=(r=(r=(r=(r=(r=(r=(r=(r=(r=(r=r.replace(/function:/g,"<span style=color:green>function:</span>")).replace(/;(\s+)/g,";")).replace(/;(.*)/g,"// <span style='color:#209020'>$1</span>")).replace(/(bl|goto|call)/g,"<b style='color:green'>call</b>")).replace(/(jmp|bne|beq|js|jnz|jae|jge|jbe|jg|je|jl|jz|jb|ja|jne)/g,"<b style='color:green'>$1</b>")).replace(/(dword|qword|word|byte|movzx|movsxd|cmovz|mov\ |lea\ )/g,"<b style='color:#1070d0'>$1</b>")).replace(/(hlt|leave|iretd|retn|ret)/g,"<b style='color:red'>$1</b>")).replace(/(add|sbb|sub|mul|div|shl|shr|and|not|xor|inc|dec|sar|sal)/g,"<b style='color:#d06010'>$1</b>")).replace(/(push|pop)/g,"<b style='color:#40a010'>$1</b>")).replace(/(test|cmp)/g,"<b style='color:#c04080'>$1</b>")).replace(/(outsd|out|string|invalid|int |int3|trap|main|in)/g,"<b style='color:red'>$1</b>")).replace(/nop/g,"<b style='color:blue'>nop</b>")).replace(/(sym|fcn|str|imp|loc)\.([^:<(\\\/ \|)\->]+)/g,"<a href='javascript:r2ui.seek(\"$1.$2\")'>$1.$2</a>")),r=r.replace(/0x([a-zA-Z0-9]+)/g,"<a href='javascript:r2ui.seek(\"0x$1\")'>0x$1</a>"),backward?(prev_curoff=e,prev_lastoff=t):(next_curoff=e,next_lastoff=t,prev_curoff||(prev_curoff=next_curoff)),r};
|
|
function findPos(e){var n=curtop=0;if(e.offsetParent)for(n=e.offsetLeft,curtop=e.offsetTop;e=e.offsetParent;)n+=e.offsetLeft,curtop+=e.offsetTop;return[n,curtop]}window.onload=function(){function e(){var e=s.defname("help");s.new_frame(e,function(e){setTimeout(function(){document.getElementById("randomcolors").onclick=function(){r2.cmd("ecr",function(){s.update_all()})}},1);return"<h2>Help</h2><div id='"+e+"_help' style='background-color:#304050;overflow:scroll;height:100%'><pre>This is the new and experimental tiled webui for r2\n\nPress the 'alt' key and the following key:\n\n hjkl - move left,down,up,right around\n x - spawn an hexdump\n d - spawn an disasfm\n f - spawn an flags panel\n c - close current frame\n . - toggle maximize mode\n - - horizontal split\n | - vertical split\n\n<input type='button' id='randomcolors' value='randomcolors'></input></div>"}(e),function(n){var t=_(e+"_help");if(t){t.style.offsetTop;var o=findPos(t);t.style.height=n.offsetHeight-o[1]+20,t.style.width=n.style.width-o[0]}})}function n(){var e=s.defname("console");s.new_frame(e,function(e){return'<div><input id="'+e+"_input\"></input></div><div id='"+e+"_output' class='frame_body'></div>"}(e),function(n){var t=_(e+"_console");if(t){t.style.offsetTop;var o=findPos(t);t.style.height=n.offsetHeight-o[1]+20,t.style.width=n.style.width-o[0]}},a,function(){var n=_(e+"_input");n.onkeyup=function(t){13==t.keyCode&&r2.cmd(n.value,function(t){_(e+"_output").innerHTML="<pre>"+t+"</pre>",n.value=""})}})}function t(){var e="debug",n=s.defname(e),t=function(){r2.cmdj("drj",function(n){r2.cmd("pxQ@rsp",function(t){r2.cmd("dbt",function(o){r2.cmd("dm",function(i){var r=function(e){return document.getElementById(e)};setTimeout(function(){function e(){s.update_all()}r("dbg-step").onclick=function(){r2.cmd("ds;.dr*",e())},r("dbg-over").onclick=function(){r2.cmd("dso;.dr*",e())},r("dbg-skip").onclick=function(){r2.cmd("dss;.dr*",e())},r("dbg-cont").onclick=function(){r2.cmd("dc;.dr*",e())},r("dbg-until").onclick=function(){var n=prompt("Until");n&&r2.cmd("dcu "+n+";.dr*",e())}},1);var f="";f+=" <a id='dbg-step' href='#'>[step]</a>",f+=" <a id='dbg-over' href='#'>[over]</a>",f+=" <a id='dbg-skip' href='#'>[skip]</a>",f+=" <a id='dbg-cont' href='#'>[cont]</a>",f+=" <a id='dbg-until' href='#'>[until]</a>",f+="<hr />Registers</hr>",f+="<table>";for(var c in n)f+="<tr><td>"+c+"</td><td><a href=#>"+("0x"+(+n[c]).toString(16))+"</a></td></tr>";f+="</table>",f+="<hr />Backtrace:<pre>"+o+"</pre>",f+="<hr />Stack:<pre>"+t+"</pre>",f+="<hr />Maps:<pre>"+i+"</pre>",document.getElementById(e+"_frame").innerHTML=f})})})})};s.new_frame(n,function(){return"<h2>Debug</h2><div id='"+e+"_frame' class='frame_body'></div>"}(),function(e){var t=_(n+"_frame");if(t){t.style.offsetTop;var o=findPos(t);t.style.height=e.offsetHeight-o[1]+20,t.style.width=e.style.width-o[0]}},a,function(){try{t()}catch(e){}})}function o(){var e=s.defname("flags");s.new_frame(e,function(e){return setTimeout(function(){r2.cmd("fs *;f",function(n){document.getElementById(e+"_flags").innerHTML="<pre>"+n+"</pre>"})},1),"<h2>Flags</h2><div id='"+e+"_flags' class='frame_body'></div>"}(e),function(n){var t=_(e+"_flags");if(t){t.style.offsetTop;var o=findPos(t);t.style.height=n.offsetHeight-o[1]+20,t.style.width=n.style.width-o[0]}},a)}function i(){var e=s.defname("hexdump"),n="<div id='"+e+"_hexdump' class='frame_body'></div>";s.new_frame(e,n,function(n){var t=_(e+"code");if(t){t.style.offsetTop;var o=findPos(t);t.style.height=n.offsetHeight-o[1]+20,t.style.width=n.style.width-o[0]}},a,function(n,t){function o(){var t=n.offset||0;r2.cmd("px 1024 @ "+t,function(t){var o=e+"_hexdump_hex_prev",i=e+"_hexdump_hex_next",r=e+"_hexdump_hex_goto";_(e+"_hexdump").innerHTML="<br /><center><a class=link href='#' id="+o+">[PREV]</a><a class=link href='#' id="+r+">[GOTO]</a><a class=link href='#' id="+i+">[NEXT]</a></center><pre>"+t+"</pre>";var f=document.getElementById(o);f.onclick=function(){n.offset=0|n.offset,n.offset-=512,n.refresh()},(f=document.getElementById(i)).onclick=function(){n.offset=0|n.offset,n.offset+=512,n.refresh()},(f=document.getElementById(r)).onclick=function(){var e=prompt("Goto");e&&r2.cmd("?v "+e,function(e){n.offset=0|+e,n.refresh()})}})}(n=t).offset?o():r2.cmd("?v entry0",function(e){n.offset=+e,o()})})}function r(){var e=s.defname("notes"),n="<div id='"+e+"_notes' class='frame_body'><textarea style='width:100%;height:100%'></textarea></div>";s.new_frame(e,n,function(n){var t=_(e+"_notes");if(t){t.style.offsetTop;var o=findPos(t);t.style.height=n.offsetHeight-o[1]+20,t.style.width=n.style.width-o[0]}},a,function(){})}function f(){var e=s.defname("settings"),n="<div id='"+e+"_settings' class='frame_body'><input type=button value=RandomColors></div>";s.new_frame(e,n,function(n){var t=_(e+"_settings");if(t){t.style.offsetTop;var o=findPos(t);t.style.height="100%",t.style.width=n.style.width-o[0]}},a,function(){r2.cmd("e??",function(n){_(e+"_settings").innerHTML="<pre>"+n+"</pre>"})})}function c(){var e=s.defname("disas"),n="<div id='"+e+"_code' class='frame_body'></div>";s.new_frame(e,n,function(n){var t=_(e+"_code");if(t){t.style.offsetTop;var o=findPos(t);t.style.height="100%",t.style.width=n.style.width-o[0]}},a,function(n,t){n=n.curframe[0];var o=(n=t).offset||"entry0";r2.cmd("pd 200 @ "+o,function(t){var o=e+"_code_prev",i=e+"_code_next",r=e+"_code_goto";_(e+"_code").innerHTML="<br /><center><a class=link href='#' id="+o+">[PREV]</a><a class=link href='#' id="+r+">[GOTO]</a><a class=link href='#' id="+i+">[NEXT]</a></center><pre>"+t+"</pre>";var f=document.getElementById(o);f.onclick=function(){n.offset=0|n.offset,n.offset-=512,n.refresh()},(f=document.getElementById(i)).onclick=function(){n.offset=0|n.offset,n.offset+=512,n.refresh()},(f=document.getElementById(r)).onclick=function(){var e=prompt("Goto");e&&r2.cmd("?v "+e,function(t){t&&(n.offset=e,n.refresh())})}})})}function d(e){u++,a=e,s.new_frame("window_"+u,"<div id='div_"+u+"'><a href='#' id='cmd_"+u+"'>cmd</a><input></input></div>",e),s.run(),s.update=function(){r2.cmd(s.cmd,function(e){_(s.key).innerHTML="<div class='frame_body'><pre>"+e+"</pre></div>"})},_("cmd_"+u).onclick=function(){s.key="div_"+u,s.cmd=prompt(),s.update()}}var a="right",s=new Tiled("canvas"),u=0;_("settings").onclick=function(){f()},_("refresh").onclick=function(){s.update_all()},_("maximize").onclick=function(){s.maximize=!s.maximize,s.run()},_("open-hex").onclick=function(){i()},_("open-dis").onclick=function(){c()},_("open-fla").onclick=function(){o()},_("open-dbg").onclick=function(){t()},_("open-hlp").onclick=function(){e()},_("open-con").onclick=function(){n()},_("open-not").onclick=function(){r()},_("add-column").onclick=function(){d("right")},_("add-row").onclick=function(){u++,a="bottom",s.new_frame("window_"+u,"<div id='div_"+u+"'><a href='#' id='cmd_"+u+"'>cmd</a></div>","bottom"),s.run(),s.update=function(){r2.cmd(s.cmd,function(e){_(s.key).innerHTML="<div class='frame_body'><pre>"+e+"</pre></div>"})},_("cmd_"+u).onclick=function(){s.key="div_"+u,s.cmd=prompt(),s.update()}},i(),c(),s.run(),window.onresize=function(){s.run()},document.t=s,_("body").onkeyup=function(e){String.fromCharCode(e.keyCode);if(e.altKey)switch(e.keyCode){case 67:s.curframe&&(s.oldframe=s.curframe),s.del_frame(),s.run();break;case 189:case 173:d("bottom");break;case 220:case 49:d("right");break;case 190:s.maximize=!s.maximize,s.run();break;case 72:s.other_frame("left");break;case 74:s.other_frame("down");break;case 75:s.other_frame("up");break;case 76:s.other_frame("right");break;case 88:case"x":i();break;case 68:case"d":c();break;case"i":r2.cmd("pi 2",function(e){alert(e)});break;case"!":r2.cmd(prompt("Command to execute"),function(e){alert(e)})}}}; |