summaryrefslogtreecommitdiff
path: root/app/assets/javascripts/app.js
blob: dd7f08f66c6d26ef908cbdd35ead3be4fe689928 (plain)
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
$(function(){
  hljs.initHighlightingOnLoad();
  $('.flash').click(function(){
    $('.flash').animate({
      opacity: 0
    }, 'fast', function(){
      $(this).animate({
        height: 0
      }, 'slow', function(){
        $(this).hide();
      });
    });
  });
  setTimeout(function(){
    $('.flash').animate({
      opacity: 0
    }, 3000, function(){
      $(this).animate({
        height: 0
      }, 'slow', function(){
        $(this).hide();
      });
    });
  }, 4000);
  var pressed = new Array(10);
  var keys    = [38,38,40,40,37,39,37,39,66,65];
  $(document).keydown(function(e) {
    pressed.push(e.keyCode);
    pressed.shift();
    if ( pressed.toString() == keys.toString() ) {
      $('html').css('overflow-x', 'hidden');
      $('body').css('animation', '1s alternate-reverse infinite wiggle');
      $('body').css('-webkit-animation', '1s alternate-reverse infinite wiggle');
      $('img').css('transform', 'rotate(180deg)');
    }
  });
  $('pre code').each(function() {
    if ($(this).attr("class")) {
      $(this).parent().attr("lang", $(this).attr("class").replace("hljs", "").toLowerCase().trim());
    } else {
      $(this).parent().attr("lang", "(language unknown)");
    }
  });

  Ago({
    format: function(time, unit) {
      time = Math.abs(time);
      if (!unit) return "just now";
      if (time === 1) time = (unit[0] == "h") ? "an" : "a";
      var tail = time < 0 ? " ahead" : " ago";
      return time + " " + unit + tail;
    }
  });
});