49 if (typeof(
Cc) ==
"undefined")
50 var
Cc = Components.classes;
51 if (typeof(
Ci) ==
"undefined")
52 var
Ci = Components.interfaces;
53 if (typeof(
Cr) ==
"undefined")
54 var
Cr = Components.results;
55 if (typeof(
Cu) ==
"undefined")
56 var
Cu = Components.utils;
59 Cu.import(
"resource://app/jsmodules/sbTimeFormatter.jsm");
92 initialize:
function DCW__initialize(aWidget) {
94 this._widget = aWidget;
97 this._deviceLibrary = this._widget.devLib;
99 this._panel = this._getElement(
"capacity-panel");
100 this._label = this._getElement(
"panel-label");
108 finalize:
function DCW_finalize() {
111 this._deviceLibrary =
null;
118 openPopup:
function DCW_openPopup(anchor) {
119 var type = anchor.getAttribute(
"type");
121 DCW._panel.openPopup(anchor,
"after_start");
140 _getElement:
function DCW__getElement(aElementID) {
141 return document.getAnonymousElementByAttribute(this._widget,
158 _update:
function DCW__update(type) {
160 if (type !=
"music" && type !=
"video")
163 var playTimeProperty =
"http://songbirdnest.com/device/1.0#" +
164 type +
"TotalPlayTime";
165 var itemCountProperty =
"http://songbirdnest.com/device/1.0#" +
167 var playTime = parseInt(this._getDevLibProperty(playTimeProperty, -1));
168 var itemCount = parseInt(this._getDevLibProperty(itemCountProperty, -1));
169 if (playTime < 0 || itemCount < 0) {
170 this._label.value =
SBString(
"device.capacity.panel." + type +
".error");
172 var
key =
"device.capacity.panel." + type;
173 playTime = TimeFormatter.formatSingle(playTime/1000000);
176 [ playTime, itemCount ],
"");
200 _getDevLibProperty:
function DCW__getDevLibProperty(aPropertyName, aDefault) {
202 if (this._deviceLibrary)
203 return this._deviceLibrary.getProperty(aPropertyName);
function SBString(aKey, aDefault, aStringBundle)
function SBFormattedCountString(aKeyBase, aCount, aParams, aDefault, aStringBundle)