faceplate.js
Go to the documentation of this file.
1 if (typeof(Cu) == "undefined")
2  var Cu = Components.utils;
3 
4 Cu.import("resource://app/jsmodules/SBDataRemoteUtils.jsm");
5 
6 function LFFPD(m) {
7  dump('last.fm faceplate debug: '+m+'\n');
8 }
9 
11  'stationPref': null,
12 };
13 
15  //LFFPD('pref change!');
16  sbLastFmFaceplate.stationChanged();
17 }
19  //LFFPD('requesting more tracks pref change!');
20  sbLastFmFaceplate.requestChanged();
21 }
22 
23 sbLastFmFaceplate.init =
24 function sbLastFmFaceplate_init() {
25  var stationIcon = document.getElementById("lastfm-station-icon");
26  stationIcon.style.visibility = "collapse";
27  this.stationPref = Application.prefs.get('songbird.lastfm.radio.station');
28  this.stationPref.events.addListener('change',
30  this.requestPref = Application.prefs.get('songbird.lastfm.radio.requesting');
31  this.requestPref.events.addListener('change',
33 
34  this._service = Components.classes['@songbirdnest.com/lastfm;1']
35  .getService().wrappedJSObject
36  // catch the case of a Feather change
37  if (this._service.station_name && this._service.station_name != '') {
38  Application.prefs.setValue('songbird.lastfm.radio.station',
39  this._service.station_name);
40  }
41 
42  this._remotePreviousDisabled =
43  SB_NewDataRemote( "playlist.previous.disabled", null );
44  this._remoteNextDisabled =
45  SB_NewDataRemote( "playlist.next.disabled", null );
46  this._remoteShuffleDisabled =
47  SB_NewDataRemote( "playlist.shuffle.disabled", null );
48  this._remoteRepeatDisabled =
49  SB_NewDataRemote( "playlist.repeat.disabled", null );
50 
51 }
52 
53 sbLastFmFaceplate.fini =
54 function sbLastFmFaceplate_fini() {
55  this.stationPref.events.removeListener('change',
57  this.stationPref = null;
58  this.requestPref.events.removeListener('change',
60  this.requestPref = null;
61  Application.prefs.setValue('songbird.lastfm.radio.station', '');
62  Application.prefs.setValue('songbird.lastfm.radio.requesting', "0");
63 
64  if(this._remotePreviousDisabled) {
65  this._remotePreviousDisabled.unbind();
66  this._remotePreviousDisabled = null;
67  }
68  if(this._remoteNextDisabled) {
69  this._remoteNextDisabled.unbind();
70  this._remoteNextDisabled = null;
71  }
72  if(this._remoteShuffleDisabled) {
73  this._remoteShuffleDisabled.unbind();
74  this._remoteShuffleDisabled = null;
75  }
76  if(this._remoteRepeatDisabled) {
77  this._remoteRepeatDisabled.unbind();
78  this._remoteRepeatDisabled = null;
79  }
80 }
81 
82 sbLastFmFaceplate.stationChanged =
83 function sbLastFmFaceplate_stationChanged() {
84  LFFPD('stationChanged');
85  var stationIcon = document.getElementById("lastfm-station-icon");
86  if (this.stationPref.value == '') {
87  // hide the radio icon from the faceplate
88  stationIcon.style.visibility = "collapse";
89  } else {
90  // disable back, shuffle and repeat controls
91  this._remotePreviousDisabled.boolValue = true;
92  this._remoteShuffleDisabled.boolValue = true;
93  this._remoteRepeatDisabled.boolValue = true;
94 
95  // show the radio icon from the faceplate
96  stationIcon.style.visibility = "visible";
97  }
98 }
99 
100 
101 sbLastFmFaceplate.requestChanged =
102 function sbLastFmFaceplate_requestChanged() {
103  LFFPD('requestChanged');
104  if (this.requestPref.value == "1") {
105  // requesting more tracks, disable the next track button
106  this._remoteNextDisabled.boolValue = true;
107  } else {
108  // enable the next track button
109  this._remoteNextDisabled.boolValue = false;
110  }
111 }
112 
113 window.addEventListener('load', function () { sbLastFmFaceplate.init() ;}, false);
114 window.addEventListener('unload', function () { sbLastFmFaceplate.fini() ;}, false);
const Cu
var Application
Definition: sbAboutDRM.js:37
function sbLastFmFaceplate_stationPref_change()
Definition: faceplate.js:14
function LFFPD(m)
Definition: faceplate.js:6
let window
const SB_NewDataRemote
function sbLastFmFaceplate_requestPref_change()
Definition: faceplate.js:18
return null
Definition: FeedWriter.js:1143
var sbLastFmFaceplate
Definition: faceplate.js:10