-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.html
1180 lines (984 loc) · 44.5 KB
/
index.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 lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<link rel="icon" type="image/png" sizes="16x16" href="favicon/favicon-16x16.png">
<link rel="manifest" href="favicon/site.webmanifest">
<link rel="mask-icon" href="favicon/safari-pinned-tab.svg" color="#5bbad5">
<meta name="msapplication-TileColor" content="#da532c">
<meta name="theme-color" content="#ffffff">
<title>Notes App</title>
<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.3.1/css/bootstrap.min.css"
integrity="sha384-ggOyR0iXCbMQv3Xipma34MD+dH/1fQ784/j6cY/iJTQUOhcWr7x9JvoRxT2MZw1T" crossorigin="anonymous">
<link rel="preconnect" href="https://fonts.googleapis.com">
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
<link href="https://fonts.googleapis.com/css2?family=Josefin+Slab:wght@500&display=swap" rel="stylesheet">
<!-- <link rel="stylesheet" href="webstyle.css"> -->
<style>
@import url('https://fonts.googleapis.com/css2?family=Montserrat&display=swap');
.progress {
height: 6px;
animation: load 1s ease-in-out 1;
}
@keyframes load {
0% {
width: 0;
}
25% {
width: 30vw;
}
50% {
width: 60vw;
}
75% {
width: 90vw;
}
99.9% {
width: 100vw;
}
100% {
width: 0;
}
}
.form-control1 {
background-color: rgba(80, 232, 104, 0.63);
width: 100%;
}
.title-control {
background-color: rgba(130, 219, 219, 0.726);
width: 100%;
}
.card-body h5 {
display: inline-block;
}
.cdchanged {
background-color: rgba(245, 222, 179, 0.63);
}
.fav {
width: 28px;
height: 2px;
padding: 0px;
align-content: flex-end;
background-color: #3bdd649a;
;
}
.card-text {
font-family: 'Josefin Slab', serif;
font-size: 15px;
}
.titlec {
color: maroon;
}
.bro {
background-image: url("R.jpg");
background-size: cover;
background-repeat: no-repeat;
}
hr {
margin-top: 1rem;
margin-bottom: 1rem;
border: 0;
border-top: 2px solid rgb(255 0 177);
}
.card {
background-image: url("pexels-bich-tran-636237.jpg");
opacity: 0.95;
}
/* ///////////////////////////////////////////////////////////////////////////////////////// */
.clip-text {
font-size: 6em;
font-weight: bold;
line-height: 1;
position: relative;
margin: .4em 0em 0.1em 0em;
padding: .3em .75em;
text-align: center;
color: #fff;
background-clip: text;
-webkit-background-clip: text;
-webkit-text-fill-color: transparent;
background-image: url(https://thumbs.dreamstime.com/z/watercolor-raster-summer-background-grass-gradient-yellow-green-streaks-smooth-lines-cover-layout-design-148910602.jpg);
}
.clip-text:before {
content: ”;
z-index: -2;
top: 0;
right: 0;
bottom: 0;
left: 0;
background-image: inherit;
position: absolute;
}
.clip-text:after {
content: ”;
position: absolute;
z-index: -1;
top: .125em;
right: .125em;
bottom: .125em;
left: .125em;
background-color: #000;
}
.alert {
animation: fadeOut 8s;
}
@keyframes fadeOut {
0% {
opacity: 1;
}
12.5% {
opacity: 0.875;
}
25% {
opacity: 0.75;
}
37.5% {
opacity: 0.625;
}
50% {
opacity: 0.50;
}
62.5% {
opacity: 0.375;
}
75% {
opacity: 0.25;
}
87.5% {
opacity: 0.125;
}
90% {
opacity: 0.1;
}
95% {
opacity: 0.05;
}
99% {
opacity: 0.01;
}
100% {
opacity: 0;
}
}
@keyframes blinks {
0% {
opacity: 1;
}
50% {
opacity: 0;
}
}
.contain {
font-family: 'Montserrat', sans-serif;
text-transform: uppercase;
text-align: center;
color: #ccc;
overflow: hidden;
display: flex;
flex-direction: column;
padding: 0 3rem;
}
.h1style {
font-weight: 200;
margin: 0.4rem;
font-size: 2 rem;
color: #ffbd2f;
}
/*cursor*/
.txt-type>.txt {
/* border-right:0.2rem solid; */
padding-right: 0.5rem;
color: white;
}
@media(min-width:1200px) {
.h1style {
font-size: 2.3rem;
}
}
@media(max-width:800px) {
.contain {
padding: 0 1rem;
}
.h1style {
font-size: 1rem;
}
}
@media(max-width:500px) {
.h1style {
font-size: 0.8rem;
}
}
#loading {
position: fixed;
width: 100%;
height: 100vh;
background: black url('Neon-Loading-gif.gif') no-repeat center;
z-index: 99999;
}
.dashed {
background: rgb(214, 206, 206);
border-style: dashed;
}
#pic {
width: 13rem;
}
#mybar {
min-width: 5rem;
background-color: green;
height: 1rem;
margin-bottom: 5px;
font-size: 0.7rem;
color: chartreuse;
}
#video {
width: 20rem;
height: 25rem;
margin-right: 2rem;
}
#myCanvas{
width: 20rem;
height: 20rem;
}
.videobox{
position: relative;
width: fit-content;
}
@media(max-width:395px) {
#video {
width: 15rem;
height: 15rem;
margin-right: 2rem;
}
#myCanvas{
width: 15rem;
height: 17rem;
}
@media(max-width:395px) {
#video {
width: 15rem;
height: 15rem;
margin-right: 2rem;
}
#myCanvas{
width: 15rem;
height: 17rem;
}
@media(min-width:395px) {
#video {
width: 25rem;
height: 25rem;
margin-right: 2rem;
}
#myCanvas{
width: 25rem;
height: 23rem;
}
</style>
</head>
<body class="bro" onload="loadingFunc()">
<div id="loading"></div>
<nav class="navbar fixed-top navbar-expand-lg navbar-dark bg-dark" style="z-index: 5;">
<a class="navbar-brand" href="#">Green Notes</a>
<button class="navbar-toggler" type="button" data-toggle="collapse" data-target="#navbarSupportedContent"
aria-controls="navbarSupportedContent" aria-expanded="false" aria-label="Toggle navigation">
<span class="navbar-toggler-icon"></span>
</button>
<div class="collapse navbar-collapse" id="navbarSupportedContent">
<ul class="navbar-nav mr-auto">
<li class="nav-item active">
<a class="nav-link" href="#">Home <span class="sr-only">(current)</span></a>
</li>
</ul>
<form class="form-inline my-2 my-lg-0">
<input id="searchTxt" class="form-control mr-sm-2" id="searchTxt" type="search" placeholder="Search"
aria-label="Search">
<button class="btn btn-outline-success my-2 my-sm-0" type="submit">Search</button>
</form>
</div>
</nav>
<div class="progress">
<div class="progress-bar progress-bar-striped bg-danger" role="progressbar"
style="width: 100%; z-index: 10; position: top;" aria-valuenow="100" aria-valuemin="0" aria-valuemax="100">
</div>
</div>
<div id="alertbar"></div>
<div class="clip-text">Green Notes</div>
<div class="contain">
<h1 class="h1style">You can
<span class="txt-type" data-wait="2000"
data-words='["create your notes!!","edit your notes!!","mark your notes as favourite!","delete your notes anytime!!","search in your notes!!","add text based on voice!!","convert image to text!!","convert webimage to text!!"]'></span>
<b class="cursor" id="cursor">|</b>
</h1>
</div>
<div class="container my-3 " style="align-content: center;z-index: 0;">
<div class="card" style="margin-bottom:23px; align-content: center; border-radius: 10px;">
<div class=" card-body cdchanged" style="border: 4px solid black; border-radius: 10px;">
<h4 class="card-title" style="color: crimson; text-decoration: underline;">Add Note</h4>
<h5 class="card-title">Add title to note</h5>
<div>
<textarea class="title-control" id="addT" rows="1"></textarea>
</div>
<div class="form-check" style="top: 4px">
<input class="form-check-input" type="radio" name="type" id="audio" value="audio">
<label class="form-check-label" for="audio">
Add Audio Note
</label>
</div>
<div class="form-check" style="top:5px;">
<input class="form-check-input" type="radio" name="type" id="addTextNote" value="addTextNote">
<label class="form-check-label" for="addTextNote">
Add Text Note
</label>
</div>
<div class="form-check" style="padding-bottom: 10px; top:5px;">
<input class="form-check-input" type="radio" name="type" id="addImage" value="addImage">
<label class="form-check-label" for="addImage">
Add Image file
</label>
</div>
<h5 class="card-title" id="addtextcom" style="margin-bottom: 7px;margin-left: 8px;margin-top: 2px;">
</h5>
<div class="form-group " id="makeNote" style="margin-bottom: 4px">
</div>
<button class="btn btn-primary" id="addBtn">Add a Note</button>
<div id="message"></div>
</div>
</div>
<h1 style="color: rgb(255, 0, 0);width: 202px;">Your Notes</h1>
<hr>
<div id="notes" class="row">
</div>
</div>
<footer _ngcontent-serverapp-c52="" class="container-fluid bg-dark my-0 py-3 text-light">
<p _ngcontent-serverapp-c52="" class="mb-0 text-center">Copyright © 2020-2021 Kumar Shashank</p>
</footer>
<script src='https://unpkg.com/tesseract.js@v2.1.0/dist/tesseract.min.js'></script>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.5.1/jquery.min.js"></script>
<script src="https://code.jquery.com/jquery-3.3.1.slim.min.js"
integrity="sha384-q8i/X+965DzO0rT7abK41JStQIAqVgRVzpbzo5smXKp4YfRvH+8abtTE1Pi6jizo"
crossorigin="anonymous"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.14.7/umd/popper.min.js"
integrity="sha384-UO2eT0CpHqdSJQ6hJty5KVphtPhzWj9WO1clHTMGa3JDZwrnQq4sF86dIHNDz0W1"
crossorigin="anonymous"></script>
<script src="https://stackpath.bootstrapcdn.com/bootstrap/4.3.1/js/bootstrap.min.js"
integrity="sha384-JjSmVgyd0p3pXB1rRibZUAYoIIy6OrQ6VrjIEaFf/nJGzIxFDsf4x0xIM+B07jRM"
crossorigin="anonymous"></script>
<!-- <script src="js/app.js"></script> -->
<script>
console.log('welcome to project');
var preloader = document.getElementById('loading');
function loadingFunc() {
preloader.style.display = 'none';
}
showNotes();
function showalert(type, displayMessage) {
let message = document.getElementById('alertbar');
message.innerHTML = `<div class="alert alert-${type} alert-dismissible fade show" role="alert" style="z-index:20;position: fixed;padding-bottom: 8px;padding-top: 8px;padding-left: 15px;left: 10px;padding-right: 48px;">
<strong>Messge:</strong> ${displayMessage}
<button type="button" class="close" data-dismiss="alert" aria-label="Close" style="align-content: center;padding-bottom: 7px;padding-top: 7px;">
<span aria-hidden="true">×</span>
</button>
</div>`;
setTimeout(function () {
message.innerHTML = ``;
}, 4000);
}
function deletealert(displayMessage, index) {
let del_message = document.getElementById('alertbar');
del_message.innerHTML = `<div class="alert alert-danger alert-dismissible fade show" role="alert" style="z-index:20;position: fixed;padding-bottom: 2px;padding-top: 2px;margin-bottom: 0px;left: 10px;padding-right: 48px;">
<strong>Messge:</strong> ${displayMessage}
<button type="button" class="close" data-dismiss="alert" aria-label="Close" style="align-content: center;padding-bottom: 7px;padding-top: 7px;">
<span aria-hidden="true">×</span>
</button>
<button type="button" class="btn btn-warning" onclick="undoDelete(${index})">Undo Delete</button>
</div>`;
setTimeout(function () {
del_message.innerHTML = ``;
}, 4000);
}
function undoDelete(index) {
//retrieve notes
notesObj.push(notesObj[notesObj.length - 1]);
for (let i = notesObj.length - 2; i >= index; i--) {
notesObj[i + 1] = notesObj[i];
}
notesObj[index] = tempArr[0];
//console.log(notesObj);
//retrieve title
titleObj.push(titleObj[titleObj.length - 1]);
for (let i = titleObj.length - 2; i >= index; i--) {
titleObj[i + 1] = titleObj[i];
}
titleObj[index] = tempArr[1];
//console.log(titleObj);
//retreive date
dateObj.push(dateObj[dateObj.length - 1]);
for (let i = dateObj.length - 2; i >= index; i--) {
dateObj[i + 1] = dateObj[i];
}
dateObj[index] = tempArr[2];
//console.log(dateObj);
//retreive time
timeObj.push(timeObj[timeObj.length - 1]);
for (let i = timeObj.length - 2; i >= index; i--) {
timeObj[i + 1] = timeObj[i];
}
timeObj[index] = tempArr[3];
//console.log(timeObj);
//retrive fav
favObj.push(favObj[favObj.length - 1]);
for (let i = favObj.length - 2; i >= index; i--) {
favObj[i + 1] = favObj[i];
}
favObj[index] = tempArr[4];
//console.log(favObj);
localStorage.setItem("notes", JSON.stringify(notesObj));
localStorage.setItem("notesTitle", JSON.stringify(titleObj));
localStorage.setItem("pdate", JSON.stringify(dateObj));
localStorage.setItem("ptime", JSON.stringify(timeObj));
localStorage.setItem("favs", JSON.stringify(favObj));
showNotes();
let del_message = document.getElementById('alertbar');
del_message.innerHTML = ``;
}
// // Function to show elements from localStorage
function showNotes() {
let notes = localStorage.getItem("notes");
let notesTitle = localStorage.getItem("notesTitle");
let pdate = localStorage.getItem("pdate");
let ptime = localStorage.getItem("ptime");
if (notes == null) {
notesObj = [];
} else {
notesObj = JSON.parse(notes);
}
if (notesTitle == null) {
titleObj = [];
} else {
titleObj = JSON.parse(notesTitle); //parse coverts string to JvaScript Object
}
if (pdate == null) {
dateObj = [];
} else {
dateObj = JSON.parse(pdate); //parse coverts string to JvaScript Object
}
if (ptime == null) {
timeObj = [];
} else {
timeObj = JSON.parse(ptime); //parse coverts string to JvaScript Object
}
let html = "";
notesObj.forEach(function (element, index) {
html += `
<div class="noteCard my-2 mx-2 card" style="border:4px solid black; border-radius: 10px;">
<div class="card-body cbody" style="width: 15rem;" draggable="true">
<button id="${index}" onclick="deleteNote(this.id)" class="btn btn-danger btn-sm delbtn" style="position: absolute; top:2px; right:2px;">✕</button>
<button id="${index}" onclick="doit(this.id)" type="button" class="btn btn-success fav" style="position: absolute;bottom:2px;right:2px;height:32px;width: 32px;"><h1 id="goodBtn"></h1></button>
<br>
<h5 class="card-title titlec">${titleObj[index]} </h5>
<p class="card-text cd" type="button" onmouseover="modifyit(${index})"> ${element}</p>
<h7 class="datebar" style="position:absolute; bottom:25px;">${dateObj[index]}</h7><br>
<h7 class="timebar" style="position:absolute; bottom:8px;">${timeObj[index]}</h7>
</div>
</div>`;
});
let notesElm = document.getElementById("notes");
if (notesObj.length != 0) {
notesElm.innerHTML = html;
} else {
notesElm.innerHTML = `Nothing to show! Use "Add a Note" section above to add notes.`;
}
let favBtn = document.getElementsByClassName("fav");
//console.log(favBtn);
let favs = localStorage.getItem('favs');
if (favs == null) {
favObj = [];
} else {
favObj = JSON.parse(favs); //parse coverts string to JvaScript Object
}
localStorage.setItem("favs", JSON.stringify(favObj));
favObj.forEach(function (element, index) {
if (favObj[index] == 1) {
//console.log(favBtn[index]);
//console.log(favBtn[index].innerHTML);
favBtn[index].innerHTML = `⭐`;
}
})
}
var clicks = new Array(10000000).fill(0);
let favs = localStorage.getItem('favs');
if (favs == null) {
favObj = [];
} else {
favObj = JSON.parse(favs); //parse coverts string to JvaScript Object
}
localStorage.setItem("favs", JSON.stringify(favObj));
function doit(index) {
clicks[index] += 1;
let favBtn = document.getElementsByClassName("fav");
if (favObj[index] == null) {
favObj[index] = 1;
favBtn[index].innerHTML = `⭐`;
}
else {
favObj[index] = null;
favBtn[index].innerHTML = ``;
}
localStorage.setItem("favs", JSON.stringify(favObj));
}
let tempArr = new Array(4);
// Function to delete a note
function deleteNote(index) {
// console.log("I am deleting", index);
let notes = localStorage.getItem("notes");
let notesTitle = localStorage.getItem("notesTitle");
let pdate = localStorage.getItem("pdate");
let ptime = localStorage.getItem("ptime");
if (notes == null) {
notesObj = [];
} else {
notesObj = JSON.parse(notes);
}
if (notesTitle == null) {
titleObj = [];
} else {
titleObj = JSON.parse(notesTitle);
}
if (pdate == null) {
dateObj = [];
} else {
dateObj = JSON.parse(pdate); //parse coverts string to JvaScript Object
}
if (ptime == null) {
timeObj = [];
} else {
timeObj = JSON.parse(ptime); //parse coverts string to JvaScript Object
}
deletealert('The note with title ' + '"' + titleObj[index] + '"' + ' has been deleted', index);
// notesObj.forEach(function(element,index){
// if(favObj[index]!=1)
// favObj[index]=null;
// })
tempArr[0] = notesObj[index];
tempArr[1] = titleObj[index];
tempArr[2] = dateObj[index];
tempArr[3] = timeObj[index];
tempArr[4] = favObj[index];
//console.log(tempArr);
notesObj.splice(index, 1);
titleObj.splice(index, 1);
dateObj.splice(index, 1);
timeObj.splice(index, 1);
favObj.splice(index, 1);
localStorage.setItem("notes", JSON.stringify(notesObj));
localStorage.setItem("notesTitle", JSON.stringify(titleObj));
localStorage.setItem("pdate", JSON.stringify(dateObj));
localStorage.setItem("ptime", JSON.stringify(timeObj));
localStorage.setItem("favs", JSON.stringify(favObj));
showNotes();
}
let search = document.getElementById('searchTxt');
search.addEventListener("input", function () {
let inputVal = search.value.toLowerCase();
let inputVal2 = search.value;
// console.log('Input event fired!', inputVal);
let noteCards = document.getElementsByClassName('noteCard');
Array.from(noteCards).forEach(function (element) {
let cardTxt = element.getElementsByTagName("p")[0].innerText;
if (cardTxt.includes(inputVal) || cardTxt.includes(inputVal2)) {
element.style.display = "block";
}
else {
element.style.display = "none";
}
//console.log(cardTxt);
})
})
let divElem = document.getElementsByClassName('cd');
function modifyit(index) {
//console.log(divElem[index]);
divElem[index].addEventListener('dblclick', function () {
let noTextAreas = document.getElementsByClassName('textarea').length;
if (noTextAreas == 0) {
let html1 = divElem[index].innerHTML;
divElem[index].innerHTML = `<textarea class="textarea"; id="textarea" rows="6" style="margin:8px; width:93%">${html1}</textarea>`;
}
let textarea = document.getElementById('textarea');
textarea.addEventListener('blur', function () {
divElem[index].innerHTML = textarea.value;
notesObj[index] = textarea.value;
localStorage.setItem("notes", JSON.stringify(notesObj));
})
});
}
let audio = document.getElementById('audio');
let addTextNote = document.getElementById('addTextNote');
let addtextcom = document.getElementById('addtextcom');
let makeNote = document.getElementById('makeNote');
let addImage = document.getElementById('addImage');
//console.log(audio, addTextNote);
audio.addEventListener('click', function () {
addtextcom.innerHTML = ``;
addtextcom.innerHTML = `Speech to Text Recognition`;
makeNote.innerHTML = ``;
makeNote.innerHTML = `<div class="form-group">
<textarea id="textbox" rows="6" class="form-control"></textarea>
</div>
<div class="form-group">
<button id="startbtn" class="btn btn-success btn-block" style="height: 40px;width: 48%;display:inline-block;margin: 0px 5px;"> <img src="mic.png" style="height:30px; widht:30px;"> Start Speech Synthesis</button>
<button id="stopbtn" class="btn btn-danger btn-block" style="height: 40px;display:inline-block; width: 48%;margin: 0px 5px;"> <img src="mic2.png" style="height:20px; width:20px;"> Stop
</button>
<p id="instructions">Press the Start Speech Synthesis Button</p>
</div>`;
perform();
// console.log('audio');
});
addTextNote.addEventListener('click', function () {
addtextcom.innerHTML = ``;
addtextcom.innerHTML = `Add text to the note`;
makeNote.innerHTML = ``;
makeNote.innerHTML = `<textarea class="form-control1" id="addTxt" rows="6"></textarea>`;
//console.log('text');
});
addImage.addEventListener('click', function () {
addtextcom.innerHTML = ``;
addtextcom.innerHTML = `Add Image file`;
makeNote.innerHTML = ``;
makeNote.innerHTML = `<input type="file" id="pic" name="pic" accept="image/png ,image/jpeg">
<button type="button" class="btn btn-warning extTxt" id="extTxt" style="padding-bottom: 4px;margin-bottom: 5px;">Extract Text</button><br>Capture through webcam <button type="button" onclick="startWebcam()" class="btn btn-success" id="extTxt" style="padding-bottom: 4px;margin-bottom: 5px;">Start Webcam</button>
<button type="button" onclick="stopWebcam();" class="btn btn-danger" id="extTxt" style="padding-bottom: 4px;margin-bottom: 5px;">Stop Webcam</button>
<button type="button" onclick="snapshot();" class="btn btn-warning" id="extTxt" style="padding-bottom: 4px;margin-bottom: 5px;">Take Snapshot</button>
<div id="mybar" >Progress:</div>
<textarea class="form-control1" id="OCRbox" rows="8"></textarea>`;
let extTxt = document.getElementById('extTxt');
let OCRbox = document.querySelector('#OCRbox');
let mybar = document.querySelector('#mybar');
mybar.style.width = 0 + '%';
extTxt.addEventListener('click', function () {
console.log(OCRbox);
OCRbox.value = ``;
let myfile = document.querySelector('input[type="file"]');
console.log(myfile.files);
if (myfile.files && myfile.files[0]) {
newurl = URL.createObjectURL(myfile.files[0]);
console.log(newurl);
}
Tesseract.recognize(
newurl,
'eng',
{
logger: m => {
console.log(m.progress);
mybar.style.width = m.progress * 100 + '%';
}
}
).then(({ data: { text } }) => {
OCRbox.value = text;
console.log(text);
})
})
});
function perform() {
var SpeechRecognition = window.SpeechRecognition || window.webkitSpeechRecognition;
var recognition = new SpeechRecognition();
var textbox = $("#textbox");
var instructions = $("#instructions");
var content = '';
recognition.continuous = true;
let startbtn = document.getElementById('startbtn');
let stopbtn = document.getElementById('stopbtn');
// console.log(startbtn);
recognition.onstart = function () {
instructions.text("Voice Recognition is ON")
}
recognition.onspeechend = function () {
instructions.text("No Activity")
}
recognition.onerror = function () {
instructions.text("Try Again")
}
recognition.onresult = function (event) {
var current = event.resultIndex;
var transcript = event.results[current][0].transcript;
instructions.text("No Activity");
content += transcript;
textbox.val(content);
}
$("#startbtn").click(function (event) {
//console.log('button fired');
console.log(content)
if (content.length) {
content += '';
}
recognition.start();
})
$("#stopbtn").click(function (event) {
//console.log('button fired');
if (content.length) {
content = textbox.value;
}
recognition.stop();
})
}
let addBtn = document.getElementById("addBtn");
addBtn.addEventListener("click", function () {
let addTxt = document.getElementById("addTxt");
let addT = document.getElementById("addT");
let textbox = document.getElementById("textbox");
let OCRbox = document.querySelector('#OCRbox');
//console.log(textbox.value);
let notes = localStorage.getItem("notes");
let pdate = localStorage.getItem("pdate");
let ptime = localStorage.getItem("ptime");
let notesTitle = localStorage.getItem("notesTitle");
if (notes == null) {
notesObj = [];
} else {
notesObj = JSON.parse(notes); //parse coverts string to JvaScript Object
}
if (notesTitle == null) {
titleObj = [];
} else {
titleObj = JSON.parse(notesTitle); //parse coverts string to JvaScript Object
}
if (pdate == null) {
dateObj = [];
} else {
dateObj = JSON.parse(pdate); //parse coverts string to JvaScript Object
}
if (ptime == null) {
timeObj = [];
} else {
timeObj = JSON.parse(ptime); //parse coverts string to JvaScript Object
}
const monName = ["Jan", "Feb", "Mar", "Apr", "May", "Jun", "July", "Aug", "Sep", "Oct", "Nov", "Dec"];
let today = new Date();
let d, y, m, t;
d = today.getDate();
m = monName[today.getMonth()];
y = today.getFullYear();
t = new Date().toLocaleTimeString([], { hour: '2-digit', minute: '2-digit' })
if (addTxt != null) {
if (addT.value && addTxt.value) {
showalert('success', 'Your text note has been successfully added');
notesObj.push(addTxt.value);
titleObj.push(addT.value);
dateObj.push(d + "-" + m + "-" + y);
timeObj.push(t);
localStorage.setItem("notes", JSON.stringify(notesObj));
localStorage.setItem("notesTitle", JSON.stringify(titleObj));
localStorage.setItem("pdate", JSON.stringify(dateObj));
localStorage.setItem("ptime", JSON.stringify(timeObj));
addTxt.value = "";
addT.value = "";
//console.log(titleObj);
showNotes();
}
else {
if (!addT.value)
showalert('danger', 'Sorry you cannot add this note. Please add the title !');
else {
showalert('danger', 'Sorry you cannot add this note. Please add text to this !');
}
}
}
else {
if (OCRbox && addT.value) {
showalert('success', 'Your image to text note has been successfully added');
notesObj.push(OCRbox.value);
titleObj.push(addT.value);
dateObj.push(d + "-" + m + "-" + y);
timeObj.push(t);
localStorage.setItem("notes", JSON.stringify(notesObj));
localStorage.setItem("notesTitle", JSON.stringify(titleObj));
localStorage.setItem("pdate", JSON.stringify(dateObj));
localStorage.setItem("ptime", JSON.stringify(timeObj));
makeNote.innerHTML = `<input type="file" id="pic" name="pic" accept="image/png ,image/jpeg">
<button type="button" class="btn btn-warning extTxt" id="extTxt" style="padding-bottom: 4px;margin-bottom: 5px;">Extract Text</button><br>Capture through webcam <button type="button" onclick="startWebcam()" class="btn btn-success" id="extTxt" style="padding-bottom: 4px;margin-bottom: 5px;">Start Webcam</button>
<button type="button" onclick="stopWebcam();" class="btn btn-danger" id="extTxt" style="padding-bottom: 4px;margin-bottom: 5px;">Stop Webcam</button>
<button type="button" onclick="snapshot();" class="btn btn-warning" id="extTxt" style="padding-bottom: 4px;margin-bottom: 5px;">Take Snapshot</button>
<div id="mybar" >Progress:</div>
<textarea class="form-control1" id="OCRbox" rows="6"></textarea>`;
OCRbox.value = "";
addT.value = "";
//console.log(titleObj);
showNotes();
} else {
if (textbox.value && addT.value) {
showalert('success', 'Your audio to text note has been successfully added');
notesObj.push(textbox.value);
titleObj.push(addT.value);
dateObj.push(d + "-" + m + "-" + y);
timeObj.push(t);
localStorage.setItem("notes", JSON.stringify(notesObj));
localStorage.setItem("notesTitle", JSON.stringify(titleObj));
localStorage.setItem("pdate", JSON.stringify(dateObj));
localStorage.setItem("ptime", JSON.stringify(timeObj));
textbox.value = "";
addT.value = "";
//console.log(titleObj);
showNotes();
}
else {
if (!addT.value)
showalert('danger', 'Sorry you cannot add this note. Please add the title !');
else {
showalert('danger', 'Sorry you cannot add this note. Please add text to this !');
}
}
}
}
});