Created
February 9, 2014 03:43
-
-
Save timothyclemans/8893942 to your computer and use it in GitHub Desktop.
[wearscript]
This file contains hidden or 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
<!--{"r":"fqtn66CAYt9g5XATyDm59iFD2lRRkjmpfA0v09hZe04=","s":"ZGa3RCqfvD45QyG+vo8tJScvjePe9WxEKVH+ObJxzIs=","v":0,"h":"https://api.picar.us/wearscript"}--> | |
<!--https://plus.google.com/100378621884093522327--> | |
<html> | |
<head> | |
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js"></script> | |
<link href='https://fonts.googleapis.com/css?family=Roboto:100,300,400,500,700' rel='stylesheet' type='text/css'> | |
<style> | |
html, body, div, span, applet, object, iframe, | |
h1, h2, h3, h4, h5, h6, p, blockquote, pre, | |
a, abbr, acronym, address, big, cite, code, | |
del, dfn, em, img, ins, kbd, q, s, samp, | |
small, strike, strong, 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; | |
background:#000; | |
color:#FFF; | |
font:50px Roboto; | |
font-weight:100; | |
margin:40px; | |
} | |
p { | |
bottom:40px; left:40px; | |
width:560px; | |
text-align:center; | |
position:absolute; | |
} | |
</style> | |
</head> | |
<body> | |
<p>Communication Toolbox</p> | |
<script> | |
var c = 0; | |
var t; | |
var timer_is_on = 0; | |
var logging = 'start'; | |
function timedCount() { | |
$('p').text(''); | |
if (c < 40) { | |
secondsLeft = 40 - c; | |
if (secondsLeft == 30) { | |
WS.say('30 seconds left'); | |
} | |
if (secondsLeft == 10) { | |
WS.say('10 seconds left'); | |
} | |
if (secondsLeft == 5) { | |
WS.say('5 seconds left'); | |
} | |
$('p').text(secondsLeft + ' seconds left'); | |
} else if (c > 40) { | |
$('p').text('Stop talking'); | |
} | |
if (c < 20) { | |
$('body').css('background', 'green'); | |
$('body').css('color', '#FFF'); | |
} else if (c < 40) { | |
if (c == 20) { | |
WS.say('wrap up'); | |
} | |
$('body').css('background', 'yellow'); | |
$('body').css('color', '#000'); | |
} else { | |
if (c % 2 == 0) { | |
WS.say('stop talking'); | |
} // every 2 seconds say "stop talking" | |
$('body').css('background', 'red'); | |
$('body').css('color', '#FFF'); | |
} | |
c = c + 1; | |
t = setTimeout("timedCount()", 1000); | |
} | |
function doTimer() { | |
if (!timer_is_on) { | |
timer_is_on = 1; | |
timedCount(); | |
} | |
} | |
function stopCount() { | |
$('body').css('background', 'black'); | |
$('p').text('Communication toolbox'); | |
clearTimeout(t); | |
c = 0; | |
timer_is_on = 0; | |
} | |
function onGesture(name) { | |
if (name == 'TAP') { | |
if (timer_is_on == 0) { | |
doTimer(); | |
} else { | |
stopCount(); | |
} | |
} | |
} | |
function addToLog(data) { | |
if (logging == 'start') { | |
logging = 'log what'; | |
WS.speechRecognize('What do you want to log?', 'addToLog'); | |
} else if (logging == 'log what') { | |
if (data == 'anger') { | |
logging = 'started situation'; | |
WS.speechRecognize('What pain/stress are you feeling? e.g. "I feel invisible like I don\'t count"', 'addToLog'); | |
} | |
} else if (logging == 'started situation') { | |
logging = 'tiggered thoughts'; | |
WS.speechRecognize('What started the situation?', 'addToLog'); | |
} else if (logging == 'tiggered thoughts') { | |
logging = 'anger rating'; | |
WS.speechRecognize('What triggered your thoughts?', 'addToLog'); | |
} else if (logging == 'anger rating') { | |
logging = 'behavior'; | |
WS.speechRecognize('What is your anger rating 0 -100?', 'addToLog'); | |
} else if (logging == 'behavior') { | |
logging = 'result to self'; | |
WS.speechRecognize('What was the result to your self?', 'addToLog'); | |
} else if (logging == 'result to self') { | |
logging = 'result to other'; | |
WS.speechRecognize('What was the result to the other person?', 'addToLog'); | |
} else if (logging == 'result to other') { | |
WS.say('all done'); | |
} | |
} | |
document.onkeypress = function (e) { | |
var char = String.fromCharCode(e.which); | |
if (char == 'c') { | |
if (timer_is_on == 0) { | |
doTimer(); | |
} else { | |
stopCount(); | |
} | |
} | |
if (char == 'l') { | |
addToLog(); | |
} | |
} | |
function server() { | |
WS.dataLog(false, true, .15); | |
} | |
$(function () { | |
WS.activityCreate(); | |
//setInterval(function () { WS.wake(); WS.activityCreate(); }, 10000); | |
WS.liveCardCreate(false, .2); | |
setInterval(function () { | |
WS.wake(); | |
}, 1000); | |
WS.gestureCallback('onGesture', 'onGesture'); | |
WS.serverConnect('{{WSUrl}}', 'server'); | |
}); </script> | |
</body> | |
</html> | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment