var ioService = Components.classes["@mozilla.org/network/io-service;1"];
ioService = ioService.getService(Components.interfaces.nsIIOService2);
// Stop automatic management of the offline status
try {
ioService.manageOfflineStatus = false;
} catch (ex) {}
ioService.offline = !value;
if (goPrefBar.IsFirefox)
navigator.preference("browser.offline", !value);
var ioService = Components.classes["@mozilla.org/network/io-service;1"];
ioService = ioService.getService(Components.interfaces.nsIIOService2);
value = !ioService.offline;
// Move our id to global, so the listener is able to find this button
window.prefbarofflinecheckid = button.id;
// Create the event listener just once.
// The listener is used, to update the checkbox, whenever the user clicks
// one of the built-in Offline buttons.
if (!("prefbarofflinecheckupdate" in window)) {
// define listener. The listener runs through all buttons, to find this one.
// Then "prefbarSetExtcheck" is called for it.
window.prefbarofflinecheckupdate = function(event) {
var buttons = document.getElementById("prefbar-buttons");
for (var i = 0; i < buttons.childNodes.length; i++) {
var btn = buttons.childNodes[i];
if (btn.collapsed == true) break;
if (btn.id == window.prefbarofflinecheckid)
prefbarSetExtcheck(btn);
}
}
// register listener to all built-in checkboxes, we find
var offlinemnu = document.getElementById("offlineGoOfflineCmd");
var offlinebtn = document.getElementById("offline-status");
var fxofflinemnu = document.getElementById("goOfflineMenuitem");
if (offlinemnu)
offlinemnu.addEventListener("command", window.prefbarofflinecheckupdate, false);
if (offlinebtn)
offlinebtn.addEventListener("command", window.prefbarofflinecheckupdate, false);
if (fxofflinemnu)
fxofflinemnu.addEventListener("command", window.prefbarofflinecheckupdate, false);
}