-
Notifications
You must be signed in to change notification settings - Fork 0
/
store.js
235 lines (164 loc) · 5.18 KB
/
store.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
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
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
// chrome://Extensions
// let myLeads = []
// let oldLeads = []
// const inputEl = document.getElementById("input-el")
// const inputBtn = document.getElementById("input-btn")
// const ulEL = document.getElementById("ul-el")
// const deleteBtn = document.getElementById("delete-btn")
// const fromLocalStorage = JSON.parse( localStorage.getItem("myLeads") )
// let tabBtn = document.getElementById("tab-btn")
// if (fromLocalStorage) {
// myLeads = fromLocalStorage
// render(myLeads)
// }
// tabBtn.addEventListener("click", function(){
// // console.log(tabs[0].url)
// chrome.tabs.query({active: true, currentWindow: true}, function(tabs){
// myLeads.push(tabs[0].url)
// localStorage.setItem("myLeads", JSON.stringify(myLeads))
// render(myLeads)
// })
// })
// function render(Leads) {
// let listItems = ""
// for (i = 0; i < Leads.length; i++) {
// // listItems += "<li><a target='_blank' href='" + myLeads[i] + "'>" + myLeads[i] + "</a></li>"
// listItems += `
// <li>
// <a target='_blank' href='${Leads[i]}'>
// ${Leads[i]}
// </a>
// </li>`
// }
// ulEL.innerHTML = listItems
// }
// deleteBtn.addEventListener("dblclick", function() {
// localStorage.clear()
// myLeads = []
// render(myLeads)
// })
// inputBtn.addEventListener("click", function() {
// myLeads.push(inputEl.value)
// inputEl.value = ""
// localStorage.setItem("myLeads", JSON.stringify(myLeads))
// render(myLeads)
// console.log(localStorage.getItem("myLeads"))
// })
// RECAP OF WHAT WE LEARNED
// const player = "per"
// const opponent = "nick"
// const game = "AmazinFighters"
// let points = 0
// let hasWon = false
// points += 100
// hasWon = true
// if (hasWon) { // I USED TEMPLATE STRINGS FOR THIS
// console.log(`${player} got ${points} point and won the ${game} game!`)
// } else {
// console.log(`The winner is ${opponent} ! ${player} lost the game`)
// }
// LOG OUT ITEMS IN AN ARRAY
// let myCourses = ["learn css animation", "UI design fundamentals", "Intro to clean code"]
// function courses(arr) {
// for (let i = 0; i < arr.length; i++) {
// console.log(arr[i])
// }
// }
// courses(myCourses)
// HOW TO SAVE TO LOCAL STORAGE
// localStorage.setItem("myWatch", "100")
// let myResults = localStorage.getItem("MyWatch")
// console.log(myResults)
// localStorage.getItem("MyWatch")
// ADD EVENT LISTENER AND OBJECT IN ARRAY
// let data = [
// {
// player: "jane",
// score: 52
// },
// {
// player: "mark",
// score: 41
// }
// ]
// let buttonEL = document.getElementById("button-el")
// buttonEL.addEventListener("click", function(){
// console.log(data[0].score)
// })
// GENERATE SENTENCE
// function generateSentence(desc, arr) {
// let sent = `The ${arr.length} ${desc} are`
// const lastIndex = arr.length - 1
// for (let i = 0; i < arr.length; i++) {
// if (i === lastIndex) {
// sent += arr[i]
// } else {
// sent += arr[i] + ","
// }
// }
// return sent
// }
// const sentence = generateSentence(" highest mountains ", ["mount Everest", " K2"])
// console.log(sentence)
// WRITE MY FIRST FUNCTION PARAMETERS
// const welcomeEl = document.getElementById("welcome-el")
// function greetUser(greeting) {
// welcomeEl.textContent = greeting + " martin vibes!"
// }
// greetUser("Welcome back,")
// MULTIPLE FUNCTION PARAMETERS
// const welcomeEl = document.getElementById("welcome-el")
// function greetUser(greeting, name, emoji) {
// welcomeEl.textContent = `${greeting} ${name} ${emoji}`
// }
// greetUser("Welcome back", "investor", "!")
// ARGUEMENT AND PARAMETER
// function greetUser(greeting, name,) {
// welcomeEl.textContent = `${greeting} ${name}`
// }
// greetUser("Welcome back", "investor",)
// function add(num1, num2) {
// return num1 + num2
// }
// console.log(add(3, 4))
// console.log(add(9, 102))
// ARRAYS AS PARAMETERS
// function getFirst(arr) {
// return arr[0]
// }
// let firstCard = getFirst([10, 7, 3])
// console.log(firstCard)
// // HOW TO ADD AND REMOVE STRING IN LOCALSTORAGE
// // let myLeads = `["www.hanner.com"]`
// // myLeads = JSON.parse(myLeads)
// // myLeads.push("hewudshbikds")
// // myLeads = JSON.stringify(myLeads)
// // console.log(typeof myLeads)
// // TEMPLATE STRING/LITERALS
// // const recipient = "james"
// // const sender = "mart"
// // // const email = "hey " + recipient + "! how is it going, cheers per"
// // const email = `
// // hey ${recipient}!
// // how is it going?
// // cheers ${sender}
// // `
// // console.log(email)
// // HOW TO USE INNER HTML
// // 1. const buy = document.getElementById("buys")
// // buys.innerHTML = "<button onclick='buy()'> buy!</button>"
// // buys.addEventListener("click", function() {
// // buys.innerHTML = "Thank you for buying"
// // })
// // OR
// // function buy(){
// // buys.innerHTML = "<p>Thank you for buying!</p>"
// // }
// // 2. const li = document.createElement("li")
// // li.textContent = myLeads[i]
// // ulEL.append(li)
// // HOW TO USE ADD EVENT LISTENER
// // let box = document.getElementById("box")
// // box.addEventListener("click", function() {
// // console.log("I want to open the box")
// // })