-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathhandler.js
More file actions
82 lines (68 loc) · 2.29 KB
/
handler.js
File metadata and controls
82 lines (68 loc) · 2.29 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
function listener(result) {
const intent_map = {
"draw_shape": draw_shape_listener,
"move_shape":move_shape_listener,
"resize_shape":resize_shape_listener,
"color_shape":color_shape_listener,
"clear_shape":clear_shape_listener,
"save_shape":save_shape_listener,
"rotate_shape":rotate_shape_listener
};
let intent = result.intent;
let function_handler = intent_map[intent];
let entities = {};
for (let i of result.entities) {
entities[i.id] = i;
}
function_handler(entities)
}
function draw_shape_listener(entities) {
const shape_name = entities["shape_name"].value
var shape_value = 10;
if (entities["shape_value"])
shape_value = entities["shape_value"].value
//console.log(shape_value);
draw_shapes(shape_name, shape_value);
}
function move_shape_listener(entities) {
const move_name = entities["move_name"].value
var move_direction = "right"
var move_value = 10
if(entities["move_direction"])
move_direction = entities["move_direction"].value
if(entities["move_value"])
move_value = entities["move_value"].value
//console.log(shape_value);
move_shapes(move_name,move_direction,move_value);
}
function resize_shape_listener(entities){
var resize_name = entities["resize_name"].value
var resize_direction = "increase"
var resize_value = 1
if(entities["resize_direction"])
resize_direction=entities["resize_direction"].value
if(entities["resize_value"])
resize_value = entities["resize_value"].value
resize_shape(resize_name,resize_direction,resize_value)
}
function color_shape_listener(entities){
var color_name = entities["color_name"].value
var color_value = 'red'
if(entities["color_value"])
color_value = entities["color_value"].value
color_shape(color_name,color_value)
}
function rotate_shape_listener(entities) {
const rotate_name = entities["rotate_name"].value
var rotate_value = 30;
if (entities["rotate_value"])
rotate_value = entities["rotate_value"].value
//console.log(shape_value);
rotate_shape(rotate_name, rotate_value);
}
function clear_shape_listener(entities){
clear_shape()
}
function save_shape_listener(entities){
save_shape()
}