File tree

2 files changed

+28
-28
lines changed

2 files changed

+28
-28
lines changed
Original file line numberDiff line numberDiff line change
@@ -5,34 +5,7 @@ Blockly.JavaScript['line_ifttt'] = function(block) {
55
var v2 = Blockly.JavaScript.valueToCode(block, 'line_ifttt_value2', Blockly.JavaScript.ORDER_ATOMIC);
66
var v3 = Blockly.JavaScript.valueToCode(block, 'line_ifttt_value3', Blockly.JavaScript.ORDER_ATOMIC);
77

8-
var arr = [];
9-
var code;
10-
11-
var js = "$.get('https://maker.ifttt.com/trigger/'+";
12-
13-
if (v1.length > 0) {
14-
arr.push("'value1='+" + v1);
15-
}
16-
if (v2.length > 0) {
17-
arr.push("'value2='+" + v2);
18-
}
19-
if (v3.length > 0) {
20-
arr.push("'value3='+" + v3);
21-
}
22-
console.log(arr,arr.length);
23-
24-
switch (arr.length) {
25-
case 1:
26-
code = js + event + "+'/with/key/'+" + key + "+'?'+" + arr[0] + ")";
27-
break;
28-
case 2:
29-
code = js + event + "+'/with/key/'+" + key + "+'?'+" + arr[0] + "+'&'+" + arr[1] + ")";
30-
break;
31-
case 3:
32-
code = js + event + "+'/with/key/'+" + key + "+'?'+" + arr[0] + "+'&'+" + arr[1]+ "+'&'+" + arr[2] + ")";
33-
break;
34-
35-
}
8+
var code = 'ifttt(event,key,v1,v2,v3);';
369

3710
return code;
3811
};
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
+(function(window, document) {
2+
3+
'use strict';
4+
5+
function ifttt(event, key, v1, v2, v3) {
6+
7+
var obj = {};
8+
9+
if (v1 != "''") {
10+
obj.value1 = v1;
11+
}
12+
if (v2 != "''") {
13+
obj.value2 = v2;
14+
}
15+
if (v3 != "''") {
16+
obj.value3 = v3;
17+
}
18+
19+
var uri = 'https://maker.ifttt.com/trigger/' + event + '/with/key/' + key;
20+
$.post(uri, obj, function(e) {
21+
console.log(e);
22+
});
23+
}
24+
25+
window.ifttt = ifttt;
26+
27+
}(window, window.document));

0 commit comments

Comments
 (0)