Skip to content

Instantly share code, notes, and snippets.

@timothyclemans
Created March 26, 2014 09:03
Show Gist options
  • Save timothyclemans/9779245 to your computer and use it in GitHub Desktop.
Save timothyclemans/9779245 to your computer and use it in GitHub Desktop.
[wearscript]
<!-- spectific drug info lookup e.g. indictions for Aderall -->
<html style="width:100%; height:100%; overflow:hidden">
<head>
<script src="http://code.jquery.com/jquery-1.10.1.min.js"></script>
<script src="https://raw.github.com/Glench/fuzzyset.js/master/lib/fuzzyset.js"></script>
<link href='https://fonts.googleapis.com/css?family=Roboto:100,300,400,500,700' rel='stylesheet' type='text/css'>
<!--<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>-->
<style>
/* recover from old-browser styling */
.oldbl {display: block !important;}
.oldin {display: inline !important;}
img.pic {display: block !important;}
.ahem, .skipper, #aboutsite, #aboutsite * {display: none !important;}
/* NS6.x-specific fix(es) */
*|*:-moz-list-bullet, *|*:-moz-list-number {font-size: 1em;}
/* IE image scaling fix */
img {-ms-interpolation-mode: bicubic;}
/* misc */
#present {z-index: 100000 !important;}
/*
http://meyerweb.com/eric/tools/css/reset/
v2.0 | 20110126
License: none (public domain)
*/
html, body, div, span, applet, object, iframe,
h1, h2, h3, h4, h5, h6, p, blockquote, pre,
a, abbr, acronym, address, big, code,
del, dfn, img, ins, kbd, q, s, samp,
small, strike, sub, sup, tt, var,
b, u, i, center,
dl, dt, dd, ol, ul, li,
fieldset, form, label, legend,
table, caption, tbody, tfoot, thead, tr, th, td,
article, aside, canvas, details, embed,
figure, figcaption, footer, header, hgroup,
menu, nav, output, ruby, section, summary,
time, mark, audio, video {
margin: 0;
padding: 0;
border: 0;
font-size: 100%;
font: inherit;
vertical-align: baseline;
}
/* HTML5 display-role reset for older browsers */
article, aside, details, figcaption, figure,
footer, header, hgroup, menu, nav, section {
display: block;
}
body {
line-height: 1;
font-family:roboto;
font-weight:100;
color:#FFF;
font-size:40px;
margin:40px;
}
ol, ul {
list-style: none;
}
blockquote, q {
quotes: none;
}
blockquote:before, blockquote:after,
q:before, q:after {
content: '';
content: none;
}
table {
border-collapse: collapse;
border-spacing: 0;
}
div {margin-bottom:40px;}
</style>
</head>
<body style="background:#000; color:#FFF; overflow:hidden;">
<div id="drug_name"></div>
<div id="info_type">dosage
</div>
<div id="info">fake dosage KJK</div>
<script>
var expressions = [[/indications of (\w+)/, "indications"], [/maximum dosage of (\w+)/, "maximum dosage"]];
function server() {
WS.log('connected');
//getData('blah blah blah')
WS.speechRecognize("What do you want to know?2", function (data) {WS.say(data); getData(data);});
}
function getData(data) {
WS.log('data: '+data);
for (var i=0; i<expressions.length; i++) {
if (data.match(expressions[i][0])) {
console.log('expression: '+expressions[i][1]);
var match = expressions[i][0].exec(data);
WS.say(match[1]);
}
}
}
function main() {
WS.serverConnect('{{WSUrl}}', server);
$.ajaxSetup({
error: function(jqXHR, exception) {
if (jqXHR.status === 0) {
WS.log('Not connect.\n Verify Network.');
} else if (jqXHR.status == 404) {
WS.log('Requested page not found. [404]');
} else if (jqXHR.status == 500) {
WS.log('Internal Server Error [500].');
} else if (exception === 'parsererror') {
WS.log('Requested JSON parse failed.');
} else if (exception === 'timeout') {
WS.log('Time out error.');
} else if (exception === 'abort') {
WS.log('Ajax request aborted.');
} else {
WS.log('Uncaught Error.\n' + jqXHR.responseText);
}
}
});
WS.liveCardCreate(false, .2);
WS.activityCreate();
/*
for (var i=0; i<expressions.length; i++) {
var data = 'indications of coca';
if (data.match(expressions[i][0])) {
console.log(expressions[i][1]);
var match = expressions[i][0].exec(data);
console.log(match[1]);
}
}
for (var i=0; i<expressions.length; i++) {
var data = 'maximum dosage of pizza';
if (data.match(expressions[i][0])) {
console.log(expressions[i][1]);
var match = expressions[i][0].exec(data);
console.log(match[1]);
}
}
*/
}
window.onload = main;
</script>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment