Skip to content

Commit

Permalink
Isolate the contents of scriptdownloader.js in a private scope.
Browse files Browse the repository at this point in the history
Signed-off-by: Johan Sundström <oyasumi+github@gmail.com>
  • Loading branch information
arantius authored and johan committed Aug 13, 2009
1 parent c31bd4d commit 85cd63e
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 1 deletion.
2 changes: 1 addition & 1 deletion content/browser.js
Original file line number Diff line number Diff line change
Expand Up @@ -218,7 +218,7 @@ GM_BrowserUI.startInstallScript = function(uri, timer) {
return;
}

this.scriptDownloader_ = new ScriptDownloader(window, uri, this.bundle);
this.scriptDownloader_ = new GM_ScriptDownloader(window, uri, this.bundle);
this.scriptDownloader_.startInstall();
};

Expand Down
9 changes: 9 additions & 0 deletions content/scriptdownloader.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
// This anonymous function exists to isolate generic names inside it to its
// private scope.
(function() {

function ScriptDownloader(win, uri, bundle) {
this.win_ = win;
this.uri_ = uri;
Expand All @@ -10,6 +14,9 @@ function ScriptDownloader(win, uri, bundle) {
this.tempFiles_ = [];
}

// Export this one important value to the global namespace.
window.GM_ScriptDownloader=ScriptDownloader;

ScriptDownloader.prototype.startInstall = function() {
this.installing_ = true;
this.startDownload();
Expand Down Expand Up @@ -279,3 +286,5 @@ PersistProgressListener.prototype.onStateChange =
this.onFinish();
}
};

})();

0 comments on commit 85cd63e

Please sign in to comment.