Skip to content

Commit

Permalink
git-svn-id: http://hotruby.googlecode.com/svn/trunk@8 4fb8041d-b042-0…
Browse files Browse the repository at this point in the history
…410-9571-f50be27af959
  • Loading branch information
yukoba@accelart.jp committed Jan 2, 2008
1 parent 835ec2e commit 5b06907
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 12 deletions.
36 changes: 24 additions & 12 deletions web/js/HotRuby.js
Expand Up @@ -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;
}
}
};

Expand Down Expand Up @@ -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);
}
},

/**
Expand Down Expand Up @@ -767,6 +770,15 @@ HotRuby.prototype = {
},
"src=" + encodeURIComponent(src)
);
},

supportRhino : function() {
HotRuby.isRhino = (typeof(alert) == "undefined");
if (HotRuby.isRhino) {
alert = function(str) {
print(str);
}
}
}
};

Expand Down
6 changes: 6 additions & 0 deletions 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);

0 comments on commit 5b06907

Please sign in to comment.