var hidden, visibilityChange; var xhr, myicon; var previous_icon=''; var _gaq = _gaq || []; if (typeof document.hidden !== "undefined") { hidden = "hidden"; visibilityChange = "visibilitychange"; } else if (typeof document.msHidden !== "undefined") { hidden = "msHidden"; visibilityChange = "msvisibilitychange"; } else if (typeof document.webkitHidden !== "undefined") { hidden = "webkitHidden"; visibilityChange = "webkitvisibilitychange"; } _gaq.push(['_setAccount', 'UA-45967354-1']); _gaq.push(['_trackPageview', '/wicon/inafplio1.js']); scriptLoader('https://www.wxplanet.com/include/easyXDM/easyXDM.min.js', function() { if (document.getElementById("wicon_inafplio1")) { if (document.getElementById("wicon_inafplio1").nodeName == 'DIV') { xhr = new easyXDM.Rpc({ remote: "https://widgets.wxplanet.com/include/easyXDM/cors/" }, { remote: { request: {} } }); get_icon(); if (typeof document.addEventListener !== "undefined" && hidden !== undefined) { document.addEventListener(visibilityChange, handleVisibilityChange, false); myicon=setInterval(function() { get_icon() }, 10000); } _gaq.push(['_trackEvent', 'Validity check of icon code', 'Passed']); } else { _gaq.push(['_trackEvent', 'Validity check of icon code', 'Not passed']); } } else { _gaq.push(['_trackEvent', 'Validity check of icon code', 'Not passed']); } }); scriptLoader('/include/visibilityjs/visibility.core.js'); function get_icon() { xhr.request({ url: "https://widgets.wxplanet.com/get_icon_name.php", method: "GET", data: {id:"inafplio1"} }, function(rpcdata){ if (previous_icon != rpcdata.data) { document.getElementById("wicon_img_inafplio1").src='https://images.wxplanet.com/icons_v0.9/'+rpcdata.data+'.png'; previous_icon=rpcdata.data; } }); _gaq.push(['_trackEvent', 'Icon viewing: /wicon/inafplio1.js', 'Success']); } (function() { var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true; ga.src = ('https:' == document.location.protocol ? 'https://' : 'http://') + 'stats.g.doubleclick.net/dc.js'; var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s); })(); function scriptLoader(path, callback) { var script = document.createElement('script'); script.type = "text/javascript"; script.async = true; script.src = path; script.onload = function(){ if(typeof(callback) == "function") { callback(); } } try { var scriptOne = document.getElementsByTagName('script')[0]; scriptOne.parentNode.insertBefore(script, scriptOne); } catch(e) { document.getElementsByTagName("head")[0].appendChild(script); } } function handleVisibilityChange() { if (document[hidden]) { clearInterval(myicon); } else { get_icon(); myicon=setInterval(function() { get_icon() }, 10000); } }