-
Notifications
You must be signed in to change notification settings - Fork 0
/
2b.js
66 lines (59 loc) · 2.09 KB
/
2b.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
//★ jQuery ★
//ensures script will only run after HTML page
//has loaded to the browser window
$(document).ready(function () {
//selecting all input elements
$("input").keydown(function (event) {
// 13 refers to the ENTER keyboard key
if (event.which == 13 && $("input").val() != "") {
//declares new variable, setting a value
var userInput = $("input").val();
//input txt disappears from text field on submit
$(this).val("");
//appends li, userinput & i:s into ul
//(= checkmark & skull appear next to new items)
$("ul").append("<li>" + userInput + "<span class='check'><i class='fa-solid fa-check'></i></span>" + "<span class='delete'><i class='fa-solid fa-skull'></i></span>");
}
});
});
// BUTTONS BELOW
//adds strike & opacity change through an individual item;
//user can undo and redo the "done" click as many times as they'd like
$("ul").on("click", "li", function () {
$(this).toggleClass("checksout");
//sets item as checked
localStorage.setItem(this, "cheksout");
});
//removes item
$(document).on("click", ".delete", function (event) {
$(this).parent().fadeOut(700, function () {
$(this).remove();
//removes item from localstorage
localStorage.removeItem(this);
});
event.stopPropagation();
});
//sends an alert message with information
//via the "i" (info) button
$(document).ready(function () {
$("#what").click(function () {
//sweetalert styling
swal({
title: "info box",
text: "You can mark an item as complete by clicking the checkmark button, or delete it entirely by clicking the skull."
});
});
});
//moon button = clears all items from list
function clearAll() {
if (confirm("By proceeding, your list will clear of all items. Do you still wish to proceed?")) {
$("#clear").attr("href", "query.php?ACTION=delete&ID='1'")
$("li").empty();
} else {
return;
}
}
//toggle thingy
$("#togglebtn").click(function () {
$("p").toggle('slow');
});