-
Notifications
You must be signed in to change notification settings - Fork 0
/
gadget_annyang.js
99 lines (86 loc) · 2.99 KB
/
gadget_annyang.js
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
90
91
92
93
94
95
96
97
98
/*jslint nomen: true, indent: 2, maxerr: 3 */
/*global window, rJS */
(function (window, rJS, CodeMirror, annyang) {
"use strict";
//var utterance = new SpeechSynthesisUtterance('ok');
//utterance.rate = 1.5;
//window.speechSynthesis.speak(utterance);
//https://github.com/alanjames1987/Cross-Browser-Voice-Recognition-with-PocketSphinx.js
rJS(window)
/////////////////////////////
// ready
/////////////////////////////
.ready(function (my_gadget) {
my_gadget.property_dict = {};
})
/////////////////////////////
// acquired methods
/////////////////////////////
.declareAcquiredMethod('routeCodeMirrorCommand', 'routeCodeMirrorCommand')
/////////////////////////////
// declared methods
/////////////////////////////
.declareMethod('setCommand', function (my_command) {
return this.routeCodeMirrorCommand(my_command);
})
.declareMethod('render', function (my_option_dict) {
var gadget = this,
commands = {},
cmd;
commands["left"] = function () {
return gadget.setCommand("myEditor_navigateLeft");
};
commands["right"] = function () {
return gadget.setCommand("myEditor_navigateRight");
};
commands["up"] = function () {
return gadget.setCommand("myEditor_navigateDown");
};
commands["down"] = function () {
return gadget.setCommand("myEditor_navigateUp");
};
commands["save"] = function () {
return gadget.setCommand("myEditor_saveFromDialog");
};
commands["close"] = function () {
return gadget.setCommand("myEditor_closeFile");
};
commands["open"] = function () {
return gadget.setCommand("myEditor_openFromDialog");
};
commands["remove"] = function () {
return gadget.setCommand("myEditor_deleteFile");
};
commands["search"] = function () {
return gadget.setCommand("myEditor_searchFileMenu");
};
commands["bulk"] = function () {
return gadget.setCommand("myEditor_bulkSaveFromDialog");
};
commands["sync"] = function () {
return gadget.setCommand("myEditor_sync");
};
commands["pick"] = function () {
return gadget.setCommand("myEditor_pickDialogOption");
};
commands["tab"] = function () {
return gadget.setCommand("myEditor_traverseDialog");
};
commands["escape"] = function () {
return gadget.setCommand("myEditor_closeDialog");
};
/*
gadget.property_dict.command_dict = my_option_dict.commands;
for (cmd in gadget.property_dict.command_dict) {
if (gadget.property_dict.command_dict.hasOwnProperty(cmd)) {
commands[cmd] = function () {
return gadget.setCommand(gadget.property_dict.command_dict[cmd]);
};
}
}
*/
annyang.addCommands(commands);
annyang.start();
return gadget;
});
}(window, rJS, CodeMirror, annyang));