var MotionJPEG = Class.create(); MotionJPEG.prototype = { initialize: function(container, delay, width, height, camera) { this.url = '/module/livevideo/read_image.php?c='+camera; this.loaded = false; var left = parseInt(width/2 - 16); var top = parseInt(height/2 - 16); var theDate = new Date(); var nodeContent = '
'; nodeContent += ''; nodeContent += '
'; $(container).update(nodeContent); Event.observe($('mjpeg-image'), 'load', ( (function(event) { this.loaded = true; }).bind(this) )); $('mjpeg-image').src = this.url+'?dummy='+theDate.getTime().toString(10); this.executer = new PeriodicalExecuter(this.reloadFrame.bind(this), delay); }, reloadFrame: function() { if (this.loaded == true) { var theDate = new Date(); this.loaded = false; $('mjpeg-image').src = this.url+'?dummy='+theDate.getTime().toString(10); } } }