forked from onebeyond/js-pills
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.js
80 lines (68 loc) · 1.83 KB
/
index.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
let interval,
isPaused = false,
timer = 60 * 2 + 29,
minutes,
seconds,
isRunning = false,
display = document.querySelector("#time");
const images = [
"./assets/Carlos.png",
"./assets/Felipe.png",
];
window.onload = function () {
document.getElementById("header-image").src =
images[Math.round(Math.random() * 1)];
};
function startTimer(display) {
isRunning = true;
interval = setInterval(function () {
minutes = parseInt(timer / 60, 10);
seconds = parseInt(timer % 60, 10);
minutes = minutes < 10 ? "0" + minutes : minutes;
seconds = seconds < 10 ? "0" + seconds : seconds;
display.textContent = minutes + ":" + seconds;
if (--timer < 0) {
timer = 0;
}
}, 1000);
}
function play() {
isPause = false;
if (isRunning) return;
startTimer(display);
}
function pause() {
isPaused = !isPaused;
isRunning = false;
clearInterval(interval);
}
function reset() {
isRunning = false;
timer = 60 * 2 + 30;
display.textContent = "02:30";
}
function openNav() {
document.getElementById("main").style.width = "80%";
}
function closeNav() {
document.getElementById("main").style.width = "100%";
}
function setIfFrameURL(url) {
$("#content").load(url, function (response) {
if (status == "error") {
var msg = "Sorry but there was an error: ";
console.log(msg + xhr.status + " " + xhr.statusText);
}
document.getElementById("secret").innerHTML = response.includes(
"Merging arrays"
)
? `<div class="felipe-comic">
<img id="felipe-image" src="./assets/Felipe.png"></img>
<div class="speech-bubble-felipe">Poco se habla del merging arrays</div>
</div>`
: ``;
var converter = new showdown.Converter({ tables: true }),
html = converter.makeHtml(response);
document.getElementById("content").innerHTML = html;
});
}