2010-12-22 05:33:58 +01:00
|
|
|
//--------------------------------------------------------------------------------------------------------------------------------
|
|
|
|
//Side Playlist Functions
|
|
|
|
//--------------------------------------------------------------------------------------------------------------------------------
|
|
|
|
|
2011-01-17 19:55:43 +01:00
|
|
|
function isTimeValid(time) {
|
|
|
|
var regExpr = new RegExp("^\\d{2}[:]\\d{2}[:]\\d{2}([.]\\d{1,6})?$");
|
|
|
|
|
|
|
|
if (!regExpr.test(time)) {
|
|
|
|
displayEditorError("please put in a time '00:00:00 (.000000)'");
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
function displayEditorError(error) {
|
|
|
|
$("#spl_error")
|
2011-01-18 19:34:36 +01:00
|
|
|
.empty()
|
2011-01-17 19:55:43 +01:00
|
|
|
.append('<span class="ui-icon ui-icon-alert"></span>')
|
|
|
|
.append(error)
|
|
|
|
.show();
|
|
|
|
}
|
|
|
|
|
|
|
|
function clearEditorError() {
|
|
|
|
$("#spl_error")
|
|
|
|
.empty()
|
|
|
|
.hide();
|
|
|
|
}
|
|
|
|
|
|
|
|
function cueSetUp(pos, json) {
|
|
|
|
|
|
|
|
$("#spl_"+pos).find(".spl_playlength")
|
|
|
|
.empty()
|
|
|
|
.append(json.response.cliplength);
|
|
|
|
|
|
|
|
$("#spl_length")
|
|
|
|
.empty()
|
|
|
|
.append(json.response.length);
|
|
|
|
}
|
|
|
|
|
|
|
|
function changeCueIn() {
|
|
|
|
var pos, url, cueIn, div;
|
|
|
|
|
2011-01-18 19:34:36 +01:00
|
|
|
span = $(this);
|
2011-01-17 19:55:43 +01:00
|
|
|
pos = span.parent().attr("id").split("_").pop();
|
|
|
|
url = "/Playlist/set-cue/format/json";
|
2011-01-18 19:34:36 +01:00
|
|
|
cueIn = span.text().trim();
|
2011-01-17 19:55:43 +01:00
|
|
|
|
|
|
|
if(!isTimeValid(cueIn)){
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
$.post(url, {cueIn: cueIn, pos: pos}, function(json){
|
|
|
|
if(json.response.error) {
|
|
|
|
displayEditorError(json.response.error);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
clearEditorError();
|
|
|
|
|
|
|
|
span.empty()
|
|
|
|
.append(json.response.cueIn);
|
|
|
|
|
|
|
|
cueSetUp(pos, json);
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
function changeCueOut() {
|
|
|
|
var pos, url, cueOut, div;
|
|
|
|
|
2011-01-18 19:34:36 +01:00
|
|
|
span = $(this);
|
2011-01-17 19:55:43 +01:00
|
|
|
pos = span.parent().attr("id").split("_").pop();
|
|
|
|
url = "/Playlist/set-cue/format/json";
|
2011-01-18 19:34:36 +01:00
|
|
|
cueOut = span.text().trim();
|
2011-01-17 19:55:43 +01:00
|
|
|
|
|
|
|
if(!isTimeValid(cueOut)){
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
$.post(url, {cueOut: cueOut, pos: pos}, function(json){
|
|
|
|
if(json.response.error) {
|
|
|
|
displayEditorError(json.response.error);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
clearEditorError();
|
|
|
|
|
|
|
|
span.empty()
|
|
|
|
.append(json.response.cueOut);
|
|
|
|
|
|
|
|
cueSetUp(pos, json);
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
function changeFadeIn() {
|
|
|
|
var pos, url, fadeIn, div;
|
|
|
|
|
2011-01-18 19:34:36 +01:00
|
|
|
span = $(this);
|
2011-01-17 19:55:43 +01:00
|
|
|
pos = span.parent().attr("id").split("_").pop();
|
|
|
|
url = "/Playlist/set-fade/format/json";
|
2011-01-18 19:34:36 +01:00
|
|
|
fadeIn = span.text().trim();
|
2011-01-17 19:55:43 +01:00
|
|
|
|
|
|
|
if(!isTimeValid(fadeIn)){
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
$.post(url, {fadeIn: fadeIn, pos: pos}, function(json){
|
|
|
|
if(json.response.error) {
|
|
|
|
displayEditorError(json.response.error);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
clearEditorError();
|
|
|
|
|
|
|
|
span.empty()
|
|
|
|
.append(json.response.fadeIn);
|
|
|
|
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
function changeFadeOut() {
|
|
|
|
var pos, url, fadeOut, div;
|
|
|
|
|
2011-01-18 19:34:36 +01:00
|
|
|
span = $(this);
|
2011-01-17 19:55:43 +01:00
|
|
|
pos = span.parent().attr("id").split("_").pop() - 1;
|
|
|
|
url = "/Playlist/set-fade/format/json";
|
2011-01-18 19:34:36 +01:00
|
|
|
fadeOut = span.text().trim();
|
2011-01-17 19:55:43 +01:00
|
|
|
|
|
|
|
if(!isTimeValid(fadeOut)){
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
$.post(url, {fadeOut: fadeOut, pos: pos}, function(json){
|
|
|
|
if(json.response.error) {
|
|
|
|
displayEditorError(json.response.error);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
clearEditorError();
|
|
|
|
|
|
|
|
span.empty()
|
|
|
|
.append(json.response.fadeOut);
|
|
|
|
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
2011-01-17 01:31:10 +01:00
|
|
|
function setEditorContent(json) {
|
|
|
|
$("#spl_editor")
|
|
|
|
.empty()
|
|
|
|
.append(json.html);
|
2011-01-17 19:55:43 +01:00
|
|
|
|
2011-01-17 19:59:16 +01:00
|
|
|
clearEditorError();
|
|
|
|
|
2011-01-18 19:34:36 +01:00
|
|
|
$(".spl_cue_in span:last").blur(changeCueIn);
|
|
|
|
$(".spl_cue_out span:last").blur(changeCueOut);
|
|
|
|
$(".spl_fade_in span:last").blur(changeFadeIn);
|
|
|
|
$(".spl_fade_out span:last").blur(changeFadeOut);
|
2011-01-17 01:31:10 +01:00
|
|
|
}
|
|
|
|
|
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
|
|
|
|
|
|
|
}
|
|
|
|
|