Last active
August 29, 2015 13:59
-
-
Save scottgwald/11000721 to your computer and use it in GitHub Desktop.
[wearscript] Picaboo
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
| <html style="width:100%; height:100%; overflow:hidden"> | |
| <head> | |
| <script src="https://cdnjs.cloudflare.com/ajax/libs/zepto/1.0/zepto.min.js"></script> | |
| </head> | |
| <body style="width:100%; height:100%; overflow:hidden; margin:0"> | |
| <img id="theImage" src="" width=640 height=360> | |
| <script> | |
| var lightThreshold = 25; | |
| var theImage = $('#theImage'); | |
| var isCovered; | |
| var currentPath = coveredPath; | |
| var coveredPath = "http://imgur.com/TVDbSR1.jpg"; | |
| var uncoveredPath = "http://imgur.com/Mk0XZNL.jpg"; | |
| function setImage() { | |
| if (isCovered) { | |
| if (currentPath != coveredPath) { | |
| WS.say("where are you"); | |
| theImage.attr('src', coveredPath); | |
| currentPath = coveredPath; | |
| } | |
| } else { | |
| if (currentPath != uncoveredPath) { | |
| WS.say("picaboo"); | |
| theImage.attr('src', uncoveredPath); | |
| currentPath = uncoveredPath; | |
| } | |
| } | |
| } | |
| function main() { | |
| if (WS.scriptVersion(1)) return; | |
| WS.sound('SUCCESS'); | |
| WS.sensorOn('light', .01, function (data) { | |
| isCovered = data['values'][0] <= lightThreshold; | |
| setImage(); | |
| }); | |
| WS.dataLog(false, true, .15); | |
| } | |
| window.onload = main; | |
| </script> | |
| </body> | |
| </html> |
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
| {"name":"Picaboo"} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment