Merge branch 'devel' of dev.sourcefabric.org:airtime into devel

This commit is contained in:
Martin Konecny 2012-08-30 12:02:44 -04:00
commit ec8d5880ed
2 changed files with 253 additions and 255 deletions

View File

@ -1,248 +1,248 @@
/* function to create popup window */ /* function to create popup window */
function popup(mylink){ function popup(mylink){
if (!window.focus) if (!window.focus)
return true; return true;
var href; var href;
if (typeof(mylink) == 'string') if (typeof(mylink) == 'string')
href=mylink; href=mylink;
else else
href=mylink.href; href=mylink.href;
window.open(href, "player", 'width=300,height=100,scrollbars=yes'); window.open(href, "player", 'width=300,height=100,scrollbars=yes');
return false; return false;
} }
/* Take a string representing a date in the format 2012-04-25 and return /* Take a string representing a date in the format 2012-04-25 and return
* a javascript date object representing this date. */ * a javascript date object representing this date. */
function getDateFromString(time){ function getDateFromString(time){
var date = time.split("-"); var date = time.split("-");
if (date.length != 3){ if (date.length != 3){
return null; return null;
} }
var year = parseInt(date[0], 10); var year = parseInt(date[0], 10);
var month = parseInt(date[1], 10) -1; var month = parseInt(date[1], 10) -1;
var day = parseInt(date[2], 10); var day = parseInt(date[2], 10);
if (isNaN(year) || isNaN(month) || isNaN(day)){ if (isNaN(year) || isNaN(month) || isNaN(day)){
return null; return null;
} }
return new Date(year, month, day); return new Date(year, month, day);
} }
function convertSecondsToDaysHoursMinutesSeconds(seconds){ function convertSecondsToDaysHoursMinutesSeconds(seconds){
if (seconds < 0) if (seconds < 0)
seconds = 0; seconds = 0;
seconds = parseInt(seconds, 10); seconds = parseInt(seconds, 10);
var days = parseInt(seconds / 86400); var days = parseInt(seconds / 86400);
seconds -= days*86400; seconds -= days*86400;
var hours = parseInt(seconds / 3600); var hours = parseInt(seconds / 3600);
seconds -= hours*3600; seconds -= hours*3600;
var minutes = parseInt(seconds / 60); var minutes = parseInt(seconds / 60);
seconds -= minutes*60; seconds -= minutes*60;
return {days:days, hours:hours, minutes:minutes, seconds:seconds}; return {days:days, hours:hours, minutes:minutes, seconds:seconds};
} }
/* Takes an input parameter of milliseconds and converts these into /* Takes an input parameter of milliseconds and converts these into
* the format HH:MM:SS */ * the format HH:MM:SS */
function convertToHHMMSS(timeInMS){ function convertToHHMMSS(timeInMS){
var time = parseInt(timeInMS); var time = parseInt(timeInMS);
var hours = parseInt(time / 3600000); var hours = parseInt(time / 3600000);
time -= 3600000*hours; time -= 3600000*hours;
var minutes = parseInt(time / 60000); var minutes = parseInt(time / 60000);
time -= 60000*minutes; time -= 60000*minutes;
var seconds = parseInt(time / 1000); var seconds = parseInt(time / 1000);
hours = hours.toString(); hours = hours.toString();
minutes = minutes.toString(); minutes = minutes.toString();
seconds = seconds.toString(); seconds = seconds.toString();
if (hours.length == 1) if (hours.length == 1)
hours = "0" + hours; hours = "0" + hours;
if (minutes.length == 1) if (minutes.length == 1)
minutes = "0" + minutes; minutes = "0" + minutes;
if (seconds.length == 1) if (seconds.length == 1)
seconds = "0" + seconds; seconds = "0" + seconds;
if (hours == "00") if (hours == "00")
return minutes + ":" + seconds; return minutes + ":" + seconds;
else else
return hours + ":" + minutes + ":" + seconds; return hours + ":" + minutes + ":" + seconds;
} }
function convertToHHMMSSmm(timeInMS){ function convertToHHMMSSmm(timeInMS){
var time = parseInt(timeInMS); var time = parseInt(timeInMS);
var hours = parseInt(time / 3600000); var hours = parseInt(time / 3600000);
time -= 3600000*hours; time -= 3600000*hours;
var minutes = parseInt(time / 60000); var minutes = parseInt(time / 60000);
time -= 60000*minutes; time -= 60000*minutes;
var seconds = parseInt(time / 1000); var seconds = parseInt(time / 1000);
time -= 1000*seconds; time -= 1000*seconds;
var ms = parseInt(time); var ms = parseInt(time);
hours = hours.toString(); hours = hours.toString();
minutes = minutes.toString(); minutes = minutes.toString();
seconds = seconds.toString(); seconds = seconds.toString();
ms = ms.toString(); ms = ms.toString();
if (hours.length == 1) if (hours.length == 1)
hours = "0" + hours; hours = "0" + hours;
if (minutes.length == 1) if (minutes.length == 1)
minutes = "0" + minutes; minutes = "0" + minutes;
if (seconds.length == 1) if (seconds.length == 1)
seconds = "0" + seconds; seconds = "0" + seconds;
if (ms.length == 3) if (ms.length == 3)
ms = ms.substring(0, 2); ms = ms.substring(0, 2);
else if (ms.length == 2) else if (ms.length == 2)
ms = "0" + ms.substring(0,1); ms = "0" + ms.substring(0,1);
else if (ms.length == 1) else if (ms.length == 1)
ms = "00"; ms = "00";
if (hours == "00") if (hours == "00")
return minutes + ":" + seconds + "." + ms; return minutes + ":" + seconds + "." + ms;
else else
return hours + ":" + minutes + ":" + seconds+ "." + ms; return hours + ":" + minutes + ":" + seconds+ "." + ms;
} }
function convertDateToHHMM(epochTime){ function convertDateToHHMM(epochTime){
var d = new Date(epochTime); var d = new Date(epochTime);
var hours = d.getUTCHours().toString(); var hours = d.getUTCHours().toString();
var minutes = d.getUTCMinutes().toString(); var minutes = d.getUTCMinutes().toString();
if (hours.length == 1) if (hours.length == 1)
hours = "0" + hours; hours = "0" + hours;
if (minutes.length == 1) if (minutes.length == 1)
minutes = "0" + minutes; minutes = "0" + minutes;
return hours + ":" + minutes; return hours + ":" + minutes;
} }
function convertDateToHHMMSS(epochTime){ function convertDateToHHMMSS(epochTime){
var d = new Date(epochTime); var d = new Date(epochTime);
var hours = d.getUTCHours().toString(); var hours = d.getUTCHours().toString();
var minutes = d.getUTCMinutes().toString(); var minutes = d.getUTCMinutes().toString();
var seconds = d.getUTCSeconds().toString(); var seconds = d.getUTCSeconds().toString();
if (hours.length == 1) if (hours.length == 1)
hours = "0" + hours; hours = "0" + hours;
if (minutes.length == 1) if (minutes.length == 1)
minutes = "0" + minutes; minutes = "0" + minutes;
if (seconds.length == 1) if (seconds.length == 1)
seconds = "0" + seconds; seconds = "0" + seconds;
return hours + ":" + minutes + ":" + seconds; return hours + ":" + minutes + ":" + seconds;
} }
/* Takes in a string of format similar to 2011-02-07 02:59:57, /* Takes in a string of format similar to 2011-02-07 02:59:57,
* and converts this to epoch/posix time. */ * and converts this to epoch/posix time. */
function convertDateToPosixTime(s){ function convertDateToPosixTime(s){
var datetime = s.split(" "); var datetime = s.split(" ");
var date = datetime[0].split("-"); var date = datetime[0].split("-");
var time = datetime[1].split(":"); var time = datetime[1].split(":");
var year = date[0]; var year = date[0];
var month = date[1]; var month = date[1];
var day = date[2]; var day = date[2];
var hour = time[0]; var hour = time[0];
var minute = time[1]; var minute = time[1];
var sec = 0; var sec = 0;
var msec = 0; var msec = 0;
if (time[2].indexOf(".") != -1){ if (time[2].indexOf(".") != -1){
var temp = time[2].split("."); var temp = time[2].split(".");
sec = temp[0]; sec = temp[0];
msec = temp[1]; msec = temp[1];
} else } else
sec = time[2]; sec = time[2];
return Date.UTC(year, month-1, day, hour, minute, sec, msec); return Date.UTC(year, month-1, day, hour, minute, sec, msec);
} }
function getFileExt(filename){ function getFileExt(filename){
return filename.split('.').pop(); return filename.split('.').pop();
} }
function audioStream(){ function audioStream(){
if ($("#jquery_jplayer_1").data("jPlayer") && $("#jquery_jplayer_1").data("jPlayer").status.paused != true){ if ($("#jquery_jplayer_1").data("jPlayer") && $("#jquery_jplayer_1").data("jPlayer").status.paused != true){
$('#jquery_jplayer_1').jPlayer('clearMedia'); $('#jquery_jplayer_1').jPlayer('clearMedia');
$('#jquery_jplayer_1').jPlayer('destroy'); $('#jquery_jplayer_1').jPlayer('destroy');
return; return;
} }
var uri = "http://localhost:8000/airtime_128.ogg"; var uri = "http://localhost:8000/airtime_128.ogg";
var ext = getFileExt(uri); var ext = getFileExt(uri);
var media; var media;
var supplied; var supplied;
if (ext == "ogg"){ if (ext == "ogg"){
media = {oga:uri}; media = {oga:uri};
supplied = "oga"; supplied = "oga";
} else { } else {
media = {mp3:uri}; media = {mp3:uri};
supplied = "mp3"; supplied = "mp3";
} }
$("#jquery_jplayer_1").jPlayer({ $("#jquery_jplayer_1").jPlayer({
ready: function () { ready: function () {
$(this).jPlayer("setMedia", media).jPlayer("play"); $(this).jPlayer("setMedia", media).jPlayer("play");
}, },
swfPath: "/js/jplayer", swfPath: "/js/jplayer",
supplied: supplied supplied: supplied
}); });
}
function resizeImg(ele, targetWidth, targetHeight){
var img = $(ele);
var width = ele.width;
var height = ele.height;
// resize img proportionaly
if( width > height && width > targetWidth){
var ratio = targetWidth/width;
img.css("width", targetHeight+"px");
var newHeight = height * ratio;
img.css("height", newHeight+"px");
}else if( width < height && height > targetHeight){
var ratio = targetHeight/height;
img.css("height", targetHeight+"px");
var newWidth = width * ratio;
img.css("width", newWidth+"px");
}else if( width == height && width > targetWidth){
img.css("height", targetHeight+"px");
img.css("width", targetWidth+"px" );
}
}
function resizeToMaxHeight(ele, targetHeight){
var img = $(ele);
var width = ele.width;
var height = ele.height;
// resize img proportionaly
if( height > targetHeight){
var ratio = targetHeight/height;
img.css("height", targetHeight+"px");
var newWidth = width * ratio;
img.css("width", newWidth+"px");
}
} }
function resizeImg(ele, targetWidth, targetHeight){
var img = $(ele);
var width = ele.width;
var height = ele.height;
// resize img proportionaly
if( width > height && width > targetWidth){
var ratio = targetWidth/width;
img.css("width", targetHeight+"px");
var newHeight = height * ratio;
img.css("height", newHeight+"px");
}else if( width < height && height > targetHeight){
var ratio = targetHeight/height;
img.css("height", targetHeight+"px");
var newWidth = width * ratio;
img.css("width", newWidth+"px");
}else if( width == height && width > targetWidth){
img.css("height", targetHeight+"px");
img.css("width", targetWidth+"px" );
}
}
function resizeToMaxHeight(ele, targetHeight){
var img = $(ele);
var width = ele.width;
var height = ele.height;
// resize img proportionaly
if( height > targetHeight){
var ratio = targetHeight/height;
img.css("height", targetHeight+"px");
var newWidth = width * ratio;
img.css("width", newWidth+"px");
}
}

