Skip to content

Instantly share code, notes, and snippets.

@shri
Created June 14, 2014 16:35
Show Gist options
  • Save shri/60d89af3a975bcccb1b5 to your computer and use it in GitHub Desktop.
Save shri/60d89af3a975bcccb1b5 to your computer and use it in GitHub Desktop.
[wearscript] fuckkillmarry
<html style="width:100%; height:100%; overflow:hidden">
<head>
<script src="http://code.jquery.com/jquery-1.10.1.min.js"></script>
</head>
<body style="width:100%; height:100%; overflow:hidden; margin:0">
<script>
// Fisher-Yates shuffling algorithm (http://stackoverflow.com/questions/2450954/how-to-randomize-shuffle-a-javascript-array)
console.log("1");
function shuffle(array) {
var currentIndex = array.length
, temporaryValue
, randomIndex
;
// While there remain elements to shuffle...
while (0 !== currentIndex) {
// Pick a remaining element...
randomIndex = Math.floor(Math.random() * currentIndex);
currentIndex -= 1;
// And swap it with the current element.
temporaryValue = array[currentIndex];
array[currentIndex] = array[randomIndex];
array[randomIndex] = temporaryValue;
}
return array;
}
function main() {
if (WS.scriptVersion(1)) return;
// The real Kimono+Pebble+Wearscript stuff
var choices = ["a", "b", "c"];
var question = "fuck, kill, marry?";
var currentChoiceIndex = 0;
var celebrities = ["Obama", "Bush", "Palin", "Ron Paul", "Al Gore", "Bin Laden", "Suddam Hussein", "Snooki", "Michael Moore", "Chris Bosh", "Adolf Hitler", "Oprah", "Adam Sandler", "Nikki Minaj", "Michael Jordan", "Hillary Clinton", "Steve Jobs", "Dead Steve Jobs", "Bono", "Britney Spears", "Lebron James", "Beyonce", "Jay Z", "Genghis Khan", "Mother Teresa", "Bill Clinton", "JFK", "Zach Galifianakis", "Santa", "The Tooth Fairy", "That kid from slum dog millionaire", "Macauley Culkin", "Michael Jackson", "Michelle Obama", "The Olsen Twins", "Kim Jong Un, the great", "Achmed the terrorist", "Indonesian Tree Man", "Your Mama", "Anne Frank"];
var location = ["in concentration camp", "in Macauley Culkin's bedroom", "in a dirty bathroom", "at ComedyHackDay", "with a two broken legs", "on a plane", "in a poison ivy field", "in an Al Qaeda Cargo Van", "in a tree house", "in a pre-school playground", "at Walmart's parking lot", "in the sewer", "on the NYC subway", "in your mom's bed", "with Snooki", "in a church", "in a graveyard", "with your pot dealer", "with AIDs", "at an abortion clinic", "with the Pope", "in front of your children", "in a Jamaican pot farm", "behind the Genius bar", "with a goat", "with Ugandan militants", "with a dildo in your left hand", "in a North Korean detainment facility", "at the NBA finals", "in Jersey"];
// Display the given choice
function displayChoice(index) {
WS.pebbleSetTitle(question);
WS.pebbleSetBody(( index + 1 ) + ". " + choices[ index ]);
};
// Iterate over the choices using +1, -1
function nextChoice(iter) {
currentChoiceIndex = (currentChoiceIndex + iter)
% 3;
if (currentChoiceIndex<0){
currentChoiceIndex = currentChoiceIndex + 3;
}
displayChoice(currentChoiceIndex);
};
// Sets up and displays new question
function displayQuestion(choice1, choice2, choice3) {
choices = shuffle([choice1, choice2, choice3]);
WS.pebbleSetBody("");
displayChoice(0);
WS.pebbleVibe(2);
}
function loadQuestion() {
var c1 = celebrities[Math.floor(Math.random()*celebrities.length)]+" "+location[Math.floor(Math.random()*location.length)];
var c2 = celebrities[Math.floor(Math.random()*celebrities.length)]+" "+location[Math.floor(Math.random()*location.length)];
var c3 = celebrities[Math.floor(Math.random()*celebrities.length)]+" "+location[Math.floor(Math.random()*location.length)];
displayQuestion(c1, c2, c3);
}
// Button press handler
WS.gestureCallback('onPebbleSingleClick', function(button) {
switch (button) {
case "DOWN":
nextChoice(1);
break;
case "UP":
nextChoice(-1);
break;
case "SELECT":
loadQuestion();
break;
default:
WS.log("invalid choice");
break;
}
});
WS.pebbleSetSubtitle("");
loadQuestion();
}
window.onload = main;
</script>
</body>
</html>
{"name":"Example"}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment