瀏覽代碼

Update when Scripts change

Will add HTML checking soon.
Nathaniel van Diepen 10 年之前
父節點
當前提交
478a35dbc2
共有 1 個文件被更改,包括 20 次插入0 次删除
  1. 20 0
      app/www/js/omnomirc.js

+ 20 - 0
app/www/js/omnomirc.js

@@ -1151,6 +1151,26 @@
 		if(settings.autoconnect){
 			$o.chat.connect();
 		}
+		// Check for script updates and update if required
+		(function checkScripts(){
+			for(var i in document.scripts){
+				(function(el,src){
+					if(exists(src) && el.innerHTML == ''){
+						$.ajax(src,{
+							success: function(source){
+								if(exists($(el).data('source')) && $(el).data('source') != source){
+									event('Reloading','update');
+									location.reload();
+								}
+								$(el).data('source',source);
+							},
+							dataType: 'text'
+						});
+					}
+				})(document.scripts[i],document.scripts[i].src);
+			}
+			setTimeout(checkScripts,1000);
+		})();
 	});
 	window.io = null;
 	runHook('load');