Permalink
Browse files

bone101/template.html: made editable

* Loaded ace.js via client.js
* Added demoEdit function
* Removed editable.html
  • Loading branch information...
1 parent 54a93af commit 6265534b0d6213252a714b063a0676584e461a14 @jadonk committed Sep 25, 2012
Showing with 17 additions and 40 deletions.
  1. +13 −1 bone101/client.js
  2. +0 −38 bone101/editable.html
  3. +4 −1 bone101/template.html
View
@@ -15,7 +15,8 @@ var scriptUrls = [
'/autoadvance.js',
'/processing.js',
'/jquery-ui.min.js', // http://ajax.googleapis.com/ajax/libs/jqueryui/1.8/jquery-ui.min.js
- '/weatherstation.js'
+ '/weatherstation.js',
+ '/ajaxorg-ace-builds-c2f3abb/ace.js' // https://github.com/ajaxorg/ace-builds/commit/c2f3abb2ecd3287f90225d804132f0fd26cfb639
];
// Placeholder to get filled in from bonescript via socket.io
@@ -68,6 +69,17 @@ var initClient = function() {
$("#slider1").slider();
$("#slider2").slider();
+ demoEdit = function(id) {
+ var editor = ace.edit(id);
+ editor.setTheme("ace/theme/monokai");
+ editor.getSession().setMode("ace/mode/javascript");
+ var originalDemoRun = demoRun;
+ demoRun = function(myid) {
+ if(myid == id) eval(editor.getValue());
+ else originalDemoRun(myid);
+ }
+ };
+
try {
var canvas = document.getElementById("canvas1");
var graphDataSize = 50;
View
@@ -1,38 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
- "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
-<html xmlns="http://www.w3.org/1999/xhtml" lang="en">
-<head>
- <title>Bonescript webpage app with in-line editor</title>
- <script src="client.js" charset="utf-8" type="text/javascript"></script>
- <link rel="icon" href="favicon.ico" type="image/x-icon" />
- <link rel="shortcut icon" href="favicon.ico" type="image/x-icon" />
- <script src="/ajaxorg-ace-builds-c2f3abb/ace.js" type="text/javascript" charset="utf-8"></script>
-</head>
-<body>
- <h1>Bonescript webpage app with in-line editor</h1>
- <p>This is a minimal example that can be extended easily.</p>
- <p><button class="dynlink" onclick="eval(editor.getValue())">Run</button></p>
- <pre id="editor" style="height: 400px">
-led = bone.USR3;
-state = 0;
-
-pinMode(led, 'out');
-toggleLED = function() {
- state = state ? 0 : 1;
- digitalWrite(led, state);
-};
-
-timer = setInterval(toggleLED, 100);
-
-stopTimer = function() {
- clearInterval(timer);
-};
-setTimeout(stopTimer, 3000);</pre>
- <script>
- var editor = ace.edit("editor");
- editor.setTheme("ace/theme/monokai");
- editor.getSession().setMode("ace/mode/javascript");
- </script>
-</body>
-</html>
@@ -11,7 +11,10 @@
<body>
<h1>Bonescript webpage app template</h1>
<p>This is a minimal example that can be extended easily.</p>
- <p><button class="dynlink" onclick="demoRun('code')">Run</button></p>
+ <p>
+ <button class="dynlink" onclick="demoRun('code')">Run</button>
+ <button class="dynlink" onclick="demoEdit('code')">Edit</button>
+ </p>
<hr />
<pre id="code">
led = bone.USR3;

0 comments on commit 6265534

Please sign in to comment.