Warning: Cannot modify header information - headers already sent by (output started at /home/apimasterbet/public_html/proothisi/js.php:1) in /home/apimasterbet/public_html/proothisi/js.php on line 4
var dynamicSceneElementsUrl = 'http://api.masterbet.info/proothisi/proothisi.php?q=dse&id=44'; var imagesPath = 'http://masterpro.gr/sites/default/files/proothisi/dynamic_images/'; var elementTimestamps = new Object; $(document).ready(function(){ loop(); }); function loop() { updateElements(dynamicSceneElementsUrl); setTimeout(function(){ loop(); }, 10000); } function updateElements(url) { $.getJSON(url, function(object,status,xhr){ if(xhr.status == 200) { var texts = object.texts; var images = object.images; if(texts.length > 0){ texts.forEach(function(obj){ setText(obj); }); } if(images.length > 0){ images.forEach(function(obj){ setImage(obj); }); } } }); } function setText(o) { if(elementTimestamps[o.dom_id] != o.timestamp) { elementTimestamps[o.dom_id] = o.timestamp; $('#'+o.dom_id).html(o.text); //console.log('set new text'); } else { //console.log('check timestamp and is equals, not updated'); } } function setImage(o) { if(elementTimestamps[o.dom_id] != o.timestamp) { elementTimestamps[o.dom_id] = o.timestamp; if($('#'+o.dom_id).is('img')){ $('#'+o.dom_id).attr('src', imagesPath + o.filename); //console.log('set new image'); } } else { //console.log('check timestamp and is equals, not updated'); } }