Skip to content

Instantly share code, notes, and snippets.

@shri
Created April 22, 2014 22:04
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save shri/11196020 to your computer and use it in GitHub Desktop.
Save shri/11196020 to your computer and use it in GitHub Desktop.
[wearscript] whosonfirst
<html style="width:100%; height:100%; overflow:hidden">
<head>
<!-- You can include external scripts here like so... -->
<!--<script src="https://cdnjs.cloudflare.com/ajax/libs/zepto/1.0/zepto.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/underscore.js/1.5.2/underscore-min.js"></script>-->
</head>
<body style="width:100%; height:100%; overflow:hidden; margin:0">
<canvas id="canvas" width="640" height="360" style="display:block"></canvas>
<script>
var abbott = ["Strange as it may seem, they give ball players nowadays very peculiar names. ","Nicknames, nicknames. Now, on the St. Louis team we have Who's on first, What's on second, I Don't Know is on third-- ","I'm telling you. Who's on first, What's on second, I Don't Know is on third-- ","Yes. ","Yes. ","Who. ","Who. ","Who is on first. ","I'm not asking you--I'm telling you. Who is on first. ","That's the man's name. ","Yes. "];
var costello = ["Funny names? ","That's what I want to find out. I want you to tell me the names of the fellows on the St. Louis team. ","You know the fellows' names? ","Well, then who's playing first? ","I mean the fellow's name on first base. ","The fellow playin' first base. ","The guy on first base. ","Well, what are you askin' me for? ","I'm asking you--who's on first? ","That's who's name? "];
var lines = [];
var rand = Math.floor(Math.random()*10000).toString();
function getLines(){
WS.publish()
}
function speakLine(line) {
return function(){WS.say(line);};
}
function actor_cb(actor, rd){
if(rd==rand){
if(actor=="Abbott"){
lines = abbott;
}
if(actor=="Costello"){
lines = costello;
}
var tree = new WS.Cards();
for(var i=0; i<lines.length; i++){
tree.add(lines[i], actor, speakLine(lines[i]));
}
WS.cardTree(tree);
WS.displayCardTree();
}
}
function server() {
WS.publish("newglass", rand);
WS.subscribe("actor", actor_cb);
}
function main() {
if (WS.scriptVersion(1)) return;
ctx = document.getElementById('canvas').getContext("2d");
WS.serverConnect('{{WSUrl}}', server);
}
window.onload = main;
</script>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment