Last active
August 29, 2015 14:01
-
-
Save fluidglassml/173aae11752b7322efac to your computer and use it in GitHub Desktop.
[wearscript] glassprov awe
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
<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 customEndpoint = 'ws://192.168.1.254:8112/'; | |
// var customEndpoint = 'ws://18.111.28.58:8112/'; | |
function server() { | |
WS.sound('SUCCESS'); | |
WS.say('wearscript dot com endpoint'); | |
} | |
function registered(channel, name) { | |
WS.say("Registered as " + name); | |
} | |
Date.prototype.today = function () { | |
return ((this.getDate() < 10)?"0":"") + this.getDate() +"/"+(((this.getMonth()+1) < 10)?"0":"") + (this.getMonth()+1) +"/"+ this.getFullYear(); | |
} | |
Date.prototype.timeNow = function () { | |
return ((this.getHours() < 10)?"0":"") + this.getHours() +":"+ ((this.getMinutes() < 10)?"0":"") + this.getMinutes() +":"+ ((this.getSeconds() < 10)?"0":"") + this.getSeconds(); | |
} | |
currentTimeString = function () { | |
return new Date().today() + " @ " + new Date().timeNow(); | |
} | |
function blobCB(channel, message) { | |
WS.sound('SELECTED'); | |
WS.wake(); | |
WS.activityCreate(); | |
tree = new WS.Cards(); | |
tree.add(message, currentTimeString()); | |
WS.cardTree(tree); | |
WS.displayCardTree(); | |
} | |
// function narrowcast(channel, message) { | |
// } | |
function serverCustom() { | |
WS.sound('SUCCESS'); | |
WS.subscribe('registered', registered); | |
WS.subscribe('blob', blobCB); | |
WS.subscribe(WS.groupDevice(), blobCB); | |
WS.publish('register', 'registered', WS.groupDevice()); | |
WS.publish('blob', 'glassmessage', 'glass body'); | |
} | |
var playground = true; | |
function toggleServer() { | |
WS.sound("SELECTED"); | |
if (!playground) { | |
WS.serverConnect('{{WSUrl}}', server); | |
playground = true; | |
} else { | |
WS.serverConnect(customEndpoint, serverCustom); | |
playground = false; | |
} | |
} | |
WS.gestureCallback('onGestureTAP', toggleServer); | |
function main() { | |
if (WS.scriptVersion(1)) return; | |
ctx = document.getElementById('canvas').getContext("2d"); | |
// WS.serverConnect('{{WSUrl}}', server); | |
toggleServer(); | |
} | |
window.onload = main; | |
</script> | |
</body> | |
</html> |
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
{ | |
"name": "GlassProv AWE" | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment