-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdata.js
More file actions
89 lines (89 loc) · 2.73 KB
/
data.js
File metadata and controls
89 lines (89 loc) · 2.73 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
if(window['c']===void 0)window['c']=Object.create(null);
window['c']['data']=function(){
var data=Object.create(null);
data['dataTypes']=new Array();
data['registerNewType']=function(datatype){
if(!(isset(datatype)&&isset(datatype.name)))return false;
data['dataTypes'][datatype.name]=datatype;
return true;
};
data['draw']=function(block){
if(logging)console.log(block);
if(!isset(block))return;
$('#objects ul').append(block.instack().addClass('data'));
};
data['refresh']=function(){
$('#objects ul .data').remove();
for(var dataType in data.dataTypes){
data.draw(data.dataTypes[dataType]);
}
$('.data').draggable().draggable({revert:true});
};
data['parseString']=function(s){
for(var dataType in data.dataTypes){
s=s['replaceAll'](dataType['activeString'], dataType['getCurrentValue']());
}
return s;
}
return data;
}
window['c']['data_init']=function(){
console.log(Data.registerNewType({
name:'SensorGyroX',
instack: function(){
var me=$('<li></li>').data('name', 'SensorGyroX').addClass('sensorgyro').html('Gyroscope X');
return me;
},
activeString:'SENSOR:GYRO-X',
inlineElement: function(){
var me=$('<span></span>').data('name', 'SensorGyroX').addClass('data').addClass('sensorgyro').html('Gyroscope X');
return me;
},
type: 'number',
getCurtentValue:function(html){return AccelerometerConstruct.x;}
}));//gyro x
Data.registerNewType({
name:'SensorGyroY',
instack: function(){
var me=$('<li></li>').data('name', 'SensorGyroY').addClass('sensorgyro').html('Gyroscope Y');
return me;
},
activeString:'SENSOR:GYRO-Y',
inlineElement: function(){
var me=$('<span></span>').data('name', 'SensorGyroY').addClass('data').addClass('sensorgyro').html('Gyroscope Y');
return me;
},
type: 'number',
getCurtentValue:function(html){return AccelerometerConstruct.y;}
});//gyro y
Data.registerNewType({
name:'SensorGyroZ',
instack: function(){
var me=$('<li></li>').data('name', 'SensorGyroZ').addClass('sensorgyro').html('Gyroscope Z');
return me;
},
activeString:'SENSOR:GYRO-Z',
inlineElement: function(){
var me=$('<span></span>').data('name', 'SensorGyroZ').addClass('data').addClass('sensorgyro').html('Gyroscope Z');
return me;
},
type: 'number',
getCurtentValue:function(html){return AccelerometerConstruct.z;}
});//gyro z
Data.registerNewType({
name:'WebcamSnapshot',
instack: function(){
var me=$('<li></li>').data('name', 'WebcamSnapshot').addClass('data').addClass('camera').html('Image');
return me;
},
activeString:'Image:Webcam',
type:'image',
inlineElement: function(){
var me=$('<span></span>').data('name', 'WebcamSnapshot').addClass('data').addClass('camera').html('Image');
return me;
},
getCurrentValue:function(html){
return webcam.snapshot();
}
});//HTML5 webcam image
};