Skip to content

Instantly share code, notes, and snippets.

@ZhangHanDong
Created July 11, 2010 22:25
Show Gist options
  • Save ZhangHanDong/471897 to your computer and use it in GitHub Desktop.
Save ZhangHanDong/471897 to your computer and use it in GitHub Desktop.
/**
* The ParentWorkerPool of Monitor whether the system is online or offline
*
* Alex(blackanger.z@gmail.com)
* 2009.3
*/
isOnlie: function(){
workerPool = google.gears.factory.create('beta.workerpool');
workerPool.onmessage = function(a, b, message) {
if (message.sender == monitorchildWorkerId) {
if(message.text == 'online'){
$('#is-connected').show();
$('#is-disconnected').hide();
}else if(message.text == 'offline'){
$('#is-disconnected').show();
$('#is-connected').hide();
}
}
};
var monitorchildWorkerId = workerPool.createWorkerFromUrl('/javascripts/js_app/models/monitor.js');
workerPool.sendMessage(window.location + '?monitor', monitorchildWorkerId);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment