Skip to content

Commit ec9068a

Browse files
committed
[DELETE]: Remove infos carroussel bar for now
1 parent b9cf2f3 commit ec9068a

File tree

1 file changed

+1
-50
lines changed

1 file changed

+1
-50
lines changed

Components/Layout/MainLayout.razor

Lines changed: 1 addition & 50 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
<div class="topbar">
55
<div id="nav_header">
66
<div class="news" id="news_screen">
7-
<div class="news-text" id="news"> Breaking news</div>
7+
<div class="news-text" id="news"></div>
88

99
</div>
1010
<div class="nav_contact">
@@ -98,55 +98,6 @@
9898
</div>
9999
<script>
100100
let news_screen = document.getElementById("news");
101-
const getNews = async () => {
102-
const response = await fetch("https://www.who.int/api/news/healthtopics");
103-
const data = await response.json();
104-
console.log(data.value);
105-
const news = data.value.map(item => {
106-
return {
107-
// Extract the relevant information from the item by removing the HTML tags
108-
title: item.Tab1Summary.replace(/<[^>]+>/g, "").trim()
109-
};
110-
});
111-
return news;
112-
};
113-
if (news_screen){
114-
getNews().then(news => {
115-
// Display the news in the news_screen element one by one
116-
let index = 0;
117-
const displayNews = () => {
118-
if (index < news.length) {
119-
news_screen.innerHTML = news[index].title;
120-
index++;
121-
setTimeout(displayNews, 5000); // Change news every 5 seconds
122-
} else {
123-
index = 0; // Reset index to loop through the news again
124-
setTimeout(displayNews, 5000);
125-
}
126-
};
127-
displayNews();
128-
moveNewsScreen(10); // Move the news screen to the left
129-
}).catch(error => {
130-
console.error("Error fetching news:", error);
131-
})
132-
}
133-
134-
// Async Function to move the news screen to the left acccording to a given time
135-
const moveNewsScreen = async (time) => {
136-
let news_screen = document.getElementById("news");
137-
let screenWidth = window.innerWidth;
138-
let screenHeight = window.innerHeight;
139-
let leftPosition = screenWidth;
140-
let topPosition = screenHeight / 2 - news_screen.offsetHeight / 2;
141-
142-
news_screen.style.left = leftPosition + "px";
143-
144-
while (leftPosition > -news_screen.offsetWidth) {
145-
leftPosition -= 1; // Move left by 1 pixel
146-
news_screen.style.left = leftPosition + "px";
147-
await new Promise(resolve => setTimeout(resolve, time));
148-
}
149-
};
150101
151102
152103
let background_compact = document.getElementById("background_compact");

0 commit comments

Comments
 (0)