mirror of
https://github.com/radareorg/radare2.git
synced 2024-11-25 06:09:50 +00:00
Enhaced script panel in /m
This commit is contained in:
parent
5724e6da79
commit
6ae641477a
1
shlr/www/m/beautify.js
Normal file
1
shlr/www/m/beautify.js
Normal file
File diff suppressed because one or more lines are too long
@ -268,8 +268,14 @@
|
||||
</defs>
|
||||
</svg>
|
||||
<a href="javascript:seek()" id="view-source" class="mdl-button mdl-js-button mdl-button--raised mdl-js-ripple-effect mdl-color--accent mdl-color-text--accent-contrast">seek</a>
|
||||
<script src="material.min.js"></script>
|
||||
<script src="r2.js"></script>
|
||||
<script src="index.js"></script>
|
||||
<script type="application/javascript;version=1.7" src="material.min.js"></script>
|
||||
<!--
|
||||
<script type="application/javascript;version=1.7" src="r2.js"></script>
|
||||
<script type="application/javascript;version=1.7" src="index.js"></script>
|
||||
<script type="application/javascript;version=1.7" src="beautify.js"></script>
|
||||
-->
|
||||
<script type="application/javascript" src="r2.js"></script>
|
||||
<script type="application/javascript" src="index.js"></script>
|
||||
<script type="application/javascript" src="beautify.js"></script>
|
||||
</body>
|
||||
</html>
|
||||
|
@ -532,9 +532,40 @@ function runSearch(text) {
|
||||
}
|
||||
}
|
||||
|
||||
function indentScript() {
|
||||
var str = document.getElementById('script').value;
|
||||
var indented = js_beautify (str);
|
||||
document.getElementById('script').value = indented;
|
||||
localStorage['script'] = indented;
|
||||
}
|
||||
|
||||
function runScript() {
|
||||
var str = document.getElementById('script').value;
|
||||
eval (str);
|
||||
localStorage['script'] = str;
|
||||
document.getElementById('scriptOutput').innerHTML = '';
|
||||
try {
|
||||
var msg = "\"use strict\";"+
|
||||
"function log(x){var a = "+
|
||||
"document.getElementById('scriptOutput'); "+
|
||||
"if (a) a.innerHTML += x + '\\n'; }\n";
|
||||
eval (msg+str);
|
||||
} catch (e) {
|
||||
alert (e);
|
||||
}
|
||||
}
|
||||
|
||||
var foo = "";
|
||||
function toggleScriptOutput() {
|
||||
var o = document.getElementById('scriptOutput');
|
||||
if (o) {
|
||||
if (foo == "") {
|
||||
foo = o.innerHTML;
|
||||
o.innerHTML = "";
|
||||
} else {
|
||||
o.innerHTML = foo;
|
||||
foo = "";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function panelScript() {
|
||||
@ -542,9 +573,16 @@ function panelScript() {
|
||||
document.getElementById('title').innerHTML = 'Script';
|
||||
var c = document.getElementById("content");
|
||||
c.style.backgroundColor = "#f0f0f0";
|
||||
var localScript = localStorage.getItem('script');
|
||||
var out = '<br />'+uiButton('javascript:runScript()', 'Run');
|
||||
out += '<br /><br /><textarea rows=32 id="script" style="width:100%">';
|
||||
out += 'r2.cmd("?e hello world", alert);</textarea>';
|
||||
out += ' '+uiButton('javascript:indentScript()', 'Indent');
|
||||
out += ' '+uiButton('javascript:toggleScriptOutput()', 'Output');
|
||||
out += '<br /><div class="output" id="scriptOutput"></div><br />';
|
||||
out += '<textarea rows=32 id="script" class="pre" style="width:100%">';
|
||||
if (!localScript) {
|
||||
localScript = 'r2.cmd("?e hello world", alert);';
|
||||
}
|
||||
out += localScript + '</textarea>';
|
||||
c.innerHTML = out;
|
||||
}
|
||||
|
||||
|
@ -366,7 +366,7 @@ function _internal_cmd(c, cb) {
|
||||
}
|
||||
if (hascmd) {
|
||||
// TODO: use setTimeout for async?
|
||||
if (typeof (r2plugin) != "undefined") {
|
||||
if (typeof (r2plugin) != 'undefined') {
|
||||
// duktape
|
||||
cb (r2cmd(c));
|
||||
} else {
|
||||
@ -398,7 +398,7 @@ r2.cmd = function(c, cb) {
|
||||
cb (res);
|
||||
});
|
||||
} else {
|
||||
_internal_cmd (c, cb);
|
||||
return _internal_cmd (c, cb);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -259,3 +259,14 @@ input {
|
||||
td {
|
||||
text-align:left !important;
|
||||
}
|
||||
|
||||
.output {
|
||||
border: 1px solid red;
|
||||
margin-left: 16px;
|
||||
margin-top: 16px;
|
||||
margin-bottom: 16px;
|
||||
background-color: white;
|
||||
font-family: Console, Courier New, monospace;
|
||||
white-space: pre;
|
||||
display: inline-block;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user