commons-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jbe...@apache.org
Subject svn commit: r957702 - /commons/sandbox/gsoc/2010/scxml-js/trunk/demo/sandbox/sandbox.html
Date Thu, 24 Jun 2010 20:17:16 GMT
Author: jbeard
Date: Thu Jun 24 20:17:16 2010
New Revision: 957702

URL: http://svn.apache.org/viewvc?rev=957702&view=rev
Log:
Added some stuff to sandbox.html to make it work in IE.

Modified:
    commons/sandbox/gsoc/2010/scxml-js/trunk/demo/sandbox/sandbox.html

Modified: commons/sandbox/gsoc/2010/scxml-js/trunk/demo/sandbox/sandbox.html
URL: http://svn.apache.org/viewvc/commons/sandbox/gsoc/2010/scxml-js/trunk/demo/sandbox/sandbox.html?rev=957702&r1=957701&r2=957702&view=diff
==============================================================================
--- commons/sandbox/gsoc/2010/scxml-js/trunk/demo/sandbox/sandbox.html (original)
+++ commons/sandbox/gsoc/2010/scxml-js/trunk/demo/sandbox/sandbox.html Thu Jun 24 20:17:16
2010
@@ -6,7 +6,7 @@
  * (the "License"); you may not use this file except in compliance with
  * the License.  You may obtain a copy of the License at
  *
- *     http://www.apache.org/licenses/LICENSE-2.0
+ *	 http://www.apache.org/licenses/LICENSE-2.0
  *
  * Unless required by applicable law or agreed to in writing, software
  * distributed under the License is distributed on an "AS IS" BASIS,
@@ -20,6 +20,8 @@ that uses the SCXMLCompiler front-end. 
 -->
 <html>
 	<head>
+		<meta http-equiv="X-UA-Compatible" content="IE=8" />
+
 		<style type="text/css">
 			body {
 				height:95%;
@@ -42,6 +44,15 @@ that uses the SCXMLCompiler front-end. 
 		
 			div{ height:100% }
 		</style>
+
+        <!-- IE doesn't seem to like the above CSS, so eliminate liquid layout -->
+        <!--[if IE]>
+            <style type="text/css">
+                textarea {
+                    height:200px;
+                }
+            </style>
+        <![endif]-->
 		<script src="../../lib/js/requirejs/require.js" type="text/javascript">true;</script>
 		<script src="../../lib/js/requirejs/require/xml.js" type="text/javascript">true;</script>
 		<script src="../../lib/js/requirejs/require/text.js" type="text/javascript">true;</script>
@@ -74,7 +85,7 @@ that uses the SCXMLCompiler front-end. 
 
 			require(
 				{
-					"baseUrl":"/"
+					"baseUrl":"/scxml-js/"
 				},
 				[ "src/javascript/scxml/cgf/SCXMLCompiler",
 					"text!test/kitchen_sink/KitchenSink_executableContent.xml",
@@ -84,6 +95,23 @@ that uses the SCXMLCompiler front-end. 
 
 					var compiledStatechartConstructor, compiledStatechartInstance;
 
+					//some browser compatibility stuff
+					function addEventListener(el,ev,fn){
+						if (el.addEventListener){
+							el.addEventListener(ev, fn, false); 
+						} else if (el.attachEvent){
+							el.attachEvent('on' + ev, fn);
+						}
+					}
+
+                    function setTextContent(el,str){
+                           if(typeof el.textContent == "string"){
+                               el.textContent+=str;
+                           }else if(typeof el.innerText == "string"){
+                               el.innerText+=str;
+                           }
+                    } 
+
 					function ccToString(conf){return conf.map(function(s){return s.toString()})}
 
 					//pull UI controls from DOM
@@ -94,18 +122,29 @@ that uses the SCXMLCompiler front-end. 
 					var send_event_button = document.getElementById("send_event_button");
 					var compile_button = document.getElementById("compile_button");
 
+					//hook up minimal console api
+					if((typeof console == "undefined") || !console.log){
+                        /*
+						   console = {log : function(str){
+												setTextContent(sc_console, str + "\n");
+												sc_console.scrollTop = sc_console.scrollHeight; 
+											} }
+                       */ 
+						   console = {log : function(str){}}
+					} 
+
 					//set initial content of scxml_input
-					scxml_input.textContent = KitchenSink_executableContent;
+					setTextContent(scxml_input, KitchenSink_executableContent);
 
 					//prepopulate stuff with stuff. 
-					compile_button.addEventListener("click",function(e){
+					addEventListener(compile_button,"click",function(e){
 
 						//TODO: provide a UI for setting these options
 						var compileLog = true;
 						var backend = "state";
 
 						//parse textArea into xml
-						var textInput = xmlUtil.parseFromString(scxml_input.textContent);
+						var textInput = xmlUtil.parseFromString(scxml_input.textContent || scxml_input.innerText);
 
 						compiler.compile({
 							inFiles:[textInput],
@@ -123,13 +162,13 @@ that uses the SCXMLCompiler front-end. 
 							compiledStatechartConstructor = StatechartExecutionContext;
 							compiledStatechartInstance = new compiledStatechartConstructor(); 
 
-							sc_console.textContent += "Initializing new statechart instance...\n"
+							setTextContent(sc_console, "Initializing new statechart instance...\n");
 
 							//initialize
 							compiledStatechartInstance.initialize();
 							
 							//update DOM
-							js_output.textContent = transformedJs;
+							setTextContent(js_output, transformedJs);
 
 							/*
 							sc_console.removeAttribute("disabled");
@@ -137,19 +176,21 @@ that uses the SCXMLCompiler front-end. 
 							send_event_button.removeAttribute("disabled");
 							*/
 
-							sc_console.textContent += ccToString(compiledStatechartInstance.getCurrentConfiguration())
+ ">";
+							setTextContent(sc_console, ccToString(compiledStatechartInstance.getCurrentConfiguration())
+ ">");
+							//sc_console.scrollTop = sc_console.scrollHeight; 
 						});
 					},false);
 
-					send_event_button.addEventListener("click",function(e){
+					addEventListener(send_event_button,"click",function(e){
 						var eventToSend = event_name_field.value;
 
-						sc_console.textContent += eventToSend + "\n";
+						setTextContent(sc_console, eventToSend + "\n");
 
 						//we use synchronous API
 						compiledStatechartInstance[eventToSend](); 
 
-						sc_console.textContent += ccToString(compiledStatechartInstance.getCurrentConfiguration())
+ ">";
+						setTextContent(sc_console, ccToString(compiledStatechartInstance.getCurrentConfiguration())
+ ">");
+						//sc_console.scrollTop = sc_console.scrollHeight; 
 					},false);
 				}
 			);



Mime
View raw message