-
Notifications
You must be signed in to change notification settings - Fork 15
Expand file tree
/
Copy pathleftronic.js
More file actions
70 lines (64 loc) · 2.48 KB
/
leftronic.js
File metadata and controls
70 lines (64 loc) · 2.48 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
/*
Requires jQuery library.
Load from Google CDN (Instructions: http://code.google.com/apis/libraries/devguide.html#jquery)
or download directly (http://jquery.com/download)
*/
// Your secret API access key
var accessKey = "YOUR_ACCESS_KEY";
function pushNumber(streamName, point) {
/* Pushing a number to a Number, Horizontal/Vertical Bar, or Dial widget */
var parameters = {};
parameters["accessKey"] = accessKey;
parameters["streamName"] = streamName;
parameters["point"] = point;
// Convert to JSON
var jsonData = JSON.stringify(parameters);
// Make request (jQuery)
$.post("https://beta.leftronic.com/customSend/", jsonData);
}
function pushGeo(streamName, lati, longi, color) {
/* Pushing a geographic location (latitude and longitude) to a Map widget.
* Color can also be passed (red, green, blue, yellow, or purple).
* Default color is red. */
var parameters = {};
parameters["accessKey"] = accessKey;
parameters["streamName"] = streamName;
parameters["point"] = {"latitude": lati, "longitude": longi, "color": color};
// Convert to JSON
var jsonData = JSON.stringify(parameters);
// Make request (jQuery)
$.post("https://beta.leftronic.com/customSend/", jsonData);
}
function pushText(streamName, myTitle, myMsg) {
/* Pushing a title and message to a Text Feed widget */
var parameters = {};
parameters["accessKey"] = accessKey;
parameters["streamName"] = streamName;
parameters["point"] = {"title": myTitle, "msg": myMsg};
// Convert to JSON
var jsonData = JSON.stringify(parameters);
// Make request (jQuery)
$.post("https://beta.leftronic.com/customSend/", jsonData);
}
function pushLeaderboard(streamName, leaderArray) {
/* Pushing an array to a Leaderboard widget */
var parameters = {};
parameters["accessKey"] = accessKey;
parameters["streamName"] = streamName;
parameters["point"] = {"leaderboard": leaderArray};
// Convert to JSON
var jsonData = JSON.stringify(parameters);
// Make request (jQuery)
$.post("https://beta.leftronic.com/customSend/", jsonData);
}
function pushList(streamName, listArray) {
/* Pushing an array to a List widget */
var parameters = {};
parameters["accessKey"] = accessKey;
parameters["streamName"] = streamName;
parameters["point"] = {"list": listArray};
// Convert to JSON
var jsonData = JSON.stringify(parameters);
// Make request (jQuery)
$.post("https://beta.leftronic.com/customSend/", jsonData);
}