-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathentertainment.html
157 lines (131 loc) · 5.87 KB
/
entertainment.html
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
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Today News</title>
<link href="https://fonts.googleapis.com/css2?family=Cairo:wght@200;300;400&display=swap" rel="stylesheet">
<link rel="shortcut icon" href="/img/icon.png" type="image/x-icon">
<link rel="stylesheet" href="css/styleNews.css">
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.6.0/jquery.min.js"></script>
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/semantic-ui/2.4.1/semantic.min.css" />
<script src="https://cdnjs.cloudflare.com/ajax/libs/semantic-ui/2.4.1/semantic.min.js"></script>
</head>
<body>
<!--Menu-->
<div class="ui large secondary inverted pointing fixedBar fixed menu">
<a class="toc item">
<i class="sidebar icon"></i>
</a>
<div class="sc-logo">News</div>
<div class="right item">
<a class="item" href="index.html">All</a>
<a class="item" href="general.html">General</a>
<a class="item" href="business.html">Business</a>
<a class="item" href="technology.html">Technology</a>
<a class="item active item" href="entertainment.html">Entertainment</a>
<a class="item" href="health.html">Health</a>
<a class="item" href="science.html">science</a>
<a class="item" href="try.html">sports</a>
</div>
</div>
<!--Weather & Time Section-->
<section class="WeatherCal-section">
<div class="ui equal width center aligned stakable padded grid">
<div class="row">
<div class="eight wide mobile eight wide tablet eight wide computer column cc">
<div class="date-container loading">
<div class="time" id="time">
<span id="am-pm"></span>
</div>
<div class="date" id="date"></div>
</div>
</div>
<div class="eight wide mobile eight wide tablet eight wide computer column cc">
<div class="card cardWeather">
<div class="search">
<input type="text" class="searchBar" placeholder="Search">
<button><i class="search link icon"></i></button>
</div>
<div class="weather loading">
<h3 class="city">weather in Buraydah</h3>
<h1 class="temp">16 °C</h1>
<img src="https://www.weatherbit.io/static/img/icons/t05d.png" alt="" class="iconWeather" />
<div class="description">mostly clear</div>
<div class="humidity">humidity</div>
<div class="wind">14 km/h</div>
</div>
</div>
</div>
</div>
</div>
</section>
<section class="search-section">
<div class="ui five column centered grid">
<div class="column search-bar">
<div class="ui icon input ">
<input type="text" id="search-bar" placeholder="Search title or description ..." />
<i class="search link icon"></i>
</div>
</div>
</div>
</section>
<!--Search, dropdown Row and Cards fetch API row-->
<section id="contents" class="sc-section">
<div class="ui stakable grid container">
<div class="row">
<div class="ui cards" id="output"></div>
</div>
</div>
</section>
<script>
const chardList = document.getElementById('output');
const search = document.getElementById('search-bar');
let state =[];
search.addEventListener('keyup' , (event) => {
//searchState(search.value));
const searchText = event.target.value.toLowerCase();
console.log(searchText);
const filterText = state.filter(states => {
return (
states.title.toLowerCase().includes(searchText) ||
states.description.toLowerCase().includes(searchText)
);
});
console.log(filterText)
outputhtml(filterText);
});
const searchState = async fetchNews => {
apiKey='8c06a7999aa843788ba579a121cc37d5';
category='entertainment';
const res = await fetch(`https://newsapi.org/v2/top-headlines?category=${this.category}&apiKey=${this.apiKey}`);
const data = await res.json();
state = data.articles;
outputhtml(state);
};
const outputhtml = matches => {
const html = matches.map(match =>
`<div class="ui fluid container card cardContainer">
<div class="image">
<img src=${match.urlToImage} class="imgnew">
</div>
<div class="content">
<h5 class="header">${match.title}</h5>
<div class="description">${match.description}</div>
</div>
<div class="extra content">
<span>
<a href=${match.url} target="_blank" class="ui button btn-read">Read more</a>
</span>
</div>
</div>`
).join('');
chardList.innerHTML = html;
};
searchState();
</script>
<script src="js/weather.js" defer></script>
<script src="js/script.js"></script>
</body>
</html>