This repository has been archived by the owner on Oct 6, 2019. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathlaunch.hl
317 lines (270 loc) · 11.4 KB
/
launch.hl
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
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
/*
* File responsible for starting module.
*/
/*
* Including Micro and its "serious" skin.
*/
micro.css.include
p5.web.include-css-file:@MAGIC/media/main.css
/*
* Creating our main wire frame, making sure we set the page's title at the same time.
*/
p5.web.page.set-title:Magic Menu dashboard
create-widget:magic-menu-main-container
class:container magic-menu-editor
events
/*
* Help context Active Event.
*/
desktop.help.get-context
return:@MAGIC/help-files/Magic Menu/index.hl
/*
* Sink necessary to make sure help is NOT loaded at the bottom,
* which would mess with our "never ending scrolling" experience.
*/
desktop.help.get-widget-arguments
return
after:magic-menu-toolbar-row
widgets
div:magic-menu-toolbar-row
class:row
widgets
div
class:col-40
widgets
div
class:strip fill
widgets
input:magic-menu-search-textbox
type:text
onkeydown:@"if (event.keyCode == 13) {p5.$('magic-menu-search-button').raise('onclick');return false;}"
oninit
/*
* Figuring out how many commands we have, and setting the placeholder's value accordingly,
* to give user a visual clue about how much data there actually is.
*/
p5.mysql.connect:[magic-menu]
p5.mysql.scalar:@"select count(*) from commands"
set-widget-property:x:/../*/_event?value
placeholder:Search among {0} commands ...
:x:/@p5.mysql.scalar?value
button:magic-menu-search-button
innerValue:@"<span class=""icon-search""></span>"
title:Search
onclick
/*
* Retrieving filter, and re-databinding grid, now with the specified filter condition.
*/
get-widget-property:magic-menu-search-textbox
value
eval-x:x:/+/*
micro.evaluate.file:@MAGIC/helpers/databind-grid.hl
filter:x:/@get-widget-property/*/*?value
/*
* For simplicity, we set focus to search textbox again.
*/
micro.page.set-focus:magic-menu-search-textbox
/*
* Making sure we store filter.
*/
p5.web.viewstate.set:magic-menu.grid-filter
src:x:/@get-widget-property/*/*?value
/*
* Enabling clear button, if we have a filter, otherwise disabling it.
*/
if:x:/@get-widget-property/*/*?value
!=:
delete-widget-property:magic-menu-clear-search-button
disabled
else
set-widget-property:magic-menu-clear-search-button
disabled
button:magic-menu-clear-search-button
innerValue:@"<span class=""icon-cross""></span>"
title:Clears filter
disabled
onclick
/*
* Clears filter and invokes Ajax event for search button.
*/
set-widget-property:magic-menu-search-textbox
value:
p5.web.widgets.ajax-events.raise:magic-menu-search-button
onclick
div
class:col-60
widgets
div
class:strip fill toolbar
widgets
container:magic-menu-select-language
element:select
oninit
/*
* Selecting all supported languages, which depends upon
* your browser's supported speech languages.
*/
micro.speech.speak.query-voices
onfinish
/*
* Looping through each voice, and creating one option element for each.
*
* But first creating our "select voice" option element.
*/
for-each:x:/../*/voices/*
p5.globalization.get-language-name:x:/@_dp/#?value
_local
if:x:/@_dp/#/*/local?value.bool
not
set:x:/@_local?value
src:", External service"
create-widget
parent:magic-menu-select-language
element:option
innerValue:{1}, {0}{2}
:x:/@_dp/#?name
:x:/@p5.globalization.get-language-name?value
:x:/@_local?value
value:{0},{1}
:x:/@_dp/#?name
:x:/@_dp/#?value
/*
* Setting widget's initial value to language setting for user, if possible.
*/
magic-menu.settings.get-language
set-widget-property:magic-menu-select-language
value:{0},{1}
:x:/@magic-menu.settings.get-language/*/voice?value
:x:/@magic-menu.settings.get-language/*/sublang?value
onchange
/*
* Updating user's settings according to voice selected.
*/
get-widget-property:x:/../*/_event?value
value
magic-menu.settings.set-language:x:/@get-widget-property/*/*?value
/*
* Re-databinding grid.
*/
micro.evaluate.file:@MAGIC/helpers/databind-grid.hl
button:magic-menu-add-command
innerValue:@"<span class=""icon-plus""></span>"
title:Add new command
class:larger
onclick
/*
* Creates a new command, by invoking file responsible for doing just that..
*/
magic-menu.command.create
global-id:your-namespace.your-concepts.some-unique-id
button
innerValue:@"<span class=""icon-download2""></span>"
title:Download dictionary
onclick
/*
* Downloads a backup of entire database as a zip file.
*/
micro.evaluate.file:@MAGIC/helpers/export-dictionary.hl
magic-menu.backup.download
micro.widgets.upload-button
title:Upload dictionary file
accept:.zip,.hl
.onupload
/*
* Invoking file responsible for handling uploads.
*/
add:x:/../*/micro.evaluate.file
src:x:/../*/files
micro.evaluate.file:@MAGIC/helpers/handle-upload-request.hl
/*
* Re-databinding grid.
*/
micro.evaluate.file:@MAGIC/helpers/databind-grid.hl
button:magic-menu-delete-all-commands
innerValue:@"<span class=""icon-bin""></span>"
title:Deletes all commands
onclick
/*
* Asking user to confirm action.
*/
micro.windows.confirm
body:Please confirm deletion of all commands
header:Are you sure you want to <strong>delete all commands</strong>? This action is permanent.
onok
/*
* Deleting all commands, and re-databinding grid.
*/
p5.mysql.connect:[magic-menu]
p5.mysql.delete:@"delete from commands"
/*
* Re-databinding datagrid, and closing modal widget.
*/
set-widget-property:magic-menu-search-textbox
value:
p5.web.widgets.ajax-events.raise:magic-menu-search-button
onclick
/*
* Giving user some feedback.
*/
micro.windows.info:All your commands was successfully deleted
class:micro-windows-info success
a
href:/
role:button
class:button
innerValue:@"<span class=""icon-home3""></span>"
title:Close Magic menu
div
class:row
widgets
container:magic-menu-content
class:col-100
widgets
/*
* Grid containing all words and phrasese Magic menu understands.
*/
micro.widgets.grid:magic-menu-phrases-grid
class:hover striped magic-menu-grid
columns
Command
Parent
Global ID
Username
Global
oninit
/*
* Evaluating file that databinds grid.
*/
micro.evaluate.file:@MAGIC/helpers/databind-grid.hl
/*
* Including JavaScript to determine if user is at the bottom of page,
* at which point we "auto-feed" grid with more items.
*/
p5.web.include-javascript:@"
window.onscroll = function() {
if ((window.innerHeight + window.scrollY) >= document.body.offsetHeight) {
if (!p5.hyperlang_end_of_dataset) {
if(p5.magic_menu_ongoing_scroll === true) {
return;
}
p5.magic_menu_ongoing_scroll = true;
var el = p5.$('magic-menu-phrases-grid');
el.raise('.onfeed',{
onsuccess:function() {
p5.magic_menu_ongoing_scroll = false;
}
});
}
}
};"
.onfeed
/*
* Invoked when grid needs more items.
*/
p5.web.viewstate.get:magic-menu.grid-offset
p5.web.viewstate.get:magic-menu.grid-filter
eval-x:x:/+/*(/offset|/filter)
micro.evaluate.file:@MAGIC/helpers/databind-grid.hl
keep-items:true
offset:x:/../*/p5.web.viewstate.get/[0,1]/*?value
filter:x:/../*/p5.web.viewstate.get/[1,2]/*?value