-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex2.html
1581 lines (1333 loc) · 40.1 KB
/
index2.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
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>Shortexts</title>
<style>
*{
outline: none;
}
body{
font-family: "Lucida Grande";
margin: 0;
font-weight: 200;
padding: 0;
background: rgba(0,0,0,0.8);
font-size: 12px;
line-height: 130%;
overflow:hidden;;
color:#fff;
-moz-user-select: none;
-webkit-user-select: none;
-ms-user-select:none;
user-select:none;
-o-user-select:none;
cursor: default;
}
.sec{
overflow: scroll;
}
.center{
text-align: center;
}
.underline{
text-decoration: underline;;
}
table{
border:1px solid black;
width:100%;
border: 0;
}
li.odd{
background: rgba(0,0,0,0.9);
}
li.even{
background: rgba(50,50,50,0.6);
}
table td{
/*border:1px solid #999;*/
padding:2px;
padding-left: 4px;
word-wrap: break-word;
max-width: 200px;
/*background: #f4f4f4;*/
}
.sec_margin{
margin-left:20px;
margin-right:20px;
}
#wrapper{
/*margin:120px 100px;*/
margin: 60px 0px;
padding-top: 0px;
overflow-y: scroll;
max-height: 400px;
/*max-height: 450px;*/
}
#menu a{
text-decoration:none;
}
.sec a{
color:#ccc;
text-decoration: underline;
}
.header_table{
width:400px;
margin:auto;
}
.header_table{
/*border: 1px solid #aaa;*/
border-bottom: 0;
}
#current_values_wrapper{
max-height: 700px;
/*width:400px;
*/
margin:auto;
overflow:scroll;
/*
border: 1px solid #aaa;
*/
/* border:1px solid #999;
padding: 0px 5px;
background: #ccc;**/
}
#current_values{
}
#current_values ul{
list-style: none;
margin:0;
padding:0;
line-height: 150%;
margin-top: 20px;
}
#current_values input, #current_values textarea{
background: none;
color: #fff;
width: 50%;
}
#current_values textarea{
width: 90%;
}
#current_values ul li{
position: relative;
}
#current_values ul li .options_cell{
text-decoration: none;
position: absolute;;
top:15px;
right:15px;
color:#555;
/*display:block;
float:right;*/
}
#current_values ul li .options_cell.encrypt_element,
#current_values ul li .options_cell.see_element,
#current_values ul li .options_cell.delete_element
{
}
#current_values ul li{
margin-bottom: 5px;
padding:15px;
/*
border-bottom: 1px solid #ccc;
*/
}
#header{
padding:0px 0px 5px 0px ;
background: #eee;
box-shadow: 0px 2px 10px #ccc;
position:fixed;
top:0px;
width:100%;
background: #000;
color:#fff;
box-shadow: 0px 2px 10px #000;
border-bottom:3px solid #333;
box-shadow: none;
}
#menu{
margin-top:20px;
margin-bottom:5px;
padding:5px;
padding-top:8px;
text-align: Center;
}
#menu a{
color: #888;
text-decoration: none;
}
#menu a.selected{
color:#333;
color:#ccc;
}
.new_text{
width:450px;
margin:auto;
}
.new_text .left{
float:left;
width:50%;
}
.new_text right{
float:left;
width:50%;
}
input[type=button],button{
font-size:16px;
padding:5px 15px;
border-radius:4px;
border: 1px solid #aaa;
background: #efefef;
cursor:pointer;
}
input[type=text],textarea{
padding:5px;
font-size: 14px;
border:1px solid #ccc;
box-shadow: 0px 0px 1px #ccc;
border-radius: 3px;
border:1px solid #333;
}
td.delete_cell{
text-align: center;
font-weight: 800;
width:40px;
}
td.delete_cell a{
}
.key_cell{
/*width: 130px;*/
margin-top:5px;
font-size:11px;
color:#aaa;
}
.val_cell{
font-size:14px;
color:#eee;
line-height: 130%;
margin-right:60px;
}
.sec_content{
margin-left: 45px;
margin-left: 0px;
margin-top:25px;
line-height: 180%;
}
.grey-box{
padding: 15px;
}
textarea#new_value{
min-height: 50px;
width: 260px;
background-size: 100%;
background-repeat: no-repeat;
background-position: center;;
border-radius: 3px;
}
input{
border-radius: 3px;
}
h2{
margin: 10px 0px 20px 0px;
}
.transparent_button{
background: rgba(130,130,130,0.5);
border:none;
border-radius: 4px;
font-size: 14px;
padding: 6px 10px;
color:#eee;
}
.new_shortext {
float: right;
margin-right: 5px;
margin-top: 5px;
}
#password_prompt, #confirmation_prompt{
position: fixed;
top:0px;
left:0px;
width: 100%;
height: 100%;
color:#fff;
text-align: center;
padding-top: 40px;
display:none;
background: rgba(0,0,0,0.8);
z-index: 9999;
}
#password_prompt input{
padding: 5px 5px;
font-size:14px;
}
#drag_area{
width:200px;
height:70px;
border: 2px dotted #ccc;
text-align: center;
padding-top:50px;
}
#new_shortext_area{
display: none;
padding: 15px;
text-align: center;
}
.new_shortext{
position: absolute;
top:0px;
right:0px;
z-index: 99999;
}
#button_new_shortext{
font-size: 16px;
padding: 2px 10px 4px 10px;;
}
img.icon{
max-width: 14px;
padding: 0;
margin: 0;
}
</style>
</head>
<body>
<div id="header">
<!-- All of the Node.js APIs are available in this renderer process. -->
<div id="menu">
<a href="" class="menu_link selected" data-id-menu-link="shortexts">ShortTexts</a>
<a href="" class="menu_link" data-id-menu-link="preferences">Preferences</a>
<a href="" class="menu_link" data-id-menu-link="feedback">Feedback</a>
<a href="" class="menu_link" data-id-menu-link="about">About</a>
</div>
</div>
<div id="wrapper">
<div id="sec_shortexts" class="sec">
<!--
<div class="center new_text">
<div class="left" style="text-align:left">
<textarea id="new_value" type="text" placeholder="Text that will be pasted"></textarea>
<br /><br />
<input type="text" id="new_key" placeholder="Shortext or label" alt="A short text to remember the text">
</div>
<div class="right">
</div>
<div style="clear:both"> </div>
<br />
<button type="button" id="add_value" value="Add Shortext">Add Shortext</button>
<br />
<span id="info"></span>
<br />
</div>
-->
<div class="" style="position:relative;top:0px;z-index:9999">
<div class="new_shortext">
<!-- <button class="transparent_button" id="button_new_shortext">New Shortext</button>-->
<button class="transparent_button" id="button_new_shortext">+</button>
</div>
<br />
<!--<div id="drag_area">
drag
</div>-->
<div style="clear:both"> </div>
<div class="header_table">
</div>
<div id="new_shortext_area">
<div class="">
<textarea id="new_value" type="text" placeholder="Text that will be pasted
OR drag an image
OR a folder to create a direct access"></textarea>
</div>
<span class="">
<input type="text" id="new_key" placeholder="Shortext or label">
</span>
<button type="button" id="add_value" class="transparent_button" value="Add Shortext">Add Shortext</button>
</div>
<div id="current_values_wrapper">
<div id="current_values">
<ul>
</ul>
</div>
</div>
</div>
</div>
<div id="sec_feedback" class="sec sec_margin" style="display:none">
<br />
<h2>Feedback</h2>
<div class="sec_content">
<p>
Shortexts is beta software still under development.
</p>
<p>
If you find anything that does not work as it should, an error or a bug, please notify.
</p>
<p>
Also if you want to suggest features, please let us know.
</p>
<p>
Go to <a href="#" style="color:#4595FF" class="go_to_website underline">Shortexts.com</a> to get support & provide feedback.
</p>
<p>
We really appreciate your feedback.
</p>
</div>
</div>
<div id="sec_preferences" class="sec sec_margin" style="display:none">
<br />
<h2>Preferences</h2>
<div class="sec_content">
<div>
<input type="checkbox" class="preference" data-id-preference="startup" id="preference_startup"> Launch app at Startup<br />
</div>
<!--<input type="checkbox" class="preference" data-id-preference="search_by_value" id="preference_search_by_value" checked> Search by value<br />-->
<div>
<input type="checkbox" class="preference" data-id-preference="press_intro" id="preference_press_intro" > Include new line after selection (you can achieve the sime holding intro one sec)<br />
</div>
<div>
<input type="checkbox" class="preference" data-id-preference="emojis" id="preference_emojis" checked> Include emojis in search<br />
</div>
<div>
</div>
</div>
<br /><br />
<h2>Password</h2>
<div class="sec_content">
<p>
You can protect values with a password.
</p>
<p>
Set it or change it here:
</p>
<div>
<input type="password" placeholder="password" id="new_password"> <a href="#" id="change_password">Set new Password</a>
</div>
<div>
</div>
</div>
<br /><br />
<h2>Import/Export Data</h2>
<div class="sec_content">
<p>Save your shortexts in a file or import the shortexts previously saved in a file:</p>
<div>
<a href="" onClick="exportar();return false;">Export Data</a>
</div>
<div>
<a href="" onClick="document.querySelector('#importar').click();return false;">Import Data</a> <input style="visibility:hidden; width: 15px;" type="file" id="importar"> <input type="checkbox" id="importar_overwrite"> Overwrite values if there's conflict
</div>
<div>
</div>
<div>
<a href="" onClick="erase_all_data();return false;">Erase All Data</a>
</div>
</div>
<br /><br />
</div>
<div id="sec_about" class="sec sec_margin" style="display:none">
<br />
<h2>About</h2>
<div class="sec_content">
<p>
Shortexts are shorcuts to texts you use frequently.
</p>
<p style="margin-top:0px;height:0px;">
</p>
<h3 style="color:#4595FF">How To Use</h3>
<p style="padding-left:20px">
1. When in an editor, document, website... Press <span style="color:#4595FF">CMD+L</span> to look for a stored text. Press intro ant it will be pasted.
</p>
<p style="padding-left:20px">
2. To store a text press <span style="color:#4595FF">CMD+SHIFT+L</span>. In the <a href="#" style="color:#4595FF" class="go_shortexts underline">Shortexts</a> section you will store your texts.
</p>
<p>
</p>
<p>
You might use it for: Loren ipsum texts, Email templates, Code Snippets, Phones/Addresses, Bank account numbers, ...
</p>
<p>
</p>
<p> </p>
<h3>Credits & Support</h3>
<p>
Shortexts it's being developed by Carlos Rubio Martí using the Atom Electrom project.
</p>
<p>
Icons made by Freepik.com from www.flaticon.com is licensed by CC 3.0 BY
</p>
<p>
Go to <a href="#" class="go_to_website underline">Shortexts.com</a> to get support, provide feedback, check updates and to know more.
</p>
<p>
</p>
<h3>Donations</h3>
<p>
If this is really helping you to be more productive, please consider buying me a coffee for further development!
</p>
<p>
<a class="go_donation underline" href="">You can do it here, any amount is great</a>!
</p>
<p>
Thanks!
</p>
<p>
</p>
</div>
</div>
</div>
<div id="password_prompt">
<div class="">
<br /><br />
<span id="password_prompt_message">Please input the password </span>
<!-- --><br /><br />
<input type="password" id="password"> <button id="password_ok">OK</button>
</div>
</div>
<div id="confirmation_prompt">
<div class="">
<br /><br />
<span id="confirmation_prompt_message">are you sure?</span>
<!-- --><br /><br />
<button id="confirmation_yes">OK</button> <button id="confirmation_no">NO</button>
</div>
</div>
</body>
<script>
// You can also require other files to run in this process
require('./renderer.js')
var remote = require('electron').remote;
var callback_password_input = function(pass){
}
var callback_confirmation_yes = function(){
}
var callback_confirmation_no = function(){
}
document.querySelector('#confirmation_yes').addEventListener('click',ev=>{
document.querySelector("#confirmation_prompt").style.display = 'none';
callback_confirmation_yes();
})
document.querySelector('#confirmation_no').addEventListener('click',ev=>{
document.querySelector("#confirmation_prompt").style.display = 'none';
callback_confirmation_no();
})
var new_password_input = document.querySelector("#new_password");
new_password_input.addEventListener('keyup', ev => {
var key = ev.which || ev.keyCode;
if (key === 13) { // 13 is enter
var e = document.createEvent('event');
e.initEvent('click', false, true);
var el = document.querySelector("#change_password");
el.dispatchEvent(e);
}
});
var password_change = document.querySelector("#change_password");
password_change.addEventListener('click', ev => {
var new_password = document.querySelector("#new_password").value;
document.querySelector("#password").value = "";
document.querySelector("#password_prompt").style.display = 'none';
if(is_password_set()){
callback_password_input = function(pass){
var args = {}
args.new_password = new_password;
args.current_password = pass;
require('electron').ipcRenderer.send('changePassword',args);
}
prompt_password("Your current password: ");
}else{
callback_password_input = function(pass){
var args = {};
if(new_password!=pass){
alert('Passwords do not match. Password has not been changed');
return;
}
args.new_password = new_password;
args.current_password = pass;
require('electron').ipcRenderer.send('changePassword',args);
}
prompt_password("Repeat password: ");
}
});
var password_input = document.querySelector("#password");
password_input.addEventListener('keyup', ev => {
var key = ev.which || ev.keyCode;
if (key === 13) { // 13 is enter
var e = document.createEvent('event');
e.initEvent('click', false, true);
var el = document.querySelector("#password_ok");
el.dispatchEvent(e);
}
});
var password_ok = document.querySelector("#password_ok");
password_ok.addEventListener('click', ev => {
var password = document.querySelector("#password").value;
document.querySelector("#password").value = "";
document.querySelector("#password_prompt").style.display = 'none';
callback_password_input(password);
});
/// LISTENERS
var menu_links = document.querySelectorAll(".menu_link");
for(i=0;i<menu_links.length;i++){
menu_links[i].addEventListener('click', ev => {
ev.preventDefault();
var secs = document.querySelectorAll(".sec");
for(j=0;j<secs.length;j++){
secs[j].style.display = 'none';
}
var links = document.querySelectorAll(".menu_link");
for(k=0;k<links.length;k++){
links[k].classList.remove('selected');
}
var sec = ev.target.getAttribute('data-id-menu-link');
document.querySelector('#sec_'+sec).style.display = 'block'
document.querySelector('.menu_link[data-id-menu-link='+sec+']').classList.add('selected');
return false;
});
}
var go_main = document.querySelectorAll(".go_shortexts");
for(i=0;i<go_main.length;i++){
go_main[i].addEventListener('click',ev=>{
document.querySelector('.menu_link[data-id-menu-link=shortexts]').click();
document.querySelector('#button_new_shortext').click();
})
}
var go_donation = document.querySelectorAll(".go_donation");
for(i=0;i<go_donation.length;i++){
go_donation[i].addEventListener('click',ev=>{
require('electron').ipcRenderer.send('goToDonation',"");
return false;
})
}
var go_url = document.querySelectorAll(".go_to_website");
for(i=0;i<go_url.length;i++){
go_url[i].addEventListener('click',ev=>{
require('electron').ipcRenderer.send('goToWebsite',"");
})
}
var prompt_password = function(message =""){
//var passwrd = prompt('Introduce the master password please!');
if(message){
document.querySelector("#password_prompt_message").innerHTML = message;
}else{
document.querySelector("#password_prompt_message").innerHTML = "Please input the password"
}
document.querySelector("#password_prompt").style.display = 'block';
document.querySelector("#password").focus();
}
var prompt_confirmation = function(){
document.querySelector("#confirmation_prompt").style.display = 'block';
}
/*
document.querySelector("#add_value").addEventListener("click",function(){
var key = document.querySelector("#new_key").value;
var val = document.querySelector("#new_value").value;
if(!key || !val){
return;
}
addElement(key,val);
document.querySelector("#new_key").value = "";
document.querySelector("#new_value").value = "";
document.querySelector("#info").innerHTML ="Inserted!"
setTimeout(function(){
document.querySelector("#info").innerHTML = ""
},5000)
printItems();
});;
*/
var prefs = document.querySelectorAll('.preference');
for(i=0; i<prefs.length;i++){
prefs[i].addEventListener("click",function(ev){
var pref = ev.target.getAttribute('data-id-preference');
var checked = ev.target.checked;
var args = {}
if(pref =='startup'){
args.option = 'launchStartup'
if(checked){
args.value = true;
}else{
args.value = false;
}
}else if(pref=='press_intro'){
args.option = 'pressIntro'
if(checked){
args.value = true;
}else{
args.value = false;
}
}else if(pref=='emojis'){
args.option = 'emojis'
if(checked){
args.value = true;
}else{
args.value = false;
}
}/*else if(pref=='search_by_value'){
if(checked){}else{}
}*/
if(args) require('electron').ipcRenderer.send('setOption',args);
})
}
require('electron').ipcRenderer.on('valueDecrypted' , function(event , data){
//var options = get_options();
if(data.error){
alert(data.error);
return;
}
alert(data.value);
});
require('electron').ipcRenderer.on('valueEncrypted' , function(event , data){
//var options = get_options();
if(data.error){
//console.log('ERROR store encrypted');
alert(data.error);
return;
}
var key = data.key;
var encrypted_value = data.encrypted_value;
if(getElement(key)){
removeElement(key);
}
encrypted_value = 'ENC_'+encrypted_value;
addElement(key,encrypted_value);
////console.log(' changed');
printItems();
});
function really_remove(key){
removeElement(key);
}
// select the target node
var target = document.querySelector('#current_values ul');
// create an observer instance
var observer = new MutationObserver(function(mutations) {
mutations.forEach(function(mutation) {
var nodes = document.querySelectorAll(".delete_element");
for(i=0;i<nodes.length;i++){
nodes[i].addEventListener("click",function(){
var key = this.getAttribute('data-key');
// is it encrypted??
// do we really want to delete?
callback_confirmation_no = function(){
return;
}
callback_confirmation_yes = function(){
removeElement(key);
printItems();
//this.parentNode.parentNode.remove();
}
//callback_confirmation_yes();
prompt_confirmation();
return;
});
}
var nodes = document.querySelectorAll('.val_cell')
for(i=0;i<nodes.length;i++){
nodes[i].addEventListener("click",function(){
var key = this.getAttribute('data-key');
var val = getElement(key);
// if encrypted???
if(val.substr(0,4)=='ENC_'){
val = val.substr(4);
callback_password_input = function(pass){
var args = {}
args.val = val;
args.password = pass;
require('electron').ipcRenderer.send('search-over-encrypted', args);
return;
}
prompt_password();
}else{
require('electron').ipcRenderer.send('search-over', val);
}
});
}
var nodes = document.querySelectorAll('.see_element')
for(i=0;i<nodes.length;i++){
nodes[i].addEventListener("click",function(){
var key = this.getAttribute('data-key');
var val = getElement(key);
if(val.substr(0,4)!='ENC_'){
alert('not encrypted');
return;
}
var encrypted_value = val.substr(4);
//console.log(encrypted_value)
callback_password_input = function(p){
if(!p){
alert('No password');
}
var args = {};
args.password = p;
args.key = key;
args.value = encrypted_value;
require('electron').ipcRenderer.send('decryptValue',args);
}
prompt_password();
});
}
var nodes = document.querySelectorAll(".encrypt_element");
for(i=0;i<nodes.length;i++){
nodes[i].addEventListener("click",function(){
// ask for password
password_set = is_password_set();
//console.log('testing passwd');
if(!password_set || typeof password_set =='undefined'){
alert('Set a password in Preferences before you encrypt');
return false;
}
var key = this.getAttribute('data-key');
//console.log('encrypting ' + key)
var value = getElement(key);
var args = {};
args.key = key;
args.value = value;
callback_password_input = function(p){
if(!p){
alert('No password');
}
//console.log('p = '+p)
args.password = p;
require('electron').ipcRenderer.send('encryptValue',args);
}
prompt_password();
});
}
var add_value = document.querySelector('#add_value');
add_value.addEventListener("click",function(){
var key = document.querySelector("#new_key").value;
var val = document.querySelector("#new_value").value;
if(!key || !val){
return;
}
if(key.length>25){
alert('Label too long');
return;
}
addElement(key,val);
document.querySelector("#new_key").value = "";
document.querySelector("#new_value").value = "";
// document.querySelector("#info").innerHTML ="Inserted!"
setTimeout(function(){
// document.querySelector("#info").innerHTML = ""
},5000)
printItems();
})
});
});
var config = { attributes: true, childList: true, characterData: true }// configuration of the observer:
observer.observe(target, config); // pass in the target node, as well as the observer options
//observer.disconnect(); // later, you can stop observing
require('electron').ipcRenderer.on('new_value' , function(event , data){
document.querySelector('#new_key').value = data;
document.querySelector('#new_value').focus();
document.querySelector('#button_new_shortext').click();
});
// In the renderer process:
var buildEditorContextMenu = remote.require('electron-editor-context-menu');
window.addEventListener('contextmenu', function(e) {
// Only show the context menu in text editors.
if (!e.target.closest('textarea, input, [contenteditable="true"]')) return;
var menu = buildEditorContextMenu();
// The 'contextmenu' event is emitted after 'selectionchange' has fired but possibly before the
// visible selection has changed. Try to wait to show the menu until after that, otherwise the
// visible selection will update after the menu dismisses and look weird.
setTimeout(function() {
menu.popup(remote.getCurrentWindow());
}, 30);