15 if (typeof(
Cc) ==
"undefined")
16 var
Cc = Components.classes;
17 if (typeof(
Ci) ==
"undefined")
18 var
Ci = Components.interfaces;
19 if (typeof(
Cu) ==
"undefined")
20 var
Cu = Components.utils;
22 Cu.import(
"resource://app/jsmodules/StringUtils.jsm");
23 Cu.import(
"resource://app/jsmodules/sbProperties.jsm");
24 Cu.import(
"resource://app/jsmodules/sbLibraryUtils.jsm");
26 if (typeof(songbirdMainWindow) ==
"undefined")
27 var songbirdMainWindow = Cc[
"@mozilla.org/appshell/window-mediator;1"]
28 .getService(Ci.nsIWindowMediator)
29 .getMostRecentWindow(
"Songbird:Main").window;
31 if (typeof(gBrowser) ==
"undefined")
32 var gBrowser = Cc[
"@mozilla.org/appshell/window-mediator;1"]
33 .getService(Ci.nsIWindowMediator)
34 .getMostRecentWindow(
"Songbird:Main").window.gBrowser;
36 #ifdef METRICS_ENABLED
37 if (typeof(gMetrics) ==
"undefined")
38 var gMetrics = Cc[
"@songbirdnest.com/Songbird/Metrics;1"]
39 .createInstance(Ci.sbIMetrics);
43 if (typeof(Components) ==
"undefined")
45 while ((typeof(Components) !=
"undefined") &&
46 Components.classes[
"@mozilla.org/thread-manager;1"].getService()
47 .currentThread.hasPendingEvents())
49 Components.classes[
"@mozilla.org/thread-manager;1"].getService()
50 .currentThread.processNextEvent(
true);
54 var
letterIndices = [
'#',
'Z',
'Y',
'X',
'W',
'V',
'U',
'T',
'S',
'R',
'Q',
'P',
'O',
'N',
55 'M',
'L',
'K',
'J',
'I',
'H',
'G',
'F',
'E',
'D',
'C',
'B',
'A'];
65 customCountries[
"Netherlands"] =
"the";
66 customCountries[
"Russian Federation"] =
"the";
67 customCountries[
"United Kingdom"] =
"the";
68 customCountries[
"United States"] =
"the";
70 if (typeof NewReleaseAlbum ==
'undefined') {
71 var NewReleaseAlbum = {};
74 NewReleaseAlbum.unload =
function() {
75 Components.classes[
"@songbirdnest.com/newreleases;1"]
76 .getService(Ci.nsIClassInfo).wrappedJSObject.unregisterDisplayCallback();
79 NewReleaseAlbum.init =
function() {
81 var servicePaneStr = Cc[
"@mozilla.org/intl/stringbundle;1"]
82 .getService(Ci.nsIStringBundleService)
83 .createBundle(
"chrome://newreleases/locale/overlay.properties");
84 document.title = servicePaneStr.GetStringFromName(
"servicePane.Name");
88 if (typeof(Ci.sbIMediacoreManager) !=
"undefined")
89 NewReleaseAlbum.newMediaCore =
true;
91 NewReleaseAlbum.newMediaCore =
false;
93 this.dateFormat =
"%a, %b %e, %Y";
94 if (navigator.platform.substr(0, 3) ==
"Win")
95 this.dateFormat =
"%a, %b %#d, %Y";
97 this.Cc = Components.classes;
98 this.Ci = Components.interfaces;
101 this.iframe = document.getElementById(
"newRelease-listings");
104 this._browseDoc = this.iframe.contentWindow.document;
107 this._strings = document.getElementById(
"newReleases-strings");
110 var headNode = this._browseDoc.getElementsByTagName(
"head")[0];
111 var cssNode = this._browseDoc.createElementNS(
112 "http://www.w3.org/1999/xhtml",
"html:link");
113 cssNode.type =
'text/css';
114 cssNode.rel =
'stylesheet';
115 cssNode.href =
'chrome://songbird/skin/html.css';
116 cssNode.media =
'screen';
117 headNode.appendChild(cssNode);
119 cssNode = this._browseDoc.createElementNS(
120 "http://www.w3.org/1999/xhtml",
"html:link");
121 cssNode.type =
'text/css';
122 cssNode.rel =
'stylesheet';
123 cssNode.href =
'chrome://newreleases/skin/browse.css';
124 cssNode.media =
'screen';
125 headNode.appendChild(cssNode);
128 this.nrSvc = Cc[
"@songbirdnest.com/newreleases;1"]
129 .getService(Ci.nsIClassInfo).wrappedJSObject;
133 .getValue(
"extensions.newreleases.filterLibraryArtists",
true);
137 .getValue(
"extensions.newreleases.showplaylink",
false);
139 .getValue(
"extensions.newreleases.showgcal",
false);
141 .getValue(
"extensions.newreleases.showExtendedInfo",
false);
143 #ifdef METRICS_ENABLED
144 gMetrics.metricsInc(
"newReleases",
"servicepane.clicked",
"");
147 if (!this.nrSvc.hasDisplayCallback()) {
148 var displayCB =
new this.displayCallback(
this);
149 displayCB.wrappedJSObject = displayCB;
150 this.nrSvc.registerDisplayCallback(displayCB);
153 if (
Application.prefs.get(
"extensions.newreleases.firstrun").value) {
155 var deck = document.getElementById(
"newReleases-deck");
156 deck.setAttribute(
"selectedIndex", 1);
159 this.nrSvc.refreshLocations();
162 if (this.nrSvc.newReleasesRefreshRunning) {
165 var deck = document.getElementById(
"newReleases-deck");
166 deck.setAttribute(
"selectedIndex", 2);
167 var
label = document.getElementById(
"loading-label");
168 var progressbar = document.getElementById(
"loading-progress");
169 label.value = this.nrSvc.progressString;
170 progressbar.value = this.nrSvc.progressPercentage;
171 this.waitForRefreshToFinish(
this);
176 this.browseNewReleases(
this);
181 NewReleaseAlbum.waitForRefreshToFinish =
function(
self) {
182 if (Components.classes[
"@songbirdnest.com/newreleases;1"]
183 .getService(Ci.nsIClassInfo).wrappedJSObject.newReleasesRefreshRunning)
185 setTimeout(this.waitForRefreshToFinish(
self), 100);
187 self.browseNewReleases(
self);
191 NewReleaseAlbum.editLocation =
function() {
194 var deck = document.getElementById(
"newReleases-deck");
195 deck.setAttribute(
"previous-selected-deck", deck.selectedIndex);
198 document.getElementById(
"pref-library").style.visibility =
"hidden";
199 document.getElementById(
"library-newrelease-box")
200 .style.visibility =
"collapse";
207 var cancel = document.getElementById(
"pref-cancel-button");
208 cancel.style.visibility=
"visible";
211 deck.setAttribute(
"selectedIndex", 1);
214 NewReleaseAlbum.displayCallback =
function(ticketingObj) {
215 this.label = document.getElementById(
"loading-label"),
216 this.progressbar = document.getElementById(
"loading-progress");
217 this.newReleaseAlbum = ticketingObj;
219 NewReleaseAlbum.displayCallback.prototype = {
220 loadingMessage :
function(
str) {
221 this.label.value =
str;
223 loadingPercentage :
function(pct) {
224 this.progressbar.value = pct;
226 timeoutError :
function() {
227 songbirdMainWindow.NewReleases.updateNewReleasesCount(0);
228 var deck = document.getElementById(
"newReleases-deck");
229 deck.setAttribute(
"selectedIndex", 4);
231 showListings :
function() {
232 this.newReleaseAlbum.browseNewReleases(this.newReleaseAlbum);
234 updateNewReleasesCount :
function() {
235 songbirdMainWindow.NewReleases.updateNewReleasesCount()
242 NewReleaseAlbum.loadNewReleaseData =
function(country) {
244 var deck = document.getElementById(
"newReleases-deck");
245 deck.setAttribute(
"selectedIndex", 2);
248 if (
Application.prefs.getValue(
"extensions.newreleases.firstrun",
false)) {
250 Application.prefs.setValue(
"extensions.newreleases.firstrun",
false);
253 songbirdMainWindow.NewReleases._setupNewReleasePlaylist();
257 var
ret = this.nrSvc.refreshNewReleases(
false, country);
260 this.browseNewReleases(
this);
263 NewReleaseAlbum.showNoNewReleases =
function() {
264 var deck = document.getElementById(
"newReleases-deck");
265 deck.setAttribute(
"selectedIndex", 3);
267 deck = document.getElementById(
"no-results-deck");
268 var
count = this.nrSvc.getNewReleasesCount(
false);
274 label = document.getElementById(
"noresults-country-1");
275 label.value = this._strings.getString(
"yourCountrySucks") +
279 var countryName = this.nrSvc.getLocationString(this.pCountry);
280 if (typeof(customCountries[countryName]) !=
"undefined")
281 label.value += customCountries[countryName] +
" ";
282 label.value += countryName;
283 sampletext = document.getElementById(
"sampleresults");
284 sampletext.style.visibility =
"hidden";
285 button = document.getElementById(
"noresults-seeallreleases-country");
286 button.style.visibility =
"hidden";
291 label = document.getElementById(
"noresults-country-1");
292 label.value = this._strings.getString(
"noLibLame");
296 var countryStr =
" ";
297 var countryName = this.nrSvc.getLocationString(this.pCountry);
300 if (typeof(customCountries[countryName]) !=
"undefined")
301 countryStr += customCountries[countryName] +
" ";
302 countryStr += countryName;
303 label = document.getElementById(
"noresults-country-2");
304 label.value = this._strings.getString(
"noLibArtistsReleases");
305 label = document.getElementById(
"noresults-country-3");
306 label.value = this._strings.getString(
"noLibArtistsReleases2") +
310 label = document.getElementById(
"noresults-country-4");
311 label.value = this._strings.getString(
"noLibArtistsReleases3");
312 label = document.getElementById(
"noresults-country-5");
313 label.value = this._strings.getString(
"noLibArtistsReleases4");
316 button = document.getElementById(
"noresults-seeallreleases-country");
317 button.label = this._strings.getString(
"seeAllNewReleases") + countryStr;
319 sampletext = document.getElementById(
"sampleresults");
320 sampletext.style.visibility =
"visible";
324 NewReleaseAlbum.showTimeoutError =
function() {
325 var deck = document.getElementById(
"newReleases-deck");
326 deck.setAttribute(
"selectedIndex", 4);
331 NewReleaseAlbum.openProviderPage =
function() {
333 if (typeof(this.nrSvc) !=
"undefined")
334 url = this.nrSvc.providerURL();
336 url = Cc[
"@songbirdnest.com/newreleases;1"]
337 .getService(Ci.nsIClassInfo).wrappedJSObject.providerURL();
339 var country =
Application.prefs.getValue(
"extensions.newreleases.country", 0);
341 url +=
"?p=21&user_location=" + country;
342 gBrowser.loadOneTab(url);
349 NewReleaseAlbum.playArtist =
function(e) {
352 #ifdef METRICS_ENABLED
353 gMetrics.metricsInc(
"newReleases",
"browse.view.artist.playartist",
"");
355 var list = songbirdMainWindow.NewReleases.releasePlaylist;
356 var view = list.createView();
357 var cfs = view.cascadeFilterSet;
359 cfs.appendSearch([
"*"], 1);
360 cfs.appendFilter(SBProperties.genre);
361 cfs.appendFilter(SBProperties.artistName);
362 cfs.appendFilter(SBProperties.albumName);
365 cfs.set(2, [artistName], 1);
367 if (NewReleaseAlbum.newMediaCore)
368 Cc[
"@songbirdnest.com/Songbird/Mediacore/Manager;1"]
369 .getService(Ci.sbIMediacoreManager)
370 .sequencer.playView(view, 0);
372 Cc[
'@songbirdnest.com/Songbird/PlaylistPlayback;1']
373 .getService(Ci.sbIPlaylistPlayback)
374 .sequencer.playView(view, 0);
381 NewReleaseAlbum.indexJump =
function(e) {
382 var iframe = document.getElementById(
"newRelease-listings");
383 this._browseDoc = iframe.contentWindow.document;
386 if (this.
id.
indexOf(
"newReleases-nav-letter-") >= 0) {
387 var letter = this.
id.replace(
"newReleases-nav-letter-",
"");
388 anchor = this._browseDoc.getElementById(
"indexLetter-" + letter);
390 var dateComponent = this.
id.split(
"-")[3];
391 anchor = this._browseDoc.getElementById(
"indexDate-" + dateComponent);
394 var
aLeft = anchor.offsetLeft;
395 var
aTop = anchor.offsetTop;
396 iframe.contentWindow.scrollTo(0, aTop);
401 NewReleaseAlbum.browseNewReleases =
function(ticketingObj) {
402 if (this.nrSvc.drawingLock)
404 this.nrSvc.drawingLock =
true;
405 this.abortDrawing =
false;
408 var deck = document.getElementById(
"newReleases-deck");
409 deck.setAttribute(
"selectedIndex", 0);
411 this._bodyNode = this._browseDoc.getElementsByTagName(
"body")[0];
414 while (this._bodyNode.firstChild) {
415 this._bodyNode.removeChild(this._bodyNode.firstChild);
418 var
doc = this._browseDoc;
419 var
str = this._strings;
422 var headerDiv = this.createBlock(
"header");
423 var newReleasesImage = doc.createElement(
"img");
424 newReleasesImage.src =
425 "chrome://newreleases/skin/NewReleases.png";
426 newReleasesImage.id =
"newReleases-logo";
427 headerDiv.appendChild(newReleasesImage);
442 this._bodyNode.appendChild(headerDiv);
445 var subHeaderDiv = this.createBlock(
"sub-header");
448 var numNewReleasesShownDiv = this.createBlock(
"num-newReleases",
450 subHeaderDiv.appendChild(numNewReleasesShownDiv);
452 var locationChangeDiv = this.createBlock(
"location",
true);
453 subHeaderDiv.appendChild(locationChangeDiv);
454 var countryNameBlock = this.createBlock(
"location-city",
true);
455 this.pCountry =
Application.prefs.getValue(
"extensions.newreleases.country",
457 var locationString = this.nrSvc.getLocationString(this.pCountry);
458 countryNameBlock.appendChild(doc.createTextNode(locationString));
459 locationChangeDiv.appendChild(countryNameBlock);
460 var changeLocation = this.createBlock(
"location-change",
true);
461 changeLocation.appendChild(doc.createTextNode(str.getString(
"changeLoc")));
462 locationChangeDiv.appendChild(changeLocation);
463 changeLocation.addEventListener(
"click", NewReleaseAlbum.editLocation,
466 var filterDiv = this.createBlock(
"filter",
true);
467 var checkbox = doc.createElement(
"input");
468 checkbox.setAttribute(
"type",
"checkbox");
469 if (this.filterLibraryArtists)
470 checkbox.setAttribute(
"checked",
true);
471 checkbox.addEventListener(
"click",
function(e)
472 { NewReleaseAlbum.changeFilter(
false); },
false);
473 filterDiv.appendChild(checkbox);
474 filterDiv.appendChild(doc.createTextNode(str.getString(
"filter")));
475 subHeaderDiv.appendChild(filterDiv);
477 var clearDiv = this.createBlock(
"sub-header-empty");
478 clearDiv.style.clear =
"both";
479 subHeaderDiv.appendChild(clearDiv);
480 this._bodyNode.appendChild(subHeaderDiv);
482 var groupBy =
Application.prefs.getValue(
"extensions.newreleases.groupby",
485 var navDiv = this.createBlock(
"newReleases-nav");
486 var viewSpan = this.createBlock(
"newReleases-nav-view",
true);
487 viewSpan.appendChild(doc.createTextNode(str.getString(
"navView")));
489 var datesSpan = this.createBlock(
"newReleases-nav-releases",
true);
490 var artistsSpan = this.createBlock(
"newReleases-nav-artists",
true);
491 if (groupBy ==
"artist") {
492 artistsSpan.className +=
" newReleases-nav-selected";
493 datesSpan.addEventListener(
"mouseover",
function(e)
495 datesSpan.className +=
" newReleases-nav-hover";
497 datesSpan.addEventListener(
"mouseout",
function(e)
499 datesSpan.className = datesSpan.className.replace(
500 " newReleases-nav-hover",
"");
502 datesSpan.addEventListener(
"click",
function(e)
504 NewReleaseAlbum.groupBy(
"date");
507 datesSpan.className +=
" newReleases-nav-selected";
508 artistsSpan.addEventListener(
"mouseover",
function(e)
510 artistsSpan.className +=
" newReleases-nav-hover";
512 artistsSpan.addEventListener(
"mouseout",
function(e)
514 artistsSpan.className = artistsSpan.className.replace(
515 " newReleases-nav-hover",
"");
517 artistsSpan.addEventListener(
"click",
function(e)
519 NewReleaseAlbum.groupBy(
"artist");
523 datesSpan.appendChild(doc.createTextNode(str.getString(
"navDates")));
524 artistsSpan.appendChild(doc.createTextNode(str.getString(
"navArtists")));
525 navDiv.appendChild(viewSpan);
526 navDiv.appendChild(datesSpan);
527 navDiv.appendChild(artistsSpan);
529 var indexDiv = this.createBlock(
"newReleases-nav-index");
530 if (groupBy ==
"artist") {
533 for (var
i in letterIndices) {
534 var l = letterIndices[
i];
535 var letterSpan = this.createBlock(
"newReleases-nav-letter",
537 letterSpan.id =
"newReleases-nav-letter-" + l;
538 letterSpan.appendChild(doc.createTextNode(l));
539 indexDiv.appendChild(letterSpan);
543 var myDate =
new Date();
546 Application.prefs.getValue(
"extensions.newreleases.futuremonths",
549 for (
i=0;
i<forwardMonths;
i++) {
550 var mon = myDate.getMonth();
551 var
year = myDate.getFullYear();
552 var
dateStr = myDate.toLocaleFormat(
"%b %Y");
553 var dateSpan = this.createBlock(
"newReleases-nav-date",
true);
554 dateSpan.appendChild(doc.createTextNode(dateStr));
555 dateSpan.id =
"newReleases-nav-date-" + mon +
year;
556 myDate.setMonth(mon+1);
557 dates.push(dateSpan);
559 for (var
i in dates.reverse()) {
560 indexDiv.appendChild(dates[
i],
null);
563 navDiv.appendChild(indexDiv);
564 clearDiv = this.createBlock(
"newReleases-nav-empty");
565 clearDiv.style.clear =
"both";
566 navDiv.appendChild(clearDiv);
567 this._bodyNode.appendChild(navDiv);
571 var newReleasesShown;
572 if (groupBy ==
"artist")
573 newReleasesShown = this.browseByArtists();
575 newReleasesShown = this.browseByDates();
578 new SBStringBundle(
"chrome://newreleases/locale/overlay.properties");
579 var numNewReleasesStr = bundle.formatCountString(
"newReleasesShown",
581 [ newReleasesShown ],
586 if (typeof(customCountries[locationString]) !=
"undefined")
587 customStr =
" " + customCountries[locationString] +
" ";
588 numNewReleasesShownDiv.appendChild(doc.createTextNode(numNewReleasesStr + customStr));
589 songbirdMainWindow.NewReleases.updateNewReleasesCount(newReleasesShown);
591 if (newReleasesShown > 0) {
592 var ft = this.createBlock(
"ft");
611 var lastUpdated = this.createBlock(
"lastUpdated");
612 var
ts = parseInt(1000*
613 Application.prefs.getValue(
"extensions.newreleases.lastupdated", 0));
616 new Date(ts).toLocaleFormat(
"%a, %b %e, %Y at %H:%M.");
617 lastUpdated.innerHTML = this._strings.getString(
"lastUpdated") +
618 " <span class='date'>" + dateString +
"</span>";
619 ft.appendChild(lastUpdated);
621 this._bodyNode.appendChild(ft);
634 this.nrSvc.drawingLock =
false;
637 NewReleaseAlbum.browseByDates =
function() {
639 var dateBlock =
null;
640 var releaseTable =
null;
641 var releases =
new this.nrSvc.releaseEnumerator(
"date",
642 this.filterLibraryArtists,
644 var newReleasesShown = 0;
646 var contentsNode = this._browseDoc.createElement(
"div");
647 contentsNode.id =
"releases-contents";
648 this._bodyNode.appendChild(contentsNode);
650 var today =
new Date();
651 var todayMon = today.getMonth();
652 var todayDate = today.getDate();
653 var todayYear = today.getFullYear();
655 #ifdef METRICS_ENABLED
656 gMetrics.metricsInc(
"newReleases",
"browse.view.date",
"");
658 while (releases.hasMoreElements()) {
659 if (this.abortDrawing)
661 var release = releases.getNext().wrappedJSObject;
663 var thisDateObj =
new Date();
664 thisDateObj.setTime(release.ts);
665 var thisMon = thisDateObj.getMonth();
666 var thisYear = thisDateObj.getFullYear();
667 var thisIndex = thisMon +
"" + thisYear;
668 var thisDate = thisYear +
'-' + thisMon +
'-' + thisDateObj.getDate();
671 if (((thisMon < todayMon) && (thisYear <= todayYear)) ||
672 (thisMon == todayMon && thisDateObj.getDate() < todayDate)) {
676 var doc = this._browseDoc;
677 var dateIndex = doc.getElementById(
"newReleases-nav-date-" + thisIndex);
678 if (dateIndex ==
null) {
681 dateIndex.className +=
" newReleases-nav-date-link";
682 dateIndex.addEventListener(
"mouseover",
function(e)
684 var el = e.currentTarget;
685 el.className +=
" newReleases-nav-hover";
687 dateIndex.addEventListener(
"mouseout",
function(e)
689 var el = e.currentTarget;
690 el.className = el.className.replace(
" newReleases-nav-hover",
"");
692 dateIndex.addEventListener(
"click", NewReleaseAlbum.indexJump,
false);
694 if (thisDate != lastDate) {
696 var dateDiv = this.createBlock(
"indexDiv");
699 var dateIndexContainer = this.createDateBlock(thisDateObj);
702 dateBlock = this.createBlock(
"releaseListing");
703 dateBlock.className +=
" releaseListingDate";
706 var releaseTableBlock = this.createBlock(
"artistBlock");
709 releaseTable = this.createTableDateView();
710 releaseTableBlock.appendChild(releaseTable);
713 dateBlock.appendChild(releaseTableBlock);
714 dateDiv.appendChild(dateIndexContainer);
715 dateDiv.appendChild(dateBlock);
716 contentsNode.appendChild(dateDiv);
721 var thisRelease = this.createRowDateView(release);
722 releaseTable.appendChild(thisRelease);
728 if (newReleasesShown == 0) {
729 if (
Application.prefs.getValue(
"extensions.newreleases.networkfailure",
731 NewReleaseAlbum.showTimeoutError();
733 NewReleaseAlbum.showNoNewReleases();
736 return newReleasesShown;
739 NewReleaseAlbum.browseByArtists =
function() {
742 var releaseBlock =
null;
743 var artistReleaseBlock =
null;
744 var thisMainArtistAnchor =
null;
747 var othersLetterDiv =
null;
749 var releases = this.nrSvc.artistReleaseEnumerator(
750 this.filterLibraryArtists, this.pCountry);
752 var newReleasesShown = 0;
754 var contentsNode = this._browseDoc.createElement(
"div");
755 contentsNode.id =
"releases-contents";
756 this._bodyNode.appendChild(contentsNode);
758 var today =
new Date();
759 var todayMon = today.getMonth();
760 var todayDate = today.getDate();
761 var todayYear = today.getFullYear();
763 #ifdef METRICS_ENABLED
764 gMetrics.metricsInc(
"newReleases",
"browse.view.artist",
"");
766 while (releases.hasMoreElements()) {
767 if (this.abortDrawing)
770 var release = releases.getNext().wrappedJSObject;
772 var thisDateObj =
new Date();
773 thisDateObj.setTime(release.ts);
774 var thisMon = thisDateObj.getMonth();
775 var thisYear = thisDateObj.getFullYear();
776 var thisIndex = thisMon +
"" + thisYear;
777 var thisDate = thisYear +
'-' + thisMon +
'-' + thisDateObj.getDate();
780 if (((thisMon < todayMon) && (thisYear <= todayYear)) ||
781 (thisMon == todayMon && thisDateObj.getDate() < todayDate))
785 var thisLetter = release.artistname[0].toUpperCase();
786 if (thisLetter < 'A' || thisLetter >
'Z')
789 var doc = this._browseDoc;
790 var letterIdx = doc.getElementById(
"newReleases-nav-letter-" + thisLetter);
791 if (letterIdx ==
null) {
794 letterIdx.className +=
" newReleases-nav-letter-link";
795 letterIdx.addEventListener(
"mouseover",
function(e)
797 var el = e.currentTarget;
798 el.className +=
" newReleases-nav-hover";
800 letterIdx.addEventListener(
"mouseout",
function(e)
802 var el = e.currentTarget;
803 el.className = el.className.replace(
" newReleases-nav-hover",
"");
805 letterIdx.addEventListener(
"click", NewReleaseAlbum.indexJump,
false);
807 if (thisLetter != lastLetter) {
809 var letterDiv = this.createBlock(
"indexDiv");
812 var letterIndexContainer = this.createLetterBlock(thisLetter);
815 releaseBlock = this.createBlock(
"releaseListing");
816 releaseBlock.className +=
" releaseListingLetter";
819 letterDiv.appendChild(letterIndexContainer);
820 letterDiv.appendChild(releaseBlock);
822 if (thisLetter !=
'#')
823 contentsNode.appendChild(letterDiv);
830 othersLetterDiv = letterDiv;
836 if (release.artistname != lastArtist) {
838 var artistBlock = this.createBlock(
"artistBlock");
841 var artistName = this.createBlock(
"mainArtistName",
true);
842 thisMainArtistAnchor = this._browseDoc.createElement(
"a");
843 var url =
"http://www.allmusic.com/cg/amg.dll?P=amg&opt1=1&sql=" + escape(release.artistname);
844 this.makeLink(thisMainArtistAnchor, url,
"artist.main");
846 this._browseDoc.createTextNode(release.artistname);
847 thisMainArtistAnchor.appendChild(artistNameText);
848 artistName.appendChild(thisMainArtistAnchor);
849 artistBlock.appendChild(artistName);
851 if (release.libartist == 1 &&
this.showPlayLink) {
853 var playBlock = this.createBlock(
"playBlock",
true);
854 var playLink = this._browseDoc.createElement(
"img");
855 playLink.className =
"ticketImage";
856 playLink.src =
"chrome://newreleases/skin/icon-play.png";
857 playBlock.className =
"playLink";
858 playBlock.appendChild(playLink);
859 playBlock.setAttribute(
"artistName", release.artistname);
860 playBlock.addEventListener(
"click", this.playArtist,
false);
861 artistBlock.appendChild(playBlock);
865 artistReleaseBlock = this.createTableArtistView();
866 artistBlock.appendChild(artistReleaseBlock);
869 releaseBlock.appendChild(artistBlock);
873 var thisRelease = this.createRowArtistView(release,
874 thisMainArtistAnchor);
875 artistReleaseBlock.appendChild(thisRelease);
877 lastLetter = thisLetter;
878 lastArtist = release.artistname;
883 if (othersLetterDiv !=
null)
884 contentsNode.appendChild(othersLetterDiv);
886 if (newReleasesShown == 0) {
887 if (
Application.prefs.getValue(
"extensions.newreleases.networkfailure",
889 NewReleaseAlbum.showTimeoutError();
891 NewReleaseAlbum.showNoNewReleases();
894 return newReleasesShown;
898 NewReleaseAlbum.createLetterBlock =
function(letter) {
900 var letterIndexContainer = this.createBlock(
"letterIndexContainer");
901 var letterIndex = this.createBlock(
"letterIndex");
902 letterIndex.id =
"indexLetter-" + letter;
903 var letterIndexText = this._browseDoc.createTextNode(letter);
904 letterIndex.appendChild(letterIndexText);
905 letterIndexContainer.appendChild(letterIndex);
906 return (letterIndexContainer);
910 NewReleaseAlbum.createDateBlock =
function(dateObj) {
911 var dateIndexContainer = this.createBlock(
"dateIndexContainer");
912 var boxBlock = this.createBlock(
"dateIndex-box");
913 var
month = this.createBlock(
"dateIndex-month");
914 var
date = this.createBlock(
"dateIndex-date");
915 var
day = this.createBlock(
"dateIndex-day");
916 dateIndexContainer.id =
"indexDate-" + dateObj.getMonth() +
917 dateObj.getFullYear();
919 this._browseDoc.createTextNode(dateObj.toLocaleFormat(
"%b"));
920 var
dateText = this._browseDoc.createTextNode(dateObj.toLocaleFormat(
"%d"));
921 var dayText = this._browseDoc.createTextNode(dateObj.toLocaleFormat(
"%a"));
922 month.appendChild(monthText);
923 day.appendChild(dayText);
924 date.appendChild(dateText);
925 boxBlock.appendChild(month);
926 boxBlock.appendChild(date);
927 dateIndexContainer.appendChild(boxBlock);
928 dateIndexContainer.appendChild(day);
929 return (dateIndexContainer);
936 NewReleaseAlbum.createTableArtistView =
function() {
937 var table = this.createTable();
938 var headerRow = this._browseDoc.createElement(
"tr");
939 var dateCol = this.createTableHeader(
"tableHeaderDate",
"date");
940 var titleCol = this.createTableHeader(
"tableHeaderTitle",
"title");
941 var labelCol = this.createTableHeader(
"tableHeaderLabel",
"label");
942 var countryCol = this.createTableHeader(
"tableHeaderCountry",
"country");
943 var typeCol = this.createTableHeader(
"tableHeaderType",
"type");
944 var tracksCol = this.createTableHeader(
"tableHeaderTracks",
"tracks");
945 var gCalCol = this.createTableHeader(
"tableHeaderGCal",
"gcal");
946 headerRow.appendChild(dateCol);
947 headerRow.appendChild(titleCol);
948 headerRow.appendChild(labelCol);
950 headerRow.appendChild(countryCol);
951 if (this.showExtendedInfo)
953 headerRow.appendChild(typeCol);
954 headerRow.appendChild(tracksCol);
957 headerRow.appendChild(gCalCol);
958 table.appendChild(headerRow);
962 NewReleaseAlbum.createTableDateView =
function() {
963 var table = this.createTable();
964 var headerRow = this._browseDoc.createElement(
"tr");
965 var artistCol = this.createTableHeader(
"tableHeaderArtist",
"artist");
966 var titleCol = this.createTableHeader(
"tableHeaderTitle",
"title");
967 var labelCol = this.createTableHeader(
"tableHeaderLabel",
"label");
968 var countryCol = this.createTableHeader(
"tableHeaderCountry",
"country");
969 var typeCol = this.createTableHeader(
"tableHeaderType",
"type");
970 var tracksCol = this.createTableHeader(
"tableHeaderTracks",
"tracks");
971 var gCalCol = this.createTableHeader(
"tableHeaderGCal",
"gcal");
972 headerRow.appendChild(artistCol);
973 headerRow.appendChild(titleCol);
974 headerRow.appendChild(labelCol);
976 headerRow.appendChild(countryCol);
977 if (this.showExtendedInfo)
979 headerRow.appendChild(typeCol);
980 headerRow.appendChild(tracksCol);
983 headerRow.appendChild(gCalCol);
984 table.appendChild(headerRow);
988 NewReleaseAlbum.createTable =
function() {
989 var table = this._browseDoc.createElement(
"table");
990 table.setAttribute(
"cellpadding",
"0");
991 table.setAttribute(
"cellspacing",
"0");
992 table.setAttribute(
"border",
"0");
998 NewReleaseAlbum.createTableHeader =
function(
str,
className) {
999 var col = this._browseDoc.createElement(
"th");
1001 if (str ==
"tableHeaderTickets" || this._strings.getString(str) ==
"")
1002 col.innerHTML =
" ";
1005 this._browseDoc.createTextNode(
this._strings.getString(str));
1006 col.appendChild(colLabel);
1014 NewReleaseAlbum.createRowArtistView =
function(release, mainAnchor) {
1015 var row = this._browseDoc.createElement(
"tr");
1016 var dateCol = this.createColumnDate(release);
1017 var titleCol = this.createColumnTitle(release);
1018 var labelCol = this.createColumnLabel(release);
1019 var countryCol = this.createColumnCountry(release);
1020 var typeCol = this.createColumnType(release);
1021 var tracksCol = this.createColumnTracks(release);
1022 var gcalCol = this.createColumnGCal(release);
1024 row.appendChild(dateCol);
1025 row.appendChild(titleCol);
1026 row.appendChild(labelCol);
1028 row.appendChild(countryCol);
1030 if (this.showExtendedInfo)
1032 row.appendChild(typeCol);
1033 row.appendChild(tracksCol);
1036 row.appendChild(gcalCol);
1040 NewReleaseAlbum.createRowDateView =
function(release) {
1041 var row = this._browseDoc.createElement(
"tr");
1042 var artistCol = this.createColumnArtist(release);
1043 var titleCol = this.createColumnTitle(release);
1044 var labelCol = this.createColumnLabel(release);
1045 var countryCol = this.createColumnCountry(release);
1046 var typeCol = this.createColumnType(release);
1047 var tracksCol = this.createColumnTracks(release);
1048 var gcalCol = this.createColumnGCal(release);
1050 row.appendChild(artistCol);
1051 row.appendChild(titleCol);
1052 row.appendChild(labelCol);
1054 row.appendChild(countryCol);
1055 if (this.showExtendedInfo)
1057 row.appendChild(typeCol);
1058 row.appendChild(tracksCol);
1061 row.appendChild(gcalCol);
1069 NewReleaseAlbum.openAndReport =
function(e) {
1070 #ifdef METRICS_ENABLED
1072 gMetrics.metricsInc(
"newReleases",
"browse.link." + metric,
"");
1074 gBrowser.loadOneTab(this.
href);
1078 NewReleaseAlbum.makeLink =
function(el,
url, metric) {
1080 el.setAttribute(
"metric-key", metric);
1081 el.addEventListener(
"click", this.openAndReport,
true);
1085 NewReleaseAlbum.appendPartnerParam =
function(
url) {
1086 return (url +
"?p=21");
1093 NewReleaseAlbum.createColumnDate =
function(release) {
1094 var dateCol = this._browseDoc.createElement(
"td");
1095 dateCol.className =
"date";
1096 var dateObj =
new Date();
1097 dateObj.setTime(release.ts);
1098 var dateStr = dateObj.toLocaleFormat(this.dateFormat);
1099 var dateColLabel = this._browseDoc.createTextNode(dateStr);
1100 dateCol.appendChild(dateColLabel);
1104 NewReleaseAlbum.createColumnTitle =
function(release) {
1105 var titleCol = this._browseDoc.createElement(
"td");
1106 titleCol.className =
"title";
1107 var anchor = this._browseDoc.createElement(
"a");
1108 var url =
"http://www.allmusic.com/cg/amg.dll?P=amg&opt1=2&sql=" +
1109 escape(release.title);
1110 this.makeLink(anchor, url,
"title");
1111 var titleColLabel = this._browseDoc.createTextNode(release.title);
1112 anchor.appendChild(titleColLabel);
1113 titleCol.appendChild(anchor);
1117 NewReleaseAlbum.createColumnLabel =
function(release) {
1118 var labelCol = this._browseDoc.createElement(
"td");
1119 labelCol.className =
"label";
1120 var anchor = this._browseDoc.createElement(
"a");
1121 var url =
"http://www.allmusic.com/cg/amg.dll?P=amg&opt1=5&sql=" +
1122 release.label.replace(/ /g,
"+");
1123 this.makeLink(anchor, url,
"label");
1124 var labelColLabel = this._browseDoc.createTextNode(release.label);
1125 anchor.appendChild(labelColLabel);
1126 labelCol.appendChild(anchor);
1130 NewReleaseAlbum.createColumnCountry =
function(release) {
1131 var countryCol = this._browseDoc.createElement(
"td");
1132 countryCol.className =
"country";
1133 var countryColLabel = this._browseDoc.createTextNode(release.country);
1134 countryCol.appendChild(countryColLabel);
1135 return (countryCol);
1138 NewReleaseAlbum.createColumnType =
function(release) {
1139 var typeCol = this._browseDoc.createElement(
"td");
1140 typeCol.className =
"type";
1141 var typeColLabel = this._browseDoc.createTextNode(release.type);
1142 typeCol.appendChild(typeColLabel);
1146 NewReleaseAlbum.createColumnTracks =
function(release) {
1147 var tracksCol = this._browseDoc.createElement(
"td");
1148 tracksCol.className =
"tracks";
1149 var tracksColLabel = this._browseDoc.createTextNode(release.tracks);
1150 tracksCol.appendChild(tracksColLabel);
1154 NewReleaseAlbum.createColumnGCal =
function(release) {
1155 var dateObj =
new Date(release.ts*1000);
1156 var dateStr = dateObj.toLocaleFormat(
"%Y%m%d");
1157 var url =
"http://www.google.com/calendar/event?action=TEMPLATE";
1158 url +=
"&text=" + escape(release.title);
1160 url += escape(release.artistname) +
",";
1162 url = url.substr(0, url.length-1);
1163 url +=
"&dates=" + dateStr +
"/" +
dateStr;
1165 var gCalLinkCol = this._browseDoc.createElement(
"td");
1166 gCalLinkCol.className =
"gcal";
1167 var gCalLink = this._browseDoc.createElement(
"a");
1168 this.makeLink(gCalLink, url,
"gcal");
1169 gCalLink.setAttribute(
"title", this._strings.getString(
"tableGCalTooltip"));
1171 var gCalImage = this._browseDoc.createElement(
"img");
1172 gCalImage.src =
"chrome://newreleases/skin/gcal.png";
1173 gCalImage.className =
"gcalImage";
1174 gCalLink.appendChild(gCalImage);
1176 gCalLinkCol.appendChild(gCalLink);
1178 return (gCalLinkCol);
1181 NewReleaseAlbum.createColumnArtist =
function(release) {
1182 var artistCol = this._browseDoc.createElement(
"td");
1183 artistCol.className =
"artist";
1184 var anchor = this._browseDoc.createElement(
"a");
1185 var url =
"http://www.allmusic.com/cg/amg.dll?P=amg&opt1=1&sql=" +
1186 escape(release.artistname);
1187 this.makeLink(anchor, url,
"artistname");
1188 var artistColLabel =
1189 this._browseDoc.createTextNode(release.artistname);
1190 anchor.appendChild(artistColLabel);
1191 artistCol.appendChild(anchor);
1196 NewReleaseAlbum.createBlock =
function(blockname, makeSpan) {
1199 var block = this._browseDoc.createElement(
"span");
1201 var block = this._browseDoc.createElement(
"div");
1202 block.className=blockname;
1207 NewReleaseAlbum.changeFilter =
function(updateCheckbox) {
1208 this.filterLibraryArtists = !this.filterLibraryArtists;
1209 Application.prefs.setValue(
"extensions.newreleases.filterLibraryArtists",
1210 this.filterLibraryArtists);
1211 #ifdef METRICS_ENABLED
1212 if (this.filterLibraryArtists)
1213 gMetrics.metricsInc(
"newReleases",
"filter.library",
"");
1215 gMetrics.metricsInc(
"newReleases",
"filter.all",
"");
1221 if (updateCheckbox) {
1222 var checkbox = document.getElementById(
"checkbox-library-artists");
1223 checkbox.setAttribute(
"checked", this.filterLibraryArtists);
1227 if (this.nrSvc.drawingLock) {
1229 this.abortDrawing =
true;
1232 this.blockAndBrowseReleases(
this);
1234 this.browseNewReleases(
this);
1238 NewReleaseAlbum.groupBy =
function(
group) {
1241 if (this.nrSvc.drawingLock) {
1243 this.abortDrawing =
true;
1246 this.blockAndBrowseReleases(
this);
1248 this.browseNewReleases(
this);
1253 NewReleaseAlbum.blockAndBrowseReleases =
function blockAndBrowseReleases(ct) {
1254 if (Cc[
"@songbirdnest.com/newreleases;1"]
1255 .
getService(Ci.nsIClassInfo).wrappedJSObject.drawingLock)
1257 setTimeout(
function() { blockAndBrowseReleases(ct);}, 100);
1259 ct.browseNewReleases(ct);
_dialogDatepicker dateText
sbOSDControlService prototype className
function doc() browser.contentDocument
getService(Ci.sbIFaceplateManager)
return elem filter &&elem filter indexOf("opacity=")>=0?(parseFloat(elem.filter.match(/opacity
this _contentSandbox label
aWindow setTimeout(function(){_this.restoreHistory(aWindow, aTabs, aTabData, aIdMap);}, 0)
function SBStringBundle(aBundle)
return aWindow document documentElement getAttribute(aAttribute)||dimension
_getSelectedPageStyle s i