Skip to content

Instantly share code, notes, and snippets.

@timothyclemans
Created February 28, 2014 16:46
Show Gist options
  • Save timothyclemans/9274526 to your computer and use it in GitHub Desktop.
Save timothyclemans/9274526 to your computer and use it in GitHub Desktop.
[wearscript] Hashtag tweets
<!-- hashtag tweets -->
<html style="width:100%; height:100%; overflow:hidden">
<body style="width:100%; height:100%; overflow:hidden;">
<link href='https://fonts.googleapis.com/css?family=Roboto:100,300,400,500,700' rel='stylesheet' type='text/css'>
<style>
body {
background:#000;
color:#FFF;
font-family:Roboto;
font-weight:100;
}
p {padding:40px;font-size:40px;}
div {
position:absolute;bottom:0;right:40px;
font-size:30px;
}
</style>
<p></p>
<div></div>
<script src="http://code.jquery.com/jquery-1.11.0.min.js"></script>
<script>
var tweets;
var current = 0;
function onEyeGesture(name) {
//WS.say(name);
WS.wake();
WS.activityCreate();
if (name == 'SWIPE_LEFT' || name == 'DOUBLE_BLINK') {
if (current == 0) {
current = tweets.length -1;
} else {
current -= 1;
}
} else if (name == 'SWIPE_RIGHT' || name == 'WINK') {
if (current == tweets.length - 1) {
current = 0;
} else {
current += 1;
}
}
tweet = tweets[current];
$('p').text(tweet.question);
$('div').text((current+1)+'/'+tweets.length+' Votes: '+tweet.votes);
}
function onItemClick(position, id) {
WS.log('onItemClick: ' + position + " " + id);
}
function onItemSelected(position, id) {
WS.log('onItemSelected: ' + position + " " + id);
}
function onNothingSelected() {
WS.log('onNothingSelected');
}
function server() {
WS.log('connected');
}
function main() {
var events = 'onItemClick onItemSelected onNothingSelected'.split(" ");
//WS.gestureCallback('onGesture', 'onEyeGesture');
//WS.gestureCallback('onEyeGesture', 'onEyeGesture');
$.get('http://askpanelanything.com/json/', function(data) {
tweets = data.questions;
tweet = tweets[current];
$('p').text(tweet.question);
$('div').text((current+1)+'/'+tweets.length+' Votes: '+tweet.votes);
});
setInterval(function () {
//WS.say('downloaded');
$.get('http://askpanelanything.com/json/', function(data) {
tweets = data.questions;
//$('p').text(tweets[0]);
});
}, 10000);
WS.liveCardCreate(false, .25);
WS.serverConnect('{{WSUrl}}', 'server');
WS.wake();
WS.activityCreate();
}
window.onload = main;
</script>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment