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