From: <ma...@us...> - 2010-11-05 18:35:36
|
Revision: 81 http://openautomation.svn.sourceforge.net/openautomation/?rev=81&view=rev Author: mayerch Date: 2010-11-05 18:35:30 +0000 (Fri, 05 Nov 2010) Log Message: ----------- New Feature: images allow refresh attribute Modified Paths: -------------- CometVisu/trunk/visu/lib/templateengine.js CometVisu/trunk/visu/lib/visudesign_pure.js CometVisu/trunk/visu/visu_config.xml Modified: CometVisu/trunk/visu/lib/templateengine.js =================================================================== --- CometVisu/trunk/visu/lib/templateengine.js 2010-11-05 10:25:12 UTC (rev 80) +++ CometVisu/trunk/visu/lib/templateengine.js 2010-11-05 18:35:30 UTC (rev 81) @@ -290,6 +290,22 @@ visu.write( data.GA, data.sendValue, data.datatype ); } +function refreshAction( target, src ) +{ + target.src = src + '&' + new Date().getTime(); +} +function setupRefreshAction() +{ + var refresh = $(this).data('refresh'); + if( refresh && refresh > 0 ) + { + var target = $('img', $(this) )[0]; + var src = target.src; + if( src.indexOf('?') < 0 ) src += '?'; + $(this).data('interval', setInterval( function(){refreshAction(target, src);}, refresh ) ); + } +} + /** * The update thread to send the slider position to the bus */ Modified: CometVisu/trunk/visu/lib/visudesign_pure.js =================================================================== --- CometVisu/trunk/visu/lib/visudesign_pure.js 2010-11-05 10:25:12 UTC (rev 80) +++ CometVisu/trunk/visu/lib/visudesign_pure.js 2010-11-05 18:35:30 UTC (rev 81) @@ -168,7 +168,11 @@ if( $(page).attr('width') ) style += 'width:' + $(page).attr('width') + ';'; if( $(page).attr('height') ) style += 'height:' + $(page).attr('height') + ';'; if( style != '' ) style = 'style="' + style + '"'; - ret_val.append( '<div class="actor"><img src="' +$(page).attr('src') + '" ' + style + ' /></div>' ); + var actor = '<div class="actor"><img src="' +$(page).attr('src') + '" ' + style + ' /></div>'; + var refresh = $(page).attr('refresh') ? $(page).attr('refresh')*1000 : 0; + ret_val.append( $(actor).data( { + 'refresh': refresh + } ).each(setupRefreshAction) ); // abuse "each" to call in context... return ret_val; } @@ -198,4 +202,14 @@ //visu.write( data.GA, data.value=='1' ? '0' : '1', data.datatype ); //FIXME eigentlich richtig... visu.write( data.GA, ui.value, data.datatype ); } + + /** + * Setup a refresh interval in seconds if the 'refresh' in the .data() + * ist bigger than 0 + */ + this.refreshAction = function(that) + { + var data = $(this).data(); + alert('this.refreshAction'); + } }; Modified: CometVisu/trunk/visu/visu_config.xml =================================================================== --- CometVisu/trunk/visu/visu_config.xml 2010-11-05 10:25:12 UTC (rev 80) +++ CometVisu/trunk/visu/visu_config.xml 2010-11-05 18:35:30 UTC (rev 81) @@ -48,6 +48,9 @@ <image src="icon/comet_128_ff8000.png" >Ein Bild</image> <image src="icon/comet_128_ff8000.png" /> <image src="icon/comet_128_ff8000.png" width="500px" height="46px" /> + <image src="http://www.e-zeeinternet.com/count.php?page=546016&style=default&nbdigits=9&reloads=1" refresh="10" >Update every 10 sec</image> + <break /> + <image src="http://www.yr.no/place/Germany/Bavaria/Holzkirchen~2899676/meteogram.png" refresh="1800" /> <line /> <info address="1/0/41" datatype="1.000" mapping="OnOff">Treppenlicht</info> <page name="Fenster Kontakte"> This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |