-
Notifications
You must be signed in to change notification settings - Fork 19
/
Copy pathindex.html
116 lines (109 loc) · 3.58 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
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
<html>
<head>
<meta charset="utf-8">
<title>disTime.js</title>
<style>
#config {
font-family: monospace;
font-size: 17px;
}
#examples {
font-family: "Lucida Grande", "Lucida Sans Unicode", Geneva, sans-serif;
font-size: 14px;
}
</style>
<script src="disTime.js" type="text/javascript"></script>
<script src="disTime.i18n.js" type="text/javascript"></script>
<script>
/*global disTime, disTimeRepeater */
/*jslint browser: true, indent: 2 */
function random(min, max) {
"use strict";
return Math.floor(Math.random() * (max - min + 1)) + min;
}
function generateExamples(config) {
"use strict";
var i,
time = new Date(),
examplesElement = document.getElementById('examples'),
examples = '',
timestamp;
i = random(-10, 0);
while (i < 15) {
timestamp = parseInt(time.getTime() / 1000 - i * (100 + random(0, 42)), 10);
examples += '<p class="distime" data-time="' + timestamp + '">' + timestamp + '</p>';
i += 1;
}
examplesElement.innerHTML += '<p class="distime" data-time="' + parseInt(time.getTime() / 1000 - parseInt(eval(config.time), 10), 10) + '">' + parseInt(time.getTime() / 1000 - parseInt(eval(config.time), 10), 10) + '</p>' + examples;
}
function init() {
"use strict";
var config,
hash,
i,
userLang = navigator.language || navigator.userLanguage;
config = {'lang' : userLang, 'time' : '60*60*24', 'detail' : 1};
hash = window.location.hash.replace('#', '').split('&');
for (i = 0; i < hash.length; i += 1) {
config[hash[i].split('=')[0]] = hash[i].split('=')[1];
}
generateExamples(config);
//disTime(<?php echo time(); ?>-parseInt(Date.now()/1000),config.lang,parseInt(config.detail,10));
disTime(0, config.lang, parseInt(config.detail, 10));
}
function changeDemo() {
"use strict";
var lang,
detail;
lang = document.getElementById('lang').value;
detail = document.getElementById('detail').value === 'on' ? true : false;
window.clearTimeout(disTimeRepeater);
disTime(0, lang, detail);
}
</script>
</head>
<body onload="javascript:init();">
<div id="config">Langauge (ISO 639-1):
<select id="lang" name="lang" size="1" onchange="changeDemo()">
<optgroup label="autodetected">
<option><script>document.write((navigator.language) ? navigator.language : navigator.userLanguage);</script></option>
</optgroup>
<optgroup label="supported">
<option>de</option>
<option>en</option>
<option>es</option>
<option>fr</option>
<option>in</option>
<option>it</option>
<option>ms</option>
<option>nl</option>
<option>no</option>
<option>oc</option>
<option>pl</option>
<option>pt</option>
<option>ro</option>
<option>ta</option>
<option>ru</option>
<option>sv</option>
<option>tl</option>
<option>tr</option>
<option>uk</option>
<option>int</option>
</optgroup>
</select>
Details:
<select id="detail" name="detail" size="1" onchange="changeDemo()">
<option>on</option>
<option>off</option>
</select>
</div><div id="examples">
<p class="distime" data-time="1563410000">1563410000</p>
<p class="distime" data-time="1503410000">1503410000</p>
<p class="distime" data-time="1473410000">1473410000</p>
<p class="distime" data-time="1443410000">1443410000</p>
<p class="distime" data-time="1413410000">1413410000</p>
<p class="distime" data-time="613112400">613112400</p>
<p class="distime" data-time="1363410000">1363410000</p>
</div>
</body>
</html>