2010-12-22 05:33:58 +01:00
|
|
|
//--------------------------------------------------------------------------------------------------------------------------------
|
|
|
|
//Side Playlist Functions
|
|
|
|
//--------------------------------------------------------------------------------------------------------------------------------
|
|
|
|
|
2011-01-17 01:31:10 +01:00
|
|
|
function setEditorContent(json) {
|
|
|
|
$("#spl_editor")
|
|
|
|
.empty()
|
|
|
|
.append(json.html);
|
|
|
|
}
|
|
|
|
|
2011-01-17 00:37:02 +01:00
|
|
|
function highlightActive(el) {
|
|
|
|
$("#spl_sortable")
|
|
|
|
.find(".ui-state-active")
|
|
|
|
.removeClass("ui-state-active");
|
|
|
|
|
|
|
|
$(el).addClass("ui-state-active");
|
|
|
|
}
|
|
|
|
|
|
|
|
function openFadeEditor(event) {
|
|
|
|
event.stopPropagation();
|
|
|
|
|
2011-01-17 01:31:10 +01:00
|
|
|
var pos, url;
|
|
|
|
|
|
|
|
pos = $(this).attr("id").split("_").pop();
|
|
|
|
url = '/Playlist/set-fade/format/json';
|
|
|
|
url = url + '/pos/' + pos;
|
|
|
|
|
2011-01-17 00:37:02 +01:00
|
|
|
highlightActive(this);
|
2011-01-17 01:31:10 +01:00
|
|
|
|
|
|
|
$.get(url, setEditorContent);
|
2011-01-17 00:37:02 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
function openCueEditor(event) {
|
|
|
|
event.stopPropagation();
|
|
|
|
|
2011-01-17 02:40:34 +01:00
|
|
|
var pos, url, li;
|
2011-01-17 01:31:10 +01:00
|
|
|
|
2011-01-17 05:43:12 +01:00
|
|
|
li = $(this).parent().parent();
|
2011-01-17 02:40:34 +01:00
|
|
|
pos = li.attr("id").split("_").pop();
|
2011-01-17 01:31:10 +01:00
|
|
|
url = '/Playlist/set-cue/format/json';
|
|
|
|
url = url + '/pos/' + pos;
|
|
|
|
|
2011-01-17 02:40:34 +01:00
|
|
|
highlightActive(li);
|
2011-01-17 01:31:10 +01:00
|
|
|
|
|
|
|
$.get(url, setEditorContent);
|
2011-01-17 00:37:02 +01:00
|
|
|
}
|
|
|
|
|
2010-12-22 05:33:58 +01:00
|
|
|
function setSPLContent(json) {
|
|
|
|
|
|
|
|
if(json.message) {
|
|
|
|
alert(json.message);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
$('#spl_name').empty()
|
|
|
|
.append(json.name);
|
|
|
|
$('#spl_length').empty()
|
|
|
|
.append(json.length);
|
|
|
|
$('#spl_sortable').empty()
|
|
|
|
.append(json.html);
|
2011-01-17 02:40:34 +01:00
|
|
|
$("#spl_editor")
|
|
|
|
.empty();
|
2011-01-16 21:35:00 +01:00
|
|
|
|
|
|
|
$(".ui-icon-close").click(deleteSPLItem);
|
2011-01-17 00:37:02 +01:00
|
|
|
$(".spl_fade_control").click(openFadeEditor);
|
2011-01-17 02:40:34 +01:00
|
|
|
$(".spl_playlength").click(openCueEditor);
|
|
|
|
|
|
|
|
return false;
|
2010-12-22 05:33:58 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
function addSPLItem(event, ui){
|
|
|
|
|
|
|
|
var url, tr, id;
|
|
|
|
|
|
|
|
tr = ui.helper;
|
|
|
|
|
|
|
|
if(tr.get(0).tagName === 'LI')
|
|
|
|
return;
|
|
|
|
|
2010-12-30 19:32:59 +01:00
|
|
|
id = tr.attr('id').split("_").pop();
|
2010-12-22 05:33:58 +01:00
|
|
|
|
|
|
|
url = '/Playlist/add-item/format/json';
|
|
|
|
url = url + '/id/'+id;
|
|
|
|
|
|
|
|
$.post(url, setSPLContent);
|
|
|
|
}
|
|
|
|
|
2011-01-17 00:37:02 +01:00
|
|
|
function deleteSPLItem(event){
|
2010-12-22 05:33:58 +01:00
|
|
|
var url, pos;
|
|
|
|
|
2011-01-17 00:37:02 +01:00
|
|
|
event.stopPropagation();
|
|
|
|
|
2011-01-17 05:43:12 +01:00
|
|
|
pos = $(this).parent().parent().attr("id").split("_").pop();
|
2010-12-22 05:33:58 +01:00
|
|
|
|
2011-01-16 21:35:00 +01:00
|
|
|
url = '/Playlist/delete-item/format/json';
|
|
|
|
url = url + '/pos/' + pos;
|
2010-12-22 05:33:58 +01:00
|
|
|
|
|
|
|
$.post(url, setSPLContent);
|
|
|
|
}
|
|
|
|
|
|
|
|
function moveSPLItem(event, ui) {
|
|
|
|
var li, newPos, oldPos, url;
|
2011-01-17 02:40:34 +01:00
|
|
|
|
2010-12-22 05:33:58 +01:00
|
|
|
li = ui.item;
|
|
|
|
|
|
|
|
newPos = li.index();
|
|
|
|
oldPos = li.attr('id').split("_").pop();
|
|
|
|
|
|
|
|
url = '/Playlist/move-item'
|
|
|
|
url = url + '/format/json';
|
|
|
|
url = url + '/oldPos/' + oldPos;
|
|
|
|
url = url + '/newPos/' + newPos;
|
|
|
|
|
|
|
|
$.post(url, setSPLContent);
|
|
|
|
}
|
|
|
|
|
2010-12-22 19:05:32 +01:00
|
|
|
function noOpenPL(json) {
|
|
|
|
$("#side_playlist")
|
|
|
|
.empty()
|
|
|
|
.append(json.html);
|
2011-01-17 00:37:02 +01:00
|
|
|
|
|
|
|
$("#spl_new")
|
|
|
|
.button()
|
|
|
|
.click(newSPL);
|
2010-12-22 19:05:32 +01:00
|
|
|
}
|
|
|
|
|
2010-12-22 18:42:46 +01:00
|
|
|
function closeSPL() {
|
|
|
|
var url;
|
|
|
|
|
2011-01-16 21:35:00 +01:00
|
|
|
url = '/Playlist/close/format/json';
|
2010-12-22 18:42:46 +01:00
|
|
|
|
2010-12-22 19:05:32 +01:00
|
|
|
$.post(url, noOpenPL);
|
|
|
|
}
|
|
|
|
|
2011-01-16 21:35:00 +01:00
|
|
|
function newSPL() {
|
2011-01-16 23:12:02 +01:00
|
|
|
var url;
|
|
|
|
|
|
|
|
url = '/Playlist/new/format/json';
|
|
|
|
|
|
|
|
$.post(url, function(json){
|
|
|
|
var submit;
|
|
|
|
|
2011-01-17 02:40:34 +01:00
|
|
|
submit = $('<button>Submit</button>')
|
2011-01-17 00:37:02 +01:00
|
|
|
.button()
|
2011-01-16 23:12:02 +01:00
|
|
|
.click(function(){
|
|
|
|
var url, data;
|
|
|
|
|
|
|
|
url = '/Playlist/metadata/format/json';
|
|
|
|
data = $("#side_playlist form").serialize();
|
|
|
|
|
|
|
|
$.post(url, data, function(json){
|
|
|
|
if(json.form){
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
openDiffSPL(json);
|
|
|
|
})
|
|
|
|
});
|
2011-01-16 21:35:00 +01:00
|
|
|
|
2011-01-16 23:12:02 +01:00
|
|
|
$("#side_playlist")
|
|
|
|
.empty()
|
|
|
|
.append(json.form)
|
|
|
|
.append(submit);
|
|
|
|
});
|
2011-01-16 21:35:00 +01:00
|
|
|
}
|
|
|
|
|
2010-12-22 19:05:32 +01:00
|
|
|
function deleteSPL() {
|
|
|
|
var url;
|
|
|
|
|
2011-01-16 21:35:00 +01:00
|
|
|
url = '/Playlist/delete-active/format/json';
|
2010-12-22 19:05:32 +01:00
|
|
|
|
|
|
|
$.post(url, noOpenPL);
|
2010-12-22 18:42:46 +01:00
|
|
|
}
|
|
|
|
|
2010-12-30 19:32:59 +01:00
|
|
|
function openDiffSPL(json) {
|
|
|
|
|
|
|
|
$("#side_playlist")
|
|
|
|
.empty()
|
|
|
|
.append(json.html);
|
|
|
|
|
|
|
|
setUpSPL();
|
|
|
|
}
|
|
|
|
|
2010-12-22 05:33:58 +01:00
|
|
|
function setUpSPL() {
|
|
|
|
|
|
|
|
$("#spl_sortable").sortable();
|
|
|
|
$("#spl_sortable" ).bind( "sortstop", moveSPLItem);
|
|
|
|
$("#spl_remove_selected").click(deleteSPLItem);
|
2011-01-17 00:37:02 +01:00
|
|
|
$("#spl_new")
|
|
|
|
.button()
|
|
|
|
.click(newSPL);
|
|
|
|
|
|
|
|
$("#spl_close")
|
|
|
|
.button()
|
|
|
|
.click(closeSPL);
|
|
|
|
|
|
|
|
$("#spl_delete")
|
|
|
|
.button()
|
|
|
|
.click(deleteSPL);
|
|
|
|
|
2011-01-16 21:35:00 +01:00
|
|
|
$(".ui-icon-close").click(deleteSPLItem);
|
2011-01-17 00:37:02 +01:00
|
|
|
$(".spl_fade_control").click(openFadeEditor);
|
2011-01-17 02:40:34 +01:00
|
|
|
$(".spl_playlength").click(openCueEditor);
|
2010-12-22 05:33:58 +01:00
|
|
|
|
2010-12-22 05:56:14 +01:00
|
|
|
$("#spl_sortable").droppable();
|
|
|
|
$("#spl_sortable" ).bind( "drop", addSPLItem);
|
2010-12-22 05:33:58 +01:00
|
|
|
|
|
|
|
}
|
|
|
|
|