1 if (typeof
Cc ==
'undefined')
2 var
Cc = Components.classes;
3 if (typeof
Ci ==
'undefined')
4 var
Ci = Components.interfaces;
7 if (typeof(gMetrics) ==
"undefined")
8 var gMetrics = Cc[
"@songbirdnest.com/Songbird/Metrics;1"]
9 .createInstance(Ci.sbIMetrics);
12 Components.utils.import(
"resource://app/jsmodules/sbColumnSpecParser.jsm");
21 Application.prefs.getValue(
"extensions.concerts.country", 1);
23 Application.prefs.getValue(
"extensions.concerts.state", 0);
25 Application.prefs.getValue(
"extensions.concerts.city", 0);
27 var countryDropdown = document.getElementById(
"menulist-country");
28 var statesDropdown = document.getElementById(
"menulist-state");
29 var citiesDropdown = document.getElementById(
"menulist-city");
32 this.skSvc = Cc[
"@songbirdnest.com/Songbird/Concerts/Songkick;1"]
33 .getService(Ci.sbISongkick);
34 this.json = Cc[
"@mozilla.org/dom/json;1"].createInstance(Ci.nsIJSON);
36 if (!this.skSvc.gotLocationInfo()) {
37 this.skSvc.refreshLocations();
40 var interval = setInterval(
function () {
41 if (!this.skSvc.locationRefreshRunning) {
43 clearInterval(interval);
46 if ( !this.skSvc.gotLocationInfo() ) {
47 ConcertTicketing.showTimeoutError();
50 self._populateInformation();
56 this._populateInformation();
59 _populateInformation:
function() {
61 this._populateCountries(this.pCountry);
64 this._populateStates(this.pCountry, this.pState);
67 this._populateCities(this.pState, this.pCity);
70 _populateCountries :
function(selectedCountry) {
71 var countries = this.json.decode(this.skSvc.getLocationCountries());
72 var countryDropdown = document.getElementById(
"menulist-country");
73 countryDropdown.removeAllItems();
75 for (var
i=0;
i<countries.length;
i++) {
76 var country = countries[
i].name;
78 country =
"United States";
79 else if (country ==
"UK")
80 country =
"United Kingdom";
81 countryDropdown.appendItem(country, countries[
i].
id);
82 if (countries[
i].
id == selectedCountry)
85 countryDropdown.selectedIndex = idx;
88 _populateStates :
function(inCountry, selectedState) {
90 this.json.decode(this.skSvc.getLocationStates(inCountry));
91 this._states.sort(
function(a, b) {
92 return (a.name > b.name); })
93 var stateDropdown = document.getElementById(
"menulist-state");
94 stateDropdown.removeAllItems();
96 if (this._states.length == 1 &&
97 (
this._states[0].name ==
"" ||
98 this._states[0].name.indexOf(
"<countrywide>")))
101 stateDropdown.disabled =
true;
102 this._populateCities(this._states[0].
id);
103 this.pState = this._states[0].id;
106 stateDropdown.disabled =
false;
108 for (let
i=0;
i<this._states.length;
i++) {
109 stateDropdown.appendItem(this._states[
i].
name,
111 if (this._states[
i].
id == selectedState)
114 stateDropdown.selectedIndex = idx;
115 this._populateCities(stateDropdown.selectedItem.value);
119 _populateCities :
function(inState, selectedCity) {
120 var cities = this.json.decode(this.skSvc.getLocationCities(inState));
121 cities.sort(
function(a, b) {
122 return (a.name > b.name); })
123 var citiesDropdown = document.getElementById(
"menulist-city");
124 citiesDropdown.removeAllItems();
126 for (let
i=0;
i<cities.length;
i++) {
127 citiesDropdown.appendItem(cities[
i].
name, cities[
i].
id);
128 if (cities[
i].
id == selectedCity)
131 citiesDropdown.selectedIndex = idx;
134 changeCountry :
function(list) {
135 var countryId = list.selectedItem.value;
136 this._populateStates(countryId);
139 changeState :
function(list) {
140 var stateId = list.selectedItem.value;
141 this._populateCities(stateId);
144 changeCity :
function(list) {
147 cancel :
function() {
148 var deck = document.getElementById(
"concerts-deck");
150 if (deck.hasAttribute(
"previous-selected-deck"))
151 prev = deck.getAttribute(
"previous-selected-deck");
152 deck.setAttribute(
"selectedIndex", prev);
156 var countryDropdown = document.getElementById(
"menulist-country");
157 var statesDropdown = document.getElementById(
"menulist-state");
158 var citiesDropdown = document.getElementById(
"menulist-city");
162 var country = parseInt(countryDropdown.selectedItem.value);
163 var city = parseInt(citiesDropdown.selectedItem.value);
166 if (
Application.prefs.getValue(
"extensions.concerts.firstrun",
false)) {
167 Application.prefs.setValue(
"extensions.concerts.country", country);
168 Application.prefs.setValue(
"extensions.concerts.city", city);
169 if (!statesDropdown.disabled) {
170 var state = parseInt(statesDropdown.selectedItem.value);
171 Application.prefs.setValue(
"extensions.concerts.state", state);
175 #ifdef METRICS_ENABLED
176 gMetrics.metricsInc(
"concerts",
"change.location",
"");
178 var box = document.getElementById(
"library-ontour-box");
179 if (box.style.visibility !=
"hidden") {
180 var
check = document.getElementById(
"checkbox-library-integration");
182 #ifdef METRICS_ENABLED
183 gMetrics.metricsInc(
"concerts",
"library.ontour.checked",
"");
189 var foundProperty =
false;
191 for each (var column
in parser.columnMap) {
192 if (column.property ==
this.skSvc.onTourImgProperty) {
193 foundProperty =
true;
199 if (!foundProperty) {
201 ColumnSpecParser.reduceWidthsProportionally(parser.columnMap, 58);
204 for each (var column
in parser.columnMap) {
205 colspec += column.property +
" " +
207 if (column.property == parser.sortID) {
208 if (parser.sortIsAscending)
214 colspec += this.skSvc.onTourImgProperty +
" 58";
215 var
property = SBProperties.columnSpec +
"+(audio)";
216 LibraryUtils.mainLibrary.setProperty(property, colspec);
220 ConcertTicketing.loadConcertData(city);
Javascript wrappers for common library tasks.
_getSelectedPageStyle s i