Last active
March 8, 2016 11:04
-
-
Save paulusm/57a5d5cbe79dcc30c3db to your computer and use it in GitHub Desktop.
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
var VCTranslate = function(e){ | |
"use strict"; | |
var coreMission = "defeating our Dalek overlords"; | |
var nouns = ["cake", "crisps", "nuts","class As","drugs","alcohol"]; | |
var activities = ["smooching", "drinking heavily", "forgetting where they live","the debauchery"]; | |
var adjectives = ["immature", "scary", "lovely", "epic", "fruity", "gorgeous"] | |
var nounCount = 0,activityCount = 0,adjIndex; | |
// Find the span elements on the page | |
var spans = document.getElementsByTagName("span"); | |
console.log(spans); | |
for(var i=0; i<spanners.length; i++){ | |
// choose whichlists to pull from based on classes | |
switch(spans[i].className){ | |
case "core-mission": | |
spans[i].textContent=coreMission; | |
break; | |
case "noun": | |
spans[i].textContent=nouns[nounCount]; | |
nounCount ++; | |
break; | |
case "activity": | |
spans[i].textContent=activities[activityCount]; | |
activityCount ++; | |
break; | |
case "adjective": | |
adjIndex = Math.round(Math.random()*5); | |
spans[i].textContent=adjectives[adjIndex]; | |
break; | |
default: | |
console.log(spans[i].className); | |
break; | |
} | |
} | |
} | |
//hook up the event here to the "control" button | |
document.getElementById("control").addEventListener("click", VCTranslate); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment