-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.html
81 lines (77 loc) · 1.96 KB
/
index.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
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="content-type" content="text/html; charset=utf-8" />
<title>Slack.ProgrammingExcuses</title>
<link href='http://fonts.googleapis.com/css?family=Molengo' rel='stylesheet' type='text/css'>
<style>
body {
background-color: #2F3129;
}
#content {
position: absolute;
left: 50%;
top: 50%;
transform: translate(-50%, -50%);
text-align: center;
color: #ffffff;
font-family: 'Molengo', Georgia, Times, serif;
text-shadow: 1px 1px 1px rgba(0,0,0,0.004);
-webkit-font-smoothing: antialiased;
-webkit-text-stroke: 1px rgba(0,0,0,0.1);
}
</style>
</head>
<body>
<h3 id="content">Preparing the excuses...</h3>
<script src="https://code.jquery.com/jquery-1.12.4.min.js"></script>
<script>
function getNewExcuse(cb) {
$.ajax({
method: 'POST',
url: '/',
dataType: 'json',
async: false,
success: function(data, textStatus, xhr) {
cb(null, data.text)
$('#content').fadeOut(200, function() {
$('#content').text(data.text);
$('#content').fadeIn(200);
});
},
error: function(err) {
cb(err);
}
});
}
function updateExcuse(excuse) {
$('#content').fadeOut(200, function() {
$('#content').text(excuse);
$('#content').fadeIn(200);
});
}
function run() {
getNewExcuse(function(err, excuse) {
if (err) {
console.error(err);
} else {
updateExcuse(excuse);
}
});
}
</script>
<script>
var currentRequests = 0;
var maxRequests = 1000;
run();
$(function() {
var interval = setInterval(function() {
if (currentRequests++ > maxRequests) {
clearInterval(interval);
}
run();
}, 8000);
});
</script>
</body>
</html>