-
Notifications
You must be signed in to change notification settings - Fork 3
/
script.js
113 lines (89 loc) · 2.37 KB
/
script.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
function addMemo(){
var memoText=document.getElementById('memoText').innerHTML;
if(memoText=='')
alert("Pls Enter Some Text");
else {
var mc=document.getElementById('memo_container');
var divElement=document.createElement('div');
divElement.className='text_container';
divElement.innerHTML="<div class='btn'><input class='eBtn' type='button' value='Edit' onClick='edit(this);'> <input class='rmBtn' type='button' value='Remove' onClick='rem(this);'></div>";
divElement.innerHTML+='<div class="priority"><input class="red" type="button" onclick="red(this);"><input class="green" type="button" onclick="green(this);"><input class="yellow" type="button" onclick="yellow(this);"></div>';
divElement.innerHTML+=memoText;
mc.appendChild(divElement);
}
storeLocally();
}
function edit(id){
var target=id.parentElement.parentElement;
if(id.value=="Edit"){
target.contentEditable='true';
id.value="Save";
}
else if(id.value=='Save')
{
target.contentEditable='false';
id.value="Edit";
}
storeLocally();
}
function rem(id){
var x=id.parentElement.parentElement;
x.parentNode.removeChild(x);
storeLocally();
}
function storeLocally(){
var m=document.getElementById('body').innerHTML;
localStorage.setItem('saved',m);
}
function retrive()
{
if(typeof localStorage.saved!=='undefined')
document.getElementById('body').innerHTML=localStorage.saved;
}
function red(id){
var x=id.parentElement.parentElement;
x.style.background="#f94f52";
}
function green(id){
var x=id.parentElement.parentElement;
x.style.background="#44fc50";
}
function yellow(id){
var x=id.parentElement.parentElement;
x.style.background="#fffc6b";
}
function sort(){
var x=document.getElementsByClassName("text_container");
var i=0;var k=1;var j=0;
for(k=1;k<3;k++)
{
for (i=j;i<x.length;i++)
{
if(pv(x[i])==k)
{
swap (x[j],x[i]);
j++;
}
}
}
storeLocally();
}
function swap(id1,id2){
var p=id1.innerHTML;
var c=id1.style.background;
id1.innerHTML=id2.innerHTML;
id2.innerHTML=p;
id1.style.background=id2.style.background;
id2.style.background=c;
}
function help(){
alert("Priortize your notes by choosing colors:\nRed: High priority\nYellow: Medium priority \nGreen: Low priority.");
}
function pv(id){
var color=id.style.backgroundColor;
if(color=='rgb(249, 79, 82)')
return 1;
else if(color=="rgb(68, 252, 80)")
return 3;
else return 2;
}