diff --git a/airtime_mvc/application/forms/SmartPlaylistCriteria.php b/airtime_mvc/application/forms/SmartPlaylistCriteria.php
index 15612b781..9b3d0b919 100644
--- a/airtime_mvc/application/forms/SmartPlaylistCriteria.php
+++ b/airtime_mvc/application/forms/SmartPlaylistCriteria.php
@@ -9,7 +9,7 @@ class Application_Form_SmartPlaylistCriteria extends Zend_Form_SubForm
"album_title" => "Album",
"artist_name" => "Artist",
"bit_rate" => "Bit Rate",
- "bmp" => "Bpm",
+ "bpm" => "Bpm",
"comments" => "Comments",
"composer" => "Composer",
"conductor" => "Conductor",
diff --git a/airtime_mvc/public/js/airtime/playlist/smart_playlistbuilder.js b/airtime_mvc/public/js/airtime/playlist/smart_playlistbuilder.js
index 33cb4d315..057199da5 100644
--- a/airtime_mvc/public/js/airtime/playlist/smart_playlistbuilder.js
+++ b/airtime_mvc/public/js/airtime/playlist/smart_playlistbuilder.js
@@ -74,6 +74,40 @@ function setSmartPlaylistEvents() {
}
$('button[id="save_button"]').text(button_text);
});
+
+ form.find('select[id^="sp_criteria"]').change(function(){
+ var criteria = $(this).val(),
+ criteria_type = criteriaTypes[criteria],
+ div = $(this);
+ $(this).next().children().remove();
+
+ if (criteria_type == 's') {
+ $.each(stringCriteriaOptions, function(key, value){
+ div.next().append($('')
+ .attr('value', key)
+ .text(value));
+ });
+ } else {
+ $.each(numericCriteriaOptions, function(key, value){
+ div.next().append($('')
+ .attr('value', key)
+ .text(value));
+ })
+ }
+ });
+
+ form.find('select[id^="sp_criteria_modifier"]').change(function(){
+ if ($(this).val() == 'is in the range') {
+ var criteria_value = $(this).next(),
+ index_name = criteria_value.attr('id'),
+ index_num = index_name.charAt(index_name.length-1);
+
+ criteria_value.after($('')
+ .attr('id', 'sp_criteria_extra_'+index_num)
+ .attr('name', 'sp_criteria_extra_'+index_num)).after(' to ');
+
+ }
+ });
}
@@ -84,3 +118,52 @@ function staticCallback() {
function dynamicCallback() {
}
+
+var criteriaTypes = {
+ 0 : "",
+ "album_title" : "s",
+ "artist_name" : "s",
+ "bit_rate" : "n",
+ "bmp" : "n",
+ "comments" : "s",
+ "composer" : "s",
+ "conductor" : "s",
+ "utime" : "n",
+ "mtime" : "n",
+ "disc_number" : "n",
+ "genre" : "s",
+ "isrc_number" : "s",
+ "label" : "s",
+ "language" : "s",
+ "length" : "n",
+ "lyricist" : "s",
+ "mood" : "s",
+ "name" : "s",
+ "orchestra" : "s",
+ "radio_station_name" : "s",
+ "rating" : "n",
+ "sample_rate" : "n",
+ "soundcloud_id" : "n",
+ "track_title" : "s",
+ "track_num" : "n",
+ "year" : "n"
+};
+
+var stringCriteriaOptions = {
+ "0" : "Select modifier",
+ "contains" : "contains",
+ "does not contain" : "does not contain",
+ "is" : "is",
+ "is not" : "is not",
+ "starts with" : "starts with",
+ "ends with" : "ends with"
+};
+
+var numericCriteriaOptions = {
+ "0" : "Select modifier",
+ "is" : "is",
+ "is not" : "is not",
+ "is greater than" : "is greater than",
+ "is less than" : "is less than",
+ "is in the range" : "is in the range"
+};