-
Notifications
You must be signed in to change notification settings - Fork 0
/
health.js
103 lines (64 loc) · 2.44 KB
/
health.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
import {footer} from "./components/footer.js"
let footer_div=document.getElementById("footer_rj");
footer_div.innerHTML=footer();
const healht_news = async()=>{
let res = await fetch (`https://newsdata.io/api/1/news?apikey=pub_11708b81b08dbf38764b8de0ebefe23602366&q=Health&country=in&category=health `)
let data = await res.json();
let actual_data = data.results
appendhealth_news(actual_data)
// console.log(data.results)
}
healht_news()
import {navbar} from "./components/navbar.js"
let navbar_div = document.getElementById('navbar_div');
navbar_div.innerHTML = navbar();
const appendhealth_news = (data) =>{
let news_div = document.getElementById('display');
news_div.innerHTML = null
// console.log(data.articles)
data.forEach(({pubDate,description,image_url,title})=>{
let div1 = document.createElement('div');
let div3 = document.createElement('div');
div3.id = 'show_news' ;
let image = document.createElement('img')
image.src = image_url
let div2 = document.createElement('div');
div2.id = 'titleanddes'
let h2 = document.createElement('h2');
h2.innerHTML = title;
let p1 = document.createElement('p');
p1.id = 'datetime'
p1.innerHTML =pubDate;
let p2 = document.createElement('p');
p2.id = 'description' ;
p2.innerHTML = description ;
div1.append(image)
div2.append(h2,p1,p2)
div3.append(div1,div2)
news_div.append(div3)
// console.log(image)
})
}
const btn = document.getElementById('menu_btn');
const overlay = document.getElementById('overlay');
const menu = document.getElementById('mobile-menu');
const section = document.getElementById('section_hidden');
btn.addEventListener('click',navToggle)
function navToggle(){
btn.classList.toggle('open');
overlay.classList.toggle('overlay_show');
document.body.classList.toggle('stop-scrolling')
menu.classList.toggle('show_menu');
section.classList.toggle('section')
}
const health_special = document.getElementById('cricket');
health_special.addEventListener("click",health_page)
function health_page (){
window.location.href="index.html"
}
const homePage_logo = document.getElementById('homePage_logo');
homePage_logo.addEventListener("click",homepage)
homePage_logo.style.cursor="pointer";
function homepage (){
window.location.href="index.html"
}