-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathsearchsk1.js
412 lines (324 loc) · 11.5 KB
/
searchsk1.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
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
//Global vars
const jsonSource= "CourseFeed_Global.json";
const display =document.querySelector("#display-data");
const input=document.querySelector('#input');
const rNum=document.querySelector('#rNum');
const cBx=document.querySelectorAll('input');
const hsrc=localStorage.getItem('hq1');
if(hsrc!=null){input.value=hsrc}
//category vars
const au = document.getElementById("Automation"), cl = document.getElementById("Cloud")
const dna = document.getElementById("Data&AI"), fin = document.getElementById("Finance");
const sec = document.getElementById("Security"),sus = document.getElementById("Sustainability");
const sys = document.getElementById("Systems");
const aul = document.getElementById("auL"), cll = document.getElementById("clL");
const dnal = document.getElementById("dnaL"), finl = document.getElementById("finL");
const secl = document.getElementById("secL"), susl = document.getElementById("susL");
const sysl = document.getElementById("sysL");
//skill level variables
const adv = document.getElementById("Advanced");
const int = document.getElementById("Intermediate");
const bas = document.getElementById("Basic");
//search functions
async function m(hId,Key,jSource) {
const check = hId.checked;;
const query=(check===true)?`${Key}`:"";
const payload = await jSource;
const filterList = payload.filter((eventData) => {
if (query === "") { return eventData; }
else if (eventData.MKTCATEGORY_NAME.toLowerCase().includes(query)) { return eventData}
})
return filterList;
}
async function sD(lId,Key,jSource) {
let filterlist = await jSource;
const sList=filterlist.filter((eventData) => {
(eventData.SKILLLEVEL.toLowerCase().includes(query)) } )
const fNum=sList.length
lId.innerHTML=`${Key} ${fNum}`
}
//data funct
const getrawData = async () => {
const res = await fetch(jsonSource); //works on server but not on local file
const data = await res.json();
return data
}
function cbclick(e){
e = e || event;
var cb = e.srcElement || e.target;
if (cb.type !== 'checkbox') {return true;}
var cbxs = document.getElementById('radiocb').getElementsByTagName('input'), i=cbxs.length;
while(i--) {
if (cbxs[i].type && cbxs[i].type == 'checkbox' && cbxs[i].id !== cb.id) {
cbxs[i].checked = false;
}
}
// if the click should always result in a checked checkbox
// unconmment this:
// cb.checked = true;
}
async function filter1(){
var filt1=null;
switch(true){
case au.checked:
filt1=m(au,"aut",getrawData())
console.log("Automation");
break
case cl.checked:
filt1=m(cl,"clo",getrawData());
console.log("Cloud");
break
case dna.checked:
filt1=m(dna,"data",getrawData());
console.log("Data and AI");
break
case fin.checked:
filt1=m(fin,"fin",getrawData());
console.log("Finance");
break
case sec.checked:
filt1=m(sec,"sec",getrawData());
console.log("Security");
break
case sus.checked:
filt1=m(sus,"sus",getrawData());
console.log("Sustainability");
break
case sys.checked:
filt1=m(sys,"sys",getrawData());
console.log("Systems");
break
default:
filt1=getrawData()
};
return filt1
}
//eventlisteners
au.addEventListener("change",()=>{
filter1();
})
cl.addEventListener("change",()=>{
filter1();
})
dna.addEventListener("change",()=>{
filter1();
})
fin.addEventListener("change",()=>{
filter1();
})
sec.addEventListener("change",()=>{
filter1();
})
sus.addEventListener("change",()=>{
filter1();
})
sys.addEventListener("change",()=>{
filter1();
})
async function s(hId,Key,jSource) {
const check = hId.checked;
const query=(check===true)?`${Key}`:"";
console.log("Filtquery:",query);
const payload = await jSource;
//seperates arrays in json into seperate objects
//filters will be tweaked to suit ideal parameters
let filterList = payload.filter((eventData) => {
if (query === "") { return eventData; }
else if (eventData.SKILLLEVEL.toLowerCase().includes(query)) { return eventData}
})
return filterList;
}
s(adv,"Advanced",filter1())
s(int,"Intermediate",filter1())
s(bas,"Basic",filter1())
async function filter2(){
var filt2=null;
switch(true){
case adv.checked:
filt2=s(adv,"adv",filter1())
break
case int.checked:
filt2=s(int,"int",filter1())
break
case bas.checked:
filt2=s(bas,"bas",filter1())
break
default:
filt2=filter1()
};
return filt2
}
adv.addEventListener("change",()=>{
filter2();
})
int.addEventListener("change",()=>{
filter2();
})
bas.addEventListener("change",()=>{
filter2();
})
const sUsers= async()=>{
let query = input.value;//input var
console.log("Query::",query);
//filter added between payload and etc because payload holds users list
const payload = await filter2();
//seperates arrays in json into seperate objects
let nuArr = payload.filter((eventData)=>{
if (query==="") {return eventData}
else if (eventData.TITLE.toLowerCase().includes(query.toLowerCase())){return eventData}
})
return nuArr
}
const sUsers1= async()=>{
let query = input.value;//input var
console.log("Query::",query);
//filter added between payload and etc because payload holds users list
const payload = await filter2();
//seperates arrays in json into seperate objects
let nuArr = payload.filter((eventData)=>{
if (query==="") {return eventData}
else if (eventData.COURSECODE.toLowerCase().includes(query.toLowerCase())){return eventData}
})
return nuArr
}
const sUsers2= async()=>{
let query = input.value;//input var
console.log("Query::",query);
//filter added between payload and etc because payload holds users list
const payload = await filter2();
//seperates arrays in json into seperate objects
let nuArr = payload.filter((eventData)=>{
if (query==="") {return eventData}
else if (eventData.KEYWORD.toLowerCase().includes(query.toLowerCase())){return eventData}
})
return nuArr
}
const tList= async()=>{
let iList1=await sUsers()
let iList2=await sUsers1()
let iList3=await sUsers2()
let iList=[...iList1,...iList2,...iList3];
let uniq = i => [...new Set(i)];
let iL=uniq(iList)
return iL;
}
input.addEventListener('keypress', function (e) {
if (e.key === 'Enter') {
tList();
}
});
const displayUsers =async () => {
let query = input.value;//input var
console.log("Query::",query);
//filter added between payload and etc because payload holds users list
const payload = await tList();
//seperates arrays in json into seperate objects
if (payload.BADGE_ID="NONE"){
dataDisplay=payload.map((object) => {
const {TITLE, SHORT_SUMMARY,SKILLLEVEL,COURSECODE,DURATION_UNIT,DURATION_LENGTH} = object;
return `
<link rel="stylesheet" href="disp.css">
<div type="container" class="search-result-blank-1">
<img class="heart-line-1-23" src="heart-line-1-22.svg" />
<img class="bookmark-fill-23" src="bookmark-fill-22.svg" />
<img class="cyber-badges-2" src="cyber-badges-22.png" />
<img class="arrow-drop-down-line-133" src="arrow-drop-down-line-132.svg"/>
<div class="course-ibm-safer-payments-hands-on-technical">
<a href="./coursedisp2.html">Course -${TITLE}</a>
</div>
<div class="code-xxxx-this-course-reviews-the-ibm-cloud-account-types-lite-pay-go-subscription-and-enterprise">
(Code:ITS-${COURSECODE})${SHORT_SUMMARY}.
</div>
<div class="sub-info-2">
<div class="ilo">ILO</div>
<img class="vector25" src="vector24.svg" />
<img class="vector26" src="vector25.svg" />
<img class="vector27" src="vector26.svg" />
<div class="request-quote">Request Qoute</div>
<div class="_3-days">${DURATION_LENGTH} ${DURATION_UNIT}</div>
<div class="basic">${SKILLLEVEL}</div>
<img class="vector28" src="vector27.svg" />
</div>
</div>
</div>
<br>
`
}).join("");
}else{
console.log(payload)
dataDisplay=payload.map((object) => {
const {TITLE, SHORT_SUMMARY,SKILLLEVEL,COURSECODE,DURATION_UNIT,DURATION_LENGTH} = object;
return `
<link rel="stylesheet" href="disp.css">
<div type="container" class="search-result-blank-1">
<img class="heart-line-1-23" src="heart-line-1-22.svg" />
<img class="bookmark-fill-23" src="bookmark-fill-22.svg" />
<img class="cyber-badges-2" src="cyber-badges-22.png" />
<img class="arrow-drop-down-line-133" src="arrow-drop-down-line-132.svg"/>
<div class="course-ibm-safer-payments-hands-on-technical">
<a href="./coursedisp2.html">Badge -${TITLE}</a>
</div>
<div class="code-xxxx-this-course-reviews-the-ibm-cloud-account-types-lite-pay-go-subscription-and-enterprise">
(Code:ITS-${COURSECODE})${SHORT_SUMMARY}.
</div>
<div class="sub-info-2">
<div class="ilo">ILO</div>
<img class="vector25" src="vector24.svg" />
<img class="vector26" src="vector25.svg" />
<img class="vector27" src="vector26.svg" />
<div class="request-quote">Request Qoute</div>
<div class="_3-days">${DURATION_LENGTH} ${DURATION_UNIT}</div>
<div class="basic">${SKILLLEVEL}</div>
<img class="vector28" src="vector27.svg" />
</div>
</div>
</div>
<br>
`
}).join("");
}
let rLen=payload.length
rNum.innerHTML=`Showing ${rLen} Results`;
display.innerHTML = dataDisplay;
}
displayUsers();
cBx.forEach((e)=>{e.addEventListener("change",function(){
displayUsers();
})});
const Jsrc=getrawData();
const cIn=document.getElementById("cIn")
localStorage.removeItem('hq1')
/*document.onclick = function(event) {
var target = event.target || event.srcElement;
// alert ( target.innerHTML );
const t=target.innerHTML
return t
};*/
const nuQ=()=>{
var target= event.target || event.srcElement
const t =target.innerHTML
const q=t.replace("Course -",'')
const qq2=q.replace("Badge -",'')
console.log(t)
console.log(q)
localStorage.setItem("qq1",qq2)
console.log(localStorage.qq1)
return JSON.stringify(q)
}
display.addEventListener('click',nuQ);
localStorage.setItem("qq","advanced machine learning models using ibm spss modeler (v18.2)")
const jt=nuQ();
console.log(jt);
let tt=bindEvent();
console.log(JSON.stringify(tt))
const v=bindEvent();//nuQ();
console.log(v);
const qr=JSON.stringify(v)
localStorage.setItem("query",JSON.stringify(v));
localStorage.qry=JSON.stringify(v);
console.log(localStorage)
document.cookie=v
// On the first page
const data = JSON.stringify(v);
const encodedData = encodeURIComponent(data);
//window.location.href = `secondPage.html?data=${encodedData}`;