style(legacy): format files

This commit is contained in:
jo 2022-07-01 18:39:02 +02:00 committed by Kyle Robbertze
parent 4d393fa14e
commit 5e8f7d430f
4 changed files with 517 additions and 517 deletions

View File

@ -855,9 +855,9 @@ class Application_Form_SmartBlockCriteria extends Zend_Form_SubForm
if (in_array($d['sp_criteria_modifier'], ['before', 'after', 'between'])) { if (in_array($d['sp_criteria_modifier'], ['before', 'after', 'between'])) {
if (!preg_match('/^[1-9][0-9]*$|0/', $d['sp_criteria_value'])) { if (!preg_match('/^[1-9][0-9]*$|0/', $d['sp_criteria_value'])) {
$element->addError(_('Only non-negative integer numbers are allowed (e.g 1 or 5) for the text value')); $element->addError(_('Only non-negative integer numbers are allowed (e.g 1 or 5) for the text value'));
$isValid = false; // TODO validate this on numeric input with whatever parsing also do for extra
// TODO validate this on numeric input with whatever parsing also do for extra
// if the modifier is before ago or between we skip validation until we confirm format // if the modifier is before ago or between we skip validation until we confirm format
$isValid = false;
} elseif (isset($d['sp_criteria_datetime_select']) && $d['sp_criteria_datetime_select'] == '0') { } elseif (isset($d['sp_criteria_datetime_select']) && $d['sp_criteria_datetime_select'] == '0') {
$element->addError(_('You must select a time unit for a relative datetime.')); $element->addError(_('You must select a time unit for a relative datetime.'));
$isValid = false; $isValid = false;

View File

@ -1688,13 +1688,13 @@ SQL;
// need to pull in the current time and subtract the value or figure out how to make it relative // need to pull in the current time and subtract the value or figure out how to make it relative
$relativedate = new DateTime($spCriteriaValue); $relativedate = new DateTime($spCriteriaValue);
$dt = $relativedate->format(DateTime::ISO8601); $dt = $relativedate->format(DateTime::ISO8601);
// Logging::info($spCriteriaValue);
$spCriteriaValue = "{$spCriteria} <= '{$dt}'"; $spCriteriaValue = "{$spCriteria} <= '{$dt}'";
// Logging::info($spCriteriaValue);
} elseif ($spCriteriaModifier == 'after') { } elseif ($spCriteriaModifier == 'after') {
$relativedate = new DateTime($spCriteriaValue); $relativedate = new DateTime($spCriteriaValue);
$dt = $relativedate->format(DateTime::ISO8601); $dt = $relativedate->format(DateTime::ISO8601);
// Logging::info($spCriteriaValue);
$spCriteriaValue = "{$spCriteria} >= '{$dt}'"; $spCriteriaValue = "{$spCriteria} >= '{$dt}'";
// Logging::info($spCriteriaValue);
} elseif ($spCriteriaModifier == 'between') { } elseif ($spCriteriaModifier == 'between') {
$fromrelativedate = new DateTime($spCriteriaValue); $fromrelativedate = new DateTime($spCriteriaValue);
$fdt = $fromrelativedate->format(DateTime::ISO8601); $fdt = $fromrelativedate->format(DateTime::ISO8601);

File diff suppressed because it is too large Load Diff

View File

@ -1,4 +1,4 @@
$(document).ready(function() { $(document).ready(function () {
setSmartBlockEvents(); setSmartBlockEvents();
}); });
@ -7,7 +7,7 @@ function setSmartBlockEvents() {
form = activeTab.find('.smart-block-form'); form = activeTab.find('.smart-block-form');
/********** ADD CRITERIA ROW **********/ /********** ADD CRITERIA ROW **********/
form.find('#criteria_add').live('click', function(){ form.find('#criteria_add').live('click', function () {
var div = $('dd[id="sp_criteria-element"]').children('div:visible:last'); var div = $('dd[id="sp_criteria-element"]').children('div:visible:last');
@ -47,7 +47,7 @@ function setSmartBlockEvents() {
}); });
/********** ADD MODIFIER ROW **********/ /********** ADD MODIFIER ROW **********/
form.find('a[id^="modifier_add"]').live('click', function(){ form.find('a[id^="modifier_add"]').live('click', function () {
var criteria_value = $(this).siblings('select[name^="sp_criteria_field"]').val(); var criteria_value = $(this).siblings('select[name^="sp_criteria_field"]').val();
@ -95,7 +95,7 @@ function setSmartBlockEvents() {
}); });
/********** REMOVE ROW **********/ /********** REMOVE ROW **********/
form.find('a[id^="criteria_remove"]').live('click', function(){ form.find('a[id^="criteria_remove"]').live('click', function () {
var curr = $(this).parent(); var curr = $(this).parent();
var curr_pos = curr.index(); var curr_pos = curr.index();
var list = curr.parent(); var list = curr.parent();
@ -117,8 +117,8 @@ function setSmartBlockEvents() {
if (count == 0) { if (count == 0) {
disableAndHideDateTimeDropdown(curr.find(':first-child'), index); disableAndHideDateTimeDropdown(curr.find(':first-child'), index);
disableAndHideExtraDateTimeDropdown(curr.find(':first-child'),index); disableAndHideExtraDateTimeDropdown(curr.find(':first-child'), index);
disableAndHideExtraField(curr.find(':first-child'),index); disableAndHideExtraField(curr.find(':first-child'), index);
} }
/* assign next row to current row for all rows below and including /* assign next row to current row for all rows below and including
@ -126,7 +126,7 @@ function setSmartBlockEvents() {
*/ */
for (var i=0; i<count; i++) { for (var i = 0; i < count; i++) {
index = getRowIndex(curr); index = getRowIndex(curr);
var criteria = next.find('[name^="sp_criteria_field"]').val(); var criteria = next.find('[name^="sp_criteria_field"]').val();
@ -153,17 +153,17 @@ function setSmartBlockEvents() {
curr.find('[name^="sp_criteria_extra"]').val(criteria_extra); curr.find('[name^="sp_criteria_extra"]').val(criteria_extra);
disableAndHideExtraField(next.find(':first-child'), getRowIndex(next)); disableAndHideExtraField(next.find(':first-child'), getRowIndex(next));
/* if only the current row has the extra criteria value, /* if only the current row has the extra criteria value,
* then just remove the current row's extra criteria element * then just remove the current row's extra criteria element
*/ */
} else if (curr.find('[name^="sp_criteria_extra"]').attr("disabled") != "disabled" } else if (curr.find('[name^="sp_criteria_extra"]').attr("disabled") != "disabled"
&& next.find('#extra_criteria').not(':visible')) { && next.find('#extra_criteria').not(':visible')) {
disableAndHideExtraField(curr.find(':first-child'), index); disableAndHideExtraField(curr.find(':first-child'), index);
/* if only the next row has the extra criteria value, /* if only the next row has the extra criteria value,
* then add the extra criteria element to current row * then add the extra criteria element to current row
* and assign next row's value to it * and assign next row's value to it
*/ */
} else if (next.find('#extra_criteria').is(':visible')) { } else if (next.find('#extra_criteria').is(':visible')) {
criteria_extra = next.find('[name^="sp_criteria_extra"]').val(); criteria_extra = next.find('[name^="sp_criteria_extra"]').val();
enableAndShowExtraField(curr.find(':first-child'), index); enableAndShowExtraField(curr.find(':first-child'), index);
@ -250,11 +250,11 @@ function setSmartBlockEvents() {
item_to_hide.find('select[name^="sp_criteria_field"]').removeClass('sp-invisible'); item_to_hide.find('select[name^="sp_criteria_field"]').removeClass('sp-invisible');
} }
item_to_hide.find('[name^="sp_criteria_field"]').val(0).end() item_to_hide.find('[name^="sp_criteria_field"]').val(0).end()
.find('[name^="sp_criteria_modifier"]').val(0).end() .find('[name^="sp_criteria_modifier"]').val(0).end()
.find('[name^="sp_criteria_datetime_select"]').end() .find('[name^="sp_criteria_datetime_select"]').end()
.find('[name^="sp_criteria_value"]').val('').end() .find('[name^="sp_criteria_value"]').val('').end()
.find('[name^="sp_criteria_extra"]').val('') .find('[name^="sp_criteria_extra"]').val('')
.find('[name^="sp_criteria_extra_datetime_select"]').end(); .find('[name^="sp_criteria_extra_datetime_select"]').end();
sizeTextBoxes(item_to_hide.find('[name^="sp_criteria_value"]'), 'sp_extra_input_text', 'sp_input_text'); sizeTextBoxes(item_to_hide.find('[name^="sp_criteria_value"]'), 'sp_extra_input_text', 'sp_input_text');
item_to_hide.hide(); item_to_hide.hide();
@ -288,17 +288,17 @@ function setSmartBlockEvents() {
// moved to spl.js // moved to spl.js
/********** GENERATE ACTION **********/ /********** GENERATE ACTION **********/
activeTab.find('button[id="generate_button"]').live("click", function(){ activeTab.find('button[id="generate_button"]').live("click", function () {
buttonClickAction('generate', 'playlist/smart-block-generate'); buttonClickAction('generate', 'playlist/smart-block-generate');
}); });
/********** SHUFFLE ACTION **********/ /********** SHUFFLE ACTION **********/
activeTab.find('button[id="shuffle_button"]').live("click", function(){ activeTab.find('button[id="shuffle_button"]').live("click", function () {
buttonClickAction('shuffle', 'playlist/smart-block-shuffle'); buttonClickAction('shuffle', 'playlist/smart-block-shuffle');
}); });
/********** CHANGE PLAYLIST TYPE **********/ /********** CHANGE PLAYLIST TYPE **********/
form.find('dd[id="sp_type-element"]').live("change", function(){ form.find('dd[id="sp_type-element"]').live("change", function () {
//buttonClickAction('generate', 'playlist/empty-content'); //buttonClickAction('generate', 'playlist/empty-content');
$(".active-tab").find('button[id="save_button"]').click(); $(".active-tab").find('button[id="save_button"]').click();
setupUI(); setupUI();
@ -306,7 +306,7 @@ function setSmartBlockEvents() {
}); });
/********** LIMIT CHANGE *************/ /********** LIMIT CHANGE *************/
form.find('select[id="sp_limit_options"]').live("change", function() { form.find('select[id="sp_limit_options"]').live("change", function () {
var limVal = form.find('input[id="sp_limit_value"]'); var limVal = form.find('input[id="sp_limit_value"]');
if ($(this).val() === 'remaining') { if ($(this).val() === 'remaining') {
disableAndHideLimitValue(); disableAndHideLimitValue();
@ -317,19 +317,19 @@ function setSmartBlockEvents() {
}); });
/********** CRITERIA CHANGE **********/ /********** CRITERIA CHANGE **********/
form.find('select[id^="sp_criteria"]:not([id^="sp_criteria_modifier"]):not([id^="sp_criteria_datetime"]):not([id^="sp_criteria_extra_datetime"]):not([id^="sp_criteria_value"])').live("change", function(){ form.find('select[id^="sp_criteria"]:not([id^="sp_criteria_modifier"]):not([id^="sp_criteria_datetime"]):not([id^="sp_criteria_extra_datetime"]):not([id^="sp_criteria_value"])').live("change", function () {
var index = getRowIndex($(this).parent()); var index = getRowIndex($(this).parent());
//need to change the criteria value for any modifier rows //need to change the criteria value for any modifier rows
var critVal = $(this).val(); var critVal = $(this).val();
var divs = $(this).parent().nextAll(':visible'); var divs = $(this).parent().nextAll(':visible');
$.each(divs, function(i, div){ $.each(divs, function (i, div) {
var critSelect = $(div).children('select[id^="sp_criteria_field"]'); var critSelect = $(div).children('select[id^="sp_criteria_field"]');
if (critSelect.hasClass('sp-invisible')) { if (critSelect.hasClass('sp-invisible')) {
critSelect.val(critVal); critSelect.val(critVal);
/* If the select box is visible we know the modifier rows /* If the select box is visible we know the modifier rows
* have ended * have ended
*/ */
} else { } else {
return false; return false;
} }
@ -338,19 +338,19 @@ function setSmartBlockEvents() {
// disable extra field and hide the span // disable extra field and hide the span
disableAndHideExtraField($(this), index); disableAndHideExtraField($(this), index);
disableAndHideDateTimeDropdown($(this), index); disableAndHideDateTimeDropdown($(this), index);
disableAndHideExtraDateTimeDropdown($(this),index); disableAndHideExtraDateTimeDropdown($(this), index);
if ($( "#sp_criteria_field_" + index +" option:selected" ).val() === 'track_type') { if ($("#sp_criteria_field_" + index + " option:selected").val() === 'track_type') {
populateTracktypeSelect(this, false); populateTracktypeSelect(this, false);
} else { } else {
disableAndHideTracktypeDropdown($(this),index); disableAndHideTracktypeDropdown($(this), index);
populateModifierSelect(this, true); populateModifierSelect(this, true);
} }
}); });
/********** MODIFIER CHANGE **********/ /********** MODIFIER CHANGE **********/
form.find('select[id^="sp_criteria_modifier"]').live("change", function(){ form.find('select[id^="sp_criteria_modifier"]').live("change", function () {
var criteria_value = $(this).next(), var criteria_value = $(this).next(),
index_num = getRowIndex($(this).parent()); index_num = getRowIndex($(this).parent());
@ -360,7 +360,7 @@ function setSmartBlockEvents() {
} }
else { else {
disableAndHideDateTimeDropdown(criteria_value, index_num); disableAndHideDateTimeDropdown(criteria_value, index_num);
disableAndHideExtraDateTimeDropdown(criteria_value,index_num); disableAndHideExtraDateTimeDropdown(criteria_value, index_num);
} }
@ -371,16 +371,16 @@ function setSmartBlockEvents() {
} }
if ($(this).val().match('between')) { if ($(this).val().match('between')) {
enableAndShowExtraField(criteria_value, index_num); enableAndShowExtraField(criteria_value, index_num);
enableAndShowDateTimeDropdown(criteria_value,index_num); enableAndShowDateTimeDropdown(criteria_value, index_num);
enableAndShowExtraDateTimeDropdown(criteria_value,index_num); enableAndShowExtraDateTimeDropdown(criteria_value, index_num);
} }
else { else {
disableAndHideExtraDateTimeDropdown(criteria_value,index_num); disableAndHideExtraDateTimeDropdown(criteria_value, index_num);
} }
var get_crit_field = $(this).siblings(':first-child'); var get_crit_field = $(this).siblings(':first-child');
var crit_field = get_crit_field[0]["id"]; var crit_field = get_crit_field[0]["id"];
if ($( "#" + crit_field +" option:selected" ).val() === 'track_type') { if ($("#" + crit_field + " option:selected").val() === 'track_type') {
if ($(this).val() == "is" || $(this).val() == "is not") { if ($(this).val() == "is" || $(this).val() == "is not") {
enableAndShowTracktypeDropdown(criteria_value, index_num); enableAndShowTracktypeDropdown(criteria_value, index_num);
} else { } else {
@ -412,7 +412,7 @@ function getRowIndex(ele) {
*/ */
function appendModAddButton() { function appendModAddButton() {
var divs = $('.active-tab .smart-block-form').find('div select[name^="sp_criteria_modifier"]').parent(':visible'); var divs = $('.active-tab .smart-block-form').find('div select[name^="sp_criteria_modifier"]').parent(':visible');
$.each(divs, function(i, div){ $.each(divs, function (i, div) {
if (i > 0) { if (i > 0) {
/* If the criteria field is hidden we know it is a modifier row /* If the criteria field is hidden we know it is a modifier row
* and can hide the previous row's modifier add button * and can hide the previous row's modifier add button
@ -425,7 +425,7 @@ function appendModAddButton() {
} }
//always add modifier add button to the last row //always add modifier add button to the last row
if (i+1 == divs.length) { if (i + 1 == divs.length) {
$(div).find('a[id^="modifier_add"]').removeClass('sp-invisible'); $(div).find('a[id^="modifier_add"]').removeClass('sp-invisible');
} }
}); });
@ -443,7 +443,7 @@ function reindexElements() {
*/ */
$('.db-logic-label').text('').hide(); $('.db-logic-label').text('').hide();
$.each(divs, function(i, div){ $.each(divs, function (i, div) {
if (i > 0 && index < 26) { if (i > 0 && index < 26) {
/* If the current row's criteria field is hidden we know it is /* If the current row's criteria field is hidden we know it is
@ -462,32 +462,33 @@ function reindexElements() {
modIndex = 0; modIndex = 0;
} }
$(div).find('select[name^="sp_criteria_field"]').attr('name', 'sp_criteria_field_'+index+'_'+modIndex); $(div).find('select[name^="sp_criteria_field"]').attr('name', 'sp_criteria_field_' + index + '_' + modIndex);
$(div).find('select[name^="sp_criteria_field"]').attr('id', 'sp_criteria_field_'+index+'_'+modIndex); $(div).find('select[name^="sp_criteria_field"]').attr('id', 'sp_criteria_field_' + index + '_' + modIndex);
$(div).find('select[name^="sp_criteria_modifier"]').attr('name', 'sp_criteria_modifier_'+index+'_'+modIndex); $(div).find('select[name^="sp_criteria_modifier"]').attr('name', 'sp_criteria_modifier_' + index + '_' + modIndex);
$(div).find('select[name^="sp_criteria_modifier"]').attr('id', 'sp_criteria_modifier_'+index+'_'+modIndex); $(div).find('select[name^="sp_criteria_modifier"]').attr('id', 'sp_criteria_modifier_' + index + '_' + modIndex);
$(div).find('input[name^="sp_criteria_value"]').attr('name', 'sp_criteria_value_'+index+'_'+modIndex); $(div).find('input[name^="sp_criteria_value"]').attr('name', 'sp_criteria_value_' + index + '_' + modIndex);
$(div).find('input[name^="sp_criteria_value"]').attr('id', 'sp_criteria_value_'+index+'_'+modIndex); $(div).find('input[name^="sp_criteria_value"]').attr('id', 'sp_criteria_value_' + index + '_' + modIndex);
$(div).find('select[name^="sp_criteria_value"]').attr('name', 'sp_criteria_value_'+index+'_'+modIndex); $(div).find('select[name^="sp_criteria_value"]').attr('name', 'sp_criteria_value_' + index + '_' + modIndex);
$(div).find('select[name^="sp_criteria_value"]').attr('id', 'sp_criteria_value_'+index+'_'+modIndex); $(div).find('select[name^="sp_criteria_value"]').attr('id', 'sp_criteria_value_' + index + '_' + modIndex);
$(div).find('input[name^="sp_criteria_extra"]').attr('name', 'sp_criteria_extra_'+index+'_'+modIndex); $(div).find('input[name^="sp_criteria_extra"]').attr('name', 'sp_criteria_extra_' + index + '_' + modIndex);
$(div).find('input[name^="sp_criteria_extra"]').attr('id', 'sp_criteria_extra_'+index+'_'+modIndex); $(div).find('input[name^="sp_criteria_extra"]').attr('id', 'sp_criteria_extra_' + index + '_' + modIndex);
$(div).find('a[name^="modifier_add"]').attr('id', 'modifier_add_'+index); $(div).find('a[name^="modifier_add"]').attr('id', 'modifier_add_' + index);
$(div).find('a[id^="criteria_remove"]').attr('id', 'criteria_remove_'+index+'_'+modIndex); $(div).find('a[id^="criteria_remove"]').attr('id', 'criteria_remove_' + index + '_' + modIndex);
} else if (i > 0) { } else if (i > 0) {
$(div).remove(); $(div).remove();
} }
}); });
} }
function buttonClickAction(clickType, url){ function buttonClickAction(clickType, url) {
var data = $('.active-tab .smart-block-form').serializeArray(), var data = $('.active-tab .smart-block-form').serializeArray(),
obj_id = $('.active-tab .obj_id').val(); obj_id = $('.active-tab .obj_id').val();
enableLoadingIcon(); enableLoadingIcon();
$.post(url, {format: "json", data: data, obj_id: obj_id, obj_type: "block", $.post(url, {
modified: AIRTIME.playlist.getModified() format: "json", data: data, obj_id: obj_id, obj_type: "block",
}, function(data){ modified: AIRTIME.playlist.getModified()
}, function (data) {
callback(data, clickType); callback(data, clickType);
disableLoadingIcon(); disableLoadingIcon();
}); });
@ -536,8 +537,8 @@ function setupUI() {
$(".playlist_type_help_icon").qtip({ $(".playlist_type_help_icon").qtip({
content: { content: {
text: $.i18n._("A static smart block will save the criteria and generate the block content immediately. This allows you to edit and view it in the Library before adding it to a show.")+"<br /><br />" + text: $.i18n._("A static smart block will save the criteria and generate the block content immediately. This allows you to edit and view it in the Library before adding it to a show.") + "<br /><br />" +
$.i18n._("A dynamic smart block will only save the criteria. The block content will get generated upon adding it to a show. You will not be able to view and edit the content in the Library.") $.i18n._("A dynamic smart block will only save the criteria. The block content will get generated upon adding it to a show. You will not be able to view and edit the content in the Library.")
}, },
hide: { hide: {
delay: 500, delay: 500,
@ -599,23 +600,23 @@ function setupUI() {
} }
}); });
activeTab.find('.collapsible-header').off('click').on('click', function(){ activeTab.find('.collapsible-header').off('click').on('click', function () {
$(this).toggleClass('visible'); $(this).toggleClass('visible');
$('.smart-block-advanced').toggle(); $('.smart-block-advanced').toggle();
}); });
} }
function enableAndShowTracktypeDropdown(valEle, index) { function enableAndShowTracktypeDropdown(valEle, index) {
console.log('tracktype show'); console.log('tracktype show');
$("#sp_criteria_value_"+index).replaceWith('<select name="sp_criteria_value_'+index+'" id="sp_criteria_value_'+index+'" class="input_select sp_input_select"></select>'); $("#sp_criteria_value_" + index).replaceWith('<select name="sp_criteria_value_' + index + '" id="sp_criteria_value_' + index + '" class="input_select sp_input_select"></select>');
$.each(stringTracktypeOptions, function(key, value){ $.each(stringTracktypeOptions, function (key, value) {
$("#sp_criteria_value_"+index).append($('<option></option>').attr('value', key).text(value)); $("#sp_criteria_value_" + index).append($('<option></option>').attr('value', key).text(value));
}); });
} }
function disableAndHideTracktypeDropdown(valEle, index) { function disableAndHideTracktypeDropdown(valEle, index) {
console.log('tracktype hide'); console.log('tracktype hide');
$("#sp_criteria_value_"+index).replaceWith('<input type="text" name="sp_criteria_value_'+index+'" id="sp_criteria_value_'+index+'" value="" class="input_text sp_input_text">'); $("#sp_criteria_value_" + index).replaceWith('<input type="text" name="sp_criteria_value_' + index + '" id="sp_criteria_value_' + index + '" value="" class="input_text sp_input_text">');
} }
/* Utilizing jQuery this function finds the #datetime_select element on the given row /* Utilizing jQuery this function finds the #datetime_select element on the given row
@ -624,12 +625,12 @@ function disableAndHideTracktypeDropdown(valEle, index) {
function enableAndShowDateTimeDropdown(valEle, index) { function enableAndShowDateTimeDropdown(valEle, index) {
console.log('datetime show'); console.log('datetime show');
var spanDatetime = valEle.nextAll("#datetime_select"); var spanDatetime = valEle.nextAll("#datetime_select");
spanDatetime.children('#sp_criteria_datetime_select_'+index).removeAttr("disabled"); spanDatetime.children('#sp_criteria_datetime_select_' + index).removeAttr("disabled");
spanDatetime.children('#sp_criteria_extra_datetime_select_'+index).removeAttr("disabled"); spanDatetime.children('#sp_criteria_extra_datetime_select_' + index).removeAttr("disabled");
spanDatetime.show(); spanDatetime.show();
//make value input smaller since we have extra element now //make value input smaller since we have extra element now
var criteria_val = $('#sp_criteria_value_'+index); var criteria_val = $('#sp_criteria_value_' + index);
sizeTextBoxes(criteria_val, 'sp_input_text', 'sp_extra_input_text'); sizeTextBoxes(criteria_val, 'sp_input_text', 'sp_extra_input_text');
} }
@ -641,11 +642,11 @@ function enableAndShowDateTimeDropdown(valEle, index) {
function disableAndHideDateTimeDropdown(valEle, index) { function disableAndHideDateTimeDropdown(valEle, index) {
console.log('datetime hide'); console.log('datetime hide');
var spanDatetime = valEle.nextAll("#datetime_select"); var spanDatetime = valEle.nextAll("#datetime_select");
spanDatetime.children('#sp_criteria_datetime_select_'+index).val("").attr("disabled", "disabled"); spanDatetime.children('#sp_criteria_datetime_select_' + index).val("").attr("disabled", "disabled");
spanDatetime.hide(); spanDatetime.hide();
//make value input larger since we don't have extra field now //make value input larger since we don't have extra field now
var criteria_value = $('#sp_criteria_value_'+index); var criteria_value = $('#sp_criteria_value_' + index);
sizeTextBoxes(criteria_value, 'sp_extra_input_text', 'sp_input_text'); sizeTextBoxes(criteria_value, 'sp_extra_input_text', 'sp_input_text');
} }
@ -655,11 +656,11 @@ function disableAndHideDateTimeDropdown(valEle, index) {
function enableAndShowExtraDateTimeDropdown(valEle, index) { function enableAndShowExtraDateTimeDropdown(valEle, index) {
console.log('datetime show'); console.log('datetime show');
var spanDatetime = valEle.nextAll("#extra_datetime_select"); var spanDatetime = valEle.nextAll("#extra_datetime_select");
spanDatetime.children('#sp_criteria_extra_datetime_select_'+index).removeAttr("disabled"); spanDatetime.children('#sp_criteria_extra_datetime_select_' + index).removeAttr("disabled");
spanDatetime.show(); spanDatetime.show();
//make value input smaller since we have extra element now //make value input smaller since we have extra element now
var criteria_val = $('#sp_criteria_value_'+index); var criteria_val = $('#sp_criteria_value_' + index);
sizeTextBoxes(criteria_val, 'sp_input_text', 'sp_extra_input_text'); sizeTextBoxes(criteria_val, 'sp_input_text', 'sp_extra_input_text');
} }
/* Utilizing jQuery this function finds the #datetime_select element on the given row /* Utilizing jQuery this function finds the #datetime_select element on the given row
@ -669,33 +670,33 @@ function enableAndShowExtraDateTimeDropdown(valEle, index) {
function disableAndHideExtraDateTimeDropdown(valEle, index) { function disableAndHideExtraDateTimeDropdown(valEle, index) {
console.log('datetime hide'); console.log('datetime hide');
var spanDatetime = valEle.nextAll("#extra_datetime_select"); var spanDatetime = valEle.nextAll("#extra_datetime_select");
spanDatetime.children('#sp_criteria_extra_datetime_select_'+index).val("").attr("disabled", "disabled"); spanDatetime.children('#sp_criteria_extra_datetime_select_' + index).val("").attr("disabled", "disabled");
spanDatetime.hide(); spanDatetime.hide();
//make value input larger since we don't have extra field now //make value input larger since we don't have extra field now
var criteria_value = $('#sp_criteria_value_'+index); var criteria_value = $('#sp_criteria_value_' + index);
sizeTextBoxes(criteria_value, 'sp_extra_input_text', 'sp_input_text'); sizeTextBoxes(criteria_value, 'sp_extra_input_text', 'sp_input_text');
} }
function enableAndShowExtraField(valEle, index) { function enableAndShowExtraField(valEle, index) {
var spanExtra = valEle.nextAll("#extra_criteria"); var spanExtra = valEle.nextAll("#extra_criteria");
console.log('shown'); console.log('shown');
spanExtra.children('#sp_criteria_extra_'+index).removeAttr("disabled"); spanExtra.children('#sp_criteria_extra_' + index).removeAttr("disabled");
spanExtra.show(); spanExtra.show();
//make value input smaller since we have extra element now //make value input smaller since we have extra element now
var criteria_val = $('#sp_criteria_value_'+index); var criteria_val = $('#sp_criteria_value_' + index);
sizeTextBoxes(criteria_val, 'sp_input_text', 'sp_extra_input_text'); sizeTextBoxes(criteria_val, 'sp_input_text', 'sp_extra_input_text');
} }
function disableAndHideExtraField(valEle, index) { function disableAndHideExtraField(valEle, index) {
var spanExtra = valEle.nextAll("#extra_criteria"); var spanExtra = valEle.nextAll("#extra_criteria");
spanExtra.children('#sp_criteria_extra_'+index).val("").attr("disabled", "disabled"); spanExtra.children('#sp_criteria_extra_' + index).val("").attr("disabled", "disabled");
spanExtra.hide(); spanExtra.hide();
console.log('hidden'); console.log('hidden');
//make value input larger since we don't have extra field now //make value input larger since we don't have extra field now
var criteria_value = $('#sp_criteria_value_'+index); var criteria_value = $('#sp_criteria_value_' + index);
sizeTextBoxes(criteria_value, 'sp_extra_input_text', 'sp_input_text'); sizeTextBoxes(criteria_value, 'sp_extra_input_text', 'sp_input_text');
} }
function disableAndHideLimitValue() { function disableAndHideLimitValue() {
@ -722,37 +723,37 @@ function populateModifierSelect(e, popAllMods) {
if (popAllMods) { if (popAllMods) {
index = index.substring(0, 1); index = index.substring(0, 1);
} }
divs = $(e).parents().find('select[id^="sp_criteria_modifier_'+index+'"]'); divs = $(e).parents().find('select[id^="sp_criteria_modifier_' + index + '"]');
$.each(divs, function(i, div){ $.each(divs, function (i, div) {
$(div).children().remove(); $(div).children().remove();
if (criteria_type == 's') { if (criteria_type == 's') {
$.each(stringCriteriaOptions, function(key, value){ $.each(stringCriteriaOptions, function (key, value) {
$(div).append($('<option></option>')
.attr('value', key)
.text(value));
});
}
else if(criteria_type == 'd') {
$.each(dateTimeCriteriaOptions, function(key, value){
$(div).append($('<option></option>') $(div).append($('<option></option>')
.attr('value', key) .attr('value', key)
.text(value)); .text(value));
}); });
} }
else if(criteria_type == 'tt') { else if (criteria_type == 'd') {
$.each(stringIsNotOptions, function(key, value){ $.each(dateTimeCriteriaOptions, function (key, value) {
$(div).append($('<option></option>')
.attr('value', key)
.text(value));
});
}
else if (criteria_type == 'tt') {
$.each(stringIsNotOptions, function (key, value) {
$(div).append($('<option></option>') $(div).append($('<option></option>')
.attr('value', key) .attr('value', key)
.text(value)); .text(value));
}); });
} }
else { else {
$.each(numericCriteriaOptions, function(key, value){ $.each(numericCriteriaOptions, function (key, value) {
$(div).append($('<option></option>') $(div).append($('<option></option>')
.attr('value', key) .attr('value', key)
.text(value)); .text(value));
}); });
} }
}); });
@ -767,13 +768,13 @@ function populateTracktypeSelect(e, popAllMods) {
if (popAllMods) { if (popAllMods) {
index = index.substring(0, 1); index = index.substring(0, 1);
} }
divs = $(e).parents().find('select[id^="sp_criteria_modifier_'+index+'"]'); divs = $(e).parents().find('select[id^="sp_criteria_modifier_' + index + '"]');
$.each(divs, function(i, div){ $.each(divs, function (i, div) {
$(div).children().remove(); $(div).children().remove();
$.each(stringIsNotOptions, function(key, value){ $.each(stringIsNotOptions, function (key, value) {
$(div).append($('<option></option>') $(div).append($('<option></option>')
.attr('value', key) .attr('value', key)
.text(value)); .text(value));
}); });
}); });
} }
@ -804,7 +805,7 @@ function callback(json, type) {
if (type == 'shuffle') { if (type == 'shuffle') {
form.find('.success').text($.i18n._('Smart block shuffled')); form.find('.success').text($.i18n._('Smart block shuffled'));
} else if (type == 'generate') { } else if (type == 'generate') {
form.find('.success').text($.i18n._('Smart block generated and criteria saved')); form.find('.success').text($.i18n._('Smart block generated and criteria saved'));
//redraw library table so the length gets updated //redraw library table so the length gets updated
dt.fnStandingRedraw(); dt.fnStandingRedraw();
} }
@ -889,7 +890,7 @@ function groupCriteriaRows() {
var visibleRows = $("#sp_criteria-element > div:visible"), var visibleRows = $("#sp_criteria-element > div:visible"),
prevRowGroup = "0"; prevRowGroup = "0";
visibleRows.each(function (index){ visibleRows.each(function (index) {
if (index > 0) { if (index > 0) {
var fieldId = $(this).find('select[id^="sp_criteria_field"]').attr("id"); var fieldId = $(this).find('select[id^="sp_criteria_field"]').attr("id");
var currRowGroup = fieldId[fieldId.length - 3]; var currRowGroup = fieldId[fieldId.length - 3];
@ -911,74 +912,74 @@ function groupCriteriaRows() {
// or numeric value in order to populate the modifier // or numeric value in order to populate the modifier
// select list // select list
var criteriaTypes = { var criteriaTypes = {
0 : "", 0: "",
"album_title" : "s", "album_title": "s",
"bit_rate" : "n", "bit_rate": "n",
"bpm" : "n", "bpm": "n",
"composer" : "s", "composer": "s",
"conductor" : "s", "conductor": "s",
"copyright" : "s", "copyright": "s",
"cuein" : "n", "cuein": "n",
"cueout" : "n", "cueout": "n",
"description" : "s", "description": "s",
"artist_name" : "s", "artist_name": "s",
"encoded_by" : "s", "encoded_by": "s",
"utime" : "d", "utime": "d",
"mtime" : "d", "mtime": "d",
"lptime" : "d", "lptime": "d",
"genre" : "s", "genre": "s",
"isrc_number" : "s", "isrc_number": "s",
"label" : "s", "label": "s",
"language" : "s", "language": "s",
"length" : "n", "length": "n",
"mime" : "s", "mime": "s",
"mood" : "s", "mood": "s",
"owner_id" : "s", "owner_id": "s",
"replay_gain" : "n", "replay_gain": "n",
"sample_rate" : "n", "sample_rate": "n",
"track_title" : "s", "track_title": "s",
"track_number" : "n", "track_number": "n",
"info_url" : "s", "info_url": "s",
"year" : "n", "year": "n",
"track_type" : "tt" "track_type": "tt"
}; };
var stringCriteriaOptions = { var stringCriteriaOptions = {
"0" : $.i18n._("Select modifier"), "0": $.i18n._("Select modifier"),
"contains" : $.i18n._("contains"), "contains": $.i18n._("contains"),
"does not contain" : $.i18n._("does not contain"), "does not contain": $.i18n._("does not contain"),
"is" : $.i18n._("is"), "is": $.i18n._("is"),
"is not" : $.i18n._("is not"), "is not": $.i18n._("is not"),
"starts with" : $.i18n._("starts with"), "starts with": $.i18n._("starts with"),
"ends with" : $.i18n._("ends with") "ends with": $.i18n._("ends with")
}; };
var numericCriteriaOptions = { var numericCriteriaOptions = {
"0" : $.i18n._("Select modifier"), "0": $.i18n._("Select modifier"),
"is" : $.i18n._("is"), "is": $.i18n._("is"),
"is not" : $.i18n._("is not"), "is not": $.i18n._("is not"),
"is greater than" : $.i18n._("is greater than"), "is greater than": $.i18n._("is greater than"),
"is less than" : $.i18n._("is less than"), "is less than": $.i18n._("is less than"),
"is in the range" : $.i18n._("is in the range") "is in the range": $.i18n._("is in the range")
}; };
var dateTimeCriteriaOptions = { var dateTimeCriteriaOptions = {
"0" : $.i18n._("Select modifier"), "0": $.i18n._("Select modifier"),
"before" : $.i18n._("before"), "before": $.i18n._("before"),
"after" : $.i18n._("after"), "after": $.i18n._("after"),
"between" : $.i18n._("between"), "between": $.i18n._("between"),
"is" : $.i18n._("is"), "is": $.i18n._("is"),
"is not" : $.i18n._("is not"), "is not": $.i18n._("is not"),
"is greater than" : $.i18n._("is greater than"), "is greater than": $.i18n._("is greater than"),
"is less than" : $.i18n._("is less than"), "is less than": $.i18n._("is less than"),
"is in the range" : $.i18n._("is in the range") "is in the range": $.i18n._("is in the range")
}; };
var stringIsNotOptions = { var stringIsNotOptions = {
"0" : $.i18n._("Select modifier"), "0": $.i18n._("Select modifier"),
"is" : $.i18n._("is"), "is": $.i18n._("is"),
"is not" : $.i18n._("is not") "is not": $.i18n._("is not")
}; };
let tracktypes = TRACKTYPES; let tracktypes = TRACKTYPES;
var stringTracktypeOptions = Object.assign({"": "Select Track Type"}, tracktypes); var stringTracktypeOptions = Object.assign({ "": "Select Track Type" }, tracktypes);