Annotation of html5/spec/load-timeout.js, revision 1.13
1.1 mike 1: var currentAlert;
2: var currentAlertTimeout;
3: function showAlert(s, href) {
4: if (!currentAlert) {
5: currentAlert = document.createElement('div');
6: currentAlert.id = 'alert';
1.13 ! mike 7: var d = document.createElement('div');
1.9 mike 8: var x = document.createElement('input');
9: x.type = "button";
1.10 mike 10: x.value = "Close";
1.1 mike 11: x.onclick = closeAlert2;
1.12 mike 12: d.appendChild(x);
13: currentAlert.appendChild(d);
1.1 mike 14: currentAlert.appendChild(document.createElement('span'));
15: currentAlert.onmousemove = function () {
16: clearTimeout(currentAlertTimeout);
17: currentAlert.className = '';
18: currentAlertTimeout = setTimeout(closeAlert, 10000);
19: }
20: document.body.appendChild(currentAlert);
21: } else {
22: clearTimeout(currentAlertTimeout);
23: currentAlert.className = '';
24: }
25: currentAlert.lastChild.textContent = s + ' ';
26: if (href) {
27: var link = document.createElement('a');
28: link.href = href;
29: link.textContent = href;
30: currentAlert.lastChild.appendChild(link);
31: }
32: currentAlertTimeout = setTimeout(closeAlert, 10000);
33: }
34: function closeAlert() {
35: clearTimeout(currentAlertTimeout);
36: if (currentAlert) {
37: currentAlert.className = 'closed';
38: currentAlertTimeout = setTimeout(closeAlert2, 3000);
39: }
40: }
41: function closeAlert2() {
42: clearTimeout(currentAlertTimeout);
43: if (currentAlert) {
44: currentAlert.parentNode.removeChild(currentAlert);
45: currentAlert = null;
46: }
47: }
48: window.addEventListener('keydown', function (event) {
49: if (event.keyCode == 27) {
50: if (currentAlert)
51: closeAlert2();
52: } else {
53: closeAlert();
54: }
55: }, false);
56: window.addEventListener('scroll', function (event) {
57: closeAlert();
58: }, false);
1.7 mike 59: if (document.body.className == "") {
60: setTimeout(function () {
1.8 mike 61: showAlert("Too slow? Try reading the multipage copy of the spec instead:", "spec.html")
1.7 mike 62: }, 6000);
63: }
Webmaster