From 2b8bd2ffe9de1ee450377c135a5ec0472b7af630 Mon Sep 17 00:00:00 2001 From: Rudi Grinberg Date: Thu, 30 Aug 2012 11:37:22 -0400 Subject: [PATCH 1/3] cc-1710 removed ^M --- .../js/airtime/dashboard/helperfunctions.js | 494 +++++++++--------- 1 file changed, 247 insertions(+), 247 deletions(-) diff --git a/airtime_mvc/public/js/airtime/dashboard/helperfunctions.js b/airtime_mvc/public/js/airtime/dashboard/helperfunctions.js index 37afa167f..818aef04d 100644 --- a/airtime_mvc/public/js/airtime/dashboard/helperfunctions.js +++ b/airtime_mvc/public/js/airtime/dashboard/helperfunctions.js @@ -1,248 +1,248 @@ -/* function to create popup window */ -function popup(mylink){ - if (!window.focus) - return true; - var href; - if (typeof(mylink) == 'string') - href=mylink; - else - href=mylink.href; - window.open(href, "player", 'width=300,height=100,scrollbars=yes'); - return false; -} - -/* Take a string representing a date in the format 2012-04-25 and return - * a javascript date object representing this date. */ -function getDateFromString(time){ - var date = time.split("-"); - - if (date.length != 3){ - return null; - } - - var year = parseInt(date[0], 10); - var month = parseInt(date[1], 10) -1; - var day = parseInt(date[2], 10); - - if (isNaN(year) || isNaN(month) || isNaN(day)){ - return null; - } - - return new Date(year, month, day); - -} - -function convertSecondsToDaysHoursMinutesSeconds(seconds){ - if (seconds < 0) - seconds = 0; - - seconds = parseInt(seconds, 10); - - var days = parseInt(seconds / 86400); - seconds -= days*86400; - - var hours = parseInt(seconds / 3600); - seconds -= hours*3600; - - var minutes = parseInt(seconds / 60); - seconds -= minutes*60; - - return {days:days, hours:hours, minutes:minutes, seconds:seconds}; -} - -/* Takes an input parameter of milliseconds and converts these into - * the format HH:MM:SS */ -function convertToHHMMSS(timeInMS){ - var time = parseInt(timeInMS); - - var hours = parseInt(time / 3600000); - time -= 3600000*hours; - - var minutes = parseInt(time / 60000); - time -= 60000*minutes; - - var seconds = parseInt(time / 1000); - - hours = hours.toString(); - minutes = minutes.toString(); - seconds = seconds.toString(); - - if (hours.length == 1) - hours = "0" + hours; - if (minutes.length == 1) - minutes = "0" + minutes; - if (seconds.length == 1) - seconds = "0" + seconds; - if (hours == "00") - return minutes + ":" + seconds; - else - return hours + ":" + minutes + ":" + seconds; -} - -function convertToHHMMSSmm(timeInMS){ - var time = parseInt(timeInMS); - - var hours = parseInt(time / 3600000); - time -= 3600000*hours; - - var minutes = parseInt(time / 60000); - time -= 60000*minutes; - - var seconds = parseInt(time / 1000); - time -= 1000*seconds; - - var ms = parseInt(time); - - hours = hours.toString(); - minutes = minutes.toString(); - seconds = seconds.toString(); - ms = ms.toString(); - - if (hours.length == 1) - hours = "0" + hours; - if (minutes.length == 1) - minutes = "0" + minutes; - if (seconds.length == 1) - seconds = "0" + seconds; - - if (ms.length == 3) - ms = ms.substring(0, 2); - else if (ms.length == 2) - ms = "0" + ms.substring(0,1); - else if (ms.length == 1) - ms = "00"; - - if (hours == "00") - return minutes + ":" + seconds + "." + ms; - else - return hours + ":" + minutes + ":" + seconds+ "." + ms; -} - -function convertDateToHHMM(epochTime){ - var d = new Date(epochTime); - - var hours = d.getUTCHours().toString(); - var minutes = d.getUTCMinutes().toString(); - - if (hours.length == 1) - hours = "0" + hours; - if (minutes.length == 1) - minutes = "0" + minutes; - - return hours + ":" + minutes; -} - -function convertDateToHHMMSS(epochTime){ - var d = new Date(epochTime); - - var hours = d.getUTCHours().toString(); - var minutes = d.getUTCMinutes().toString(); - var seconds = d.getUTCSeconds().toString(); - - if (hours.length == 1) - hours = "0" + hours; - if (minutes.length == 1) - minutes = "0" + minutes; - if (seconds.length == 1) - seconds = "0" + seconds; - return hours + ":" + minutes + ":" + seconds; -} - -/* Takes in a string of format similar to 2011-02-07 02:59:57, - * and converts this to epoch/posix time. */ -function convertDateToPosixTime(s){ - - var datetime = s.split(" "); - - var date = datetime[0].split("-"); - var time = datetime[1].split(":"); - - var year = date[0]; - var month = date[1]; - var day = date[2]; - var hour = time[0]; - var minute = time[1]; - var sec = 0; - var msec = 0; - - if (time[2].indexOf(".") != -1){ - var temp = time[2].split("."); - sec = temp[0]; - msec = temp[1]; - } else - sec = time[2]; - - return Date.UTC(year, month-1, day, hour, minute, sec, msec); -} - -function getFileExt(filename){ - return filename.split('.').pop(); -} - -function audioStream(){ - - if ($("#jquery_jplayer_1").data("jPlayer") && $("#jquery_jplayer_1").data("jPlayer").status.paused != true){ - $('#jquery_jplayer_1').jPlayer('clearMedia'); - $('#jquery_jplayer_1').jPlayer('destroy'); - return; - } - - var uri = "http://localhost:8000/airtime_128.ogg"; - var ext = getFileExt(uri); - - var media; - var supplied; - if (ext == "ogg"){ - media = {oga:uri}; - supplied = "oga"; - } else { - media = {mp3:uri}; - supplied = "mp3"; - } - - $("#jquery_jplayer_1").jPlayer({ - ready: function () { - $(this).jPlayer("setMedia", media).jPlayer("play"); - }, - swfPath: "/js/jplayer", - supplied: supplied - }); +/* function to create popup window */ +function popup(mylink){ + if (!window.focus) + return true; + var href; + if (typeof(mylink) == 'string') + href=mylink; + else + href=mylink.href; + window.open(href, "player", 'width=300,height=100,scrollbars=yes'); + return false; +} + +/* Take a string representing a date in the format 2012-04-25 and return + * a javascript date object representing this date. */ +function getDateFromString(time){ + var date = time.split("-"); + + if (date.length != 3){ + return null; + } + + var year = parseInt(date[0], 10); + var month = parseInt(date[1], 10) -1; + var day = parseInt(date[2], 10); + + if (isNaN(year) || isNaN(month) || isNaN(day)){ + return null; + } + + return new Date(year, month, day); + +} + +function convertSecondsToDaysHoursMinutesSeconds(seconds){ + if (seconds < 0) + seconds = 0; + + seconds = parseInt(seconds, 10); + + var days = parseInt(seconds / 86400); + seconds -= days*86400; + + var hours = parseInt(seconds / 3600); + seconds -= hours*3600; + + var minutes = parseInt(seconds / 60); + seconds -= minutes*60; + + return {days:days, hours:hours, minutes:minutes, seconds:seconds}; +} + +/* Takes an input parameter of milliseconds and converts these into + * the format HH:MM:SS */ +function convertToHHMMSS(timeInMS){ + var time = parseInt(timeInMS); + + var hours = parseInt(time / 3600000); + time -= 3600000*hours; + + var minutes = parseInt(time / 60000); + time -= 60000*minutes; + + var seconds = parseInt(time / 1000); + + hours = hours.toString(); + minutes = minutes.toString(); + seconds = seconds.toString(); + + if (hours.length == 1) + hours = "0" + hours; + if (minutes.length == 1) + minutes = "0" + minutes; + if (seconds.length == 1) + seconds = "0" + seconds; + if (hours == "00") + return minutes + ":" + seconds; + else + return hours + ":" + minutes + ":" + seconds; +} + +function convertToHHMMSSmm(timeInMS){ + var time = parseInt(timeInMS); + + var hours = parseInt(time / 3600000); + time -= 3600000*hours; + + var minutes = parseInt(time / 60000); + time -= 60000*minutes; + + var seconds = parseInt(time / 1000); + time -= 1000*seconds; + + var ms = parseInt(time); + + hours = hours.toString(); + minutes = minutes.toString(); + seconds = seconds.toString(); + ms = ms.toString(); + + if (hours.length == 1) + hours = "0" + hours; + if (minutes.length == 1) + minutes = "0" + minutes; + if (seconds.length == 1) + seconds = "0" + seconds; + + if (ms.length == 3) + ms = ms.substring(0, 2); + else if (ms.length == 2) + ms = "0" + ms.substring(0,1); + else if (ms.length == 1) + ms = "00"; + + if (hours == "00") + return minutes + ":" + seconds + "." + ms; + else + return hours + ":" + minutes + ":" + seconds+ "." + ms; +} + +function convertDateToHHMM(epochTime){ + var d = new Date(epochTime); + + var hours = d.getUTCHours().toString(); + var minutes = d.getUTCMinutes().toString(); + + if (hours.length == 1) + hours = "0" + hours; + if (minutes.length == 1) + minutes = "0" + minutes; + + return hours + ":" + minutes; +} + +function convertDateToHHMMSS(epochTime){ + var d = new Date(epochTime); + + var hours = d.getUTCHours().toString(); + var minutes = d.getUTCMinutes().toString(); + var seconds = d.getUTCSeconds().toString(); + + if (hours.length == 1) + hours = "0" + hours; + if (minutes.length == 1) + minutes = "0" + minutes; + if (seconds.length == 1) + seconds = "0" + seconds; + return hours + ":" + minutes + ":" + seconds; +} + +/* Takes in a string of format similar to 2011-02-07 02:59:57, + * and converts this to epoch/posix time. */ +function convertDateToPosixTime(s){ + + var datetime = s.split(" "); + + var date = datetime[0].split("-"); + var time = datetime[1].split(":"); + + var year = date[0]; + var month = date[1]; + var day = date[2]; + var hour = time[0]; + var minute = time[1]; + var sec = 0; + var msec = 0; + + if (time[2].indexOf(".") != -1){ + var temp = time[2].split("."); + sec = temp[0]; + msec = temp[1]; + } else + sec = time[2]; + + return Date.UTC(year, month-1, day, hour, minute, sec, msec); +} + +function getFileExt(filename){ + return filename.split('.').pop(); +} + +function audioStream(){ + + if ($("#jquery_jplayer_1").data("jPlayer") && $("#jquery_jplayer_1").data("jPlayer").status.paused != true){ + $('#jquery_jplayer_1').jPlayer('clearMedia'); + $('#jquery_jplayer_1').jPlayer('destroy'); + return; + } + + var uri = "http://localhost:8000/airtime_128.ogg"; + var ext = getFileExt(uri); + + var media; + var supplied; + if (ext == "ogg"){ + media = {oga:uri}; + supplied = "oga"; + } else { + media = {mp3:uri}; + supplied = "mp3"; + } + + $("#jquery_jplayer_1").jPlayer({ + ready: function () { + $(this).jPlayer("setMedia", media).jPlayer("play"); + }, + swfPath: "/js/jplayer", + 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"); - } -} From bed9989d2aa002704cce937cf8fb71719da197c9 Mon Sep 17 00:00:00 2001 From: Rudi Grinberg Date: Thu, 30 Aug 2012 11:40:05 -0400 Subject: [PATCH 2/3] cc-1710: Added more supported extensions to the allowed upload list --- airtime_mvc/public/js/airtime/library/plupload.js | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/airtime_mvc/public/js/airtime/library/plupload.js b/airtime_mvc/public/js/airtime/library/plupload.js index ab222b6b6..78b476cfa 100644 --- a/airtime_mvc/public/js/airtime/library/plupload.js +++ b/airtime_mvc/public/js/airtime/library/plupload.js @@ -9,7 +9,7 @@ $(document).ready(function() { unique_names: 'true', multiple_queues : 'true', 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"); }else{ 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); if(jr.error !== undefined) { var row = $("") From c09ebce1f0511b16714c1ac3baf126f4891edd0b Mon Sep 17 00:00:00 2001 From: Rudi Grinberg Date: Thu, 30 Aug 2012 11:43:11 -0400 Subject: [PATCH 3/3] cc-1710: Removed verbosity --- airtime_mvc/public/js/airtime/library/plupload.js | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/airtime_mvc/public/js/airtime/library/plupload.js b/airtime_mvc/public/js/airtime/library/plupload.js index 78b476cfa..949cce940 100644 --- a/airtime_mvc/public/js/airtime/library/plupload.js +++ b/airtime_mvc/public/js/airtime/library/plupload.js @@ -46,12 +46,8 @@ $(document).ready(function() { var uploadProgress = false; uploader.bind('QueueChanged', function(){ - if(uploader.files.length > 0){ - uploadProgress = true; - }else{ - uploadProgress = false; - } - }); + uploadProgress = (uploader.files.length > 0) + }); uploader.bind('UploadComplete', function(){ uploadProgress = false;