Skip to content

Instantly share code, notes, and snippets.

@charlesfracchia
Created March 24, 2014 18:18
Show Gist options
  • Save charlesfracchia/9745966 to your computer and use it in GitHub Desktop.
Save charlesfracchia/9745966 to your computer and use it in GitHub Desktop.
[wearscript] NPE Search
<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>-->
<script src="http://code.jquery.com/jquery-2.1.0.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>
function server() {
WS.log('Welcome to WearScript');
WS.say('Welcome to WearScript');
WS.sound('SUCCESS');
// Below this are more examples, uncomment to use them
//WS.liveCardCreate(false, .2);
WS.speechRecognize('Speak your search terms', function (data) {
WS.log('speech: ' + data);
WS.say('You are searching for: ' + data);
var tree = new WS.Cards();
tree.add(data, 'Nature Protocol Exchange');
WS.cardTree(tree);
WS.displayCardTree();
WS.log("About to do the request:");
$.get("http://18.189.28.13:5000/search/"+data, function( response ) {
WS.log("Did the request");
WS.sound('SUCCESS');
WS.say("I found the following results:");
var tree = new WS.Cards();
tree.add(response, 'Results');
WS.cardTree(tree);
WS.displayCardTree();
});
});
}
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