Skip to content

Instantly share code, notes, and snippets.

@rajeshbiib
Created April 7, 2014 23:24
Show Gist options
  • Save rajeshbiib/10072995 to your computer and use it in GitHub Desktop.
Save rajeshbiib/10072995 to your computer and use it in GitHub Desktop.
[wearscript] BIIBTest
<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 type="text/html" id="tpl_card1">
<article>
<section>
<ul class="text-x-small">
<li>Menu Item #1 or say 1</li>
<li>Menu Item #2 or say 2</li>
<li>Menu Item #3 or say 3</li>
<li>SPills SOP or say 4</li>
<li>Menu Item #5 or say 5</li>
</ul>
</section>
<footer>
<p>SOP list. Tap and say option id</p>
</footer>
</article>
</script>
<script type="text/html" id="tpl_card2">
<article>
<section>
<ul class="text-x-small">
<li>Hazard Spill or say 1</li>
<li>Napalm Spill or say 2</li>
<li>Uranium Spill or say 3</li>
<li>Coffee Spillor say 4</li>
<li>Baby Diaper Spill or say 5</li>
<li>Red Bull Spill or say 6</li>
</ul>
</section>
<footer>
<p>SOP list</p>
</footer>
</article>
</script>
<script>
function server() {
WS.log('Welcome to WearScript');
WS.say('Welcome to BIIB Sops');
WS.sound('SUCCESS')
// Below this are more examples, uncomment to use them
//WS.liveCardCreate(false, .2);
var tree = new WS.Cards();
tree.addHTML('tpl_card1',function(){WS.say('selected')},function(){
WS.speechRecognize('Say Sop Name',function(recongizedText) {
WS.log(recongizedText);
var sopSteps = new WS.Cards();
if('4' === recongizedText) {
sopSteps.addHTML('tpl_card2',function(){WS.say('selected')},function(){
WS.speechRecognize('Say SUB Name',function(recongizedText) {
WS.log(recongizedText);
var sopSteps = new WS.Cards();
if('4' === recongizedText) {
sopSteps.add('Please dont panic, call 911.', 'DEVSOP1050 Step 1 of 4');
sopSteps.add('Get dry cloth.', 'DEVSOP1050 Step 2 of 4');
sopSteps.add('Wipe clean the keyboard.', 'DEVSOP1050 Step 3 of 4');
sopSteps.add('Stop drinking water near keyboard.', 'DEVSOP1050 Step 4 of 4 ',function(){},function(){
WS.qr(function (data) {
$.get("http//localhost:8080/biibglass/inventory/12345",[], function(remoteData){
WS.log(remoteData);
});
WS.say(data);
})
});
}
WS.cardTree(sopSteps);
WS.displayCardTree();
});
});
}
else if('1060' === recongizedText) {
sopSteps.add('Please dont panic.', 'DEVSOP1060 Step 1 of 4');
sopSteps.add('Get paper.', 'DEVSOP1060 Step 2 of 4');
sopSteps.add('Wipe the keybord with paper.', 'DEVSOP1060 Step 3 of 4');
sopSteps.add('Stop drinking wine near keyboard.', 'DEVSOP1060 Step 4 of 4');
}
WS.cardTree(sopSteps);
WS.displayCardTree();
});
});
tree.add('Body 1', 'Footer 1');
tree.add('', 'tap to speak', function () {WS.say('selected')}, function () {WS.say('tapped')},
'Recognize Text', function () {
WS.speechRecognize("Say your problem", function (recognizedText) {
var newTree = new WS.Cards();
// do ajax call, sending recognized text to web,
// get back your list, to newTree.add on each item to create your cards
newTree.add(recognizedText);
WS.cardTree(newTree);
WS.displayCardTree();
})},
'Menu1', function () {WS.say('menu1')});
tree.add('Body text', 'Footer text', (new WS.Cards()).add('Child0', '0').add('Child1', '1'));
WS.cardTree(tree);
WS.displayCardTree();
/*
WS.speechRecognize('Say Something', function (data) {
WS.log('speech: ' + data);
WS.say('you said ' + data);
});
*/
//WS.cameraPhoto();
//WS.cameraVideo();
//WS.cameraOff();
//WS.shutdown();
}
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