diff --git a/Commands/Run Javascript.tmCommand b/Commands/Run Javascript.tmCommand new file mode 100644 index 0000000..65690d9 --- /dev/null +++ b/Commands/Run Javascript.tmCommand @@ -0,0 +1,70 @@ + + + + + beforeRunningCommand + nop + command + #!/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> +<pre id="log"> +$YOURCODE +<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 + + input + selection + keyEquivalent + @r + name + Run Javascript + output + showAsHTML + scope + source.js + uuid + EA26235D-2A24-4ED4-8BC2-5424B9E80CFF + +