-
Notifications
You must be signed in to change notification settings - Fork 60
/
Copy pathsettings.html
735 lines (711 loc) · 38.6 KB
/
settings.html
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
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
<!DOCTYPE html>
<html>
<head>
<title>Settings</title>
<meta charset="UTF-8" />
<meta http-equiv="Content-Type" content="text/html" />
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, minimal-ui" />
<script>
if (typeof module === 'object') {
window.module = module; module = undefined;
}
</script>
<!-- solve the electron-jquery conflict, style changed due to a vscode problem -->
<link rel="preload" as="style" href="loader.css" onload="this.rel='stylesheet'">
<!-- loader style preload -->
<script src="res/lib/jquery.slim.min.js"></script>
<script src="res/lib/bootstrap.min.js"></script>
<link rel="stylesheet" type="text/css" href="res/lib/bootstrap.min.css" />
<link rel="stylesheet" type="text/css" href="style.css" />
<script src="res/lib/all.js"></script>
<script src="res/lib/v4-shims.js"></script><!-- font-awesome 5 use as 4 -->
</head>
<body>
<!-- loader -->
<div id="loader-wrapper">
<div id="loader"></div>
<div class="loader-section section-left"></div>
<div class="loader-section section-right"></div>
</div>
<script>
window.onload = function () {
$("body").addClass("loaded");
setTimeout(function () { $('#loader-wrapper').remove() }, 1000);
}
</script>
<script src="supporter.js"></script>
<div id="controller">
<a href="javascript:window.close()" class="small rest"><i class="fa fa-times fa-fw" id="exit-and-save"></i></a>
<script>
$('#exit-and-save').attr('title', i18n.__('exit-and-save'));
if (process.platform == "darwin") $("#controller").css("display", "none");
</script>
</div>
<div class="d-flex h3 rest" id="settings-title">
<i class="fa fa-cog fa-fw" aria-hidden="true"></i>
<script>document.write(i18n.__('settings'));</script>
</div>
<div id="settings-sidebar">
<div class="settings-sidebar-block lead should-lock" id="predefined-tasks-sidebar"
onclick="settingsGoto('predefined-tasks')">
<div class="container-fluid">
<div class="row align-items-start">
<div class="col-3 text-center">
<i class="fa fa-superpowers" aria-hidden="true"></i>
</div>
<div class="col-9">
<script>document.write(i18n.__('predefined-tasks-settings'));</script>
</div>
</div>
</div>
</div>
<div class="settings-sidebar-block lead should-lock" id="global-settings-sidebar"
onclick="settingsGoto('global-settings')">
<div class="container-fluid">
<div class="row align-items-start">
<div class="col-3 text-center">
<i class="fa fa-globe fa-fw" aria-hidden="true"></i>
</div>
<div class="col-9">
<script>document.write(i18n.__('global-settings'));</script>
</div>
</div>
</div>
</div>
<div class="settings-sidebar-block lead" id="locker-sidebar" onclick="settingsGoto('locker')">
<div class="container-fluid">
<div class="row align-items-start">
<div class="col-3 text-center">
<i class="fa fa-lock" aria-hidden="true"></i>
</div>
<div class="col-9">
<script>document.write(i18n.__('locker-settings'));</script>
</div>
</div>
</div>
</div>
<div class="settings-sidebar-block lead should-lock" id="other-things-sidebar"
onclick="settingsGoto('other-things')">
<div class="container-fluid">
<div class="row align-items-start">
<div class="col-3 text-center">
<i class="fa fa-ellipsis-h fa-fw" aria-hidden="true"></i>
</div>
<div class="col-9">
<script>document.write(i18n.__('other-things'));</script>
</div>
</div>
</div>
</div>
</div>
<div class="d-flex" id="settings-container">
<div class="text-left">
<!-- 1. time settings (formally, deleted) -->
<!-- 2. predefined tasks settings -->
<div id="predefined-tasks" class="should-lock">
<div class="align-content-center form-text">
<ul>
<li class="align-self-start text-left small text-muted" type="none">
<script>document.write(i18n.__('predefined-tasks-settings-tip'));</script>
</li>
</ul>
<div class="d-flex text-left">
<div id="itemlist">
<ul id="itemlist-ul"></ul>
</div>
<br /><br />
</div>
<div class="align-self-start text-left">
<a href="javascript:add()" class="text-info underlined">
<script>document.write(i18n.__('add'));</script>
</a>
</div>
</div>
<br />
</div>
<!-- 3. global settings -->
<div id="global-settings" class="should-lock">
<!-- language setting -->
<div class="container">
<div class="row">
<div class="col-1 text-center">
<input id="language-setting" type="checkbox" onchange="languageSetting()" />
</div>
<div class="col-11 text-left">
<label>
<script>document.write(i18n.__('language-setting'));</script>
</label>
<br />
<span class="text-muted small">
<script>document.write(i18n.__('language-setting-tip'));</script>
<b>
<script>document.write(i18n.__('need-to-restart-now-tip'));</script>
</b>
</span>
</div>
</div>
</div>
<br />
<!-- notifying sound setting -->
<div class="container">
<div class="row">
<div class="col-1 text-center">
<input id="notifying-sound-setting" type="checkbox" onchange="notifyingSoundSetting()"
checked />
</div>
<div class="col-11 text-left">
<label>
<script>document.write(i18n.__('sound-to-notify-setting'));</script>
</label>
<br />
<span class="text-muted small">
<script>document.write(i18n.__('sound-to-notify-setting-tip'));</script>
</span>
</div>
</div>
</div>
<br />
<!-- always-on-top setting -->
<div class="container">
<div class="row">
<div class="col-1 text-center">
<input id="always-on-top-setting" type="checkbox" onchange="alwaysOnTopSetting()" />
</div>
<div class="col-11 text-left">
<label>
<script>document.write(i18n.__('always-on-top-setting'));</script>
</label>
<br />
<span class="text-muted small">
<script>document.write(i18n.__('always-on-top-setting-tip'));</script>
<b>
<script>document.write(i18n.__('need-to-restart-now-tip'));</script>
</b>
</span>
</div>
</div>
</div>
<br />
<!-- wnr auto-start setting -->
<div class="container">
<div class="row">
<div class="col-1 text-center">
<input id="auto-start-setting" type="checkbox" onchange="autoStartSetting()" />
</div>
<div class="col-11 text-left">
<label>
<script>document.write(i18n.__('auto-start-setting'));</script>
</label>
<br />
<span class="text-muted small">
<script>document.write(i18n.__('auto-start-setting-tip'));</script>
</span>
</div>
</div>
</div>
<br />
<!-- auto update check setting -->
<div class="container">
<div class="row">
<div class="col-1 text-center">
<input id="auto-check-update-setting" type="checkbox" onchange="autoCheckSetting()" />
</div>
<div class="col-11 text-left">
<label>
<script>document.write(i18n.__('auto-check-update-setting'));</script>
</label>
<br />
<span class="text-muted small">
<script>document.write(i18n.__('auto-check-update-setting-tip'));</script>
</span>
</div>
</div>
</div>
<br />
<!-- alarm for not using setting -->
<div class="container">
<div class="row">
<div class="col-1 text-center">
<input id="alarm-for-not-using-wnr-dialog-box-title-setting" type="checkbox"
onchange="alarmForNotUsingSetting()" />
</div>
<div class="col-11 text-left">
<label>
<script>document.write(i18n.__('is-alarm-for-not-using-wnr-on'));</script>
</label>
<br />
<span class="text-muted small">
<script>document.write(i18n.__('is-alarm-for-not-using-wnr-on-tip'));</script>
</span>
</div>
</div>
</div>
<br />
<!-- one minute left setting -->
<div class="container">
<div class="row">
<div class="col-1 text-center">
<input id="one-min-left-notification-setting" type="checkbox"
onchange="oneMinLeftNotificationSetting()" />
</div>
<div class="col-11 text-left">
<label>
<script>document.write(i18n.__('is-one-min-left-notification-on'));</script>
</label>
<br />
<span class="text-muted small">
<script>document.write(i18n.__('is-one-min-left-notification-on-tip'));</script>
</span>
</div>
</div>
</div>
<br />
<!-- auto start the default task setting -->
<div class="container">
<div class="row">
<div class="col-1 text-center">
<input id="auto-start-task-setting" type="checkbox"
onchange="autoStartDefaultTaskSetting()" />
</div>
<div class="col-11 text-left">
<label>
<script>document.write(i18n.__('is-auto-start-task-setting-on'));</script>
</label>
<br />
<span class="text-muted small">
<script>document.write(i18n.__('is-auto-start-task-setting-on-tip'));</script>
</span>
</div>
</div>
</div>
<br />
<!-- local time shown when timer setting -->
<div class="container">
<div class="row">
<div class="col-1 text-center">
<input id="local-time-setting" type="checkbox" onchange="localTimeSetting()" />
</div>
<div class="col-11 text-left">
<label>
<script>document.write(i18n.__('is-local-time-setting-on'));</script>
</label>
<br />
<span class="text-muted small">
<script>document.write(i18n.__('is-local-time-setting-on-tip'));</script>
</span>
</div>
</div>
</div>
<br />
</div>
<!-- 4. lock mode settings -->
<div id="locker">
<div class="align-content-center form-text">
<label>
<script>
document.write(i18n.__('locker-settings-tip-part-1') + i18n.__('locker-settings-tip-part-2') + '<span class="font-weight-bold rest">'
+ (store.get('islocked') ? i18n.__('on') : i18n.__('off')) + '</span>' + i18n.__('period-symbol'));
</script>
</label>
<br />
<input name="passcode-locker" id="passcode-locker" type="password" maxlength="11"
onkeydown="if(event.keyCode == 13) lock($('#passcode-locker').val(), $('#passcode-locker-again').val());" />
<br />
<input name="passcode-locker-again" id="passcode-locker-again" type="password" maxlength="11"
onkeydown="if(event.keyCode == 13) lock($('#passcode-locker').val(), $('#passcode-locker-again').val());" />
<br />
<span class="text-muted small">
<script>
$('#passcode-locker').attr('placeholder', i18n.__('locker-settings-input'));
$('#passcode-locker-again').attr('placeholder', i18n.__('locker-settings-input-again'));
document.write(store.get('islocked') ? i18n.__('locker-settings-input-tip-lock-mode-on') : i18n.__('locker-settings-input-tip-lock-mode-off'));
</script>
</span>
</div>
<br />
</div>
<!-- 5. other things -->
<div id="other-things" class="should-lock">
<ul>
<!-- manually check for update -->
<li>
<script>document.write(i18n.__('manually-check-for-update-msg'));</script>
<p class="small text-muted">
<a href="javascript:updateChecker(2)" class="rest underlined">
<span id="manually">
<script>document.write(i18n.__('manually-check-for-update'));</script>
</span>
</a>
<b>
<script>document.write(i18n.__('manually-check-for-update-tip-1') + i18n.__('v') + require("./package.json").version + i18n.__('manually-check-for-update-tip-2'))</script>
</b>
</p>
</li>
<!-- hotkey for show or hide -->
<li id="hotkey-tip">
<script>document.write(i18n.__('hotkey-for-show-or-hide-setting'));</script>
<p class="small text-muted">
<script>document.write(cmdOrCtrl._("short", "pascal"))</script>
+ Shift + Alt + <input id="hotkey-for-show-or-hide-setting" class="hotkeyset" type="text"
maxlength="1" onchange="hotkeyForShowOrHideSetting()" />.<br />
<b>
<script>document.write(i18n.__('hotkey-for-show-or-hide-setting-tip') + i18n.__('need-to-restart-now-tip'));</script>
</b>
</p>
</li>
<!-- hotkey for start or stop the task -->
<li id="hotkey2-tip">
<script>document.write(i18n.__('hotkey-for-start-or-stop-setting'));</script>
<p class="small text-muted">
<script>document.write(cmdOrCtrl._("short", "pascal"))</script>
+ Shift + Alt + <input id="hotkey-for-start-or-stop-setting" class="hotkeyset" type="text"
maxlength="1" onchange="hotkeyForStartOrStopSetting()" />.<br />
<b>
<script>document.write(i18n.__('hotkey-for-start-or-stop-setting-tip') + i18n.__('need-to-restart-now-tip'));</script>
</b>
</p>
</li>
<!-- delete all the data -->
<li>
<script>document.write(i18n.__('delete-all-data-msg'));</script>
<p class="small text-muted">
<a href="javascript:call('delete-all-data')" class="rest underlined">
<script>document.write(i18n.__('delete-all-data'));</script>
</a>
<b>
<script>document.write(i18n.__('need-to-restart-now-tip'));</script>
</b>
</p>
</li>
<!-- settings backup -->
<li>
<script>document.write(i18n.__('settings-backup-msg'));</script>
<p class="small text-muted">
<a href="javascript:settingsBackup()" class="rest underlined">
<script>document.write(i18n.__('settings-backup'));</script>
</a>
<script>document.write(i18n.__('settings-backup-tip'));</script>
</p>
</li>
<!-- settings import -->
<li>
<script>document.write(i18n.__('settings-import-msg'));</script>
<br />
<input name="settings-import-input" id="settings-import-input" type="password"
onkeydown="if(event.keyCode == 13) settingsImport($('#settings-import-input').val());" />
<script> $('#settings-import-input').attr('placeholder', i18n.__('settings-import'));</script>
<p class="small text-muted">
<script>document.write(i18n.__('settings-import-tip'));</script>
<b>
<script>document.write(i18n.__('need-to-restart-now-tip'));</script>
</b>
</p>
</li>
<!-- tip for notification-sending -->
<li>
<script>document.write(i18n.__('notification-sending-tip-msg'));</script>
<p class="small text-muted">
<script>
document.write(i18n.__('notification-sending-tip'));
</script>
</p>
</li>
</ul>
</div>
</div>
</div>
<div class="get-help" id="settings-helper">
<a class="small rest">
<i class="fa fa-question" id="helper"></i>
</a>
</div>
<script>
if (process.platform == 'darwin') $("#hotkey-tip").css("display", "none");
$(".get-help").attr('title', i18n.__('helper'));
settingsGoto(store.get("settings-goto"));
function settingsGoto(mask) {
if (mask == "locker") {
$("#settings-helper a").attr("href", "javascript:getHelp('settings/4-lock-mode-settings')");
$("#locker-sidebar").addClass("settings-sidebar-block-highlighted");
$("#predefined-tasks-sidebar").removeClass("settings-sidebar-block-highlighted");
$("#other-things-sidebar").removeClass("settings-sidebar-block-highlighted");
$("#global-settings-sidebar").removeClass("settings-sidebar-block-highlighted");
$("#locker").css("display", "block");
$("#predefined-tasks").css("display", "none");
$("#global-settings").css("display", "none");
$("#other-things").css("display", "none");
} else if ((mask == "predefined-tasks" || mask == "normal" || mask == "" || mask == null) && (!store.get('islocked'))) {
$("#settings-helper a").attr("href", "javascript:getHelp('settings/2-predefined-tasks-settings')");
$("#locker-sidebar").removeClass("settings-sidebar-block-highlighted");
$("#predefined-tasks-sidebar").addClass("settings-sidebar-block-highlighted");
$("#other-things-sidebar").removeClass("settings-sidebar-block-highlighted");
$("#global-settings-sidebar").removeClass("settings-sidebar-block-highlighted");
$("#locker").css("display", "none");
$("#predefined-tasks").css("display", "block");
$("#global-settings").css("display", "none");
$("#other-things").css("display", "none");
} else if (mask == "global-settings" && (!store.get('islocked'))) {
$("#settings-helper a").attr("href", "javascript:getHelp('settings/3-global-settings')");
$("#locker-sidebar").removeClass("settings-sidebar-block-highlighted");
$("#predefined-tasks-sidebar").removeClass("settings-sidebar-block-highlighted");
$("#other-things-sidebar").removeClass("settings-sidebar-block-highlighted");
$("#global-settings-sidebar").addClass("settings-sidebar-block-highlighted");
$("#locker").css("display", "none");
$("#predefined-tasks").css("display", "none");
$("#global-settings").css("display", "block");
$("#other-things").css("display", "none");
} else if (mask == "other-things" && (!store.get('islocked'))) {
$("#settings-helper a").attr("href", "javascript:getHelp('settings/5-other-things')");
$("#locker-sidebar").removeClass("settings-sidebar-block-highlighted");
$("#predefined-tasks-sidebar").removeClass("settings-sidebar-block-highlighted");
$("#other-things-sidebar").addClass("settings-sidebar-block-highlighted");
$("#global-settings-sidebar").removeClass("settings-sidebar-block-highlighted");
$("#locker").css("display", "none");
$("#predefined-tasks").css("display", "none");
$("#global-settings").css("display", "none");
$("#other-things").css("display", "block");
}
}
</script>
<script src="updater.js"></script>
<script>
var timeOut = null;//temporary variable
//defaults settings
let defaultArray = store.get("predefined-tasks");
let newItem = {
name: "new item",
workTime: 30,
restTime: 10,
loops: 4,
focusWhenWorking: false,
focusWhenResting: false
};
defaultArray.forEach(function (item, index, array) {
append(item, index);
});
setAsDefault(store.get("default-task"));
function edit(index) {
defaultArray[index].name = $("#title" + index).val();
if (Number($("#work-time" + index).val()) != NaN && Number($("#work-time" + index).val()) >= 2) defaultArray[index].workTime = $("#work-time" + index).val();
else $("#work-time" + index).val(defaultArray[index].workTime);
if (Number($("#rest-time" + index).val()) != NaN && Number($("#rest-time" + index).val()) >= 2) defaultArray[index].restTime = $("#rest-time" + index).val();
else $("#rest-time" + index).val(defaultArray[index].restTime);
if (Number($("#loops" + index).val()) != NaN && Number($("#loops" + index).val()) >= 1) defaultArray[index].loops = $("#loops" + index).val();
else $("#loops" + index).val(defaultArray[index].loops);
if (document.getElementById("focus-when-working" + index).checked) defaultArray[index].focusWhenWorking = true;
else defaultArray[index].focusWhenWorking = false;
if (document.getElementById("focus-when-resting" + index).checked) defaultArray[index].focusWhenResting = true;
else defaultArray[index].focusWhenResting = false;
store.set("predefined-tasks", defaultArray);
}
function append(item, index) {
$("#itemlist-ul").append(
"<li id='item" + index + "'> <input name='title' id='title" + index + "' type='text' class='lead rest' maxlength='11' value='" +
item.name + "'onchange='edit(" + index + ")' /> <br /><div class='text-muted small'>" +
i18n.__('predefined-tasks-settings-tip-part-1') + " <input id='work-time" + index + "' class='hotkeyset' type='number' value='" +
item.workTime + "'onchange='edit(" + index + ")' oninput='if (value.length > 2) value = value.slice(0, 2)' style='ime-mode:Disabled' /> " +
i18n.__('min') +
i18n.__('predefined-tasks-settings-tip-part-2') + " <input id='rest-time" + index + "' class='hotkeyset' type='number' value='" +
item.restTime + "'onchange='edit(" + index + ")' oninput='if (value.length > 2) value = value.slice(0, 2)' style='ime-mode:Disabled' /> " +
i18n.__('min') +
i18n.__('predefined-tasks-settings-tip-part-3') + " <input id='loops" + index + "' class='hotkeyset' type='number' value='" +
item.loops + "'onchange='edit(" + index + ")' oninput='if (value.length > 2) value = value.slice(0, 2)' style='ime-mode:Disabled' /> " +
i18n.__('times') +
"<br />" + i18n.__('focus-when-working') + " <input id='focus-when-working" + index + "' class='focuser' type='checkbox' onchange='edit(" + index + ")' /> | " +
i18n.__('focus-when-resting') + " <input id='focus-when-resting" + index + "' class='focuser' type='checkbox' onchange='edit(" + index + ")' />\
<br /><span id='set-as-default-task-container" + index + "'><a class='rest underlined' href='javascript:setAsDefault(" + index + ")'>" + i18n.__('set-as-default-task') + "</a> | </span>\
<span id='deleter" + index + "'><a href='javascript:erase(" + index + ")' class='work underlined'>" + i18n.__('delete') + "</a></span>\
</div><hr /></li>"
);
if (item.focusWhenWorking) document.getElementById("focus-when-working" + index).checked = true;
else document.getElementById("focus-when-working" + index).checked = false;
if (item.focusWhenResting) document.getElementById("focus-when-resting" + index).checked = true;
else document.getElementById("focus-when-resting" + index).checked = false;
}
function erase(index) {
defaultArray.splice(index, 1);
store.set("predefined-tasks", defaultArray);
$("#item" + index).remove();
}
function add() {
defaultArray.push(newItem);
store.set("predefined-tasks", defaultArray);
append(newItem, defaultArray.length - 1);
}
function setAsDefault(index) {
$("#deleter" + store.get("default-task")).css("display", "inline");
$("#set-as-default-task-container" + store.get("default-task")).css("display", "inline");
$('#title' + store.get("default-task")).removeClass("work");
$('#title' + store.get("default-task")).addClass("rest");
store.set("default-task", index);
$("#deleter" + index).css("display", "none");
$("#set-as-default-task-container" + index).css("display", "none");
$('#title' + index).removeClass("rest");
$('#title' + index).addClass("work");
}
//global settings
if (store.get("i18n") != undefined) {
if (store.get("i18n") == 'en') document.getElementById("language-setting").checked = true;
else document.getElementById("language-setting").checked = false;
}
function languageSetting() {
if (document.getElementById("language-setting").checked == true) store.set("i18n", 'en');
else {
var lang = navigator.language;
if ((lang.charAt(3) == 'T' && lang.charAt(4) == 'W') && (lang.charAt(3) == 'H' && lang.charAt(4) == 'K')) lang = 'zh-TW';
else lang = 'zh-CN';
store.set('i18n', lang);
}
timeOut = setTimeout("call('relauncher')", 500);
}
if (store.get("sound") != undefined) {
if (store.get("sound")) document.getElementById("notifying-sound-setting").checked = true;
else document.getElementById("notifying-sound-setting").checked = false;
}
function notifyingSoundSetting() {
if (document.getElementById("notifying-sound-setting").checked == true) store.set("sound", true);
else store.set("sound", false);
}
if (store.get("top") != undefined) {
if (store.get("top") == true) document.getElementById("always-on-top-setting").checked = true;
else document.getElementById("always-on-top-setting").checked = false;
}
function alwaysOnTopSetting() {
if (document.getElementById("always-on-top-setting").checked == true) store.set("top", true);
else store.set("top", false);
timeOut = setTimeout("call('relauncher')", 500);
}
if (store.get("autostart") == true) document.getElementById("auto-start-setting").checked = true;
else document.getElementById("auto-start-setting").checked = false;
function autoStartSetting() {
var AutoLaunch = require('auto-launch');
var wnrLauncher = new AutoLaunch({ name: 'wnr' });
if (document.getElementById("auto-start-setting").checked == true) {
store.set("autostart", true);
wnrLauncher.isEnabled()
.then(function (isEnabled) {
if (isEnabled) {
return;
}
wnrLauncher.enable();
})
}
else {
store.set("autostart", false);
wnrLauncher.isEnabled()
.then(function (isEnabled) {
if (isEnabled) {
wnrLauncher.disable();
}
return;
})
}
}
if (store.get("autocheck") != false) document.getElementById("auto-check-update-setting").checked = true;
else document.getElementById("auto-check-update-setting").checked = false;
function autoCheckSetting() {
if (document.getElementById("auto-check-update-setting").checked == true) store.set("autocheck", true);
else store.set("autocheck", false);
}
if (store.get("alarmtip") != false) document.getElementById("alarm-for-not-using-wnr-dialog-box-title-setting").checked = true;
else document.getElementById("alarm-for-not-using-wnr-dialog-box-title-setting").checked = false;
function alarmForNotUsingSetting() {
if (document.getElementById("alarm-for-not-using-wnr-dialog-box-title-setting").checked == true) store.set("alarmtip", true);
else store.set("alarmtip", false);
}
if (store.get("onemintip") != false) document.getElementById("one-min-left-notification-setting").checked = true;
else document.getElementById("one-min-left-notification-setting").checked = false;
function oneMinLeftNotificationSetting() {
if (document.getElementById("one-min-left-notification-setting").checked == true) store.set("onemintip", true);
else store.set("onemintip", false);
}
if (store.get("autostarttask") == true) document.getElementById("auto-start-task-setting").checked = true;
else document.getElementById("auto-start-task-setting").checked = false;
function autoStartDefaultTaskSetting() {
if (document.getElementById("auto-start-task-setting").checked == true) store.set("autostarttask", true);
else store.set("autostarttask", false);
}
if (store.get("localtime") != false) document.getElementById("local-time-setting").checked = true;
else document.getElementById("local-time-setting").checked = false;
function localTimeSetting() {
if (document.getElementById("local-time-setting").checked != false) store.set("localtime", true);
else store.set("localtime", false);
}
//lock mode settings
function lock(passcode, again) {
var md5 = require('crypto-js/md5');
if (passcode == "" || again == "") ipc.send("locker-passcode", 'empty');
else
if (!store.get('islocked')) {
if (passcode == again) {
store.set('lockerpasscode', md5(passcode).toString());
store.set('islocked', true);
ipc.send("locker-passcode", 'lock-mode-on');
window.close();
} else ipc.send("locker-passcode", 'not-same-password');
} else {
if (passcode == again) {
if (passcode == store.get('lockerpasscode') || md5(passcode).toString() == store.get('lockerpasscode')) {
store.set('islocked', false);
ipc.send("locker-passcode", 'lock-mode-off');
window.close();
} else ipc.send("locker-passcode", 'wrong-passcode');
} else ipc.send("locker-passcode", 'not-same-password');
}
}
//other things
$("#hotkey-for-show-or-hide-setting").val(store.get("hotkey1").toUpperCase());
function hotkeyForShowOrHideSetting() {
if ($("#hotkey-for-show-or-hide-setting").val() != null && $("#hotkey-for-show-or-hide-setting").val()) {
if ($("#hotkey-for-show-or-hide-setting").val().toUpperCase() != store.get('hotkey2')) {
$("#hotkey-for-show-or-hide-setting").val($("#hotkey-for-show-or-hide-setting").val().toUpperCase());
store.set("hotkey1", $("#hotkey-for-show-or-hide-setting").val());
timeOut = setTimeout("call('relauncher')", 500);
} else $("#hotkey-for-show-or-hide-setting").val(store.get("hotkey1"));
} else {
store.set("hotkey1", 'W');
timeOut = setTimeout("call('relauncher')", 500);
}
}
$("#hotkey-for-start-or-stop-setting").val(store.get("hotkey2").toUpperCase());
function hotkeyForStartOrStopSetting() {
if ($("#hotkey-for-start-or-stop-setting").val() != null && $("#hotkey-for-start-or-stop-setting").val()) {
if ($("#hotkey-for-start-or-stop-setting").val().toUpperCase() != store.get('hotkey1')) {
$("#hotkey-for-start-or-stop-setting").val($("#hotkey-for-start-or-stop-setting").val().toUpperCase());
store.set("hotkey2", $("#hotkey-for-start-or-stop-setting").val());
timeOut = setTimeout("call('relauncher')", 500);
} else $("#hotkey-for-start-or-stop-setting").val(store.get("hotkey2"));
} else {
store.set("hotkey2", 'S');
timeOut = setTimeout("call('relauncher')", 500);
}
}
// settings backup & import
var aes = require("crypto-js/aes");
var encoding = require("crypto-js/enc-utf8");
var copyToClipboard = require("copy-to-clipboard");
function settingsBackup() {
var ciphertext = aes.encrypt(JSON.stringify(store.store), 'We all love wnr, so please do not use this passcode to do bad things.');
copyToClipboard(ciphertext.toString());
alert(i18n.__('copied'));
}
function settingsImport(token) {
var bytes = aes.decrypt(token, 'We all love wnr, so please do not use this passcode to do bad things.');
var isAllRight = true;
try {
var decryptedData = JSON.parse(bytes.toString(encoding));
store.set(decryptedData);
} catch (error) {
if (error instanceof SyntaxError) {
alert(i18n.__('settings-import-error'))
isAllRight = false;
}
}
setTimeout(function () {
if (isAllRight) call('relauncher');
}, 500);
}
</script>
<script src="renderer.js"></script>
</body>
</html>