-
Notifications
You must be signed in to change notification settings - Fork 1
/
main.js
32 lines (26 loc) · 1.06 KB
/
main.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
import "./style.css";
import Experience from "./Experience/Experience.js";
import Facts from "./Facts.js";
import { shuffleArray, factTittles, docTitles } from "./Facts.js";
const experience = new Experience(document.querySelector(".experience-canvas"));
document.addEventListener("DOMContentLoaded", function() {
const factPlaceholder = document.getElementById("fact");
const facttitle = document.getElementById("fact-title");
shuffleArray(factTittles);
facttitle.innerText =factTittles[ Math.floor(Math.random() * factTittles.length)];
var factNumber;
function randomFact(){
shuffleArray(Facts)
return Facts[factNumber];
}
factNumber = Math.floor(Math.random() * Facts.length);
factPlaceholder.textContent = randomFact();
let docTitle = document.title;
window.addEventListener("blur", ()=>{
const docTitleNumber = Math.floor(Math.random() * docTitles.length);
document.title = docTitles[docTitleNumber];
} )
window.addEventListener("focus", ()=>{
document.title = docTitle;
})
});