From 5b06907a2d2ce37d40f8286ed4322e922084e4d0 Mon Sep 17 00:00:00 2001 From: "yukoba@accelart.jp" Date: Wed, 2 Jan 2008 02:11:12 +0000 Subject: [PATCH] git-svn-id: http://hotruby.googlecode.com/svn/trunk@8 4fb8041d-b042-0410-9571-f50be27af959 --- web/js/HotRuby.js | 36 ++++++++++++++++++++++++------------ web/js/RunRhino.js | 6 ++++++ 2 files changed, 30 insertions(+), 12 deletions(-) create mode 100644 web/js/RunRhino.js diff --git a/web/js/HotRuby.js b/web/js/HotRuby.js index 31d9563..2e203e8 100644 --- a/web/js/HotRuby.js +++ b/web/js/HotRuby.js @@ -15,14 +15,13 @@ var HotRuby = function() { * @type Array */ this.endBlocks = []; - /** - * Debug DOM - * @type HTMLElement - */ - this.debugDom = document.getElementById("debug"); - - if (this.debugDom == null) { - this.debugDom = document.body; + + this.supportRhino(); + if(!HotRuby.isRhino) { + this.debugDom = document.getElementById("debug"); + if (this.debugDom == null) { + this.debugDom = document.body; + } } }; @@ -722,10 +721,14 @@ HotRuby.prototype = { * @param {String} str */ printDebug : function(str) { - var div = document.createElement("div"); - var text = document.createTextNode(str); - div.appendChild(text); - this.debugDom.appendChild(div); + if(HotRuby.isRhino) { + print(str); + } else { + var div = document.createElement("div"); + var text = document.createTextNode(str); + div.appendChild(text); + this.debugDom.appendChild(div); + } }, /** @@ -767,6 +770,15 @@ HotRuby.prototype = { }, "src=" + encodeURIComponent(src) ); + }, + + supportRhino : function() { + HotRuby.isRhino = (typeof(alert) == "undefined"); + if (HotRuby.isRhino) { + alert = function(str) { + print(str); + } + } } }; diff --git a/web/js/RunRhino.js b/web/js/RunRhino.js new file mode 100644 index 0000000..e90a501 --- /dev/null +++ b/web/js/RunRhino.js @@ -0,0 +1,6 @@ +/* + * Usage: + * java -jar "C:\Program Files\Java\rhino1_6R7\js.jar" RunRhino.js test\Const.js + */ +load("HotRuby.js", "NativeMethods.js", arguments[0]); +new HotRuby().run(src); \ No newline at end of file