js/bootstrap-386.js
author indvd00m (gotoindvdum[at]gmail[dot]com)
Fri, 04 Jul 2014 16:42:41 +0400
changeset 0 ba8ab09f730e
permissions -rw-r--r--
First home page
     1 $(function(){
     2   var 
     3     character = {
     4       height: 20,
     5       width: 12.4
     6     },
     7     wrap = document.createElement('div'),
     8     bar = wrap.appendChild(document.createElement('div')),
     9 
    10     cursor = document.createElement('div'),
    11     // If the user specified that the visibility is hidden, then we
    12     // start at the first pass ... otherwise we just do the 
    13     // cursor fly-by
    14     pass = ($(document.body).css('visibility') == 'visible') ? 1 : 0,
    15     height = $(window).height(),
    16     width = $(window).width(),
    17 
    18     // this makes the loading of the screen proportional to the real-estate of the window.
    19     // it helps keep the cool sequence there while not making it waste too much time.
    20     rounds = (height * width / 165000),
    21     column = width, row = height - character.height;
    22     // TODO: externalize this
    23     //
    24   wrap.setAttribute('style', 'z-index:9999999;background:#000084;position:fixed;bottom:0;right:0;height:100%;width:100%');
    25   bar.setAttribute('style', 'color:#fff;font-weight:bold;float:right;background:#000084;height:20px;margin-top:-20px;width:100%');
    26   cursor.setAttribute('style', 'z-index:9999999;color:#fff;font-weight:bold;position:fixed;bottom:0;right:0');
    27 
    28   cursor.innerHTML = bar.innerHTML = '▄';
    29 
    30   // only inject the wrap if the pass is 0
    31   if(pass === 0) {
    32     document.body.appendChild(wrap);
    33     document.body.style.visibility='visible';
    34   } else {
    35     document.body.appendChild(cursor);
    36     rounds /= 2;
    37     character.height *= 4;
    38   }
    39 
    40   var ival = setInterval(function(){
    41     for(var m = 0; m < rounds; m++) {
    42       column -= character.width;
    43 
    44       if(column <= 0) {
    45         column = width;
    46         row -= character.height;
    47       }
    48       if(row <= 0) {
    49         pass++;
    50         row = height - character.height;
    51 
    52         if(pass == 2) {
    53           document.body.removeChild(cursor);
    54           clearInterval(ival);
    55         } else {
    56           wrap.parentNode.removeChild(wrap);
    57           document.body.appendChild(cursor);
    58           rounds /= 2;
    59           character.height *= 4;
    60         }
    61       }
    62 
    63       if(pass === 0) {
    64         bar.style.width = column + "px";
    65         wrap.style.height = row + "px";
    66       } else {
    67         cursor.style.right = column + "px";
    68         cursor.style.bottom = row + "px";
    69       }
    70     }
    71   }, 1);
    72 });
    73