Skip to content

Instantly share code, notes, and snippets.

@paulusm
Last active March 8, 2016 11:04
Show Gist options
  • Save paulusm/57a5d5cbe79dcc30c3db to your computer and use it in GitHub Desktop.
Save paulusm/57a5d5cbe79dcc30c3db to your computer and use it in GitHub Desktop.
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