| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354 |
- <html>
- <head>
- <title> GrowCam </title>
- <script>
- var i = 0;
- var pictures = [];
- var interval = null;
- function reload() {
- if (i >= pictures.length) i = 0;
- document.getElementById('picture').src = '/pictures/' + pictures[i++];
- document.getElementById('currentPictureLabel').innerText = pictures[i++];
- }
- function getPictureList() {
- var req = new XMLHttpRequest();
- req.addEventListener('load', function () {
- pictures = JSON.parse(this.responseText).pictures;
- document.getElementById('pictureCount').innerText = pictures.length;
- });
- req.open('GET', '/pictures');
- req.send();
- }
- function pausePlay() {
- if (interval) {
- clearInterval(interval);
- interval = null;
- } else {
- interval = setInterval(reload, 100);
- }
- }
- window.onload = function () {
- getPictureList();
- pausePlay();
- // setInterval(reload, 100);
- };
- </script>
- </head>
- <body>
- <p>Pictures available: <span id="pictureCount"></span> showing <span id="currentPictureLabel"></span></p>
- <img id="picture" width="800" height="600" onclick="pausePlay()"/>
- </body>
- </html>
|