-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathscript.js
189 lines (130 loc) · 4.99 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
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
// var username = prompt("What is your name?")
// $("h1").append(username+"'s To Do List")
$("h1").append("To Do List")
// document.getElementById('createNew').addEventListener('click', function(){
// var newItem = prompt("Create a new task:");
// var newItemText = document.createTextNode(newItem);
// var newP = document.createElement("p");
// newP.appendChild(newItemText);
// document.body.appendChild(newP);
// });
var count = 0;
var numCompleted = $(".complete").length;
$("#plural").text("s");
// $("#submit").click(function() {
// var newJob = document.getElementById("newObject").value;
// console.log(newJob)
// })
$("#submit").click(function () {
// var newTask = prompt("Create a new to do:");
var newJob = document.getElementById("newObject").value;
var newCategory = document.getElementById("newCat").value;
var myDiv = $("<div></div>");
myDiv.addClass("testID"+count);
myDiv.addClass("taskItem");
myDiv.addClass("incomplete");
// var workCheck = $("input[value='workcheck']:checked").length ? "Yes" : "No";
// var playCheck = $("input[value='playcheck']:checked").length ? "Yes" : "No";
// if (workCheck === "Yes") {$('.work').append(myDiv);}
// else if (playCheck === "Yes") {$('.play').append(myDiv);}
// else {alert("Please check a box!")}
$('.list').append(myDiv);
var newItem = $("<span><img class='box' src='http://www.clker.com/cliparts/d/o/Q/L/c/T/nxt-checkbox-unchecked-th.png' height='20' weight='20'/>"+" "+newJob+" "+"</span>");
newItem.addClass("item"+count)
newItem.addClass("checkbox")
myDiv.append(newItem);
var newTrash = $("<img id='delete' src='https://www.iconexperience.com/_img/o_collection_png/green_dark_grey/256x256/plain/navigate_cross.png' height='25' weight='25'/>");
// newTrash.css('opacity', '0.6');
myDiv.append(newTrash);
newTrash.click(function() {
console.log("trash!");
$(this).parent().remove();
});
var catTag = $("<div>"+newCategory+"</div>");
catTag.addClass("tag"+count)
catTag.addClass("tags")
myDiv.addClass(newCategory)
if ($(newCat).val().length === 0) {myDiv.append(" ");}
else {myDiv.append(catTag);};
// catTag.click(function() {
// console.log("tag!");
// $(".taskItem:not(."+newCategory+")").slideUp();
// });
var catTagBottom = $("<div>"+newCategory+"</div>");
catTagBottom.addClass("bottomTag")
catTagBottom.addClass("tag"+newCategory)
if ($(newCat).val().length === 0) {$('.tagsRow').append(" ");}
else if ($('.tag'+newCategory).length === 0) {$('.tagsRow').append(catTagBottom);}
else {$('.tagsRow').append(" ");};
catTagBottom.click(function() {
console.log("tag!");
$('.taskItem').show();
$(".taskItem:not(."+newCategory+")").slideUp();
});
$('.item'+count).click(function() {
console.log("hello! click!");
$(this).parent().toggleClass("complete");
$(this).parent().toggleClass("incomplete");
if ($(this).parent().hasClass("complete")) {numCompleted++;}
else if ($(this).parent().hasClass("incomplete")) {numCompleted--;}
else {console.log("surprise!")};
$("#numberOfCompleted").text(numCompleted);
if (numCompleted===1) {$("#plural").text("");}
else {$("#plural").text("s")};
$(".incomplete .checkbox .box").attr('src','http://www.clker.com/cliparts/d/o/Q/L/c/T/nxt-checkbox-unchecked-th.png');
$(".complete .checkbox .box").attr('src','http://www.clker.com/cliparts/B/2/v/i/n/T/tick-check-box-th.png');
})
count++;
});
$("#numberOfCompleted").append(numCompleted)
$("#filterComplete").click(function () {
$(".complete").slideDown()
$(".incomplete").slideUp()
});
$("#filterIncomplete").click(function () {
$(".complete").slideUp()
$(".incomplete").slideDown()
});
$("#filterAll").click(function () {
$(".complete").slideDown()
$(".incomplete").slideDown()
});
$("#deleteComplete").click(function () {
$(".complete").remove()
$(".incomplete").slideDown()
});
$("#deleteAll").click(function () {
$(".complete").remove()
$(".incomplete").remove()
});
$("#resetCounter").click(function () {
numCompleted = 0;
$("#numberOfCompleted").text(numCompleted);
if (numCompleted===1) {$("#plural").text();}
else {$("#plural").text("s")};
});
$("#grey").click(function () {
$("body").css('background-color','#C9C9C9')
$(".buttons").css('background-color','#C9C9C9')
});
$("#green").click(function () {
$("body").css('background-color','#A1D1B5')
$(".buttons").css('background-color','#A1D1B5')
});
$("#yellow").click(function () {
$("body").css('background-color','#F3DE8A')
$(".buttons").css('background-color','#F3DE8A')
});
$("#red").click(function () {
$("body").css('background-color','#EB9486')
$(".buttons").css('background-color','#EB9486')
});
$("#purple").click(function () {
$("body").css('background-color','#9697B7')
$(".buttons").css('background-color','#9697B7')
});
$("#blue").click(function () {
$("body").css('background-color','#9EB7BC')
$(".buttons").css('background-color','#9EB7BC')
});
// "<div id=ID)> <img class='box incomplete' src=' ' height='30' weight='30'/> <img class='box complete' src=' ' height='30' weight='30' style='display: none'/></div>"+newTask+"<br><br>