Last active
August 29, 2015 14:27
-
-
Save jose-villegas/8c74de0e41b0e9d4ccbc to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function checkTime(i) { | |
if (i<10) {i = "0" + i}; // add zero in front of numbers < 10 | |
return i; | |
} | |
var colorMeBadInterval, | |
funkyTownInterval, | |
varPartyModeOn = false; | |
function startTime() { | |
var today=new Date(); | |
var h=today.getHours(); | |
var m=today.getMinutes(); | |
var s=today.getSeconds(); | |
var suffix = h >= 12 ? "PM":"AM"; | |
m = checkTime(m); | |
s = checkTime(s); | |
// h = 4; m = s % 21; m = m > 17 && m < 23 ? 20 : m; // testing mode | |
if(h == 4 && m == 20 && !partyModeOn) | |
{ | |
partyModeOn = true; | |
colorMeBadInterval = setInterval(colorMeBadd, 300); | |
funkyTownInterval = setInterval(funkyTown, 250); | |
} | |
else | |
{ | |
partyModeOn = false; | |
clearInterval(colorMeBadInterval); | |
clearInterval(funkyTownInterval); | |
$('#motdwrap').removeAttr('class'); | |
$("#motdwrap span").each(function(){ | |
$(this).removeAttr('class'); | |
}); | |
} | |
if(!document.getElementById("taimaClock")) { | |
document.getElementById('motdwrap').innerHTML += | |
"<div id='taimaClock'>" | |
+"<span id='hour'>"+((h + 11) % 12 + 1)+"</span>:" | |
+"<span id='minute'>"+m+"</span>:" | |
+"<span id='second'>"+s+"</span>" | |
+" <span id='suffix'>"+suffix+"</span>" | |
"</div>"; | |
} | |
else { | |
document.getElementById('hour').innerHTML = ((h + 11) % 12 + 1); | |
document.getElementById('minute').innerHTML = m; | |
document.getElementById('second').innerHTML = s; | |
document.getElementById('suffix').innerHTML = suffix; | |
} | |
var t = setTimeout(function(){startTime()},500); | |
} | |
startTime(); | |
function colorMeBadd(){ | |
var arrayOfClassNames = ['color1','color2','color3','color4','color5','color6','color7','color8'], | |
randomChoice = arrayOfClassNames[Math.floor(Math.random() * arrayOfClassNames.length)]; | |
$('#motdwrap').removeAttr('class').addClass(randomChoice); | |
}; | |
function colorMeBadd(){ | |
var arrayOfClassNames = ['color1','color2','color3','color4','color5','color6','color7','color8'], | |
randomChoice = arrayOfClassNames[Math.floor(Math.random() * arrayOfClassNames.length)]; | |
$('#motdwrap').removeAttr('class').addClass(randomChoice); | |
}; | |
function funkyTown(){ | |
var lettersArray = []; | |
$("#motdwrap span").each(function(){ | |
lettersArray.push(this); | |
}); | |
var randomSpan = lettersArray[Math.floor(Math.random() * lettersArray.length)]; | |
var arrayOfClassNames = ['span1','span2','span3','span4','span5','span6','span7','span8'], | |
arrayOfAnimations = ['bounce','shake','tada','swing','wobble','flash','wiggle','pulse'], | |
randomChoice = arrayOfClassNames[Math.floor(Math.random() * arrayOfClassNames.length)], | |
randomAnimate = arrayOfAnimations[Math.floor(Math.random() * arrayOfAnimations.length)]; | |
$(randomSpan).removeAttr('class').addClass(randomChoice).addClass('animated').addClass(randomAnimate); | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment