Skip to content

Commit 7dec3d7

Browse files
committed
slight changes to make motion lab frontend work
1 parent 324ba0e commit 7dec3d7

File tree

2 files changed

+24
-5
lines changed

2 files changed

+24
-5
lines changed

utils.js

Lines changed: 23 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,12 @@ function µ(id, elem) {
1010
ret = document.createElement(spl[0].substring(1));
1111
if (elem) elem.appendChild(ret);
1212
break;
13-
default:
13+
case '#':
1414
ret = root.querySelector(spl[0]);
1515
break;
16+
default:
17+
ret = root.querySelectorAll(spl[0]);
18+
break;
1619
}
1720
if (spl.length <= 1) return ret;
1821
else return ret.getAttribute(spl[1]);
@@ -277,6 +280,25 @@ function zeroPad(num, size) {
277280
return s;
278281
}
279282

283+
function position(elem) {
284+
var offset = { x:0, y:0 };
285+
while (elem)
286+
{
287+
offset.x += elem.offsetLeft;
288+
offset.y += elem.offsetTop;
289+
elem = elem.offsetParent;
290+
}
291+
292+
return offset;
293+
}
294+
295+
function extractNumber(value)
296+
{
297+
var n = parseInt(value);
298+
299+
return n == null || isNaN(n) ? 0 : n;
300+
}
301+
280302
// Reduce a fraction by finding the Greatest Common Divisor and dividing by it.
281303
function reduce(numerator, denominator) {
282304
var gcd = function gcd(a, b) {

websocket.js

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
1-
include([], function() {
2-
31
var websocket = function() {
4-
this.address = 'ws://' + window.location.host + '/';
2+
this.address = 'ws://' + window.location.host + ':8080/';
53
this.connectInterval = null;
64
this.serialport = '';
75
var ws = null;
@@ -44,4 +42,3 @@ include([], function() {
4442
};
4543

4644
window.wsClient = new websocket();
47-
});

0 commit comments

Comments
 (0)