Permalink
Browse files

git-svn-id: http://hotruby.googlecode.com/svn/trunk@8 4fb8041d-b042-0…

…410-9571-f50be27af959
  • Loading branch information...
1 parent 835ec2e commit 5b06907a2d2ce37d40f8286ed4322e922084e4d0 yukoba@accelart.jp committed Jan 2, 2008
Showing with 30 additions and 12 deletions.
  1. +24 −12 web/js/HotRuby.js
  2. +6 −0 web/js/RunRhino.js
View
@@ -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);
+ }
+ }
}
};
View
@@ -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.