Created
August 6, 2014 06:11
-
-
Save n8henrie/e9b044b79987f5e5931f to your computer and use it in GitHub Desktop.
Wedding Countdown Timer (copy from Google Sites since it won't let me copy to Google Drive)
This file contains 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 doGet() { | |
var template = HtmlService.createTemplateFromFile('index'); | |
var htmlOutput = template.evaluate() | |
.setSandboxMode(HtmlService.SandboxMode.NATIVE); | |
return htmlOutput; | |
} | |
function include(filename) { | |
return HtmlService.createHtmlOutputFromFile(filename) | |
.getContent(); | |
} |
This file contains 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
<?!= include('stylesheet'); ?> | |
<div id="countdown"></div> | |
<?!= include('javascript'); ?> |
This file contains 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
<script type="text/javascript"> | |
// console.clear(); | |
var countdown_html = document.getElementById("countdown"); | |
function countdown() { | |
var return_string = 'Only '; | |
var today = new Date(); | |
var weddingDate = new Date(2014, 10, 8, 16); | |
var ms = weddingDate - today; | |
if (ms > 0) { | |
var d = ms / (1000 * 60 * 60 * 24) | 0; | |
var h = ms % (1000 * 60 * 60 * 24) / (1000 * 60 * 60) | 0; | |
var m = ms % (1000 * 60 * 60) / (1000 * 60) | 0; | |
var s = ms % (1000 * 60) / (1000) | 0; | |
var timeParts = [d, h, m, s]; | |
// console.log(timeParts); | |
var timeStringParts = new Array(); | |
var timeString = ""; | |
for (var i = 0; i < 4; i++) { | |
switch (i) { | |
case 0: | |
timeString = " day"; | |
break; | |
case 1: | |
timeString = " hour"; | |
break; | |
case 2: | |
timeString = " minute"; | |
break; | |
case 3: | |
timeString = " second"; | |
break; | |
} | |
if (timeParts[i] > 1) { | |
timeString += 's'; | |
} | |
if (timeParts[i] > 0) { | |
timeStringParts.push(timeParts[i] + timeString); | |
} | |
} | |
for (var i = 0; i < timeStringParts.length - 1; i++) { | |
return_string += timeStringParts[i] + ', '; | |
} | |
return_string += (' and ' + timeStringParts[timeStringParts.length - 1] + ' until man and wife!') | |
} | |
else { | |
return_string = "It's finally here!!"; | |
} | |
return return_string; | |
} | |
setInterval(function() { | |
countdown_html.innerHTML = '<p>' + countdown() + '</p>'; | |
}, 1000); | |
</script> |
This file contains 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
<style> | |
p { | |
font-family: 'Bad Script', cursive; | |
color: #469280; | |
font-size: 24px; | |
text-align: center; | |
vertical-align: "top"; | |
} | |
body { | |
background-color: transparent; | |
} | |
</style> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment