Mercurial > code > home > repos > homeauto
changeset 63:e108d5f80b66
remoteslideshow
Ignore-this: 5e379e60e9d487851b18df18cfe59f54
author | drewp@bigasterisk.com |
---|---|
date | Wed, 10 Apr 2013 20:50:24 -0700 |
parents | f8cc3d1baa85 |
children | e573af8c2428 |
files | service/remoteSlideshow/www/index.jade service/remoteSlideshow/www/show.coffee |
diffstat | 2 files changed, 81 insertions(+), 0 deletions(-) [+] |
line wrap: on
line diff
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/service/remoteSlideshow/www/index.jade Wed Apr 10 20:50:24 2013 -0700 @@ -0,0 +1,21 @@ +html + head + style + body { + background: black; + color: white; + } + img#main { + position: absolute; + left: 0px; + top: 0px; + width: 100%; + height: 100%; + z-index: -10; + } + body + img(id='main', src="#") + h1 Ari's bed cactus + script(src="../lib/jquery-1.9.1.min.js") + script(src='show.js') + \ No newline at end of file
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/service/remoteSlideshow/www/show.coffee Wed Apr 10 20:50:24 2013 -0700 @@ -0,0 +1,60 @@ + + +reconnectingWebSocket = (url, onMessage) -> + connect = -> + ws = new WebSocket(url) + ws.onopen = -> + $("#status").text "connected" + + ws.onerror = (e) -> + $("#status").text "error: " + e + + ws.onclose = -> + pong = 1 - pong + $("#status").text "disconnected (retrying " + ((if pong then "<U+1F63C>" else "<U+1F63A>")) + ")" + + # this should be under a requestAnimationFrame to + # save resources + setTimeout connect, 2000 + + ws.onmessage = (evt) -> + onMessage JSON.parse(evt.data) + pong = 0 + connect() + + +images = [ + '../images/3387331383_d5c530cd9e_z.jpg', + '../images/1878786955_1356972060.jpg', + '../images/cactus_3731166_lrg.jpg', + '../images/cactus-header-1024x683.jpg', + '../images/cactus.jpg', + '../images/Nopal-cactus.jpg', + '../images/round-cactus.jpg', + '../images/Singapore_Botanic_Gardens_Cactus_Garden_2.jpg', + '../images/f10.jpg', + '../images/f11.jpg', + '../images/f12.jpg', + '../images/f13.jpg', + '../images/f1.jpg', + '../images/f2.jpg', + '../images/f3.jpg', + '../images/f4.jpg', + '../images/f5.jpg', + '../images/f6.jpg', + '../images/f7.jpg', + '../images/f8.jpg', + '../images/f9.jpg', +] +imageIndex = -1 + +nextImage = -> + imageIndex = (imageIndex + 1) % images.length + $("#main").attr('src', images[imageIndex]) +nextImage() + +reconnectingWebSocket("ws://bang:9071/events", (msg) -> + console.log("got", msg) + if msg.o == "http://bigasterisk.com/host/star/slideshow/advance" + nextImage() +) \ No newline at end of file