-
-
Save kevint2u/7cd77e6e163a1e720ee6 to your computer and use it in GitHub Desktop.
[wearscript] kimono crawler
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> | |
<head> | |
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.11.0/jquery.min.js"></script> | |
<script type="text/javascript"> | |
function kimonoCallback(data) { | |
console.log(data); | |
if(data.lastrunstatus=="success"){ | |
$("#a").text(JSON.stringify(data)); | |
}else{ | |
getRandomWords(); | |
} | |
} | |
function getRandomWords(){ | |
var url = "http://www.kimonolabs.com/api/dwrmpm04?apikey=989877be85a3ca05477428c8b41d4fbe&callback=kimonoCallback&kimpath1="; | |
var num = Math.floor(Math.random()*1000000)+3000000; | |
console.log(num); | |
url = url+num+"&kimpath2="; | |
console.log(url); | |
$.ajax({ | |
"url": url, | |
"crossDomain":true, | |
"dataType":"jsonp" | |
}); | |
} | |
</script> | |
<body> | |
<div id="a"></div> | |
</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
<html style="width:100%; height:100%; overflow:hidden"> | |
<head> | |
<meta charset="UTF-8"> | |
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.11.0/jquery.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 kimonoSet = [['frog','ribbit'],['snake','hiss'],['cat','meow'],['dog','bark'],['horse','neigh'],['lion','roar'],['mouse','squeak'],['wolf','howl']]; | |
function kimonoCallback(data) { | |
if(data.lastrunstatus=="success"){ | |
WS.say('hi'); | |
// console.log(JSON.stringify(data.results.collection1[0].question)); | |
// console.log(JSON.stringify(data.results.collection1[0].answer)); | |
window.kimonoSet.length = 0; | |
for(var i=0;i<data.results.collection1.length;i++){ | |
window.kimonoSet.push([data.results.collection1[i].question,data.results.collection1[i].answer]); | |
} | |
console.log(JSON.stringify(kimonoSet)); | |
}else{ | |
getRandomWords(); | |
} | |
} | |
function getRandomWords(){ | |
var url = "http://www.kimonolabs.com/api/dwrmpm04?apikey=989877be85a3ca05477428c8b41d4fbe&callback=kimonoCallback&kimpath1="; | |
var num = Math.floor(Math.random()*1000000)+3000000; | |
url = url+num+"&kimpath2="; | |
$.ajax({ | |
"url": url, | |
"crossDomain":true, | |
"dataType":"jsonp" | |
}); | |
} | |
getRandomWords(); | |
// setTimeout(function(){console.log(JSON.stringify(kimonoSet));},5000); | |
// setTimeout(function(){console.log(JSON.stringify(kimonoSet[0][0]));},5000); | |
// Constants | |
var DBG = true; | |
var i = 0; | |
var secondLineText = "Second line"; | |
var wakeTime; | |
var timeDeltaText = ""; | |
var wakeInterval = 5*60*1000; | |
var wordInterval = 10*1000; | |
var timeNow = new Date().getTime(); | |
var tillNextSet = Math.floor(wakeInterval / 1000); | |
var tillNextWord = Math.floor(wordInterval / 1000); | |
var deltasMaxLength = 10; | |
var timeDeltas = []; | |
var woken; | |
var timeDeltaTitleText = "Between Last Wakes:"; | |
var batteryLevelText = "Battery level: "; | |
var showDashboard = true; | |
var cameraCB; | |
var showImageInterval = 10000; | |
var pauseFudgeFactor = 500; | |
var videoLength = 10; | |
var animals = '{ "animals": [ { "spanish": "ardilla", "english": "squirrel" }, { "spanish": "Ballena", "english": "Whale" }, { "spanish": "Bandada", "english": "Flock of birds" }, { "spanish": "Buey (m)", "english": "Ox" }, { "spanish": "Burro", "english": "Donkey" }, { "spanish": "Caballo", "english": "Horse" }, { "spanish": "Cabra", "english": "Goat" }, { "spanish": "Cachorro", "english": "Cub (puppy)" }, { "spanish": "Camello", "english": "Camel" }, { "spanish": "Canguro", "english": "Kangaroo" }, { "spanish": "Carnero", "english": "Ram, mutton" }, { "spanish": "Cebra", "english": "Zebra" }, { "spanish": "Cerdo, Puerco", "english": "Pig" }, { "spanish": "Colmena", "english": "Beehive" }, { "spanish": "Conejo", "english": "Rabbit" }, { "spanish": "Cordero", "english": "Lamb" }, { "spanish": "Culebra", "english": "Snake" }, { "spanish": "Delfín (m)", "english": "Dolphin" }, { "spanish": "Elefante (m)", "english": "Elephant" }, { "spanish": "Foca", "english": "Seal" }, { "spanish": "Gato", "english": "Cat" }, { "spanish": "Jirafa", "english": "Giraffe" }, { "spanish": "GusanoLombriz", "english": "Worm" }, { "spanish": "León (m)", "english": "Lion" }, { "spanish": "Liebre (f)", "english": "Hare" }, { "spanish": "Lobo", "english": "Wolf" }, { "spanish": "Manada", "english": "Herd, fock, pack" }, { "spanish": "Mapache (m)Mapachín", "english": "Raccoon" }, { "spanish": "Mono", "english": "Monkey" }, { "spanish": "Mulo", "english": "Mule" }, { "spanish": "Murciélago", "english": "Bat" }, { "spanish": "Ordeñar", "english": "To milk" }, { "spanish": "Oso", "english": "Bear" }, { "spanish": "Oveja", "english": "Sheep, ewe" }, { "spanish": "Panal (m)", "english": "Honeycomb" }, { "spanish": "Perro", "english": "Dog" }, { "spanish": "Potro", "english": "Colt" }, { "spanish": "Rana", "english": "Frog" }, { "spanish": "Rata", "english": "Rat" }, { "spanish": "Ratón (m)", "english": "Mouse" }, { "spanish": "Rebaño", "english": "Flock (of sheep)" }, { "spanish": "Sapo", "english": "Toad" }, { "spanish": "Serpiente (f)", "english": "Serpent, snake" }, { "spanish": "Ternero", "english": "Calf" }, { "spanish": "Tigre (m)", "english": "Tiger" }, { "spanish": "Toro", "english": "Bull" }, { "spanish": "Tortuga", "english": "Turtle" }, { "spanish": "Vaca", "english": "Cow" }, { "spanish": "Venado", "english": "StagDeer" }, { "spanish": "Yegua", "english": "Mare" }, { "spanish": "Zorro", "english": "Fox" }, { "spanish": "Solitario", "english": "Tape worm" } ]}'; | |
var cities = '{ "cities": [ { "spanish": "el aeropuerto", "english": "Air Port" }, { "spanish": "El anticuario", "english": "Antique Shop" }, { "spanish": "el árbol", "english": "Tree" }, { "spanish": "El autobús", "english": "Bus" }, { "spanish": "el banco", "english": "Bank" }, { "spanish": "el café", "english": "Cafe" }, { "spanish": "el café internet", "english": "Internet Cafe" }, { "spanish": "El campo", "english": "Country" }, { "spanish": "el cementrairo", "english": "Cementary" }, { "spanish": "el centro comercial", "english": "Mall" }, { "spanish": "el césped", "english": "Lawn/Grass" }, { "spanish": "el cine", "english": "Movie Theather" }, { "spanish": "el carro, el coche", "english": "Car" }, { "spanish": "el correo", "english": "Post office" }, { "spanish": "el cuadro", "english": "Block" }, { "spanish": "el edificio", "english": "Building" }, { "spanish": "el estadio", "english": "Stadium" }, { "spanish": "el estacionamiento", "english": "Parking Lot" }, { "spanish": "el gimnasio", "english": "Gym" }, { "spanish": "el hopsital", "english": "Hospital" }, { "spanish": "el jardín", "english": "Graden" }, { "spanish": "el lago", "english": "Lake" }, { "spanish": "el mercado", "english": "Market" }, { "spanish": "el mueso", "english": "Mueseum" }, { "spanish": "el Fuente", "english": "Fountain" }, { "spanish": "el parque", "english": "Park" }, { "spanish": "el piso", "english": "Floor (Story of the house)" }, { "spanish": "el puente", "english": "Bridge" }, { "spanish": "el quiosco", "english": "Kiosk" }, { "spanish": "el restaurante", "english": "Resturant" }, { "spanish": "el río", "english": "River" }, { "spanish": "el supermercado", "english": "Super Market" }, { "spanish": "el teatro", "english": "Theater" }, { "spanish": "el zoológico", "english": "zoo" }, { "spanish": "la acera", "english": "Side-Walk" }, { "spanish": "La avenida", "english": "Avenue" }, { "spanish": "la biblioteca", "english": "Library" }, { "spanish": "la calle", "english": "Street" }, { "spanish": "la camioneta", "english": "Truck" }, { "spanish": "La carnicería", "english": "Brewery" }, { "spanish": "la discoteca", "english": "Dance Club" }, { "spanish": "La escuela", "english": "School" }, { "spanish": "la estación de bomberos", "english": "Fire Station" }, { "spanish": "la estación de tren", "english": "Train Station" }, { "spanish": "le floristería", "english": "Flower Shop" }, { "spanish": "La galería de arte", "english": "Art Gallery" }, { "spanish": "La gasolinera", "english": "Gas Station" }, { "spanish": "La estación de policía", "english": "Police Station" }, { "spanish": "La iglesia", "english": "Church" }, { "spanish": "La joyería", "english": "Jewlery Shop" }, { "spanish": "La Libería", "english": "Book Store" }, { "spanish": "La oficina del dentista", "english": "Dentist Office" }, { "spanish": "la panadería", "english": "Bakery" }, { "spanish": "La peluquería", "english": "Hair Salon" }, { "spanish": "la piscina", "english": "Pool" }, { "spanish": "la playa", "english": "Beach" }, { "spanish": "la plaza", "english": "Square" }, { "spanish": "la tienda de comestiblies", "english": "Grocery Store" }, { "spanish": "la tienda de juguetes", "english": "Toy Store" }, { "spanish": "la tienda de ropa", "english": "Clothing Store" }, { "spanish": "La zapatería", "english": "Shoe Store" }, { "spanish": "Las montañas", "english": "Mountains" }, { "spanish": "la ciudod", "english": "City" }, { "spanish": "Los Lugares", "english": "Places" }, { "spanish": "Las Direcciones", "english": "Directions" }, { "spanish": "a la derecha (de)", "english": "To the right of" }, { "spanish": "a la izquierda (de)", "english": "Next To" }, { "spanish": "detrás(de)", "english": "Behind" }, { "spanish": "entre", "english": "Between" }, { "spanish": "encima (de)", "english": "On top of" }, { "spanish": "enfrente (de)", "english": "infront of" }, { "spanish": "lejos (de)", "english": "Far From" }, { "spanish": "cerca (de)", "english": "Close to" }, { "spanish": "delante (de)", "english": "Infront" }, { "spanish": "debajo (de)", "english": "Below or Under" }, { "spanish": "nor", "english": "north" }, { "spanish": "sur", "english": "South" }, { "spanish": "este", "english": "East" }, { "spanish": "Oeste", "english": "West" }, { "spanish": "al cruz (de)", "english": "Across From" } ]}'; | |
var household = '{ "household": [ { "spanish": "el amario", "english": "closet" }, { "spanish": "el baño", "english": "bathroom" }, { "spanish": "la basura", "english": "trash can" }, { "spanish": "la calefacción", "english": "heating" }, { "spanish": "la chimenea", "english": "fireplace" }, { "spanish": "la cocina", "english": "kitchen" }, { "spanish": "el comedor", "english": "dining room" }, { "spanish": "el cuarto", "english": "room" }, { "spanish": "la escalera", "english": "stairs" }, { "spanish": "el garaje", "english": "garage" }, { "spanish": "la habitación", "english": "bedroom" }, { "spanish": "la lavandería", "english": "laundry room" }, { "spanish": "el pasillo", "english": "hall" }, { "spanish": "la piscina", "english": "pool" }, { "spanish": "el piso", "english": "apartment" }, { "spanish": "la planta baja", "english": "first floor" }, { "spanish": "la terraza", "english": "terrace" }, { "spanish": "la alfombra", "english": "rug" }, { "spanish": "la butaca", "english": "chair" }, { "spanish": "la cama", "english": "bed" }, { "spanish": "la cómoda", "english": "dresser" }, { "spanish": "la cortina", "english": "curtains" }, { "spanish": "el cuadro", "english": "painting" }, { "spanish": "el espejo", "english": "mirror" }, { "spanish": "la lámpara", "english": "lamp" }, { "spanish": "el sofá", "english": "sofa" }, { "spanish": "la aspiradora", "english": "vacuum cleaner" }, { "spanish": "la lavadora", "english": "washer" }, { "spanish": "el lavaplatos", "english": "dishwasher" }, { "spanish": "el microondas", "english": "microwave" }, { "spanish": "el radio", "english": "radio" }, { "spanish": "el refrigerador", "english": "refrigerator" }, { "spanish": "la secadora", "english": "dryer" }, { "spanish": "el ventilador", "english": "fan" }, { "spanish": "la sábana", "english": "sheet" }, { "spanish": "la bañera", "english": "bathtub" }, { "spanish": "el inodoro", "english": "toliet" }, { "spanish": "el jabón", "english": "soap" }, { "spanish": "el lavabo", "english": "bathroom sink" }, { "spanish": "la toalla", "english": "towel" }, { "spanish": "la estufa", "english": "stove" }, { "spanish": "el fregadero", "english": "kitchen sink" }, { "spanish": "el plato", "english": "plate" }, { "spanish": "la barbacoa", "english": "barbecue pit" }, { "spanish": "el césped", "english": "lawn" }, { "spanish": "la ducha", "english": "shower" } ]}'; | |
var sports = '{ "sports": [ { "spanish": "el equipo", "english": "team" }, { "spanish": "ganar", "english": "to win" }, { "spanish": "el gol", "english": "goal" }, { "spanish": "jugar (eu)", "english": "to play" }, { "spanish": "el partido", "english": "game" }, { "spanish": "la tienda de deportes", "english": "sporting goods store" }, { "spanish": "andar en patineta", "english": "to skateboard" }, { "spanish": "el baloncesto", "english": "basketball (game)" }, { "spanish": "el béisbol", "english": "baseball (game)" }, { "spanish": "esquiar", "english": "to ski" }, { "spanish": "el fútbol", "english": "soccer" }, { "spanish": "el fútbol americano", "english": "football (US)" }, { "spanish": "el hockey", "english": "hockey" }, { "spanish": "levantar pesas", "english": "to lift weights" }, { "spanish": "el surfing", "english": "surfing" }, { "spanish": "el tenis", "english": "tennis" }, { "spanish": "el voleibol", "english": "volleyball" }, { "spanish": "el bate", "english": "bat" }, { "spanish": "la bola", "english": "ball" }, { "spanish": "el casco", "english": "helmet" }, { "spanish": "la gorra", "english": "baseball cap" }, { "spanish": "el guante", "english": "glove" }, { "spanish": "los patines", "english": "skates" }, { "spanish": "la patineta", "english": "(the) skateboard" }, { "spanish": "la pelota", "english": "(the) baseball" }, { "spanish": "la raqueta", "english": "racket" }, { "spanish": "al aire libre", "english": "outdoors" }, { "spanish": "el campo", "english": "field" }, { "spanish": "la cancha", "english": "court" }, { "spanish": "el estadio", "english": "stadium" }, { "spanish": "la piscina", "english": "swimming pool" }, { "spanish": "sobre hielo", "english": "on ice" }, { "spanish": "cerrar (ie)", "english": "to close" }, { "spanish": "empezar (ie)", "english": "to begin" }, { "spanish": "entender (ie)", "english": "to understand" }, { "spanish": "favorito(a)", "english": "favorite" }, { "spanish": "loco(a)", "english": "crazy" }, { "spanish": "merendar (ie)", "english": "to have a snack" }, { "spanish": "peligroso(a)", "english": "dangerous" }, { "spanish": "pensar (ie)", "english": "to think, to plan" }, { "spanish": "perder (ie)", "english": "to lose" } ]}'; | |
var animalsJSON = JSON.parse(animals); | |
var citiesJSON = JSON.parse(cities); | |
var householdJSON = JSON.parse(household); | |
var sportsJSON = JSON.parse(sports); | |
var wordsDone = 0; | |
var wordsRight = 0; | |
var accuracy = 100.0; | |
var setSize = 4; | |
var counter = 0; | |
var setIndex = Math.floor((Math.random()*setSize)); | |
var quizzing = false; | |
var currWord; | |
var currDef; | |
var idle = true; | |
var context; | |
var wordsToDisplay = new Array(); | |
function drawModeName(name) { | |
upperBase = 40; | |
context.fillStyle = "rgb(200,200,200)"; | |
context.font = '28pt Calibri'; | |
context.textAlign = 'left'; | |
context.fillText(name, 10, upperBase); | |
} | |
function drawSecondLine(name) { | |
upperBase = 90; | |
context.fillStyle = "rgb(200,200,200)"; | |
context.font = '28pt Calibri'; | |
context.textAlign = 'left'; | |
context.fillText(name, 10, upperBase); | |
} | |
function drawTextLine(text, _number) { | |
var number = _number; | |
if ( number === undefined ) { | |
console.log("No number given, setting to 0"); | |
number = 0; | |
} | |
baseline = 88 + 100 * number; | |
context.fillStyle = "rgb(200,200,200)"; | |
context.font = '60pt Calibri'; | |
context.textAlign = 'left'; | |
context.fillText(text, 10, baseline); | |
} | |
function clearCanvas() { | |
context.fillStyle = "rgb(0, 0, 0)"; | |
context.fillRect(0, 0, 640, 360); | |
} | |
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(); | |
} | |
// MAIN | |
function draw() { | |
if (showDashboard) { | |
// clearCanvas(); | |
// drawTextLine('Tests Taken: '+wordsDone,0); | |
// drawTextLine('Accuracy: '+accuracy+'%',1); | |
} | |
// list of last times | |
// drawModeName("" + i); | |
// drawSecondLine(secondLineText); | |
} | |
currentTimeString = function () { | |
return new Date().today() + " @ " + new Date().timeNow(); | |
} | |
timeString = function(date) { | |
return date.today() + " @ " + date.timeNow(); | |
} | |
function server() { | |
WS.wake(); | |
if (!DBG) WS.serverConnect('0.0.0.0', null); | |
WS.log('Welcome to WearScript'); | |
// WS.say('Welcome to WearScript'); | |
WS.sound('SUCCESS'); | |
WS.dataLog(true, false, 1); | |
WS.sensorOn("battery", 1, function (data) { | |
console.log("Got battery callback"); | |
console.log(JSON.stringify(data)); | |
batteryLevelText = "Battery Level: " + Math.round(data.values[0] * 100) + "%"; | |
if (Math.round(data.values[0] * 100) <= 20) WS.say("Low battery."); | |
batteryLevelText += " @ " + new Date(parseInt(data.timestamp * 1000)).timeNow(); | |
}); | |
clearCanvas(); | |
drawModeName("Rock and roll"); | |
// draw(); | |
var createDisplay = function(wordsDone,accuracy){ | |
WS.activityDestroy(); | |
setIndex = Math.floor((Math.random()*setSize)); | |
var tree = new WS.Cards(); | |
var roundedAcc = Math.round(accuracy * 100) / 100; | |
tree.add('Words Quizzed: '+wordsDone+'\n'+'Accuracy: '+roundedAcc+'%', 'Tap for a new word!',undefined,createQuiz); | |
WS.cardTree(tree); | |
WS.displayCardTree(); | |
} | |
var test = function(wordsDone,accuracy){ | |
var temp = accuracy; | |
if(quizzing){ | |
var ansTree = new WS.Cards(); | |
ansTree.add(decodeURIComponent(escape(currWord))+'\n'+decodeURIComponent(escape(currDef)),''); | |
WS.cardTree(ansTree); | |
WS.displayCardTree(); | |
setTimeout(function() { | |
quizzing = false; | |
test(wordsDone,accuracy); | |
}, 4000); | |
return | |
} | |
if(counter>4){ | |
createDisplay(wordsDone,accuracy); | |
counter = 0; | |
idle = true; | |
} | |
else{ | |
idle = false; | |
quizzing = true; | |
createQuiz(); | |
} | |
} | |
var processWord = function(w, d){ | |
word = w; | |
def = d; | |
WS.say(word); | |
var incorrectPhrase= "incorrect. The correct definition is: " + def; | |
WS.speechRecognize(decodeURIComponent(escape(word)), function speech(data) {if(def.toUpperCase().indexOf(data.toUpperCase())!=-1){WS.say('correct');wordsRight+=1;}else{WS.say(incorrectPhrase);}wordsDone+=1;accuracy=100*wordsRight/wordsDone;counter+=1;test(wordsDone,accuracy);}); | |
} | |
//processWord('goodbye','hello'); | |
var createQuiz = function(){ | |
quizzing = true; | |
var quiztree = new WS.Cards(); | |
if(setIndex==0){ | |
var currentSetSize=animalsJSON.animals.length; | |
for (var i=0;i<1;i++) | |
{ | |
var wordIndex = Math.floor((Math.random()*currentSetSize)) | |
quiztree.add('','',processWord(animalsJSON.animals[wordIndex].spanish,animalsJSON.animals[wordIndex].english)); | |
currWord = animalsJSON.animals[wordIndex].spanish; | |
currDef = animalsJSON.animals[wordIndex].english; | |
} | |
} | |
else if(setIndex==1){ | |
var currentSetSize=citiesJSON.cities.length; | |
for (var i=0;i<1;i++) | |
{ | |
var wordIndex = Math.floor((Math.random()*currentSetSize)) | |
quiztree.add('','',processWord(citiesJSON.cities[wordIndex].spanish,citiesJSON.cities[wordIndex].english)); | |
currWord = citiesJSON.cities[wordIndex].spanish; | |
currDef = citiesJSON.cities[wordIndex].english; | |
} | |
} | |
else if(setIndex==2){ | |
var currentSetSize=householdJSON.household.length; | |
for (var i=0;i<1;i++) | |
{ | |
var wordIndex = Math.floor((Math.random()*currentSetSize)) | |
quiztree.add('','',processWord(householdJSON.household[wordIndex].spanish,householdJSON.household[wordIndex].english)); | |
currWord = householdJSON.household[wordIndex].spanish; | |
currDef = householdJSON.household[wordIndex].english; | |
} | |
} | |
else if(setIndex==3){ | |
var currentSetSize=sportsJSON.sports.length; | |
for (var i=0;i<1;i++) | |
{ | |
var wordIndex = Math.floor((Math.random()*currentSetSize)) | |
quiztree.add('','',processWord(sportsJSON.sports[wordIndex].spanish,sportsJSON.sports[wordIndex].english)); | |
currWord = sportsJSON.sports[wordIndex].spanish; | |
currDef = sportsJSON.sports[wordIndex].english; | |
} | |
} | |
WS.cardTree(quiztree); | |
WS.displayCardTree(); | |
} | |
createDisplay(0,0); | |
var processScenery = function(wordsToDisplay,context,index){ | |
WS.wake(); | |
w = wordsToDisplay[0][0]; | |
d = wordsToDisplay[0][1]; | |
c = context; | |
displayScenery(w,d,c); | |
} | |
var displayScenery = function(w,d,c){ | |
WS.wake(); | |
var tree = new WS.Cards(); | |
tree.add(decodeURIComponent(escape(w))+'\n'+d,c); | |
WS.cardTree(tree); | |
WS.displayCardTree(); | |
} | |
var newWord = function(){ | |
if(sceneryMode){ | |
WS.wake(); | |
// display a new word. | |
processScenery(wordsToDisplay,context); | |
wordsToDisplay.splice(0, 1); | |
if(wordsToDisplay.length==0){ | |
sceneryMode=false; | |
createDisplay(wordsDone,accuracy); | |
} | |
WS.wake(); | |
} | |
} | |
var wakeUp = function(){ | |
if(idle){ | |
sceneryMode = true; | |
setIndex = Math.floor((Math.random()*setSize)); | |
if(setIndex==0){ | |
var currentSetSize=animalsJSON.animals.length; | |
for (var i=0;i<6;i++) | |
{ | |
var wordIndex = Math.floor((Math.random()*currentSetSize)); | |
wordsToDisplay.push([animalsJSON.animals[wordIndex].spanish,animalsJSON.animals[wordIndex].english]); | |
context = 'animals'; | |
} | |
} | |
else if(setIndex==1){ | |
var currentSetSize=citiesJSON.cities.length; | |
for (var i=0;i<6;i++) | |
{ | |
var wordIndex = Math.floor((Math.random()*currentSetSize)); | |
wordsToDisplay.push([citiesJSON.cities[wordIndex].spanish,citiesJSON.cities[wordIndex].english]); | |
context = 'cities'; | |
} | |
} | |
else if(setIndex==2){ | |
var currentSetSize=householdJSON.household.length; | |
for (var i=0;i<6;i++) | |
{ | |
var wordIndex = Math.floor((Math.random()*currentSetSize)); | |
wordsToDisplay.push([householdJSON.household[wordIndex].spanish,householdJSON.household[wordIndex].english]); | |
context = 'household'; | |
} | |
} | |
else if(setIndex==3){ | |
var currentSetSize=sportsJSON.sports.length; | |
for (var i=0;i<6;i++) | |
{ | |
var wordIndex = Math.floor((Math.random()*currentSetSize)); | |
wordsToDisplay.push([sportsJSON.sports[wordIndex].spanish,sportsJSON.sports[wordIndex].english]); | |
context = 'sports'; | |
} | |
} | |
} | |
} | |
setInterval(wakeUp,wakeInterval); | |
setInterval(newWord,wordInterval); | |
// WS.wake(); | |
// WS.activityCreate(); | |
// Below this are more examples, uncomment to use them | |
WS.liveCardCreate(true, .2); | |
WSRAW.recordWSVideo(videoLength); | |
/* | |
var tree = new WS.Cards(); | |
tree.add('Body text', 'Footer text', function () {WS.say('selected')}, function () {WS.say('tapped')}, 'Menu0', function () {WS.say('menu0')}, '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; | |
context = 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