mirror of
https://github.com/radareorg/radare2.git
synced 2025-01-05 20:50:06 +00:00
3 lines
22 KiB
JavaScript
3 lines
22 KiB
JavaScript
function _(e){return document.getElementById(e)}var Tiled=function(e){var y=document.getElementById(e);this.curframe=void 0,this.frames=[];var c=20,o=3,u=0;this.update_size=function(e,t){o=e||window.innerWidth,u=t||window.innerHeight},this.max_width=function(e){var 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=o,r=u-(f=c);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=r,void(l.update&&l.update(l.obj))}function s(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}var i=this.frames.length;e=0;for(var a in this.frames){var h=this.frames[a].length,f=c,n=(i=this.frames.length,s(this,a));t=o/i,r=(u-c)/h;for(var m in this.curframe&&1<this.frames.length&&(t=a==this.curframe[1]?o/2:o/2/(i-1)),this.frames[a]){var l=this.frames[a][m];if(n&&1<this.frames[a].length)if(l.selected)r=(u-c)/h*1.7;else r=(u-1.7*(u-c)/h)/(h-1);else r=(u-c)/h;r|=0,l.obj.style.position="absolute",l.obj.style.top=f,l.obj.style.left=e,l.obj.style.width=t,0==m&&(r-=22),l.obj.style.height=r,l.update&&l.update(l.obj),f+=r}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;var r,s,i;alert("moveright Col is "+t),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),0<s.length&&(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":var t=+this.curframe[1];if(0<(s=+this.curframe[2])){s--;var r=this.frames[t][s];this.select_frame(r.name),this.curframe=[r,t,s],this.run()}break;case"down":var s;t=+this.curframe[1];if((s=+this.curframe[2])<=this.frames[t].length)s++,(r=this.frames[t][s])&&(this.select_frame(r.name),this.curframe=[r,t,s],this.run());break;case"left":if(0<(t=+this.curframe[1]))t--,(r=this.frames[t][0])&&(this.select_frame(r.name),this.curframe=[r,t,0],this.run());break;case"right":if((t=+this.curframe[1])>=this.frames.length-1&&(t=-1),t<this.frames.length)t++,(r=this.frames[t])&&(r=r[0]),r&&(this.select_frame(r.name),this.curframe=[r,t,0],this.run())}},this.select_frame=function(e){var t=void 0;for(var r in!e&&this.curframe&&(e=this.curframe[0].name),this.oldframe=this.curframe,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,t,r,s,i){var a={};a.name=e=e||this.defname();var h=document.createElement("div");h.className="frame_title",h.id="frame_"+e;var f,n,m=document.createElement("div");m.style.backgroundColor="#c0c0c0",m.style["overflow-x"]="hidden",(o=document.createElement("a")).innerHTML="[x]",o.href="#",f=this,n=e,o.onclick=function(){f.del_frame(n)},m.appendChild(o);var l=document.createElement("a");l.innerHTML="[r]",l.href="#",l.ival=null;var c=this;l.onclick=function(){l.ival?(clearInterval(l.ival),l.ival=null,l.innerHTML="[r]"):(l.innerHTML="[R]",i&&(i(c,a),l.ival=setInterval(function(){i(c,a)},1e3)))},m.appendChild(l),(g=document.createElement("a")).innerHTML="[@] ",g.href="#",g.onclick=a.refresh=function(){i&&i(c,a)},m.appendChild(g),(b=document.createElement("a")).innerHTML=e,b.href="#",m.appendChild(b),h.appendChild(m),b.onclick=function(){prompt("title")},"string"==typeof r&&(s=r,r=void 0),a.update=r,a.obj=document.createElement("div");var o,u,d;h.outerHTML;switch(a.obj.className="frame",a.obj.id=a.name,a.obj.appendChild(h),(o=document.createElement("p")).innerHTML=t,a.obj.appendChild(h),a.obj.appendChild(o),y.appendChild(a.obj),s){case"bottom":var v=this.curframe?this.curframe[1]:0;this.frames.push([a]),this.frames[v].push(this.frames.pop()[0]);break;case"right":var p=this.curframe?this.curframe[1]:0,b=this.frames.slice(0,p+1),g=this.frames.slice(p+1);b.push([a]),this.frames=b.concat(g);break;default:this.frames.push([a])}return this.select_frame(e),i&&i(c,a),u=this,_("frame_"+(d=e)).onmouseup=function(){u.select_frame(d)||alert("Cant find frame for "+d)},a},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 t=void 0;for(var r in!e&&this.curframe&&(e=this.curframe[0].name),this.frames)for(var s in this.frames[r]){var i=this.frames[r][s];if(i.name==e){if(i!=this.curframe[0])return;if(this.curframe[0]!=this.oldframe[0])return;if(1<this.frames[r].length)for(var a=this.frames[r].splice(s).slice(1),h=0;h<a.length;h++)this.frames[r].push(a[h]);else for(a=this.frames.splice(r).slice(1),h=0;h<a.length;h++)this.frames.push(a[h]);if(y.removeChild(i.obj),!t)for(var r in this.frames)for(var s in this.frames[r]){t=this.frames[r][s];break}return this.select_frame(t),i}t=i.name}this.tile()},this.run=function(){this.update_size(),y.style.position="absolute",y.style.top=0,y.style.left=0,y.style.width=o,y.style.height=u,y.style.backgroundColor="#202020",this.tile()}};
|
|
var r2={},backward=!1,next_curoff=0,next_lastoff=0,prev_curoff=0,prev_lastoff=0,hascmd=!1,r2_root=self.location.pathname.split("/").slice(0,-2).join("/");function isFirefoxOS(){return"undefined"!=typeof locationbar&&!locationbar.visible&&-1<navigator.userAgent.indexOf("Firefox")&&-1<navigator.userAgent.indexOf("Mobile")&&"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}r2.asyncMode="sync",r2.err=null,isFirefoxOS()?r2.root="http://cloud.radare.org":r2.root=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){}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}r2.root=r2_root,r2.analAll=function(){r2.cmd("aa",function(){})},r2.analOp=function(r,e){r2.cmd("aoj 1 @ "+r,function(n){try{e(JSON.parse(n)[0])}catch(r){console.error(r),e(n)}})},r2.varMap=[];var ajax_in_process=!(r2.argMap=[]);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;var a=void 0;if(isFirefoxOS())a=new XMLHttpRequest({mozSystem:!0});else 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)}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){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-1<r2.sections[e].flags.indexOf("x")?"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(null!=n)for(var e in r2.flags={},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(n){r2.cmd("fj|",function(r){n(r?JSON.parse(r):[])})},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){for(var n in conf=r.split("\n"),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(){for(var r in cmd="",r2.asm_config)cmd+="e "+r+"="+r2.asm_config[r]+";";r2.cmd(cmd,function(){})},r2.get_info=function(n){r2.cmd("ij|",function(r){n(JSON.parse(r))})},r2.bin_relocs=function(n){r2.cmd("irj|",function(r){n(JSON.parse(r))})},r2.bin_imports=function(n){r2.cmd("iij|",function(r){n(JSON.parse(r))})},r2.bin_symbols=function(n){r2.cmd("isj|",function(r){n(JSON.parse(r))})},r2.bin_sections=function(n){r2.cmd("iSj|",function(r){n(JSON.parse(r))})},r2.cmds=function(n,e){if(0!=n.length){var t=n[0];n=n.splice(1),r2.cmd(t,function r(){null!=t&&0!=n.length&&(t=n[0],n=n.splice(1),r2.cmd(t,r),e&&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(n){r2.cmd("b",function(r){r&&r.length(),n&&n(r)})},r2.getTextLogger=function(o){return"object"!=typeof o&&(o={}),o.last=0,o.events={},o.interval=null,r2.cmd("Tl",function(r){o.last=+r}),o.load=function(n){r2.cmd('"Tj '+(o.last+1)+'"',function(r){n&&n(JSON.parse(r))})},o.clear=function(r){r2.cmd("T-",r)},o.send=function(r,n){r2.cmd('"T '+r+'"',n)},o.refresh=function(t){o.load(function(r){for(var n=0;n<r.length;n++){var e=r[n];o.events.message({id:e[0],text:e[1]}),e[0]>o.last&&(o.last=e[0])}t&&t()})},o.autorefresh=function(n){n?o.interval=setTimeout(function r(){return o.refresh(function(){}),"Logs"===r2ui.selected_panel?setTimeout(r,1e3*n):console.log("Not in logs :("),!0},1e3*n):o.interval&&o.interval.stop()},o.on=function(r,n){return o.events[r]=n,o},o},r2.filter_asm=function(r,n){var e,t=backward?prev_curoff:next_curoff,o=backward?prev_lastoff:next_lastoff,a=r.split(/\n/g);r2.cmd("s",function(r){t=r});for(var i=a.length-1;0<i;i--){var c=a[i].match(/0x([a-fA-F0-9]+)/);if(c&&0<c.length){o=c[0].replace(/:/g,"");break}}if("afl"==n){var s="";for(i=0;i<a.length;i++){s+=(f=a[i].replace(/\ +/g," ").split(/ /g))[0]+" "+f[3]+"\n"}r=s}else if("f"==n[0]){if("s"==n[1]){for(s="",i=0;i<a.length;i++){var f,l="*"==(f=a[i].replace(/\ +/g," ").split(/ /g))[1]?"*":" ",u=f[2]?f[2]:f[1];u&&(s+=f[0]+" "+l+" <a href=\"javascript:runcmd('fs "+u+"')\">"+u+"</a>\n")}r=s}}else if("i"==n[0]&&n[1]){for(s="",i=0;i<a.length;i++){for(var d=a[i].split(/ /g),m="",p="",g=0;g<d.length;g++){var _=d[g].split(/=/);"addr"==_[0]&&(p=_[1]),"name"==_[0]&&(m=_[1]),"string"==_[0]&&(m=_[1])}s+=p+" "+m+"\n"}r=s}return("p"==(e=n)[0]&&"d"==e[1]||-1!=e.indexOf(";pd"))&&(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=t,prev_lastoff=o):(next_curoff=t,next_lastoff=o,prev_curoff||(prev_curoff=next_curoff)),r};
|
|
function findPos(e){var t=curtop=0;if(e.offsetParent)for(t=e.offsetLeft,curtop=e.offsetTop;e=e.offsetParent;)t+=e.offsetLeft,curtop+=e.offsetTop;return[t,curtop]}window.onload=function(){var n="right",d=new Tiled("canvas"),t=0;function e(){var c="debug",o=d.defname(c);d.new_frame(o,"<h2>Debug</h2><div id='debug_frame' class='frame_body'></div>",function(e){var t=_(o+"_frame");if(t){t.style.offsetTop;var n=findPos(t);t.style.height=e.offsetHeight-n[1]+20,t.style.width=e.style.width-n[0]}},n,function(){try{r2.cmdj("drj",function(f){r2.cmd("pxQ@rsp",function(r){r2.cmd("dbt",function(i){r2.cmd("dm",function(e){var n=function(e){return document.getElementById(e)};setTimeout(function(){function t(){d.update_all()}n("dbg-step").onclick=function(){r2.cmd("ds;.dr*",t())},n("dbg-over").onclick=function(){r2.cmd("dso;.dr*",t())},n("dbg-skip").onclick=function(){r2.cmd("dss;.dr*",t())},n("dbg-cont").onclick=function(){r2.cmd("dc;.dr*",t())},n("dbg-until").onclick=function(){var e=prompt("Until");e&&r2.cmd("dcu "+e+";.dr*",t())}},1);var t="";for(var o in t+=" <a id='dbg-step' href='#'>[step]</a>",t+=" <a id='dbg-over' href='#'>[over]</a>",t+=" <a id='dbg-skip' href='#'>[skip]</a>",t+=" <a id='dbg-cont' href='#'>[cont]</a>",t+=" <a id='dbg-until' href='#'>[until]</a>",t+="<hr />Registers</hr>",t+="<table>",f)t+="<tr><td>"+o+"</td><td><a href=#>0x"+(+f[o]).toString(16)+"</a></td></tr>";t+="</table>",t+="<hr />Backtrace:<pre>"+i+"</pre>",t+="<hr />Stack:<pre>"+r+"</pre>",t+="<hr />Maps:<pre>"+e+"</pre>",document.getElementById(c+"_frame").innerHTML=t})})})})}catch(e){}})}function o(){var r=d.defname("hexdump"),e="<div id='"+r+"_hexdump' class='frame_body'></div>";d.new_frame(r,e,function(e){var t=_(r+"code");if(t){t.style.offsetTop;var n=findPos(t);t.style.height=e.offsetHeight-n[1]+20,t.style.width=e.style.width-n[0]}},n,function(i,e){function t(){var e=i.offset||0;r2.cmd("px 1024 @ "+e,function(e){var t=r+"_hexdump_hex_prev",n=r+"_hexdump_hex_next",o=r+"_hexdump_hex_goto";_(r+"_hexdump").innerHTML="<br /><center><a class=link href='#' id="+t+">[PREV]</a><a class=link href='#' id="+o+">[GOTO]</a><a class=link href='#' id="+n+">[NEXT]</a></center><pre>"+e+"</pre>",document.getElementById(t).onclick=function(){i.offset=0|i.offset,i.offset-=512,i.refresh()},document.getElementById(n).onclick=function(){i.offset=0|i.offset,i.offset+=512,i.refresh()},document.getElementById(o).onclick=function(){var e=prompt("Goto");e&&r2.cmd("?v "+e,function(e){i.offset=0|+e,i.refresh()})}})}(i=e).offset?t():r2.cmd("?v entry0",function(e){i.offset=+e,t()})})}function i(){var r=d.defname("disas"),e="<div id='"+r+"_code' class='frame_body'></div>";d.new_frame(r,e,function(e){var t=_(r+"_code");if(t){t.style.offsetTop;var n=findPos(t);t.style.height="100%",t.style.width=e.style.width-n[0]}},n,function(i,e){i=i.curframe[0];var t=(i=e).offset||"entry0";r2.cmd("pd 200 @ "+t,function(e){var t=r+"_code_prev",n=r+"_code_next",o=r+"_code_goto";_(r+"_code").innerHTML="<br /><center><a class=link href='#' id="+t+">[PREV]</a><a class=link href='#' id="+o+">[GOTO]</a><a class=link href='#' id="+n+">[NEXT]</a></center><pre>"+e+"</pre>",document.getElementById(t).onclick=function(){i.offset=0|i.offset,i.offset-=512,i.refresh()},document.getElementById(n).onclick=function(){i.offset=0|i.offset,i.offset+=512,i.refresh()},document.getElementById(o).onclick=function(){var t=prompt("Goto");t&&r2.cmd("?v "+t,function(e){e&&(i.offset=t,i.refresh())})}})})}function r(e){t++,n=e,d.new_frame("window_"+t,"<div id='div_"+t+"'><a href='#' id='cmd_"+t+"'>cmd</a><input></input></div>",e),d.run(),d.update=function(){r2.cmd(d.cmd,function(e){_(d.key).innerHTML="<div class='frame_body'><pre>"+e+"</pre></div>"})},_("cmd_"+t).onclick=function(){d.key="div_"+t,d.cmd=prompt(),d.update()}}_("settings").onclick=function(){var o,e;o=d.defname("settings"),e="<div id='"+o+"_settings' class='frame_body'><input type=button value=RandomColors></div>",d.new_frame(o,e,function(e){var t=_(o+"_settings");if(t){t.style.offsetTop;var n=findPos(t);t.style.height="100%",t.style.width=e.style.width-n[0]}},n,function(){r2.cmd("e??",function(e){_(o+"_settings").innerHTML="<pre>"+e+"</pre>"})})},_("refresh").onclick=function(){d.update_all()},_("maximize").onclick=function(){d.maximize=!d.maximize,d.run()},_("open-hex").onclick=function(){o()},_("open-dis").onclick=function(){i()},_("open-fla").onclick=function(){var t,o;o=d.defname("flags"),d.new_frame(o,(t=o,setTimeout(function(){r2.cmd("fs *;f",function(e){document.getElementById(t+"_flags").innerHTML="<pre>"+e+"</pre>"})},1),"<h2>Flags</h2><div id='"+t+"_flags' class='frame_body'></div>"),function(e){var t=_(o+"_flags");if(t){t.style.offsetTop;var n=findPos(t);t.style.height=e.offsetHeight-n[1]+20,t.style.width=e.style.width-n[0]}},n)},_("open-dbg").onclick=function(){e()},_("open-hlp").onclick=function(){var e,o;o=d.defname("help"),d.new_frame(o,(e=o,setTimeout(function(){document.getElementById("randomcolors").onclick=function(){r2.cmd("ecr",function(){d.update_all()})}},1),"<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>"),function(e){var t=_(o+"_help");if(t){t.style.offsetTop;var n=findPos(t);t.style.height=e.offsetHeight-n[1]+20,t.style.width=e.style.width-n[0]}})},_("open-con").onclick=function(){var e,o;o=d.defname("console"),d.new_frame(o,'<div><input id="'+(e=o)+"_input\"></input></div><div id='"+e+"_output' class='frame_body'></div>",function(e){var t=_(o+"_console");if(t){t.style.offsetTop;var n=findPos(t);t.style.height=e.offsetHeight-n[1]+20,t.style.width=e.style.width-n[0]}},n,function(){var t=_(o+"_input");t.onkeyup=function(e){13==e.keyCode&&r2.cmd(t.value,function(e){_(o+"_output").innerHTML="<pre>"+e+"</pre>",t.value=""})}})},_("open-not").onclick=function(){var o,e;o=d.defname("notes"),e="<div id='"+o+"_notes' class='frame_body'><textarea style='width:100%;height:100%'></textarea></div>",d.new_frame(o,e,function(e){var t=_(o+"_notes");if(t){t.style.offsetTop;var n=findPos(t);t.style.height=e.offsetHeight-n[1]+20,t.style.width=e.style.width-n[0]}},n,function(){})},_("add-column").onclick=function(){r("right")},_("add-row").onclick=function(){t++,n="bottom",d.new_frame("window_"+t,"<div id='div_"+t+"'><a href='#' id='cmd_"+t+"'>cmd</a></div>","bottom"),d.run(),d.update=function(){r2.cmd(d.cmd,function(e){_(d.key).innerHTML="<div class='frame_body'><pre>"+e+"</pre></div>"})},_("cmd_"+t).onclick=function(){d.key="div_"+t,d.cmd=prompt(),d.update()}},o(),i(),d.run(),window.onresize=function(){d.run()},document.t=d,_("body").onkeyup=function(e){String.fromCharCode(e.keyCode);if(e.altKey)switch(e.keyCode){case 67:d.curframe&&(d.oldframe=d.curframe),d.del_frame(),d.run();break;case 189:case 173:r("bottom");break;case 220:case 49:r("right");break;case 190:d.maximize=!d.maximize,d.run();break;case 72:d.other_frame("left");break;case 74:d.other_frame("down");break;case 75:d.other_frame("up");break;case 76:d.other_frame("right");break;case 88:case"x":o();break;case 68:case"d":i();break;case"i":r2.cmd("pi 2",function(e){alert(e)});break;case"!":r2.cmd(prompt("Command to execute"),function(e){alert(e)})}}}; |