Annotation of html5/spec/load-timeout.js, revision 1.3

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';
                      7:     var x = document.createElement('button');
                      8:     x.textContent = '\u2573';
                      9:     x.onclick = closeAlert2;
                     10:     currentAlert.appendChild(x);
                     11:     currentAlert.appendChild(document.createElement('span'));
                     12:     currentAlert.onmousemove = function () {
                     13:       clearTimeout(currentAlertTimeout);
                     14:       currentAlert.className = '';
                     15:       currentAlertTimeout = setTimeout(closeAlert, 10000);
                     16:     }
                     17:     document.body.appendChild(currentAlert);
                     18:   } else {
                     19:     clearTimeout(currentAlertTimeout);
                     20:     currentAlert.className = '';
                     21:   }
                     22:   currentAlert.lastChild.textContent = s + ' ';
                     23:   if (href) {
                     24:     var link = document.createElement('a');
                     25:     link.href = href;
                     26:     link.textContent = href;
                     27:     currentAlert.lastChild.appendChild(link);
                     28:   }
                     29:   currentAlertTimeout = setTimeout(closeAlert, 10000);
                     30: }
                     31: function closeAlert() {
                     32:   clearTimeout(currentAlertTimeout);
                     33:   if (currentAlert) {
                     34:     currentAlert.className = 'closed';
                     35:     currentAlertTimeout = setTimeout(closeAlert2, 3000);
                     36:   }
                     37: }
                     38: function closeAlert2() {
                     39:   clearTimeout(currentAlertTimeout);
                     40:   if (currentAlert) {
                     41:     currentAlert.parentNode.removeChild(currentAlert);
                     42:     currentAlert = null;
                     43:   }
                     44: }
                     45: window.addEventListener('keydown', function (event) {
                     46:   if (event.keyCode == 27) {
                     47:     if (currentAlert)
                     48:       closeAlert2();
                     49:   } else {
                     50:     closeAlert();
                     51:   }
                     52: }, false);
                     53: window.addEventListener('scroll', function (event) {
                     54:   closeAlert();
                     55: }, false);
1.3     ! mike       56: setTimeout(function () {
        !            57:   showAlert("Too slow? Try reading the multipage copy of the spec instead:", "./"), 6000);
1.1       mike       58: }

Webmaster