1 var name = "#floatMenu";
4 $(document).ready(function(){
6 menuYloc = parseInt($(name).css("top").substring(0,$(name).css("top").indexOf("px")));
7 $(window).scroll(function () {
8 var offset = menuYloc+$(document).scrollTop()+"px";
9 $(name).animate({top:offset},{duration:500,queue:false});
14 $(document).ready(function(){
15 $('.cloud9-url').each(function() {
16 this.href = 'http://' + window.location.host + ':3000';
18 $('.gateone-url').each(function() {
19 this.href = 'https://' + window.location.host;
24 if($('#accordian').length) {
25 $("#accordion").accordion({
31 $(document).ready(function(){
32 if($('#side-menu').length) {
33 $.get('/static/side-menu.html', function(data){
34 $('#side-menu').replaceWith(data);
39 $(document).ready(function(){
40 if($('#connect-status').length) {
41 var connectState = 'init';
42 var statusDisconnected = '' +
43 '<div id="connect-status">' +
44 ' <div class="browser-connect">' +
45 ' <img alt="Not Connected" src="/static/images/usb.png" border="0">' +
46 ' <div id="browser-content"><strong>Did you know?</strong> This page can interact with your BeagleBone<br />' +
47 'Type in your BeagleBone's IP address here:<input id="connect-ip"></input>' +
51 var statusConnected = '' +
52 '<div id="connect-status">' +
53 ' <div class="browser-connected">' +
54 ' <img alt="Connected" src="/static/images/green_check.png" border="0">' +
55 ' <div id="browser-content"><strong>Your board is connected!</strong><br>' +
56 ' <div id="board-info"></div>' +
67 $('#connect-status').replaceWith(statusDisconnected);
69 // note, due to a bug in Firefox, the call is moved below
71 function testForConnection() {
73 handlers.callback = callback;
74 handlers.initialized = initialized;
75 handlers.connecting = disconnected;
76 handlers.connect_failed = connect_failed;
77 handlers.reconnect_failed = disconnected;
78 handlers.disconnect = disconnected;
79 handlers.connect = connected;
80 handlers.reconnect = connected;
81 handlers.reconnecting = connected;
82 $('#connect-ip').keypress(oninput);
83 setTargetAddress(serversToTry[i], handlers);
85 if(i >= serversToTry.length) i = 0;
88 if(e.which == 10 || e.which == 13) {
89 var givenAddress = $('#connect-ip').val();
90 setTargetAddress(givenAddress, handlers);
91 serversToTry = [ givenAddress ];
96 if(typeof _bonescript == 'undefined') {
97 setTimeout(testForConnection, 1000);
100 function connected() {
101 if(connectState == 'disconnected') {
102 console.log('Bonescript: connected');
103 connectState = 'reconnecting';
106 function initialized() {
107 console.log('Bonescript: initialized');
108 $('#connect-status').replaceWith(statusConnected);
110 if(typeof onbonescriptinit == 'function') onbonescriptinit();
111 connectState = 'connected';
113 function disconnected() {
114 if(connectState == 'connected') {
115 console.log('Bonescript: disconnected');
116 $('#connect-status').replaceWith(statusDisconnected);
117 connectState = 'disconnected';
120 function connect_failed() {
121 if(connectState == 'init') {
122 _onSocketIOLoaded_workaround();
133 function updateBoardInfo() {
134 var b = require('bonescript');
135 b.getPlatform(function(x) {
136 var info = '<div id="board-info">' + x.name;
137 if(typeof x.version != 'undefined')
138 info += ' rev ' + x.version;
139 if(typeof x.serialNumber != 'undefined')
140 info += ' S/N ' + x.serialNumber;
141 if(typeof _bonescript.address != 'undefined')
142 info += ' at ' + _bonescript.address;
144 $('#board-info').replaceWith(info);
148 function _onSocketIOLoaded_workaround() {
149 //console.log("socket.io loaded");
150 var socket_addr = 'http://' + _bonescript.address + ':80';
151 var socket = io.connect(socket_addr);
152 socket.on('require', getRequireData);
153 socket.on('bonescript', _seqcall);
154 socket.on('connect', _bonescript.on.connect);
155 socket.on('connecting', _bonescript.on.connecting);
156 socket.on('disconnect', _bonescript.on.disconnect);
157 socket.on('connect_failed', _bonescript.on.connect_failed);
158 socket.on('error', _bonescript.on.error);
159 socket.on('reconnect', _bonescript.on.reconnect);
160 socket.on('reconnect_failed', _bonescript.on.reconnect_failed);
161 socket.on('reconnecting', _bonescript.on.reconnecting);
162 socket.on('initialized', _bonescript.on.initialized);
164 function getRequireData(m) {
165 if(!m.module || !m.data)
166 throw('Invalid "require" message sent for "' + m.module + '"');
167 //console.log('Initialized module: ' + m.module);
168 _bonescript.modules[m.module] = {};
169 for(var x in m.data) {
170 if(!m.data[x].type || !m.data[x].name || (typeof m.data[x].value == 'undefined'))
171 throw('Invalid data in "require" message sent for "' + m.module + '.' + m.data[x] + '"');
172 if(m.data[x].type == 'function') {
173 // define the function
175 throw('Missing args in "require" message sent for "' + m.module + '.' + m.data[x] + '"');
176 var myargs = m.data[x].value;
178 // eval of objString builds the call data out of arguments passed in
180 for(var y in myargs) {
181 if(isNaN(y)) continue; // Need to find the source of this bug
182 if(myargs[y] == 'callback') continue;
183 objString += ' if(typeof ' + myargs[y] + ' == "function") {\n';
184 objString += ' ' + myargs[y] + ' = ' + myargs[y] + '.toString();\n';
186 objString += ' calldata.' + myargs[y] + ' = ' + myargs[y] + ';\n';
188 var argsString = myargs.join(', ');
189 var handyfunc = '_bonescript.modules["' + m.module + '"].' + m.data[x].name +
191 'function (' + argsString + ') {\n' +
192 ' var calldata = {};\n' +
194 ' if(callback) {\n' +
195 ' _bonescript._callbacks[_bonescript._seqnum] = callback;\n' +
196 ' calldata.seq = _bonescript._seqnum;\n' +
197 ' _bonescript._seqnum++;\n' +
199 ' socket.emit("' + m.module + '$' + m.data[x].name + '", calldata);\n' +
203 _bonescript.modules[m.module][m.data[x].name] = m.data[x].value;
206 _bonescript.on.initialized();