2 '/static/jquery.terminal.css', // http://terminal.jcubic.pl/js/jquery.terminal.css
3 '/static/jquery-ui.css', // http://ajax.googleapis.com/ajax/libs/jqueryui/1.8/themes/base/jquery-ui.css
9 '/static/jquery.dimensions.js',
10 '/static/jquery.ui.core.js',
11 '/static/jquery.ui.widget.js',
12 '/static/jquery.ui.accordion.js',
13 '/static/jquery.svg.js',
14 '/static/jquery.terminal.js', // http://terminal.jcubic.pl/js/jquery.terminal-0.4.12.min.js
15 '/static/jquery.mousewheel.js', // http://terminal.jcubic.pl/js/jquery.mousewheel-min.js
16 '/static/jquery-ui.min.js', // http://ajax.googleapis.com/ajax/libs/jqueryui/1.8/jquery-ui.min.js
17 '/static/bonescript.js',
18 '/static/beagle-ui.js',
19 '/static/ajaxorg-ace-builds-c2f3abb/ace.js'// https://github.com/ajaxorg/ace-builds/commit/c2f3abb2ecd3287f90225d804132f0fd26cfb639
22 var oldLog = console.log;
28 var area = $('#console-output');
29 for(var i in arguments) {
30 str += arguments[i].toString() + '\n';
32 oldLog.apply(console, arguments);
35 area.scrollTop(area[0].scrollHeight - area.height());
40 var url = cssUrls.shift();
42 var head = document.getElementsByTagName('head')[0];
43 var link = document.createElement('link');
44 link.rel = 'stylesheet';
45 link.type = 'text/css';
47 var linkObj = head.appendChild(link);
54 // based loosely on http://stackoverflow.com/questions/950087/include-javascript-file-inside-javascript-file
55 function loadScripts() {
56 var url = scriptUrls.shift();
58 loadScript(url, loadScripts);
64 function loadScript(url, callback) {
65 var head = document.getElementsByTagName('head')[0];
66 var script = document.createElement('script');
67 script.type = 'text/javascript';
69 script.charset = 'UTF-8';
70 var scriptObj = head.appendChild(script);
71 scriptObj.onload = callback;
74 function initClient() {
75 $('.use-editor').each(demoEdit);
76 var co_style = $('#console-output').attr('style');
77 $('#console-output').replaceWith('<textarea id="console-output" />')
78 $('#console-output').attr('style', co_style);
80 function demoEdit(index) {
81 if(typeof editor == 'undefined') editor = {};
83 editor[this.id].original = this.innerHTML;
84 editor[this.id].editor = ace.edit(this.id);
85 editor[this.id].editor.setTheme("ace/theme/textmate");
86 if($(this).attr('syntax') == 'sh')
87 editor[this.id].editor.getSession().setMode("ace/mode/sh");
88 else editor[this.id].editor.getSession().setMode("ace/mode/javascript");
89 var originalDemoRun = demoRun;
90 demoRun = function(myid) {
91 if(typeof editor[myid].editor != 'undefined') {
92 var code = editor[myid].editor.getValue();
95 originalDemoRun(myid);
98 var originalShellRun = shellRun;
99 shellRun = function(myid) {
100 if(typeof editor[myid].editor != 'undefined') {
101 var code = editor[myid].editor.getValue();
104 originalShellRun(myid);
110 function doAlert(m) {
111 alert(JSON.stringify(m));
114 function demoRun(id) {
115 var myScript = document.getElementById(id).innerHTML;
116 myScript = myScript.replace("<", "<");
117 myScript = myScript.replace(">", ">");
118 myScript = myScript.replace("&", "&");
122 function onShell(x) {
126 function myShell(code) {
127 var b = require('bonescript');
128 b.socket.on('shell', onShell);
129 b.socket.emit('shell', code);
132 function shellRun(id) {
133 var myScript = document.getElementById(id).innerHTML;
137 function demoRestore(id) {
138 if(typeof editor[id] == 'undefined') return;
139 editor[id].editor.setValue(editor[id].original);
142 function myeval(script) {
146 console.log('Exception: ' + ex);