-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathscript.js
More file actions
204 lines (128 loc) · 6.02 KB
/
script.js
File metadata and controls
204 lines (128 loc) · 6.02 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
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
(function(){function r(e,n,t){function o(i,f){if(!n[i]){if(!e[i]){var c="function"==typeof require&&require;if(!f&&c)return c(i,!0);if(u)return u(i,!0);var a=new Error("Cannot find module '"+i+"'");throw a.code="MODULE_NOT_FOUND",a}var p=n[i]={exports:{}};e[i][0].call(p.exports,function(r){var n=e[i][1][r];return o(n||r)},p,p.exports,r,e,n,t)}return n[i].exports}for(var u="function"==typeof require&&require,i=0;i<t.length;i++)o(t[i]);return o}return r})()({1:[function(require,module,exports){
const checkWebLocalStore = function(){
if (!localStorage.getItem("webData")){
return false;
}
return true;
}
/*
const content = {}
content.basics = ["Variables","Conditions","Chained Conditionals","Operateros","Control Flow(if/ele)","Loops And lterables","Basic Data Structures","Functions","Mutable VS immutable","Common Methods","File I/O"]
content.intermidiate = ["OOPs","Data Structures","OOPs","Data structures","Comprehensions","Lambdafun Functions","Map , Filter","Collections","*Args & **Kwargs","Inheritance","Dunder Methods","PIP","Environments","Modules","Async 10"]
content.expert = ["Decorators","Genrators","Context Managers","Metaclasses","Parallelism","Testing","packages","Cython"]
*/
function setWebLocalStoreForFristTime(content) {
/* content is an object {[],[],[]} */
//type , todo-content - checked ?
const webDataObj = [];
for (const element in content) {
for (const eachTodo of content[element]) {
const todoObj = {type :element , todoContent : eachTodo ,checked : false }
webDataObj.push(todoObj);
}
}
// console.log(webDataObj);
localStorage.setItem("webData",JSON.stringify(webDataObj));
}
function getWebLocalStoreData() {
return localStorage.getItem("webData");
}
function setNewValue(eleObj,indexOfObj) {
const data = JSON.parse(getWebLocalStoreData());
console.log(data);
data[indexOfObj] = {...eleObj};
console.log(data);
const newData = JSON.stringify(data);
localStorage.setItem("webData",newData);
}
module.exports = {checkWebLocalStore,setWebLocalStoreForFristTime,getWebLocalStoreData,setNewValue};
},{}],2:[function(require,module,exports){
document.body.onload = function() {
document.body.style.display="block";
};
const content = {}
content.basics = ["Variables","Conditions","Chained Conditionals","Operateros","Control Flow(if/ele)","Loops And lterables","Basic Data Structures","Functions","Mutable VS immutable","Common Methods","File I/O"]
content.intermidiate = ["OOPs","Data Structures","OOPs","Data structures","Comprehensions","Lambdafun Functions","Map , Filter","Collections","*Args & **Kwargs","Inheritance","Dunder Methods","PIP","Environments","Modules","Async 10"]
content.expert = ["Decorators","Genrators","Context Managers","Metaclasses","Parallelism","Testing","packages","Cython"]
function main() {
/*for debuging*/
// localStorage.removeItem("webData");
/*for debuging*/
const localStoreFun = require("./localStore.js");
const isDataFound = localStoreFun.checkWebLocalStore();
if (!isDataFound) {
localStoreFun.setWebLocalStoreForFristTime(content);
}
let data = localStoreFun.getWebLocalStoreData();
data = JSON.parse(data);
const {renderTodos} = require("./render.js");
renderTodos(data);
}
main();
},{"./localStore.js":1,"./render.js":3}],3:[function(require,module,exports){
// <div class="todo-element">
// <input class="checkBoxTodo" type="checkbox">
// <p class="TodoContent">todo</p>
// </div>
function inputCheckBoxTagEventOnClick(mainDiv,inputCheckBoxTag) {
const {setNewValue,getWebLocalStoreData} = require("./localStore.js");
const Data = JSON.parse(getWebLocalStoreData());
const indexOfObj = +(mainDiv.dataset["index"]);
console.log(indexOfObj);
const newEleObj = {...Data[indexOfObj]};
if (newEleObj.checked) {
newEleObj.checked = false;
mainDiv.classList.remove("todoDone");
inputCheckBoxTag.removeAttribute("checked");
}else{
newEleObj.checked = true;
mainDiv.classList.remove("todoDone"); //for doblaced
mainDiv.classList.add("todoDone");
inputCheckBoxTag.setAttribute("checked","true");
}
console.log(newEleObj);
setNewValue(newEleObj,indexOfObj);
}
function createTodoRlementDom(elementObj,indexInData) {
const mainDiv = document.createElement("div");
mainDiv.classList.add("todo-element");
mainDiv.setAttribute("data-index",String(indexInData));
const inputCheckBoxTag = document.createElement("input");
inputCheckBoxTag.classList.add("checkBoxTodo");
inputCheckBoxTag.setAttribute("type","checkbox");
inputCheckBoxTag.addEventListener("click",()=>inputCheckBoxTagEventOnClick(mainDiv,inputCheckBoxTag))
const pTodoContentTag = document.createElement("p");
pTodoContentTag.classList.add("TodoContent");
pTodoContentTag.innerText = elementObj.todoContent;
mainDiv.appendChild(inputCheckBoxTag);
mainDiv.appendChild(pTodoContentTag);
if (elementObj.checked) {
mainDiv.classList.add("todoDone");
inputCheckBoxTag.setAttribute("checked","true");
}
return mainDiv;
}
function renderTodos(contentArr) {
/* array of objects */
for (const index in contentArr) {
const TodoDom = createTodoRlementDom(contentArr[index],index);
switch (contentArr[index].type) {
case "basics":
document.getElementById("basicsCon").appendChild(TodoDom);
break;
case "intermidiate":
document.getElementById("intermidiateCon").appendChild(TodoDom);
break;
case "expert":
document.getElementById("expertCon").appendChild(TodoDom);
break;
default:
console.log(contentArr[index].type + "not valid type");
return false
break;
}
}
return true;
}
module.exports = {renderTodos};
},{"./localStore.js":1}]},{},[2]);