| 1 | jQuery.githubUser = function(username, callback) { |
| 2 | jQuery.getJSON("http://github.com/api/v1/json/" + username + "?callback=?", callback); |
| 3 | } |
| 4 | |
| 5 | var nicknames = ["Dragon", "Gizzard", "The Enforcer", |
| 6 | "Mizungu", "The Hammer"] |
| 7 | var phrases = ["also feels that specialization is for insects", |
| 8 | "my dogs named tater tooooo", |
| 9 | "every movie should have a cast dance scene at the end", |
| 10 | "honey, you're a tool of the masses", |
| 11 | "my life is kinda like the Matrix, really", |
| 12 | "too fat to fit into Japanese pants", |
| 13 | "it's like the finger of God!"] |
| 14 | function changeBlurb() { |
| 15 | var phrase = phrases[Math.floor(Math.random()*phrases.length)] |
| 16 | $('#page-heading').text(phrase) |
| 17 | t=setTimeout("changeBlurb()",30000); |
| 18 | } |
| 19 | |
| 20 | function changeNickname() { |
| 21 | var nickname = nicknames[Math.floor(Math.random()*nicknames.length)] |
| 22 | $('#nickname').text(nickname) |
| 23 | t=setTimeout("changeNickname()",30000); |
| 24 | } |
| 25 | |
| 26 | function showHome() { |
| 27 | $('#break').show() |
| 28 | $('.non_home_box').hide('scale') |
| 29 | $('.home_box').show('scale') |
| 30 | } |
| 31 | |
| 32 | function showTalks() { |
| 33 | $('#break').hide() |
| 34 | $('#info_box').show() |
| 35 | $("#info_box").load("talks.html", null, function() { |
| 36 | window.location.hash = 'talks' |
| 37 | }); |
| 38 | } |
| 39 | |
| 40 | function showScribbles() { |
| 41 | $('#break').hide() |
| 42 | $('#info_box').show() |
| 43 | $("#info_box").load("scribbles.html", null, function() { |
| 44 | window.location.hash = 'scribbles' |
| 45 | }); |
| 46 | } |
| 47 | |
| 48 | function showAbout() { |
| 49 | $('#break').hide() |
| 50 | $('#info_box').show() |
| 51 | $("#info_box").load("about.html", null, function() { |
| 52 | window.location.hash = 'about' |
| 53 | $("a#menu_talks").click(function(event){ |
| 54 | hideAll() |
| 55 | showTalks() |
| 56 | }) |
| 57 | }); |
| 58 | } |
| 59 | |
| 60 | function showCode() { |
| 61 | $('#break').hide() |
| 62 | $('#info_box').show() |
| 63 | $("#info_box").load("code.html", null, function() { |
| 64 | $.githubUser('schacon', function(data) { |
| 65 | $('#github-projects').text('') |
| 66 | var repos = data.user.repositories; |
| 67 | repos.sort(function(a,b) { |
| 68 | return b.watchers - a.watchers; |
| 69 | }); |
| 70 | |
| 71 | $(repos).each(function() { |
| 72 | if((!this.fork) && (!this.private)) { |
| 73 | $('#github-projects').append("\ |
| 74 | <div class='repo'>\ |
| 75 | <h3><a href='" + this.url + "'>" + this.name + "</a></h3>\ |
| 76 | <span class='desc'>"+this.description+"</span>\ |
| 77 | <span class='watchers'>" + this.watchers + " </span>\ |
| 78 | <span class='forks'>" + this.forks + "</span>\ |
| 79 | </div>"); |
| 80 | } |
| 81 | }); |
| 82 | }); |
| 83 | window.location.hash = 'code' |
| 84 | }); |
| 85 | } |
| 86 | |
| 87 | function hideAll() { |
| 88 | $('.non_home_box').hide() |
| 89 | $('.home_box').hide() |
| 90 | } |
| 91 | |
| 92 | $(document).ready(function(){ |
| 93 | changeBlurb() |
| 94 | changeNickname() |
| 95 | if(window.location.hash != "") { |
| 96 | page = window.location.hash |
| 97 | if(page == '#talks') { |
| 98 | hideAll() |
| 99 | showTalks() |
| 100 | } |
| 101 | if(page == '#code') { |
| 102 | hideAll() |
| 103 | showCode() |
| 104 | } |
| 105 | if(page == '#about') { |
| 106 | hideAll() |
| 107 | showAbout() |
| 108 | } |
| 109 | if(page == '#scribbles') { |
| 110 | hideAll() |
| 111 | showScribbles() |
| 112 | } |
| 113 | } |
| 114 | |
| 115 | $("a#menu_home").click(function(event){ |
| 116 | showHome() |
| 117 | }) |
| 118 | |
| 119 | $("a#menu_talks").click(function(event){ |
| 120 | hideAll() |
| 121 | showTalks() |
| 122 | }) |
| 123 | |
| 124 | $("a#menu_code").click(function(event){ |
| 125 | hideAll() |
| 126 | showCode() |
| 127 | }) |
| 128 | |
| 129 | $("a#menu_about").click(function(event){ |
| 130 | hideAll() |
| 131 | showAbout() |
| 132 | }) |
| 133 | |
| 134 | $("a#menu_scribbles").click(function(event){ |
| 135 | hideAll() |
| 136 | showScribbles() |
| 137 | }) |
| 138 | |
| 139 | }) |