Added option to set media type for tracks.

This commit is contained in:
Codenift 2019-09-20 03:09:41 -04:00
parent 2e23238f2c
commit b411d6d6f2
17 changed files with 281 additions and 129 deletions

View file

@ -54,7 +54,8 @@ var AIRTIME = (function(AIRTIME) {
"owner_id" : "s",
"info_url" : "s",
"replay_gain" : "n",
"artwork" : "s"
"artwork" : "s",
"media_type" : "s"
};
if (AIRTIME.library === undefined) {
@ -591,6 +592,7 @@ var AIRTIME = (function(AIRTIME) {
/* Cue Out */ { "sTitle" : $.i18n._("Cue Out") , "mDataProp" : "cueout" , "bVisible" : false , "sClass" : "library_length" , "sWidth" : "80px" },
/* Description */ { "sTitle" : $.i18n._("Description") , "mDataProp" : "description" , "bVisible" : false , "sClass" : "library_description" , "sWidth" : "150px" },
/* Encoded */ { "sTitle" : $.i18n._("Encoded By") , "mDataProp" : "encoded_by" , "bVisible" : false , "sClass" : "library_encoded" , "sWidth" : "150px" },
/* Media Type */ { "sTitle" : $.i18n._("Type") , "mDataProp" : "media_type" , "bVisible" : false , "sClass" : "library_media_type" , "sWidth" : "60px" },
/* Genre */ { "sTitle" : $.i18n._("Genre") , "mDataProp" : "genre" , "sClass" : "library_genre" , "sWidth" : "100px" },
/* ISRC Number */ { "sTitle" : $.i18n._("ISRC") , "mDataProp" : "isrc_number" , "bVisible" : false , "sClass" : "library_isrc" , "sWidth" : "150px" },
/* Label */ { "sTitle" : $.i18n._("Label") , "mDataProp" : "label" , "bVisible" : false , "sClass" : "library_label" , "sWidth" : "125px" },
@ -615,7 +617,7 @@ var AIRTIME = (function(AIRTIME) {
);
}
var colExclude = onDashboard ? [0, 1, 2, 33] : [0, 1, 2];
var colExclude = onDashboard ? [0, 1, 2, 34] : [0, 1, 2];
/* ############################################
DATATABLES
@ -1597,6 +1599,7 @@ var validationTypes = {
"track_number" : "i",
"info_url" : "s",
"artwork" : "s",
"media_type" : "s",
"year" : "i"
};

View file

@ -8,7 +8,7 @@ function setSmartBlockEvents() {
/********** ADD CRITERIA ROW **********/
form.find('#criteria_add').live('click', function(){
var div = $('dd[id="sp_criteria-element"]').children('div:visible:last');
if (div.length == 0) {
@ -26,7 +26,7 @@ function setSmartBlockEvents() {
div.find('.db-logic-label').text('and').css('display', 'table');
div.removeClass('search-row-or').addClass('search-row-and');
div = div.next().show();
div.children().removeAttr('disabled');
@ -45,11 +45,11 @@ function setSmartBlockEvents() {
}
});
/********** ADD MODIFIER ROW **********/
form.find('a[id^="modifier_add"]').live('click', function(){
var criteria_value = $(this).siblings('select[name^="sp_criteria_field"]').val();
//make new modifier row
var newRow = $(this).parent().clone(),
@ -63,13 +63,13 @@ function setSmartBlockEvents() {
if (newRow.children().hasClass('errors sp-errors')) {
newRow.find('span[class="errors sp-errors"]').remove();
}
//hide the critieria field select box
newRowCrit.addClass('sp-invisible');
//keep criteria value the same
newRowCrit.val(criteria_value);
//reset all other values
newRowMod.val('0');
newRowVal.val('');
@ -78,12 +78,12 @@ function setSmartBlockEvents() {
disableAndHideDateTimeDropdown(newRowVal);
disableAndHideExtraDateTimeDropdown(newRowVal);
sizeTextBoxes(newRowVal, 'sp_extra_input_text', 'sp_input_text');
//remove the 'criteria add' button from new modifier row
newRow.find('#criteria_add').remove();
$(this).parent().after(newRow);
// remove extra spacing from previous row
newRow.prev().removeClass('search-row-and').addClass('search-row-or');
@ -93,7 +93,7 @@ function setSmartBlockEvents() {
removeButtonCheck();
groupCriteriaRows();
});
/********** REMOVE ROW **********/
form.find('a[id^="criteria_remove"]').live('click', function(){
var curr = $(this).parent();
@ -128,10 +128,10 @@ function setSmartBlockEvents() {
for (var i=0; i<count; i++) {
index = getRowIndex(curr);
var criteria = next.find('[name^="sp_criteria_field"]').val();
curr.find('[name^="sp_criteria_field"]').val(criteria);
var modifier = next.find('[name^="sp_criteria_modifier"]').val();
populateModifierSelect(curr.find('[name^="sp_criteria_field"]'), false);
curr.find('[name^="sp_criteria_modifier"]').val(modifier);
@ -148,7 +148,7 @@ function setSmartBlockEvents() {
*/
if (curr.find('[name^="sp_criteria_extra"]').attr("disabled") != "disabled"
&& next.find('#extra_criteria').is(':visible')) {
var criteria_extra = next.find('[name^="sp_criteria_extra"]').val();
curr.find('[name^="sp_criteria_extra"]').val(criteria_extra);
disableAndHideExtraField(next.find(':first-child'), getRowIndex(next));
@ -159,7 +159,7 @@ function setSmartBlockEvents() {
} else if (curr.find('[name^="sp_criteria_extra"]').attr("disabled") != "disabled"
&& next.find('#extra_criteria').not(':visible')) {
disableAndHideExtraField(curr.find(':first-child'), index);
/* if only the next row has the extra criteria value,
* then add the extra criteria element to current row
* and assign next row's value to it
@ -231,12 +231,12 @@ function setSmartBlockEvents() {
curr.find('select[name^="sp_criteria_field"]').removeClass('sp-invisible');
}
}
curr = next;
next = curr.next();
}
/* Disable the last visible row since it holds the values the user removed
* Reset the values to empty and resize the criteria value textbox
* in case the row had the extra criteria textbox
@ -255,12 +255,12 @@ function setSmartBlockEvents() {
.find('[name^="sp_criteria_value"]').val('').end()
.find('[name^="sp_criteria_extra"]').val('')
.find('[name^="sp_criteria_extra_datetime_select"]').end();
sizeTextBoxes(item_to_hide.find('[name^="sp_criteria_value"]'), 'sp_extra_input_text', 'sp_input_text');
item_to_hide.hide();
list.next().show();
//check if last row is a modifier row
var last_row = list.find('div:visible:last');
if (last_row.find('[name^="sp_criteria_field"]').val() == last_row.prev().find('[name^="sp_criteria_field"]').val()) {
@ -268,22 +268,22 @@ function setSmartBlockEvents() {
last_row.find('select[name^="sp_criteria_field"]').addClass('sp-invisible');
}
}
// always put '+' button on the last enabled row
appendAddButton();
reindexElements();
// always put '+' button on the last modifier row
appendModAddButton();
// remove the 'x' button if only one row is enabled
removeButtonCheck();
groupCriteriaRows();
});
/********** SAVE ACTION **********/
// moved to spl.js
@ -291,12 +291,12 @@ function setSmartBlockEvents() {
activeTab.find('button[id="generate_button"]').live("click", function(){
buttonClickAction('generate', 'playlist/smart-block-generate');
});
/********** SHUFFLE ACTION **********/
activeTab.find('button[id="shuffle_button"]').live("click", function(){
buttonClickAction('shuffle', 'playlist/smart-block-shuffle');
});
/********** CHANGE PLAYLIST TYPE **********/
form.find('dd[id="sp_type-element"]').live("change", function(){
//buttonClickAction('generate', 'playlist/empty-content');
@ -334,14 +334,14 @@ function setSmartBlockEvents() {
return false;
}
});
// disable extra field and hide the span
disableAndHideExtraField($(this), index);
disableAndHideDateTimeDropdown($(this), index);
disableAndHideExtraDateTimeDropdown($(this),index);
populateModifierSelect(this, true);
});
/********** MODIFIER CHANGE **********/
form.find('select[id^="sp_criteria_modifier"]').live("change", function(){
var criteria_value = $(this).next(),
@ -384,7 +384,7 @@ function getRowIndex(ele) {
start = 3,
tokens = id.split(delimiter).slice(start),
index = tokens.join(delimiter);
return index;
}
@ -428,7 +428,7 @@ function reindexElements() {
$.each(divs, function(i, div){
if (i > 0 && index < 26) {
/* If the current row's criteria field is hidden we know it is
* a modifier row
*/
@ -444,7 +444,7 @@ function reindexElements() {
index++;
modIndex = 0;
}
$(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_modifier"]').attr('name', 'sp_criteria_modifier_'+index+'_'+modIndex);
@ -464,7 +464,7 @@ function reindexElements() {
function buttonClickAction(clickType, url){
var data = $('.active-tab .smart-block-form').serializeArray(),
obj_id = $('.active-tab .obj_id').val();
enableLoadingIcon();
$.post(url, {format: "json", data: data, obj_id: obj_id, obj_type: "block",
modified: AIRTIME.playlist.getModified()
@ -499,7 +499,7 @@ function setupUI() {
shuffleButton.addClass('ui-state-disabled');
shuffleButton.attr('disabled', 'disabled');
}
if (activeTab.find('.obj_type').val() == 'block') {
if (playlist_type == "1") {
shuffleButton.removeAttr("disabled");
@ -514,7 +514,7 @@ function setupUI() {
//sortable.children().hide();
}
}
$(".playlist_type_help_icon").qtip({
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 />" +
@ -536,7 +536,7 @@ function setupUI() {
at: "right center"
}
});
$(".repeat_tracks_help_icon").qtip({
content: {
text: sprintf($.i18n._("The desired block length will not be reached if %s cannot find enough unique tracks to match your criteria. Enable this option if you wish to allow tracks to be added multiple times to the smart block."), PRODUCT_NAME)
@ -661,7 +661,7 @@ function disableAndHideExtraField(valEle, index) {
spanExtra.children('#sp_criteria_extra_'+index).val("").attr("disabled", "disabled");
spanExtra.hide();
console.log('hidden');
//make value input larger since we don't have extra field now
var criteria_value = $('#sp_criteria_value_'+index);
sizeTextBoxes(criteria_value, 'sp_extra_input_text', 'sp_input_text');
@ -685,15 +685,15 @@ function populateModifierSelect(e, popAllMods) {
var criteria_type = getCriteriaOptionType(e),
index = getRowIndex($(e).parent()),
divs;
if (popAllMods) {
index = index.substring(0, 1);
}
divs = $(e).parents().find('select[id^="sp_criteria_modifier_'+index+'"]');
$.each(divs, function(i, div){
$(div).children().remove();
if (criteria_type == 's') {
$.each(stringCriteriaOptions, function(key, value){
$(div).append($('<option></option>')
@ -777,7 +777,7 @@ function appendAddButton() {
enabled = rows.find('select[name^="sp_criteria_field"]:enabled');
rows.find('#criteria_add').remove();
if (enabled.length > 1) {
rows.find('select[name^="sp_criteria_field"]:enabled:last')
.siblings('a[id^="criteria_remove"]')
@ -821,7 +821,7 @@ function disableLoadingIcon() {
function groupCriteriaRows() {
// check whether rows should be "grouped" and shown with an "or" "logic label", or separated by an "and" "logic label"
var visibleRows = $("#sp_criteria-element > div:visible"),
var visibleRows = $("#sp_criteria-element > div:visible"),
prevRowGroup = "0";
visibleRows.each(function (index){
@ -837,7 +837,7 @@ function groupCriteriaRows() {
}
});
// ensure spacing below last visible row
// ensure spacing below last visible row
$("#sp_criteria-element > div:visible:last").addClass("search-row-and").removeClass("search-row-or");
}
@ -874,7 +874,8 @@ var criteriaTypes = {
"track_title" : "s",
"track_number" : "n",
"info_url" : "s",
"year" : "n"
"year" : "n",
"media_type" : "s"
};
var stringCriteriaOptions = {
@ -886,7 +887,7 @@ var stringCriteriaOptions = {
"starts with" : $.i18n._("starts with"),
"ends with" : $.i18n._("ends with")
};
var numericCriteriaOptions = {
"0" : $.i18n._("Select modifier"),
"is" : $.i18n._("is"),