sanitize.js
Go to the documentation of this file.
1 /*
2  //
3 // BEGIN SONGBIRD GPL
4 //
5 // This file is part of the Songbird web player.
6 //
7 // Copyright(c) 2005-2008 POTI, Inc.
8 // http://songbirdnest.com
9 //
10 // This file may be licensed under the terms of of the
11 // GNU General Public License Version 2 (the "GPL").
12 //
13 // Software distributed under the License is distributed
14 // on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, either
15 // express or implied. See the GPL for the specific language
16 // governing rights and limitations.
17 //
18 // You should have received a copy of the GPL along with this
19 // program. If not, go to http://www.gnu.org/licenses/gpl.html
20 // or write to the Free Software Foundation, Inc.,
21 // 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
22 //
23 // END SONGBIRD GPL
24 //
25 */
26 
27 if (typeof(Sanitizer) != "undefined") {
28 
29  var gSongbirdSanitize = {
30  onLoad: function() { gSongbirdSanitize.init(); },
31  onUnload: function(event) { gSongbirdSanitize.reset(); },
32 
33  init: function() {
34  if (document.documentElement.getAttribute("windowtype") == "Songbird:Core") {
35  this.onSanitizerStartup();
36  }
37  window.removeEventListener('load', gSongbirdSanitize.onLoad, false);
38  window.addEventListener('unload', gSongbirdSanitize.onUnload, false);
39 
40  var prefs = Components.classes["@mozilla.org/preferences-service;1"]
41  .getService(Components.interfaces.nsIPrefBranch2);
42  var guid = prefs.getComplexValue("songbird.library.web",
43  Components.interfaces.nsISupportsString);
44 
45  var libraryManager =
46  Components.classes["@songbirdnest.com/Songbird/library/Manager;1"]
47  .getService(Components.interfaces.sbILibraryManager);
48 
49  var webLibrary = libraryManager.getLibrary(guid);
50  Sanitizer.prototype.items["mediaHistory"] = {
51  clear: function ()
52  {
53  webLibrary.clear();
54  },
55 
56  get canClear()
57  {
58  return webLibrary.length > 0;
59  }
60  };
61  if (typeof(gSanitizePromptDialog) != "undefined") {
62  var oldfn = gSanitizePromptDialog.sanitize;
63  gSanitizePromptDialog.sanitize = function() {
64  oldfn.call(gSanitizePromptDialog);
65  if (document.getElementById("sanitize.mediaHistory").checked) {
66  Sanitizer.prototype.items["mediaHistory"].clear();
67  }
68  };
69  }
70  },
71 
72  reset: function() {
73  window.removeEventListener('unload', gSongbirdSanitize.onUnload, false);
74  if (document.documentElement.getAttribute("windowtype") == "Songbird:Core") {
75  this.onSanitizerShutdown();
76  }
77  },
78 
79  onSanitizerStartup: function() {
80  Sanitizer.onStartup();
81  Sanitizer.prefs.setBoolPref(Sanitizer.prefDidShutdown, false);
82  },
83 
84  onSanitizerShutdown: function() {
85  Sanitizer.onShutdown();
86  },
87 
88  };
89 
90  window.addEventListener('load', gSongbirdSanitize.onLoad, false);
91 }
function clear(dbq)
var event
let window
_window init
Definition: FeedWriter.js:1144
var gSanitizePromptDialog
Lastfm onLoad
Definition: mini.js:36
var libraryManager
var prefs
Definition: FeedWriter.js:1169
function Sanitizer()
Definition: sanitize.js:42
function onUnload()
onUnload - called when the cover preview window unloads.
Definition: coverPreview.js:36