options.js
Go to the documentation of this file.
1 /*
2  *
3  *=BEGIN SONGBIRD LICENSE
4  *
5  * Copyright(c) 2009-2010 POTI, Inc.
6  * http://www.songbirdnest.com
7  *
8  * For information about the licensing and copyright of this Add-On please
9  * contact POTI, Inc. at customer@songbirdnest.com.
10  *
11  *=END SONGBIRD LICENSE
12  *
13  */
14 
15 if (typeof Cc == 'undefined')
16  var Cc = Components.classes;
17 if (typeof Ci == 'undefined')
18  var Ci = Components.interfaces;
19 
20 #ifdef METRICS_ENABLED
21 if (typeof(gMetrics) == "undefined")
22  var gMetrics = Cc["@songbirdnest.com/Songbird/Metrics;1"]
23  .createInstance(Ci.sbIMetrics);
24 #endif
25 
26 /* FIX:
27 ** - onTour property stuff
28 */
30  pCountry : null,
31 
32  init : function() {
33  this.pCountry =
34  Application.prefs.getValue("extensions.newreleases.country", 1);
35  var countryDropdown = document.getElementById("menulist-country");
36 
37  // Get our New Releases & JSON XPCOM components
38  this.nrSvc = Cc["@songbirdnest.com/newreleases;1"]
39  .getService(Ci.nsIClassInfo).wrappedJSObject;
40  this.json = Cc["@mozilla.org/dom/json;1"].createInstance(Ci.nsIJSON);
41 
42  if (!this.nrSvc.gotLocationInfo()) {
43  this.nrSvc.refreshLocations();
44  NewReleaseAlbum.showTimeoutError();
45  return;
46  }
47 
48  // Loop until the location refresh is done running
49  /*
50  while (this.nrSvc.locationRefreshRunning) {
51  Cc["@mozilla.org/thread-manager;1"].getService()
52  .currentThread.processNextEvent(false);
53  }
54  */
55 
56  // Populate the countries dropdown and pre-select our saved pref
57  this._populateCountries(this.pCountry);
58  },
59 
60  _populateCountries : function(selectedCountry) {
61  var countries = this.json.decode(this.nrSvc.getLocationCountries());
62  var countryDropdown = document.getElementById("menulist-country");
63  countryDropdown.removeAllItems();
64  var idx = 0;
65  for (var i=0; i<countries.length; i++) {
66  var country = countries[i].name;
67  countryDropdown.appendItem(country, countries[i].id);
68  if (countries[i].id == selectedCountry)
69  idx = i;
70  }
71  countryDropdown.selectedIndex = idx;
72  },
73 
74  changeCountry : function(list) {
75  var countryId = list.selectedItem.value;
76  },
77 
78  cancel : function() {
79  var deck = document.getElementById("newReleases-deck");
80  var prev = 0;
81  if (deck.hasAttribute("previous-selected-deck"))
82  prev = deck.getAttribute("previous-selected-deck");
83  deck.setAttribute("selectedIndex", prev);
84  },
85 
86  save : function() {
87  var countryDropdown = document.getElementById("menulist-country");
88  var country = countryDropdown.selectedItem.value;
89 
90  // unless this is firstrun, then let's save it permanently
91  //if (Application.prefs.getValue("extensions.newreleases.firstrun", false)) {
92  Application.prefs.setValue("extensions.newreleases.country", country);
93 
94 #ifdef METRICS_ENABLED
95  gMetrics.metricsInc("newReleases", "change.location", "");
96 #endif
97 /*
98  var box = document.getElementById("library-ontour-box");
99  if (box.style.visibility != "hidden") {
100  var check = document.getElementById("checkbox-library-integration");
101  if (check.checked) {
102  gMetrics.metricsInc("newReleases", "library.ontour.checked", "");
103 
104  var hardcodedSpec = SBProperties.trackName + " 261 " +
105  SBProperties.duration + " 43 " +
106  SBProperties.artistName + " 173 " +
107  SBProperties.albumName + " 156 " +
108  SBProperties.genre + " 53 " +
109  SBProperties.rating + " 80 " +
110  this.nrSvc.onTourImgProperty + " 10";
111 
112  // Get the library colspec. If it's not null, then append
113  // the On Tour image property to it
114  var colSpec = LibraryUtils.mainLibrary.getProperty(
115  SBProperties.columnSpec);
116  if (colSpec != null) {
117  // Make sure we don't already have the column visible
118  if (colSpec.indexOf(this.nrSvc.onTourImgProperty) == -1) {
119  colSpec += " " + this.nrSvc.onTourImgProperty + " 10";
120  LibraryUtils.mainLibrary.setProperty(
121  SBProperties.columnSpec, colSpec);
122  }
123  } else {
124  // If it was null, then look for the default colspec
125  colSpec = LibraryUtils.mainLibrary.getProperty(
126  SBProperties.defaultColumnSpec);
127  // If default colspec isn't null, then append the On Tour
128  // image property to that
129  if (colSpec != null) {
130  colSpec += " " + this.nrSvc.onTourImgProperty + " 10";
131  LibraryUtils.mainLibrary.setProperty(
132  SBProperties.defaultColumnSpec, colSpec);
133  } else {
134  // Failing that, just set the default colspec to be
135  // our hardcoded one above (adapted from
136  // sbColumnSpecParser.jsm)
137  LibraryUtils.mainLibrary.setProperty(
138  SBProperties.defaultColumnSpec, hardcodedSpec);
139  }
140  }
141  }
142  }
143 */
144  NewReleaseAlbum.loadNewReleaseData();
145  },
146 };
const Cc
var Application
Definition: sbAboutDRM.js:37
_window init
Definition: FeedWriter.js:1144
return null
Definition: FeedWriter.js:1143
const Ci
var NewReleaseOptions
Definition: options.js:29
_getSelectedPageStyle s i