-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathmain.js
More file actions
54 lines (43 loc) · 1.77 KB
/
Copy pathmain.js
File metadata and controls
54 lines (43 loc) · 1.77 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
// I am not using main.js for no optmize way to share data one file to another :Window object can help but it dely
// No full controll over timing data loads etc
// This file only using $(select) function that select element by id or class name
// function Query(){
// fetch('https://data.techforpalestine.org/api/v2/killed-in-gaza.json')
// .then(res => res.json())
// .then(data => console.log(data));
// }
// window.addEventListener('load', function(){
// Query()
// });
// Quick select element
function $(select){
return document.querySelector(select);
}
// (async ()=>{
// let x = await Query('https://data.techforpalestine.org/api/v2/killed-in-gaza.json');
// for(let i = 0; i < x.data.length; i++){
// console.log(x.data[i].name);
// }
// })()
// let categorizedData = {};
// (async () => {
// let result = await Query('https://data.techforpalestine.org/api/v2/killed-in-gaza.json');
// if (result.error) {
// console.error('Error fetching data:', result.error);
// return;
// }
// const data = result.data;
// const females = data.filter(person => person.gender === 'female');
// const currentYear = new Date().getFullYear();
// const currentYearData = data.filter(person => new Date(person.date).getFullYear() === currentYear);
// const children = data.filter(person => person.age && person.age <= 18);
// const today = new Date().toISOString().split('T')[0];
// const todayData = data.filter(person => person.date && !isNaN(new Date(person.date)) && new Date(person.date).toISOString().split('T')[0] === today);
// categorizedData = {
// females,
// currentYearData,
// children,
// todayData
// };
// console.log(categorizedData);
// })();