View File

@ -9,7 +9,7 @@ $(document).ready(function() {
unique_names: 'true', unique_names: 'true',
multiple_queues : 'true', multiple_queues : 'true',
filters : [ filters : [
{title: "Audio Files", extensions: "ogg,mp3"} {title: "Audio Files", extensions: "ogg,mp3,oga,flac,aac,bwf"}
] ]
}); });
@ -27,7 +27,9 @@ $(document).ready(function() {
$("#plupload_error table").css("display", "inline-table"); $("#plupload_error table").css("display", "inline-table");
}else{ }else{
var tempFileName = j.tempfilepath; var tempFileName = j.tempfilepath;
$.get('/Plupload/copyfile/format/json/name/'+encodeURIComponent(file.name)+'/tempname/'+encodeURIComponent(tempFileName), function(json){ $.get('/Plupload/copyfile/format/json/name/' +
encodeURIComponent(file.name)+'/tempname/' +
encodeURIComponent(tempFileName), function(json){
var jr = jQuery.parseJSON(json); var jr = jQuery.parseJSON(json);
if(jr.error !== undefined) { if(jr.error !== undefined) {
var row = $("<tr/>") var row = $("<tr/>")
@ -44,12 +46,8 @@ $(document).ready(function() {
var uploadProgress = false; var uploadProgress = false;
uploader.bind('QueueChanged', function(){ uploader.bind('QueueChanged', function(){
if(uploader.files.length > 0){ uploadProgress = (uploader.files.length > 0)
uploadProgress = true; });
}else{
uploadProgress = false;
}
});
uploader.bind('UploadComplete', function(){ uploader.bind('UploadComplete', function(){
uploadProgress = false; uploadProgress = false;