Skip to content

Commit 8532a57

Browse files
committed
Time function
add seconds display timing without refreshing the page
2 parents 806cca8 + c21799e commit 8532a57

File tree

3 files changed

+36
-13
lines changed

3 files changed

+36
-13
lines changed

feature-intro.js

+8-2
Original file line numberDiff line numberDiff line change
@@ -9,10 +9,16 @@ const date = new Date();
99
const hours = date.getHours();
1010

1111
const dateString = date.toLocaleDateString();
12-
const timeString = date.toTimeString().substr(0,5)
1312
const timeOfDay = getTimeOfDay(hours);
1413

1514
introTitle.textContent = `Good ${timeOfDay}! `;
1615
introDate.textContent = `Today is ${dateString}`;
17-
introTime.textContent = `It's ${timeString}`;
1816

17+
function upDateTime(){
18+
const date = new Date();
19+
const timeString = date.toTimeString().substr(0, 8);
20+
introTime.textContent = `It's ${timeString}`;
21+
}
22+
23+
setInterval(upDateTime, 1000);
24+
upDateTime();

feature-meme.js

+25-10
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,30 @@
1-
request("https://corporatebs-generator.sameerkumar.website/", function(response) {
2-
const sentence = document.querySelector('.sentence');
3-
let p = document.createElement('p')
4-
p.textContent = response.phrase;
5-
sentence.appendChild(p);
6-
});
7-
1+
// request("https://corporatebs-generator.sameerkumar.website/", function(response) {
2+
// const sentence = document.querySelector('.sentence');
3+
// let p = document.createElement('p')
4+
// p.textContent = response.phrase;
5+
// sentence.appendChild(p);
6+
// console.log("TEXT")
7+
// });
88

99
const pages = Math.floor(Math.random() * 10);
1010

11-
request(`https://picsum.photos/v2/list?page=${pages}&limit=100`, function(response) {
12-
const image = document.querySelector('.image');
11+
request(`https://picsum.photos/v2/list?page=${pages}&limit=100`, function(
12+
response
13+
) {
14+
const image = document.querySelector(".image");
1315
const random = Math.floor(Math.random() * 100);
14-
image.src = response[random].download_url
16+
17+
image.src = response[random].download_url;
18+
image.addEventListener("load", () => {
19+
console.log("IMAGE loaded");
20+
request("https://corporatebs-generator.sameerkumar.website/", function(
21+
response
22+
) {
23+
const sentence = document.querySelector(".sentence");
24+
let p = document.createElement("p");
25+
p.textContent = response.phrase;
26+
sentence.appendChild(p);
27+
console.log("TEXT");
28+
});
29+
});
1530
});

style.css

+3-1
Original file line numberDiff line numberDiff line change
@@ -200,7 +200,8 @@ section {
200200

201201
.sentence {
202202
position: absolute;
203-
left: 0;
203+
width: 100%;
204+
204205
}
205206

206207
.sentence p {
@@ -224,6 +225,7 @@ section {
224225
.tube-section {
225226
max-width: 800px;
226227
}
228+
227229
}
228230

229231
@media only screen and (min-width: 900px) {

0 commit comments

Comments
 (0)