-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathappES5.js
More file actions
89 lines (61 loc) · 2.45 KB
/
appES5.js
File metadata and controls
89 lines (61 loc) · 2.45 KB
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
/*
ES5 JAVASCRIPT
ABDURRAHİM BULUT
10 HAZİRAN 2019
*/
function ToDo(title,content,important){
this.title=title;
this.content=content;
this.important=important;
}
function UI(){
}
UI.prototype.addToDo= function(toDo){
const list=document.getElementById('list');
if(toDo.important==true){
var htmlBadges = " <span class=\"badge badge-warning\"> Önemli</span>";
toDo.title+=htmlBadges;
//console.log(toDo.title);
}
var html= '<tr><td>'+ toDo.title + '</td><td>'+toDo.content+'</td><td class="islemler"><button href="#" class="btn btn-danger btn-sm delete"> <i class="far fa-times-circle deletei"></i></button><button href="#" class="btn btn-success btn-sm completed "><i class="far fa-check-circle completedi"></i></button></td></tr>';
list.innerHTML+=html;
}
UI.prototype.clearControls= function(){
const title = document.getElementById('title').value="";
const content = document.getElementById('content').value="";
const important=document.getElementById('important').checked=false;
}
UI.prototype.click=function(element){
/* Delete icon and button | Sil buton ve ikon */
if (element.classList.contains('delete')) {
element.parentElement.parentElement.remove();
}
if (element.classList.contains('deletei')) {
element.parentElement.parentElement.parentElement.remove();
}
/* Completed icon and button | Yapıldı buton ve ikon */
if (element.classList.contains('completed')) {
element.parentElement.parentElement.classList.toggle("table-success");
}
if (element.classList.contains('completedi')) {
element.parentElement.parentElement.parentElement.classList.toggle("table-success");
}
}
document.getElementById('toDoList').addEventListener('submit',
function(e){
const title = document.getElementById('title').value;
const content = document.getElementById('content').value;
const important=document.getElementById('important').checked;
//console.log(title, content, important);
const toDo= new ToDo(title,content,important);
//console.log(toDoList);
const ui = new UI();
ui.addToDo(toDo);
ui.clearControls();
e.preventDefault(); //eğer bu fonksiyon olmazsa submit devam eder ve sayfa yenilenir.
});
document.getElementById('list').addEventListener('click',function (e) {
const ui =new UI();
ui.click(e.target);
})
/* ES5 ABDURRAHİM BULUT 10 HAZİRAN 2019 */