mirror of
https://github.com/kennethreitz-archive/kJS.tmbundle.git
synced 2026-06-05 23:50:19 +00:00
74 lines
1.9 KiB
Plaintext
74 lines
1.9 KiB
Plaintext
<?xml version="1.0" encoding="UTF-8"?>
|
||
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
|
||
<plist version="1.0">
|
||
<dict>
|
||
<key>beforeRunningCommand</key>
|
||
<string>nop</string>
|
||
<key>command</key>
|
||
<string>#!/usr/bin/env bash
|
||
. "$TM_SUPPORT_PATH/lib/webpreview.sh"
|
||
html_header "Javascript Runner" "Open Web Inspector for log"
|
||
|
||
YOURCODE=`cat`
|
||
|
||
cat <<HTML
|
||
<script>
|
||
(function(){try{
|
||
|
||
function e_sh(s){
|
||
return s
|
||
.toString()
|
||
.replace(/\x27/g,"’")
|
||
.replace(/\"/g,'\\\"')
|
||
;
|
||
};
|
||
|
||
window.alert = function(s){
|
||
TextMate.system('"$DIALOG" -e -p \'{messageTitle="JavaScript";informativeText="'+e_sh(s)+'";}\'', null);
|
||
};
|
||
|
||
var __TM_confirm_Status;
|
||
window.confirm = function(s){
|
||
TextMate.system('"$DIALOG" -e -p \'{messageTitle="JavaScript";informativeText="'+e_sh(s)+'";buttonTitles=("OK","Cancel");}\'', null)
|
||
.onreadoutput = function(s){ __TM_confirm_Status = s != 1; };
|
||
return(__TM_confirm_Status);
|
||
};
|
||
|
||
}catch(e){ console.log(e.message); }; })();
|
||
</script>
|
||
<input type="button" value="Show Code" onclick="var c=document.getElementById('code');c.style.display==''?c.style.display='none':c.style.display='';" />
|
||
<pre id="code" style="display:none">
|
||
$YOURCODE
|
||
</pre>
|
||
<pre id="log">
|
||
<script>
|
||
try{throw {}}catch(e){ window.__line=(e.line||0) + 3 };
|
||
try{
|
||
/*---- YOUR CODE ----*/
|
||
$YOURCODE
|
||
/*---- /YOUR CODE ----*/
|
||
}catch(e){
|
||
console.log(e);
|
||
var __line_offset = ${TM_INPUT_START_LINE:-1};
|
||
alert("$TM_FILEPATH:" + ((e.line||1) - __line + __line_offset) +"\n"+ e.message||'')
|
||
};
|
||
</script></pre>
|
||
HTML
|
||
|
||
html_footer
|
||
</string>
|
||
<key>input</key>
|
||
<string>selection</string>
|
||
<key>keyEquivalent</key>
|
||
<string>@r</string>
|
||
<key>name</key>
|
||
<string>Run Javascript</string>
|
||
<key>output</key>
|
||
<string>showAsHTML</string>
|
||
<key>scope</key>
|
||
<string>source.js</string>
|
||
<key>uuid</key>
|
||
<string>EA26235D-2A24-4ED4-8BC2-5424B9E80CFF</string>
|
||
</dict>
|
||
</plist>
|