27 Components.utils.import(
"resource://app/jsmodules/sbSmartMediaListColumnSpecUpdater.jsm");
30 Ci.sbILocalDatabaseSmartMediaList;
32 var
SB_NS =
"http://songbirdnest.com/data/1.0#";
43 property: SB_NS +
"albumName",
48 property: SB_NS +
"artistName",
53 property: SB_NS +
"genre",
58 property: SB_NS +
"trackName",
63 property: SB_NS +
"rating",
68 property: SB_NS +
"rating",
73 property: SB_NS +
"lastPlayTime",
77 value:
"least_recent",
78 property: SB_NS +
"lastPlayTime",
83 property: SB_NS +
"playCount",
88 property: SB_NS +
"playCount",
93 property: SB_NS +
"created",
98 property: SB_NS +
"created",
104 var
dialog = document.documentElement;
105 var ok = dialog.getButton(
"accept");
110 var
check = document.getElementById(
"smart_match_check");
111 var checkwhat = document.getElementById(
"smart_any_list");
112 var following = document.getElementById(
"smart_following_label");
114 var smartConditions = document.getElementById(
"smart_conditions");
115 var conditions = smartConditions.conditions;
117 if (conditions.length == 1) {
118 check.setAttribute(
"label", check.getAttribute(
"labelsingle"));
119 checkwhat.hidden =
true;
120 following.hidden =
true;
122 check.setAttribute(
"label", check.getAttribute(
"labelmultiple"));
123 checkwhat.hidden =
false;
124 following.hidden =
false;
146 var smartConditions = document.getElementById(
"smart_conditions");
147 smartConditions.addEventListener(
"input",
onUserInput,
false);
148 smartConditions.addEventListener(
"select",
onUserInput,
false);
149 smartConditions.addEventListener(
"additem",
onAddCondition,
false);
152 var
limit = document.getElementById(
"smart_songs_count");
153 limit.addEventListener(
"blur",
onLimitBlur,
false);
158 var smartConditions = document.getElementById(
"smart_conditions");
159 smartConditions.removeEventListener(
"input",
onUserInput,
false);
160 smartConditions.removeEventListener(
"select",
onUserInput,
false);
161 smartConditions.removeEventListener(
"additem",
onAddCondition,
false);
164 var
limit = document.getElementById(
"smart_songs_count");
165 limit.removeEventListener(
"blur",
onLimitBlur,
false);
170 var list =
window.arguments[0];
172 if (list instanceof sbILocalDatabaseSmartMediaList) {
175 var smartConditions = document.getElementById(
"smart_conditions");
176 if (list.conditionCount > 0) {
178 for (var
i = 0;
i < list.conditionCount;
i++) {
179 var condition = list.getConditionAt(
i);
181 metadata: condition.propertyID,
182 condition: condition.operator.operator,
183 value: condition.leftValue,
184 value2: condition.rightValue,
185 unit: condition.displayUnit,
187 source: list.sourceLibraryGuid
190 smartConditions.conditions = conditions;
193 smartConditions.newCondition();
197 var matchSomething = document.getElementById(
"smart_match_check");
198 var matchAnyAll = document.getElementById(
"smart_any_list");
199 switch(list.matchType) {
200 case sbILocalDatabaseSmartMediaList.MATCH_TYPE_ANY:
201 matchAnyAll.value =
"any";
202 matchSomething.checked =
true;
204 case sbILocalDatabaseSmartMediaList.MATCH_TYPE_ALL:
205 matchAnyAll.value =
"all";
206 matchSomething.checked =
true;
208 case sbILocalDatabaseSmartMediaList.MATCH_TYPE_NONE:
209 matchAnyAll.value =
"any";
210 matchSomething.checked =
false;
215 var uiLimitType = list.getProperty(SB_PROPERTY_UILIMITTYPE) ||
"songs";
220 var
limit = document.getElementById(
"smart_songs_check");
221 var
count = document.getElementById(
"smart_songs_count");
222 var limitType = document.getElementById(
"smart_songs_list");
223 if (list.limitType == sbILocalDatabaseSmartMediaList.LIMIT_TYPE_NONE) {
224 limit.checked =
false;
226 limitType.value =
"songs";
229 var mismatch =
false;
230 switch(uiLimitType) {
232 if (list.limitType != sbILocalDatabaseSmartMediaList.LIMIT_TYPE_ITEMS) {
236 count.value = list.limit;
239 if (list.limitType != sbILocalDatabaseSmartMediaList.LIMIT_TYPE_USECS) {
246 if (list.limitType != sbILocalDatabaseSmartMediaList.LIMIT_TYPE_USECS) {
253 if (list.limitType != sbILocalDatabaseSmartMediaList.LIMIT_TYPE_BYTES) {
260 if (list.limitType != sbILocalDatabaseSmartMediaList.LIMIT_TYPE_BYTES) {
268 limit.checked =
false;
270 limitType.value =
"songs";
273 limit.checked =
true;
274 limitType.value = uiLimitType;
279 var selectBy = document.getElementById(
"smart_selected_list");
280 if (list.randomSelection) {
281 selectBy.value =
"random";
285 selectBy.value =
value;
289 var autoUpdate = document.getElementById(
"smart_autoupdate_check");
291 list.autoUpdate ==
true;
297 var smartConditions = document.getElementById(
"smart_conditions");
299 smartConditions.newCondition();
301 var matchSomething = document.getElementById(
"smart_match_check");
302 var matchAnyAll = document.getElementById(
"smart_any_list");
304 matchAnyAll.value =
"all";
305 matchSomething.checked =
true;
307 var
limit = document.getElementById(
"smart_songs_check");
308 var
count = document.getElementById(
"smart_songs_count");
309 var limitType = document.getElementById(
"smart_songs_list");
311 limit.checked =
false;
313 limitType.value =
"songs";
315 var selectBy = document.getElementById(
"smart_selected_list");
316 selectBy.value =
"artist";
318 var autoUpdate = document.getElementById(
"smart_autoupdate_check");
319 autoUpdate.checked =
true;
329 var smartConditions = document.getElementById(
"smart_conditions");
330 var
check = document.getElementById(
"smart_match_check");
331 var check_limit = document.getElementById(
"smart_songs_check");
332 var
count = document.getElementById(
"smart_songs_count");
333 var check_match = document.getElementById(
"smart_match_check");
334 return ((smartConditions.isValid || !check.checked) &&
335 (!check_limit.checked || parseInt(count.value) > 0) &&
336 (check_limit.checked || check_match.checked));
345 var smart_conditions = document.getElementById(
"smart_conditions");
346 var conditions = smart_conditions.conditions;
347 var
check = document.getElementById(
"smart_match_check");
359 var list =
window.arguments[0];
360 var paramObject =
null;
361 var newSmartPlaylist =
null;
362 if (!(list instanceof sbILocalDatabaseSmartMediaList)) {
368 if (paramObject.newSmartPlaylist)
369 list = paramObject.newSmartPlaylist;
371 list = paramObject.newPlaylistFunction();
372 newSmartPlaylist = list;
384 if (!success && newSmartPlaylist) {
385 newSmartPlaylist.library.remove(newSmartPlaylist);
386 newSmartPlaylist =
null;
391 paramObject.newSmartPlaylist = newSmartPlaylist;
399 .classes[
"@songbirdnest.com/Songbird/Properties/PropertyManager;1"]
400 .getService(
Ci.sbIPropertyManager);
403 var smart_conditions = document.getElementById(
"smart_conditions");
404 var conditions = smart_conditions.conditions;
406 list.clearConditions();
407 var
check = document.getElementById(
"smart_match_check");
409 conditions.forEach(
function(condition) {
410 var info = pm.getPropertyInfo(condition.metadata);
414 info.QueryInterface(
Ci.sbIDatetimePropertyInfo);
417 info.QueryInterface(
Ci.sbIBooleanPropertyInfo);
420 var op = info.getOperator(condition.condition);
424 if (op.operator != info.OPERATOR_ISTRUE &&
425 op.operator != info.OPERATOR_ISFALSE &&
426 op.operator != info.OPERATOR_ISSET &&
427 op.operator != info.OPERATOR_ISNOTSET)
428 leftValue = condition.value;
429 if (op.operator == info.OPERATOR_BETWEEN ||
430 op.operator == info.OPERATOR_BETWEENDATES)
431 rightValue = condition.value2;
432 if (condition.useunits)
433 unit = condition.unit;
434 list.appendCondition(condition.metadata,
443 var matchSomething = document.getElementById(
"smart_match_check");
444 var matchAnyAll = document.getElementById(
"smart_any_list");
445 if (matchSomething.checked) {
446 if (matchAnyAll.value ==
"all") {
447 list.matchType = sbILocalDatabaseSmartMediaList.MATCH_TYPE_ALL;
450 list.matchType = sbILocalDatabaseSmartMediaList.MATCH_TYPE_ANY;
454 list.matchType = sbILocalDatabaseSmartMediaList.MATCH_TYPE_NONE;
458 var
limit = document.getElementById(
"smart_songs_check");
459 var
count = document.getElementById(
"smart_songs_count");
460 var limitType = document.getElementById(
"smart_songs_list");
462 list.setProperty(SB_PROPERTY_UILIMITTYPE, limitType.value);
465 switch(limitType.value) {
467 list.limitType = sbILocalDatabaseSmartMediaList.LIMIT_TYPE_ITEMS;
468 list.limit = count.value;
471 list.limitType = sbILocalDatabaseSmartMediaList.LIMIT_TYPE_USECS;
475 list.limitType = sbILocalDatabaseSmartMediaList.LIMIT_TYPE_USECS;
479 list.limitType = sbILocalDatabaseSmartMediaList.LIMIT_TYPE_BYTES;
483 list.limitType = sbILocalDatabaseSmartMediaList.LIMIT_TYPE_BYTES;
489 list.limitType = sbILocalDatabaseSmartMediaList.LIMIT_TYPE_NONE;
494 var selectBy = document.getElementById(
"smart_selected_list");
495 if (selectBy.value ==
"random") {
496 list.randomSelection =
true;
497 list.selectPropertyID =
"";
500 list.randomSelection =
false;
504 var autoUpdate = document.getElementById(
"smart_autoupdate_check");
505 list.autoUpdate = autoUpdate.checked;
507 SmartMediaListColumnSpecUpdater.update(list);
521 selectByList.forEach(
function(e) {
522 if (e.property == list.selectPropertyID &&
523 e.direction == list.selectDirection) {
535 selectByList.forEach(
function(e) {
536 if (e.value ==
value) {
537 list.selectPropertyID = e.property;
538 list.selectDirection = e.direction;
553 var check_limit = document.getElementById(
"smart_songs_check");
554 if (check_limit.checked) {
565 var selectBy = document.getElementById(
"smart_selected_list");
566 var
limit = document.getElementById(
"smart_songs_check");
567 var autoUpdate = document.getElementById(
"smart_autoupdate_check");
569 selectBy.value ==
"random") {
570 autoUpdate.checked =
false;
571 autoUpdate.disabled =
true;
573 autoUpdate.removeAttribute(
"disabled");
578 var pm = Components.classes[
"@songbirdnest.com/Songbird/Properties/PropertyManager;1"]
579 .getService(
Ci.sbIPropertyManager);
580 var firstFailure = -1;
581 for (var
i=0;
i<aConditions.length;
i++) {
582 var condition = aConditions[
i];
583 var info = pm.getPropertyInfo(condition.metadata)
584 if (condition.condition == info.OPERATOR_CONTAINS ||
585 condition.condition == info.OPERATOR_NOTCONTAINS ||
586 condition.condition == info.OPERATOR_BEGINSWITH ||
587 condition.condition == info.OPERATOR_NOTBEGINSWITH ||
588 condition.condition == info.OPERATOR_ENDSWITH ||
589 condition.condition == info.OPERATOR_NOTENDSWITH) {
590 if (!condition.value) {
591 aConditionsDrawer.makeInvalid(
i);
592 if (firstFailure == -1)
597 if (firstFailure != -1) {
598 aConditionsDrawer.focusInput(firstFailure);
609 var
limit = document.getElementById(
"smart_songs_count");
626 limit.value = Math.min(limit.value, 99999999999999);
627 limit.value = Math.max(limit.value, 0);
function onCheckLimit(evt)
function updateMatchControls()
var SB_PROPERTY_UILIMITTYPE
function configureList(list)
function getValueForSelectBy(list)
function onRemoveCondition()
function onSelectSelectedBy(evt)
function isConfigurationValid()
aWindow setTimeout(function(){_this.restoreHistory(aWindow, aTabs, aTabData, aIdMap);}, 0)
function onAddCondition()
function updateOkButton()
function onCheckMatch(evt)
function testAdditionalRestrictions(aConditions, aConditionsDrawer)
function checkIfCanAutoUpdate()
function onLimitBlur(evt)
_getSelectedPageStyle s i
function loadConditions()
function setSelectBy(list, value)