style(legacy): format (#2039)
This commit is contained in:
parent
7082c9693d
commit
1550d44ac5
122 changed files with 18369 additions and 15819 deletions
|
@ -1,5 +1,5 @@
|
|||
$(document).ready(function() {
|
||||
$.ajaxSetup({
|
||||
cache: false
|
||||
});
|
||||
$(document).ready(function () {
|
||||
$.ajaxSetup({
|
||||
cache: false,
|
||||
});
|
||||
});
|
||||
|
|
|
@ -3,246 +3,273 @@ var _idToPostionLookUp;
|
|||
var URL_BAR_HEIGHT = 32;
|
||||
|
||||
/**
|
||||
*When the page loads the ready function will get all the data it can from the hidden span elements
|
||||
*and call one of three functions depending on weather the window was open to play an audio file,
|
||||
*or a playlist or a show.
|
||||
*/
|
||||
$(document).ready(function(){
|
||||
*When the page loads the ready function will get all the data it can from the hidden span elements
|
||||
*and call one of three functions depending on weather the window was open to play an audio file,
|
||||
*or a playlist or a show.
|
||||
*/
|
||||
$(document).ready(function () {
|
||||
$.jPlayer.timeFormat.showHour = true;
|
||||
|
||||
$.jPlayer.timeFormat.showHour = true;
|
||||
var audioUri = $(".audioUri").text();
|
||||
var audioMime = $(".audioMime").text();
|
||||
var playlistID = $(".playlistID").text();
|
||||
var playlistIndex = $(".playlistIndex").text();
|
||||
var showID = $(".showID").text();
|
||||
var showIndex = $(".showIndex").text();
|
||||
var blockId = $(".blockId").text();
|
||||
var blockIndex = $(".blockIndex").text();
|
||||
|
||||
var audioUri = $('.audioUri').text();
|
||||
var audioMime = $('.audioMime').text();
|
||||
var playlistID = $('.playlistID').text();
|
||||
var playlistIndex = $('.playlistIndex').text();
|
||||
var showID = $('.showID').text();
|
||||
var showIndex = $('.showIndex').text();
|
||||
var blockId = $('.blockId').text();
|
||||
var blockIndex = $('.blockIndex').text();
|
||||
|
||||
_playlist_jplayer = new jPlayerPlaylist({
|
||||
jPlayer: "#jquery_jplayer_1",
|
||||
cssSelectorAncestor: "#jp_container_1"
|
||||
},[], //array of songs will be filled with below's json call
|
||||
_playlist_jplayer = new jPlayerPlaylist(
|
||||
{
|
||||
swfPath: baseUrl+"js/jplayer",
|
||||
supplied:"oga, mp3, m4v, m4a, wav",
|
||||
size: {
|
||||
width: "0px",
|
||||
height: "0px",
|
||||
cssClass: "jp-video-270p"
|
||||
},
|
||||
playlistOptions: {
|
||||
autoPlay: false,
|
||||
loopOnPrevious: false,
|
||||
shuffleOnLoop: true,
|
||||
enableRemoveControls: false,
|
||||
displayTime: 0,
|
||||
addTime: 0,
|
||||
removeTime: 0,
|
||||
shuffleTime: 0
|
||||
},
|
||||
ready: function(){
|
||||
if (playlistID != "" && playlistID !== ""){
|
||||
playAllPlaylist(playlistID, playlistIndex);
|
||||
}else if (audioUri != "") {
|
||||
playOne(audioUri, audioMime);
|
||||
}else if (showID != "") {
|
||||
playAllShow(showID, showIndex);
|
||||
}else if(blockId != "" && blockIndex != ""){
|
||||
playBlock(blockId, blockIndex);
|
||||
}
|
||||
jPlayer: "#jquery_jplayer_1",
|
||||
cssSelectorAncestor: "#jp_container_1",
|
||||
},
|
||||
[], //array of songs will be filled with below's json call
|
||||
{
|
||||
swfPath: baseUrl + "js/jplayer",
|
||||
supplied: "oga, mp3, m4v, m4a, wav",
|
||||
size: {
|
||||
width: "0px",
|
||||
height: "0px",
|
||||
cssClass: "jp-video-270p",
|
||||
},
|
||||
playlistOptions: {
|
||||
autoPlay: false,
|
||||
loopOnPrevious: false,
|
||||
shuffleOnLoop: true,
|
||||
enableRemoveControls: false,
|
||||
displayTime: 0,
|
||||
addTime: 0,
|
||||
removeTime: 0,
|
||||
shuffleTime: 0,
|
||||
},
|
||||
ready: function () {
|
||||
if (playlistID != "" && playlistID !== "") {
|
||||
playAllPlaylist(playlistID, playlistIndex);
|
||||
} else if (audioUri != "") {
|
||||
playOne(audioUri, audioMime);
|
||||
} else if (showID != "") {
|
||||
playAllShow(showID, showIndex);
|
||||
} else if (blockId != "" && blockIndex != "") {
|
||||
playBlock(blockId, blockIndex);
|
||||
}
|
||||
});
|
||||
},
|
||||
}
|
||||
);
|
||||
|
||||
$("#jp_container_1").on("mouseenter", "ul.jp-controls li", function(ev) {
|
||||
$(this).addClass("ui-state-hover");
|
||||
});
|
||||
|
||||
$("#jp_container_1").on("mouseleave", "ul.jp-controls li", function(ev) {
|
||||
$(this).removeClass("ui-state-hover");
|
||||
});
|
||||
$("#jp_container_1").on("mouseenter", "ul.jp-controls li", function (ev) {
|
||||
$(this).addClass("ui-state-hover");
|
||||
});
|
||||
|
||||
$("#jp_container_1").on("mouseleave", "ul.jp-controls li", function (ev) {
|
||||
$(this).removeClass("ui-state-hover");
|
||||
});
|
||||
});
|
||||
|
||||
/**
|
||||
* Sets up the jPlayerPlaylist to play.
|
||||
* - Get the playlist info based on the playlistID give.
|
||||
* - Update the playlistIndex to the position in the pllist to start playing.
|
||||
* - Select the element played from and start playing. If playlist is null then start at index 0.
|
||||
**/
|
||||
* Sets up the jPlayerPlaylist to play.
|
||||
* - Get the playlist info based on the playlistID give.
|
||||
* - Update the playlistIndex to the position in the pllist to start playing.
|
||||
* - Select the element played from and start playing. If playlist is null then start at index 0.
|
||||
**/
|
||||
function playAllPlaylist(p_playlistID, p_playlistIndex) {
|
||||
var viewsPlaylistID = $('.playlistID').text();
|
||||
var viewsPlaylistID = $(".playlistID").text();
|
||||
|
||||
if ( _idToPostionLookUp !== undefined && viewsPlaylistID == p_playlistID ) {
|
||||
play(p_playlistIndex);
|
||||
}else {
|
||||
buildplaylist(baseUrl+"audiopreview/get-playlist/playlistID/"+p_playlistID, p_playlistIndex);
|
||||
}
|
||||
if (_idToPostionLookUp !== undefined && viewsPlaylistID == p_playlistID) {
|
||||
play(p_playlistIndex);
|
||||
} else {
|
||||
buildplaylist(
|
||||
baseUrl + "audiopreview/get-playlist/playlistID/" + p_playlistID,
|
||||
p_playlistIndex
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
function playBlock(p_blockId, p_blockIndex)
|
||||
{
|
||||
var viewsBlockId = $('.blockId').text();
|
||||
function playBlock(p_blockId, p_blockIndex) {
|
||||
var viewsBlockId = $(".blockId").text();
|
||||
|
||||
if ( _idToPostionLookUp !== undefined && viewsBlockId == p_blockId ) {
|
||||
play(p_blockIndex);
|
||||
} else {
|
||||
buildplaylist(baseUrl+"audiopreview/get-block/blockId/"+p_blockId, p_blockIndex);
|
||||
}
|
||||
if (_idToPostionLookUp !== undefined && viewsBlockId == p_blockId) {
|
||||
play(p_blockIndex);
|
||||
} else {
|
||||
buildplaylist(
|
||||
baseUrl + "audiopreview/get-block/blockId/" + p_blockId,
|
||||
p_blockIndex
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets up the show to play.
|
||||
* checks with the show id given to the show id on the page/view
|
||||
* if the show id and the page or views show id are the same it means the user clicked another
|
||||
* file in the same show, so don't refresh the show content tust play the track from the preloaded show.
|
||||
* if the the ids are different they we'll need to get the show's context so create the uri
|
||||
* and call the controller.
|
||||
**/
|
||||
* Sets up the show to play.
|
||||
* checks with the show id given to the show id on the page/view
|
||||
* if the show id and the page or views show id are the same it means the user clicked another
|
||||
* file in the same show, so don't refresh the show content tust play the track from the preloaded show.
|
||||
* if the the ids are different they we'll need to get the show's context so create the uri
|
||||
* and call the controller.
|
||||
**/
|
||||
function playAllShow(p_showID, p_index) {
|
||||
|
||||
var viewsShowID = $('.showID').text();
|
||||
if ( _idToPostionLookUp !== undefined && viewsShowID == p_showID ) {
|
||||
play(p_index);
|
||||
}else {
|
||||
buildplaylist(baseUrl+"audiopreview/get-show/showID/"+p_showID, p_index);
|
||||
}
|
||||
var viewsShowID = $(".showID").text();
|
||||
if (_idToPostionLookUp !== undefined && viewsShowID == p_showID) {
|
||||
play(p_index);
|
||||
} else {
|
||||
buildplaylist(
|
||||
baseUrl + "audiopreview/get-show/showID/" + p_showID,
|
||||
p_index
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* This function will call the AudiopreviewController to get the contents of
|
||||
* either a show or playlist Looping throught the returned contents and
|
||||
* creating media for each track.
|
||||
*
|
||||
* Then trigger the jplayer to play the list.
|
||||
*/
|
||||
* This function will call the AudiopreviewController to get the contents of
|
||||
* either a show or playlist Looping throught the returned contents and
|
||||
* creating media for each track.
|
||||
*
|
||||
* Then trigger the jplayer to play the list.
|
||||
*/
|
||||
function buildplaylist(p_url, p_playIndex) {
|
||||
_idToPostionLookUp = Array();
|
||||
$.getJSON(p_url, function(data){ // get the JSON array produced by my PHP
|
||||
var myPlaylist = new Array();
|
||||
var media;
|
||||
var index;
|
||||
var total = 0;
|
||||
var skipped = 0;
|
||||
_idToPostionLookUp = Array();
|
||||
$.getJSON(p_url, function (data) {
|
||||
// get the JSON array produced by my PHP
|
||||
var myPlaylist = new Array();
|
||||
var media;
|
||||
var index;
|
||||
var total = 0;
|
||||
var skipped = 0;
|
||||
|
||||
for(index in data) {
|
||||
if (data[index]['type'] == 0) {
|
||||
if (data[index]['element_mp3'] != undefined){
|
||||
media = {title: data[index]['element_title'],
|
||||
artist: data[index]['element_artist'],
|
||||
mp3:data[index]['uri']
|
||||
};
|
||||
} else if (data[index]['element_oga'] != undefined) {
|
||||
media = {title: data[index]['element_title'],
|
||||
artist: data[index]['element_artist'],
|
||||
oga:data[index]['uri']
|
||||
};
|
||||
} else if (data[index]['element_m4a'] != undefined) {
|
||||
media = {title: data[index]['element_title'],
|
||||
artist: data[index]['element_artist'],
|
||||
m4a:data[index]['uri']
|
||||
};
|
||||
} else if (data[index]['element_wav'] != undefined) {
|
||||
media = {title: data[index]['element_title'],
|
||||
artist: data[index]['element_artist'],
|
||||
wav:data[index]['uri']
|
||||
};
|
||||
} else {
|
||||
// skip this track since it's not supported
|
||||
console.log("continue");
|
||||
skipped++;
|
||||
continue;
|
||||
}
|
||||
} else if (data[index]['type'] == 1) {
|
||||
var mime = data[index]['mime'];
|
||||
if (mime.search(/mp3/i) > 0 || mime.search(/mpeg/i) > 0) {
|
||||
key = "mp3";
|
||||
} else if (mime.search(/og(g|a)/i) > 0 || mime.search(/vorbis/i) > 0) {
|
||||
key = "oga";
|
||||
} else if (mime.search(/mp4/i) > 0) {
|
||||
key = "m4a";
|
||||
} else if (mime.search(/wav/i) > 0) {
|
||||
key = "wav";
|
||||
}
|
||||
|
||||
if (key) {
|
||||
media = {title: data[index]['element_title'],
|
||||
artist: data[index]['element_artist']
|
||||
};
|
||||
media[key] = data[index]['uri']
|
||||
}
|
||||
}
|
||||
if (media && isAudioSupported(data[index]['mime'])) {
|
||||
// javascript doesn't support associative array with numeric key
|
||||
// so we need to remove the gap if we skip any of tracks due to
|
||||
// browser incompatibility.
|
||||
myPlaylist[index-skipped] = media;
|
||||
}
|
||||
// we should create a map according to the new position in the
|
||||
// player itself total is the index on the player
|
||||
_idToPostionLookUp[data[index]['element_id']] = total;
|
||||
total++;
|
||||
for (index in data) {
|
||||
if (data[index]["type"] == 0) {
|
||||
if (data[index]["element_mp3"] != undefined) {
|
||||
media = {
|
||||
title: data[index]["element_title"],
|
||||
artist: data[index]["element_artist"],
|
||||
mp3: data[index]["uri"],
|
||||
};
|
||||
} else if (data[index]["element_oga"] != undefined) {
|
||||
media = {
|
||||
title: data[index]["element_title"],
|
||||
artist: data[index]["element_artist"],
|
||||
oga: data[index]["uri"],
|
||||
};
|
||||
} else if (data[index]["element_m4a"] != undefined) {
|
||||
media = {
|
||||
title: data[index]["element_title"],
|
||||
artist: data[index]["element_artist"],
|
||||
m4a: data[index]["uri"],
|
||||
};
|
||||
} else if (data[index]["element_wav"] != undefined) {
|
||||
media = {
|
||||
title: data[index]["element_title"],
|
||||
artist: data[index]["element_artist"],
|
||||
wav: data[index]["uri"],
|
||||
};
|
||||
} else {
|
||||
// skip this track since it's not supported
|
||||
console.log("continue");
|
||||
skipped++;
|
||||
continue;
|
||||
}
|
||||
} else if (data[index]["type"] == 1) {
|
||||
var mime = data[index]["mime"];
|
||||
if (mime.search(/mp3/i) > 0 || mime.search(/mpeg/i) > 0) {
|
||||
key = "mp3";
|
||||
} else if (mime.search(/og(g|a)/i) > 0 || mime.search(/vorbis/i) > 0) {
|
||||
key = "oga";
|
||||
} else if (mime.search(/mp4/i) > 0) {
|
||||
key = "m4a";
|
||||
} else if (mime.search(/wav/i) > 0) {
|
||||
key = "wav";
|
||||
}
|
||||
_playlist_jplayer.setPlaylist(myPlaylist);
|
||||
_playlist_jplayer.option("autoPlay", true);
|
||||
play(p_playIndex);
|
||||
|
||||
window.scrollbars = false;
|
||||
|
||||
var container = $("#jp_container_1");
|
||||
// Add 2px to account for borders
|
||||
window.resizeTo(container.width() + 2, container.height() + URL_BAR_HEIGHT + 2);
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
*Function simply plays the given index, for playlists index can be different so need to look up the
|
||||
*right index.
|
||||
*/
|
||||
function play(p_playlistIndex){
|
||||
playlistIndex = _idToPostionLookUp[p_playlistIndex];
|
||||
if(playlistIndex == undefined){
|
||||
playlistIndex = 0
|
||||
if (key) {
|
||||
media = {
|
||||
title: data[index]["element_title"],
|
||||
artist: data[index]["element_artist"],
|
||||
};
|
||||
media[key] = data[index]["uri"];
|
||||
}
|
||||
}
|
||||
if (media && isAudioSupported(data[index]["mime"])) {
|
||||
// javascript doesn't support associative array with numeric key
|
||||
// so we need to remove the gap if we skip any of tracks due to
|
||||
// browser incompatibility.
|
||||
myPlaylist[index - skipped] = media;
|
||||
}
|
||||
// we should create a map according to the new position in the
|
||||
// player itself total is the index on the player
|
||||
_idToPostionLookUp[data[index]["element_id"]] = total;
|
||||
total++;
|
||||
}
|
||||
//_playlist_jplayer.select(playlistIndex);
|
||||
_playlist_jplayer.play(playlistIndex);
|
||||
}
|
||||
_playlist_jplayer.setPlaylist(myPlaylist);
|
||||
_playlist_jplayer.option("autoPlay", true);
|
||||
play(p_playIndex);
|
||||
|
||||
/**
|
||||
* Playing one audio track occurs from the library. This function will create the media, setup
|
||||
* jplayer and play the track.
|
||||
*/
|
||||
function playOne(uri, mime) {
|
||||
var playlist = new Array();
|
||||
|
||||
var media = null;
|
||||
var key = null;
|
||||
if (mime.search(/mp3/i) > 0 || mime.search(/mpeg/i) > 0) {
|
||||
key = "mp3";
|
||||
} else if (mime.search(/og(g|a)/i) > 0 || mime.search(/vorbis/i) > 0) {
|
||||
key = "oga";
|
||||
} else if (mime.search(/mp4/i) > 0) {
|
||||
key = "m4a";
|
||||
} else if (mime.search(/wav/i) > 0) {
|
||||
key = "wav";
|
||||
}
|
||||
|
||||
if (key) {
|
||||
media = {title: $('.audioFileTitle').text() != 'null' ?$('.audioFileTitle').text():"",
|
||||
artist: $('.audioFileArtist').text() != 'null' ?$('.audioFileArtist').text():""
|
||||
};
|
||||
media[key] = uri;
|
||||
}
|
||||
|
||||
if (media) {
|
||||
_playlist_jplayer.option("autoPlay", true);
|
||||
playlist[0] = media;
|
||||
_playlist_jplayer.setPlaylist(playlist);
|
||||
_playlist_jplayer.play(0);
|
||||
}
|
||||
window.scrollbars = false;
|
||||
|
||||
var container = $("#jp_container_1");
|
||||
// Add 2px to account for borders
|
||||
window.resizeTo(container.width() + 2, container.height() + URL_BAR_HEIGHT + 2);
|
||||
window.resizeTo(
|
||||
container.width() + 2,
|
||||
container.height() + URL_BAR_HEIGHT + 2
|
||||
);
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
*Function simply plays the given index, for playlists index can be different so need to look up the
|
||||
*right index.
|
||||
*/
|
||||
function play(p_playlistIndex) {
|
||||
playlistIndex = _idToPostionLookUp[p_playlistIndex];
|
||||
if (playlistIndex == undefined) {
|
||||
playlistIndex = 0;
|
||||
}
|
||||
//_playlist_jplayer.select(playlistIndex);
|
||||
_playlist_jplayer.play(playlistIndex);
|
||||
}
|
||||
|
||||
/**
|
||||
* Playing one audio track occurs from the library. This function will create the media, setup
|
||||
* jplayer and play the track.
|
||||
*/
|
||||
function playOne(uri, mime) {
|
||||
var playlist = new Array();
|
||||
|
||||
var media = null;
|
||||
var key = null;
|
||||
if (mime.search(/mp3/i) > 0 || mime.search(/mpeg/i) > 0) {
|
||||
key = "mp3";
|
||||
} else if (mime.search(/og(g|a)/i) > 0 || mime.search(/vorbis/i) > 0) {
|
||||
key = "oga";
|
||||
} else if (mime.search(/mp4/i) > 0) {
|
||||
key = "m4a";
|
||||
} else if (mime.search(/wav/i) > 0) {
|
||||
key = "wav";
|
||||
}
|
||||
|
||||
if (key) {
|
||||
media = {
|
||||
title:
|
||||
$(".audioFileTitle").text() != "null"
|
||||
? $(".audioFileTitle").text()
|
||||
: "",
|
||||
artist:
|
||||
$(".audioFileArtist").text() != "null"
|
||||
? $(".audioFileArtist").text()
|
||||
: "",
|
||||
};
|
||||
media[key] = uri;
|
||||
}
|
||||
|
||||
if (media) {
|
||||
_playlist_jplayer.option("autoPlay", true);
|
||||
playlist[0] = media;
|
||||
_playlist_jplayer.setPlaylist(playlist);
|
||||
_playlist_jplayer.play(0);
|
||||
}
|
||||
|
||||
var container = $("#jp_container_1");
|
||||
// Add 2px to account for borders
|
||||
window.resizeTo(
|
||||
container.width() + 2,
|
||||
container.height() + URL_BAR_HEIGHT + 2
|
||||
);
|
||||
}
|
||||
|
|
|
@ -1,50 +1,51 @@
|
|||
var AIRTIME = (function(AIRTIME) {
|
||||
var mod, DEFAULT_CLASS = 'ui-button ui-state-default', DISABLED_CLASS = 'ui-state-disabled';
|
||||
var AIRTIME = (function (AIRTIME) {
|
||||
var mod,
|
||||
DEFAULT_CLASS = "ui-button ui-state-default",
|
||||
DISABLED_CLASS = "ui-state-disabled";
|
||||
|
||||
if (AIRTIME.button === undefined) {
|
||||
AIRTIME.button = {};
|
||||
if (AIRTIME.button === undefined) {
|
||||
AIRTIME.button = {};
|
||||
}
|
||||
mod = AIRTIME.button;
|
||||
|
||||
mod.isDisabled = function (c, useParent) {
|
||||
var button = $("." + c);
|
||||
if (useParent) {
|
||||
button = button.parent();
|
||||
}
|
||||
mod = AIRTIME.button;
|
||||
|
||||
mod.isDisabled = function(c, useParent) {
|
||||
var button = $("." + c);
|
||||
if (useParent) {
|
||||
button = button.parent();
|
||||
}
|
||||
if (button.hasClass(DISABLED_CLASS)) {
|
||||
return true;
|
||||
}
|
||||
|
||||
if (button.hasClass(DISABLED_CLASS)) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
};
|
||||
|
||||
return false;
|
||||
};
|
||||
mod.enableButton = function (c, useParent) {
|
||||
if (useParent) {
|
||||
var button = $("." + c).parent();
|
||||
} else {
|
||||
var button = $("." + c);
|
||||
}
|
||||
|
||||
mod.enableButton = function(c, useParent) {
|
||||
if (useParent) {
|
||||
var button = $("." + c).parent();
|
||||
} else {
|
||||
var button = $("." + c);
|
||||
}
|
||||
if (button.hasClass(DISABLED_CLASS)) {
|
||||
button.removeClass(DISABLED_CLASS);
|
||||
button.removeAttr("disabled");
|
||||
}
|
||||
};
|
||||
|
||||
if (button.hasClass(DISABLED_CLASS)) {
|
||||
button.removeClass(DISABLED_CLASS);
|
||||
button.removeAttr('disabled');
|
||||
}
|
||||
};
|
||||
mod.disableButton = function (c, useParent) {
|
||||
if (useParent) {
|
||||
var button = $("." + c).parent();
|
||||
} else {
|
||||
var button = $("." + c);
|
||||
}
|
||||
|
||||
mod.disableButton = function(c, useParent) {
|
||||
if (useParent) {
|
||||
var button = $("." + c).parent();
|
||||
} else {
|
||||
var button = $("." + c);
|
||||
}
|
||||
if (!button.hasClass(DISABLED_CLASS)) {
|
||||
button.addClass(DISABLED_CLASS);
|
||||
button.attr("disabled", "disabled");
|
||||
}
|
||||
};
|
||||
|
||||
if (!button.hasClass(DISABLED_CLASS)) {
|
||||
button.addClass(DISABLED_CLASS);
|
||||
button.attr('disabled', 'disabled');
|
||||
}
|
||||
};
|
||||
|
||||
return AIRTIME;
|
||||
|
||||
}(AIRTIME || {}));
|
||||
return AIRTIME;
|
||||
})(AIRTIME || {});
|
||||
|
|
|
@ -1,24 +1,28 @@
|
|||
function isAudioSupported(mime) {
|
||||
var audio = new Audio();
|
||||
|
||||
function isAudioSupported(mime){
|
||||
var audio = new Audio();
|
||||
if (typeof mime !== "string" || mime === null) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if ((typeof mime) !== "string" || (mime === null)) {
|
||||
return false;
|
||||
}
|
||||
var bMime = null;
|
||||
if (mime.indexOf("ogg") != -1 || mime.indexOf("vorbis") != -1) {
|
||||
bMime = 'audio/ogg; codecs="vorbis"';
|
||||
} else {
|
||||
bMime = mime;
|
||||
}
|
||||
|
||||
var bMime = null;
|
||||
if (mime.indexOf("ogg") != -1 || mime.indexOf("vorbis") != -1) {
|
||||
bMime = 'audio/ogg; codecs="vorbis"';
|
||||
} else {
|
||||
bMime = mime;
|
||||
}
|
||||
|
||||
//return a true of the browser can play this file natively, or if the
|
||||
//file is an mp3 and flash is installed (jPlayer will fall back to flash to play mp3s).
|
||||
//Note that checking the navigator.mimeTypes value does not work for IE7, but the alternative
|
||||
//is adding a javascript library to do the work for you, which seems like overkill....
|
||||
return (!!audio.canPlayType && audio.canPlayType(bMime) != "") ||
|
||||
(mime.indexOf("mp3") != -1 && navigator.mimeTypes ["application/x-shockwave-flash"] != undefined) ||
|
||||
(mime.indexOf("mp4") != -1 && navigator.mimeTypes ["application/x-shockwave-flash"] != undefined) ||
|
||||
(mime.indexOf("mpeg") != -1 && navigator.mimeTypes ["application/x-shockwave-flash"] != undefined);
|
||||
//return a true of the browser can play this file natively, or if the
|
||||
//file is an mp3 and flash is installed (jPlayer will fall back to flash to play mp3s).
|
||||
//Note that checking the navigator.mimeTypes value does not work for IE7, but the alternative
|
||||
//is adding a javascript library to do the work for you, which seems like overkill....
|
||||
return (
|
||||
(!!audio.canPlayType && audio.canPlayType(bMime) != "") ||
|
||||
(mime.indexOf("mp3") != -1 &&
|
||||
navigator.mimeTypes["application/x-shockwave-flash"] != undefined) ||
|
||||
(mime.indexOf("mp4") != -1 &&
|
||||
navigator.mimeTypes["application/x-shockwave-flash"] != undefined) ||
|
||||
(mime.indexOf("mpeg") != -1 &&
|
||||
navigator.mimeTypes["application/x-shockwave-flash"] != undefined)
|
||||
);
|
||||
}
|
||||
|
|
|
@ -1,17 +1,18 @@
|
|||
var previewWidth = 482,
|
||||
previewHeight = 110;
|
||||
previewHeight = 110;
|
||||
|
||||
$(document).ready(function() {
|
||||
$(document).ready(function () {
|
||||
/* Removed as this is now (hopefully) unnecessary */
|
||||
//$("#Panel").stickyPanel({
|
||||
// topPadding: 1,
|
||||
// afterDetachCSSClass: "floated-panel",
|
||||
// savePanelSpace: true
|
||||
//});
|
||||
|
||||
/* Removed as this is now (hopefully) unnecessary */
|
||||
//$("#Panel").stickyPanel({
|
||||
// topPadding: 1,
|
||||
// afterDetachCSSClass: "floated-panel",
|
||||
// savePanelSpace: true
|
||||
//});
|
||||
|
||||
//this statement tells the browser to fade out any success message after 5 seconds
|
||||
setTimeout(function(){$(".success").fadeOut("slow")}, 5000);
|
||||
//this statement tells the browser to fade out any success message after 5 seconds
|
||||
setTimeout(function () {
|
||||
$(".success").fadeOut("slow");
|
||||
}, 5000);
|
||||
});
|
||||
|
||||
/*
|
||||
|
@ -19,105 +20,104 @@ $(document).ready(function() {
|
|||
* which we use in multiple places
|
||||
*/
|
||||
var i18n_months = [
|
||||
$.i18n._("January"),
|
||||
$.i18n._("February"),
|
||||
$.i18n._("March"),
|
||||
$.i18n._("April"),
|
||||
$.i18n._("May"),
|
||||
$.i18n._("June"),
|
||||
$.i18n._("July"),
|
||||
$.i18n._("August"),
|
||||
$.i18n._("September"),
|
||||
$.i18n._("October"),
|
||||
$.i18n._("November"),
|
||||
$.i18n._("December")
|
||||
$.i18n._("January"),
|
||||
$.i18n._("February"),
|
||||
$.i18n._("March"),
|
||||
$.i18n._("April"),
|
||||
$.i18n._("May"),
|
||||
$.i18n._("June"),
|
||||
$.i18n._("July"),
|
||||
$.i18n._("August"),
|
||||
$.i18n._("September"),
|
||||
$.i18n._("October"),
|
||||
$.i18n._("November"),
|
||||
$.i18n._("December"),
|
||||
];
|
||||
|
||||
var i18n_months_short = [
|
||||
$.i18n._("Jan"),
|
||||
$.i18n._("Feb"),
|
||||
$.i18n._("Mar"),
|
||||
$.i18n._("Apr"),
|
||||
$.i18n._("May"),
|
||||
$.i18n._("Jun"),
|
||||
$.i18n._("Jul"),
|
||||
$.i18n._("Aug"),
|
||||
$.i18n._("Sep"),
|
||||
$.i18n._("Oct"),
|
||||
$.i18n._("Nov"),
|
||||
$.i18n._("Dec")
|
||||
$.i18n._("Jan"),
|
||||
$.i18n._("Feb"),
|
||||
$.i18n._("Mar"),
|
||||
$.i18n._("Apr"),
|
||||
$.i18n._("May"),
|
||||
$.i18n._("Jun"),
|
||||
$.i18n._("Jul"),
|
||||
$.i18n._("Aug"),
|
||||
$.i18n._("Sep"),
|
||||
$.i18n._("Oct"),
|
||||
$.i18n._("Nov"),
|
||||
$.i18n._("Dec"),
|
||||
];
|
||||
|
||||
var i18n_days_short = [
|
||||
$.i18n._("Su"),
|
||||
$.i18n._("Mo"),
|
||||
$.i18n._("Tu"),
|
||||
$.i18n._("We"),
|
||||
$.i18n._("Th"),
|
||||
$.i18n._("Fr"),
|
||||
$.i18n._("Sa")
|
||||
$.i18n._("Su"),
|
||||
$.i18n._("Mo"),
|
||||
$.i18n._("Tu"),
|
||||
$.i18n._("We"),
|
||||
$.i18n._("Th"),
|
||||
$.i18n._("Fr"),
|
||||
$.i18n._("Sa"),
|
||||
];
|
||||
|
||||
var HTTPMethods = Object.freeze({
|
||||
GET: "GET",
|
||||
POST: "POST",
|
||||
PUT: "PUT",
|
||||
PATCH: "PATCH",
|
||||
DELETE: "DELETE",
|
||||
OPTIONS: "OPTIONS"
|
||||
GET: "GET",
|
||||
POST: "POST",
|
||||
PUT: "PUT",
|
||||
PATCH: "PATCH",
|
||||
DELETE: "DELETE",
|
||||
OPTIONS: "OPTIONS",
|
||||
});
|
||||
|
||||
var dateStartId = "#sb_date_start",
|
||||
timeStartId = "#sb_time_start",
|
||||
dateEndId = "#sb_date_end",
|
||||
timeEndId = "#sb_time_end";
|
||||
timeStartId = "#sb_time_start",
|
||||
dateEndId = "#sb_date_end",
|
||||
timeEndId = "#sb_time_end";
|
||||
|
||||
function getDatatablesStrings(overrideDict) {
|
||||
var dict = {
|
||||
sEmptyTable: $.i18n._("No data available in table"),
|
||||
sInfo: $.i18n._("Showing _START_ to _END_ of _TOTAL_ entries"),
|
||||
sInfoEmpty: $.i18n._("Showing 0 to 0 of 0 entries"),
|
||||
sInfoFiltered: "", // $.i18n._("(filtered from _MAX_ total entries)"),
|
||||
sInfoPostFix: $.i18n._(""),
|
||||
sInfoThousands: $.i18n._(","),
|
||||
sLengthMenu: $.i18n._("Show _MENU_"),
|
||||
sLoadingRecords: $.i18n._("Loading..."),
|
||||
//"sProcessing": $.i18n._("Processing..."),
|
||||
sProcessing: $.i18n._(""),
|
||||
sSearch: $.i18n._(""),
|
||||
sZeroRecords: $.i18n._("No matching records found"),
|
||||
oPaginate: {
|
||||
sFirst: "«",
|
||||
sLast: "»",
|
||||
sNext: "›",
|
||||
sPrevious: "‹",
|
||||
},
|
||||
//"oPaginate": {
|
||||
// "sFirst": $.i18n._("First"),
|
||||
// "sLast": $.i18n._("Last"),
|
||||
// "sNext": $.i18n._("Next"),
|
||||
// "sPrevious": $.i18n._("Previous")
|
||||
//},
|
||||
oAria: {
|
||||
sSortAscending: $.i18n._(": activate to sort column ascending"),
|
||||
sSortDescending: $.i18n._(": activate to sort column descending"),
|
||||
},
|
||||
};
|
||||
|
||||
var dict = {
|
||||
"sEmptyTable": $.i18n._("No data available in table"),
|
||||
"sInfo": $.i18n._("Showing _START_ to _END_ of _TOTAL_ entries"),
|
||||
"sInfoEmpty": $.i18n._("Showing 0 to 0 of 0 entries"),
|
||||
"sInfoFiltered": "", // $.i18n._("(filtered from _MAX_ total entries)"),
|
||||
"sInfoPostFix": $.i18n._(""),
|
||||
"sInfoThousands": $.i18n._(","),
|
||||
"sLengthMenu": $.i18n._("Show _MENU_"),
|
||||
"sLoadingRecords": $.i18n._("Loading..."),
|
||||
//"sProcessing": $.i18n._("Processing..."),
|
||||
"sProcessing": $.i18n._(""),
|
||||
"sSearch": $.i18n._(""),
|
||||
"sZeroRecords": $.i18n._("No matching records found"),
|
||||
"oPaginate": {
|
||||
"sFirst": "«",
|
||||
"sLast": "»",
|
||||
"sNext": "›",
|
||||
"sPrevious": "‹"
|
||||
},
|
||||
//"oPaginate": {
|
||||
// "sFirst": $.i18n._("First"),
|
||||
// "sLast": $.i18n._("Last"),
|
||||
// "sNext": $.i18n._("Next"),
|
||||
// "sPrevious": $.i18n._("Previous")
|
||||
//},
|
||||
"oAria": {
|
||||
"sSortAscending": $.i18n._(": activate to sort column ascending"),
|
||||
"sSortDescending": $.i18n._(": activate to sort column descending")
|
||||
}
|
||||
};
|
||||
|
||||
return $.extend({}, dict, overrideDict);
|
||||
return $.extend({}, dict, overrideDict);
|
||||
}
|
||||
|
||||
function adjustDateToServerDate(date, serverTimezoneOffset){
|
||||
//date object stores time in the browser's localtime. We need to artificially shift
|
||||
//it to
|
||||
var timezoneOffset = date.getTimezoneOffset()*60*1000;
|
||||
function adjustDateToServerDate(date, serverTimezoneOffset) {
|
||||
//date object stores time in the browser's localtime. We need to artificially shift
|
||||
//it to
|
||||
var timezoneOffset = date.getTimezoneOffset() * 60 * 1000;
|
||||
|
||||
date.setTime(date.getTime() + timezoneOffset + serverTimezoneOffset*1000);
|
||||
date.setTime(date.getTime() + timezoneOffset + serverTimezoneOffset * 1000);
|
||||
|
||||
/* date object has been shifted to artificial UTC time. Now let's
|
||||
* shift it to the server's timezone */
|
||||
return date;
|
||||
/* date object has been shifted to artificial UTC time. Now let's
|
||||
* shift it to the server's timezone */
|
||||
return date;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -129,27 +129,31 @@ var _preview_window = null;
|
|||
*Gets the info from the view when menu action play choosen and opens the jplayer window.
|
||||
*/
|
||||
function openAudioPreview(p_event) {
|
||||
p_event.stopPropagation();
|
||||
p_event.stopPropagation();
|
||||
|
||||
var audioFileID = $(this).attr('audioFile');
|
||||
var objId = $('.obj_id:first').attr('value');
|
||||
var objType = $('.obj_type:first').attr('value');
|
||||
var playIndex = $(this).parent().parent().attr('id');
|
||||
playIndex = playIndex.substring(4); //remove the spl_
|
||||
var audioFileID = $(this).attr("audioFile");
|
||||
var objId = $(".obj_id:first").attr("value");
|
||||
var objType = $(".obj_type:first").attr("value");
|
||||
var playIndex = $(this).parent().parent().attr("id");
|
||||
playIndex = playIndex.substring(4); //remove the spl_
|
||||
|
||||
if (objType == "playlist") {
|
||||
open_playlist_preview(objId, playIndex);
|
||||
} else if (objType == "block") {
|
||||
open_block_preview(objId, playIndex);
|
||||
}
|
||||
if (objType == "playlist") {
|
||||
open_playlist_preview(objId, playIndex);
|
||||
} else if (objType == "block") {
|
||||
open_block_preview(objId, playIndex);
|
||||
}
|
||||
}
|
||||
|
||||
function open_audio_preview(type, id) {
|
||||
// The reason that we need to encode artist and title string is that
|
||||
// sometime they contain '/' or '\' and apache reject %2f or %5f
|
||||
// so the work around is to encode it twice.
|
||||
openPreviewWindow(baseUrl+'audiopreview/audio-preview/audioFileID/'+id+'/type/'+type, previewWidth, previewHeight);
|
||||
_preview_window.focus();
|
||||
// The reason that we need to encode artist and title string is that
|
||||
// sometime they contain '/' or '\' and apache reject %2f or %5f
|
||||
// so the work around is to encode it twice.
|
||||
openPreviewWindow(
|
||||
baseUrl + "audiopreview/audio-preview/audioFileID/" + id + "/type/" + type,
|
||||
previewWidth,
|
||||
previewHeight
|
||||
);
|
||||
_preview_window.focus();
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -159,26 +163,43 @@ function open_audio_preview(type, id) {
|
|||
*given index.
|
||||
*/
|
||||
function open_playlist_preview(p_playlistID, p_playlistIndex) {
|
||||
if (p_playlistIndex == undefined) //Use a resonable default.
|
||||
p_playlistIndex = 0;
|
||||
if (p_playlistIndex == undefined)
|
||||
//Use a resonable default.
|
||||
p_playlistIndex = 0;
|
||||
|
||||
|
||||
if (_preview_window != null && !_preview_window.closed)
|
||||
_preview_window.playAllPlaylist(p_playlistID, p_playlistIndex);
|
||||
else
|
||||
openPreviewWindow(baseUrl+'audiopreview/playlist-preview/playlistIndex/'+p_playlistIndex+'/playlistID/'+p_playlistID, previewWidth, previewHeight);
|
||||
_preview_window.focus();
|
||||
if (_preview_window != null && !_preview_window.closed)
|
||||
_preview_window.playAllPlaylist(p_playlistID, p_playlistIndex);
|
||||
else
|
||||
openPreviewWindow(
|
||||
baseUrl +
|
||||
"audiopreview/playlist-preview/playlistIndex/" +
|
||||
p_playlistIndex +
|
||||
"/playlistID/" +
|
||||
p_playlistID,
|
||||
previewWidth,
|
||||
previewHeight
|
||||
);
|
||||
_preview_window.focus();
|
||||
}
|
||||
|
||||
function open_block_preview(p_blockId, p_blockIndex) {
|
||||
if (p_blockIndex == undefined) //Use a resonable default.
|
||||
p_blockIndex = 0;
|
||||
if (p_blockIndex == undefined)
|
||||
//Use a resonable default.
|
||||
p_blockIndex = 0;
|
||||
|
||||
if (_preview_window != null && !_preview_window.closed)
|
||||
_preview_window.playBlock(p_blockId, p_blockIndex);
|
||||
else
|
||||
openPreviewWindow(baseUrl+'audiopreview/block-preview/blockIndex/'+p_blockIndex+'/blockId/'+p_blockId, previewWidth, previewHeight);
|
||||
_preview_window.focus();
|
||||
if (_preview_window != null && !_preview_window.closed)
|
||||
_preview_window.playBlock(p_blockId, p_blockIndex);
|
||||
else
|
||||
openPreviewWindow(
|
||||
baseUrl +
|
||||
"audiopreview/block-preview/blockIndex/" +
|
||||
p_blockIndex +
|
||||
"/blockId/" +
|
||||
p_blockId,
|
||||
previewWidth,
|
||||
previewHeight
|
||||
);
|
||||
_preview_window.focus();
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -188,134 +209,159 @@ function open_block_preview(p_blockId, p_blockIndex) {
|
|||
*given index.
|
||||
*/
|
||||
function open_show_preview(p_showID, p_showIndex) {
|
||||
if (_preview_window != null && !_preview_window.closed)
|
||||
_preview_window.playAllShow(p_showID, p_showIndex);
|
||||
else
|
||||
openPreviewWindow(baseUrl+'audiopreview/show-preview/showID/'+p_showID+'/showIndex/'+p_showIndex, previewWidth, previewHeight);
|
||||
_preview_window.focus();
|
||||
if (_preview_window != null && !_preview_window.closed)
|
||||
_preview_window.playAllShow(p_showID, p_showIndex);
|
||||
else
|
||||
openPreviewWindow(
|
||||
baseUrl +
|
||||
"audiopreview/show-preview/showID/" +
|
||||
p_showID +
|
||||
"/showIndex/" +
|
||||
p_showIndex,
|
||||
previewWidth,
|
||||
previewHeight
|
||||
);
|
||||
_preview_window.focus();
|
||||
}
|
||||
|
||||
function openPreviewWindow(url, w, h) {
|
||||
var dim = (w && h) ? 'width=' + w + ',height=' + h + ',' : '';
|
||||
// Hardcoding this here is kinda gross, but the alternatives aren't much better...
|
||||
_preview_window = window.open(url, $.i18n._('Audio Player'), dim + 'scrollbars=yes');
|
||||
return false;
|
||||
var dim = w && h ? "width=" + w + ",height=" + h + "," : "";
|
||||
// Hardcoding this here is kinda gross, but the alternatives aren't much better...
|
||||
_preview_window = window.open(
|
||||
url,
|
||||
$.i18n._("Audio Player"),
|
||||
dim + "scrollbars=yes"
|
||||
);
|
||||
return false;
|
||||
}
|
||||
|
||||
function validateTimeRange() {
|
||||
var oRange,
|
||||
inputs = $('.sb-timerange > input'),
|
||||
start, end;
|
||||
var oRange,
|
||||
inputs = $(".sb-timerange > input"),
|
||||
start,
|
||||
end;
|
||||
|
||||
oRange = AIRTIME.utilities.fnGetScheduleRange(dateStartId, timeStartId, dateEndId, timeEndId);
|
||||
oRange = AIRTIME.utilities.fnGetScheduleRange(
|
||||
dateStartId,
|
||||
timeStartId,
|
||||
dateEndId,
|
||||
timeEndId
|
||||
);
|
||||
|
||||
start = oRange.start;
|
||||
end = oRange.end;
|
||||
start = oRange.start;
|
||||
end = oRange.end;
|
||||
|
||||
if (end >= start) {
|
||||
inputs.removeClass('error');
|
||||
} else {
|
||||
if (!inputs.hasClass('error')) {
|
||||
inputs.addClass('error');
|
||||
}
|
||||
if (end >= start) {
|
||||
inputs.removeClass("error");
|
||||
} else {
|
||||
if (!inputs.hasClass("error")) {
|
||||
inputs.addClass("error");
|
||||
}
|
||||
}
|
||||
|
||||
return {
|
||||
start: start,
|
||||
end: end,
|
||||
isValid: end >= start
|
||||
};
|
||||
return {
|
||||
start: start,
|
||||
end: end,
|
||||
isValid: end >= start,
|
||||
};
|
||||
}
|
||||
|
||||
// validate uploaded images
|
||||
function validateImage(img, el) {
|
||||
// remove any existing error messages
|
||||
if ($("#img-err")) { $("#img-err").remove(); }
|
||||
// remove any existing error messages
|
||||
if ($("#img-err")) {
|
||||
$("#img-err").remove();
|
||||
}
|
||||
|
||||
if (img.size > 2048000) { // 2MB - pull this from somewhere instead?
|
||||
// hack way of inserting an error message
|
||||
var err = $.i18n._("Selected file is too large");
|
||||
el.parent().after(
|
||||
"<ul id='img-err' class='errors'>" +
|
||||
"<li>" + err + "</li>" +
|
||||
"</ul>");
|
||||
return false;
|
||||
} else if (validateMimeType(img.type) < 0) {
|
||||
var err = $.i18n._("File format is not supported");
|
||||
el.parent().after(
|
||||
"<ul id='img-err' class='errors'>" +
|
||||
"<li>" + err + "</li>" +
|
||||
"</ul>");
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
if (img.size > 2048000) {
|
||||
// 2MB - pull this from somewhere instead?
|
||||
// hack way of inserting an error message
|
||||
var err = $.i18n._("Selected file is too large");
|
||||
el.parent().after(
|
||||
"<ul id='img-err' class='errors'>" + "<li>" + err + "</li>" + "</ul>"
|
||||
);
|
||||
return false;
|
||||
} else if (validateMimeType(img.type) < 0) {
|
||||
var err = $.i18n._("File format is not supported");
|
||||
el.parent().after(
|
||||
"<ul id='img-err' class='errors'>" + "<li>" + err + "</li>" + "</ul>"
|
||||
);
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
// validate image mime type
|
||||
function validateMimeType(mime) {
|
||||
var extensions = [
|
||||
'image/jpeg',
|
||||
'image/png',
|
||||
'image/gif'
|
||||
// BMP?
|
||||
];
|
||||
return $.inArray(mime, extensions);
|
||||
var extensions = [
|
||||
"image/jpeg",
|
||||
"image/png",
|
||||
"image/gif",
|
||||
// BMP?
|
||||
];
|
||||
return $.inArray(mime, extensions);
|
||||
}
|
||||
|
||||
function pad(number, length) {
|
||||
return sprintf("%'0"+length+"d", number);
|
||||
return sprintf("%'0" + length + "d", number);
|
||||
}
|
||||
|
||||
function removeSuccessMsg() {
|
||||
var $status = $('.success');
|
||||
var $status = $(".success");
|
||||
|
||||
$status.fadeOut("slow", function(){$status.empty()});
|
||||
$status.fadeOut("slow", function () {
|
||||
$status.empty();
|
||||
});
|
||||
}
|
||||
|
||||
function hideHint(h) {
|
||||
h.hide("slow").addClass("hidden");
|
||||
h.hide("slow").addClass("hidden");
|
||||
}
|
||||
|
||||
function showHint(h) {
|
||||
h.show("slow").removeClass("hidden");
|
||||
h.show("slow").removeClass("hidden");
|
||||
}
|
||||
|
||||
function getUsabilityHint() {
|
||||
var pathname = window.location.pathname;
|
||||
$.getJSON(baseUrl + "api/get-usability-hint", {"format": "json", "userPath": pathname}, function(json) {
|
||||
var $hint_div = $('.usability_hint');
|
||||
var current_hint = $hint_div.html();
|
||||
if (json === "") {
|
||||
// there are no more hints to display to the user
|
||||
hideHint($hint_div);
|
||||
} else if (current_hint !== json) {
|
||||
// we only change the message if it is new
|
||||
if ($hint_div.is(":visible")) {
|
||||
hideHint($hint_div);
|
||||
}
|
||||
$hint_div.html(json);
|
||||
showHint($hint_div);
|
||||
} else {
|
||||
// hint is the same before we hid it so we just need to show it
|
||||
if ($hint_div.is(":hidden")) {
|
||||
showHint($hint_div);
|
||||
}
|
||||
var pathname = window.location.pathname;
|
||||
$.getJSON(
|
||||
baseUrl + "api/get-usability-hint",
|
||||
{ format: "json", userPath: pathname },
|
||||
function (json) {
|
||||
var $hint_div = $(".usability_hint");
|
||||
var current_hint = $hint_div.html();
|
||||
if (json === "") {
|
||||
// there are no more hints to display to the user
|
||||
hideHint($hint_div);
|
||||
} else if (current_hint !== json) {
|
||||
// we only change the message if it is new
|
||||
if ($hint_div.is(":visible")) {
|
||||
hideHint($hint_div);
|
||||
}
|
||||
});
|
||||
$hint_div.html(json);
|
||||
showHint($hint_div);
|
||||
} else {
|
||||
// hint is the same before we hid it so we just need to show it
|
||||
if ($hint_div.is(":hidden")) {
|
||||
showHint($hint_div);
|
||||
}
|
||||
}
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
// TODO: build this out so we can use it as a fallback in fail cases
|
||||
function buildErrorDialog(message) {
|
||||
var el = $("<div id='error_dialog'></div>");
|
||||
el.text(message);
|
||||
$(document.body).append(el);
|
||||
$("#error_dialog").dialog({
|
||||
title: $.i18n._("Something went wrong!"),
|
||||
resizable: false,
|
||||
modal: true,
|
||||
width: "auto",
|
||||
height: "auto"
|
||||
});
|
||||
var el = $("<div id='error_dialog'></div>");
|
||||
el.text(message);
|
||||
$(document.body).append(el);
|
||||
$("#error_dialog").dialog({
|
||||
title: $.i18n._("Something went wrong!"),
|
||||
resizable: false,
|
||||
modal: true,
|
||||
width: "auto",
|
||||
height: "auto",
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -324,35 +370,44 @@ function buildErrorDialog(message) {
|
|||
* @param selector jQuery selector to search descendants
|
||||
* @returns {jQuery}
|
||||
*/
|
||||
jQuery.fn.addTitles = function(selector) {
|
||||
this.each(function() {
|
||||
// Put this in a mouseenter event handler so it's dynamic
|
||||
// (newly created elements will have the title applied on hover)
|
||||
$(this).on("mouseenter", selector, function () {
|
||||
$(this).attr("title", $(this).text());
|
||||
});
|
||||
jQuery.fn.addTitles = function (selector) {
|
||||
this.each(function () {
|
||||
// Put this in a mouseenter event handler so it's dynamic
|
||||
// (newly created elements will have the title applied on hover)
|
||||
$(this).on("mouseenter", selector, function () {
|
||||
$(this).attr("title", $(this).text());
|
||||
});
|
||||
});
|
||||
|
||||
return this; // jQuery chaining
|
||||
return this; // jQuery chaining
|
||||
};
|
||||
|
||||
// XXX: Old code to pan selector text; keeping this around in case we want to use it later - Duncan
|
||||
jQuery.fn.scrollText = function(selector) {
|
||||
this.each(function () {
|
||||
$(this).on("mouseenter", selector, function () {
|
||||
var sw = $(this)[0].scrollWidth - parseFloat($(this).css("textIndent")), iw = $(this).innerWidth();
|
||||
if (sw > iw) {
|
||||
$(this).stop().animate({
|
||||
textIndent: "-" + (sw + 1 - iw) + "px"
|
||||
}, sw * 8);
|
||||
}
|
||||
});
|
||||
$(this).on("mouseleave", selector, function () {
|
||||
$(this).stop().animate({
|
||||
textIndent: "0"
|
||||
}, 500);
|
||||
});
|
||||
jQuery.fn.scrollText = function (selector) {
|
||||
this.each(function () {
|
||||
$(this).on("mouseenter", selector, function () {
|
||||
var sw = $(this)[0].scrollWidth - parseFloat($(this).css("textIndent")),
|
||||
iw = $(this).innerWidth();
|
||||
if (sw > iw) {
|
||||
$(this)
|
||||
.stop()
|
||||
.animate(
|
||||
{
|
||||
textIndent: "-" + (sw + 1 - iw) + "px",
|
||||
},
|
||||
sw * 8
|
||||
);
|
||||
}
|
||||
});
|
||||
$(this).on("mouseleave", selector, function () {
|
||||
$(this).stop().animate(
|
||||
{
|
||||
textIndent: "0",
|
||||
},
|
||||
500
|
||||
);
|
||||
});
|
||||
});
|
||||
|
||||
return this;
|
||||
return this;
|
||||
};
|
||||
|
|
|
@ -1,88 +1,100 @@
|
|||
|
||||
$(document).ready(function() {
|
||||
$("#facebook-login").click(function() {
|
||||
AIRTIME.facebook.promptForFacebookPage();
|
||||
});
|
||||
$(document).ready(function () {
|
||||
$("#facebook-login").click(function () {
|
||||
AIRTIME.facebook.promptForFacebookPage();
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
window.fbAsyncInit = function() {
|
||||
FB.init({
|
||||
appId : FACEBOOK_APP_ID,
|
||||
xfbml : true,
|
||||
version : 'v2.4'
|
||||
});
|
||||
window.fbAsyncInit = function () {
|
||||
FB.init({
|
||||
appId: FACEBOOK_APP_ID,
|
||||
xfbml: true,
|
||||
version: "v2.4",
|
||||
});
|
||||
};
|
||||
|
||||
var AIRTIME = (function(AIRTIME) {
|
||||
var AIRTIME = (function (AIRTIME) {
|
||||
//Module initialization
|
||||
if (AIRTIME.facebook === undefined) {
|
||||
AIRTIME.facebook = {};
|
||||
}
|
||||
|
||||
//Module initialization
|
||||
if (AIRTIME.facebook === undefined) {
|
||||
AIRTIME.facebook = {};
|
||||
var mod = AIRTIME.facebook;
|
||||
|
||||
(function (d, s, id) {
|
||||
var js,
|
||||
fjs = d.getElementsByTagName(s)[0];
|
||||
if (d.getElementById(id)) {
|
||||
return;
|
||||
}
|
||||
js = d.createElement(s);
|
||||
js.id = id;
|
||||
js.src = "//connect.facebook.net/en_US/sdk.js";
|
||||
fjs.parentNode.insertBefore(js, fjs);
|
||||
})(document, "script", "facebook-jssdk");
|
||||
|
||||
var mod = AIRTIME.facebook;
|
||||
|
||||
(function (d, s, id) {
|
||||
var js, fjs = d.getElementsByTagName(s)[0];
|
||||
if (d.getElementById(id)) {
|
||||
return;
|
||||
mod.promptForFacebookPage = function () {
|
||||
FB.login(
|
||||
function (response) {
|
||||
if (response.authResponse) {
|
||||
mod.getPagesOwnedByUser(
|
||||
response.authResponse.userID,
|
||||
response.authResponse.accessToken
|
||||
);
|
||||
mod.addPageTab();
|
||||
} else {
|
||||
console.log("Authorization failed.");
|
||||
}
|
||||
js = d.createElement(s);
|
||||
js.id = id;
|
||||
js.src = "//connect.facebook.net/en_US/sdk.js";
|
||||
fjs.parentNode.insertBefore(js, fjs);
|
||||
}(document, 'script', 'facebook-jssdk'));
|
||||
},
|
||||
{ scope: "manage_pages" }
|
||||
);
|
||||
};
|
||||
|
||||
mod.promptForFacebookPage = function() {
|
||||
FB.login(function (response) {
|
||||
if (response.authResponse) {
|
||||
mod.getPagesOwnedByUser(response.authResponse.userID, response.authResponse.accessToken);
|
||||
mod.addPageTab();
|
||||
mod.getPagesOwnedByUser = function (userId, accessToken) {
|
||||
FB.api(
|
||||
"/" + userId + "/accounts",
|
||||
function (response) {
|
||||
console.log(response);
|
||||
},
|
||||
{ access_token: accessToken }
|
||||
);
|
||||
};
|
||||
|
||||
} else {
|
||||
console.log('Authorization failed.');
|
||||
mod.addPageTab = function () {
|
||||
FB.ui(
|
||||
{ method: "pagetab" },
|
||||
function (resp) {
|
||||
console.log("response:");
|
||||
console.log(resp);
|
||||
var pageIdList = [];
|
||||
var tabs = resp["tabs_added"];
|
||||
|
||||
if (tabs != undefined && Object.keys(tabs).length > 0) {
|
||||
for (var pageId in tabs) {
|
||||
pageIdList.push(pageId);
|
||||
}
|
||||
|
||||
//POST these back to Airtime, which will then proxy it over to our social app. (multiple requests from Airtime)
|
||||
$.post(
|
||||
"facebook-tab-success",
|
||||
{ pages: JSON.stringify(pageIdList) },
|
||||
function () {
|
||||
alert("Successfully added to your Facebook page!");
|
||||
}
|
||||
}, {scope: 'manage_pages'});
|
||||
}
|
||||
)
|
||||
.done(function () {})
|
||||
.fail(function () {
|
||||
alert(
|
||||
"Sorry, an error occurred and we were unable to add the widget to your Facebook page."
|
||||
);
|
||||
});
|
||||
}
|
||||
},
|
||||
{
|
||||
app_id: FACEBOOK_APP_ID,
|
||||
//redirect_uri: 'https://localhost'
|
||||
}
|
||||
);
|
||||
};
|
||||
|
||||
mod.getPagesOwnedByUser = function(userId, accessToken) {
|
||||
FB.api('/' + userId + '/accounts', function (response) {
|
||||
console.log(response);
|
||||
}, {access_token: accessToken});
|
||||
}
|
||||
|
||||
mod.addPageTab = function() {
|
||||
FB.ui(
|
||||
{ method: 'pagetab' },
|
||||
function (resp) {
|
||||
console.log("response:");
|
||||
console.log(resp);
|
||||
var pageIdList = [];
|
||||
var tabs = resp["tabs_added"];
|
||||
|
||||
if ((tabs != undefined) && (Object.keys(tabs).length > 0)) {
|
||||
for (var pageId in tabs) {
|
||||
pageIdList.push(pageId);
|
||||
}
|
||||
|
||||
//POST these back to Airtime, which will then proxy it over to our social app. (multiple requests from Airtime)
|
||||
$.post('facebook-tab-success', { "pages" : JSON.stringify(pageIdList) }, function() {
|
||||
alert("Successfully added to your Facebook page!");
|
||||
}).done(function() {
|
||||
|
||||
}).fail(function() {
|
||||
alert("Sorry, an error occurred and we were unable to add the widget to your Facebook page.");
|
||||
});
|
||||
}
|
||||
},
|
||||
{
|
||||
app_id: FACEBOOK_APP_ID,
|
||||
//redirect_uri: 'https://localhost'
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
return AIRTIME;
|
||||
|
||||
}(AIRTIME || {}));
|
||||
return AIRTIME;
|
||||
})(AIRTIME || {});
|
||||
|
|
|
@ -22,7 +22,6 @@ var live_dj_on_air = false;
|
|||
var scheduled_play_on_air = false;
|
||||
var scheduled_play_source = false;
|
||||
|
||||
|
||||
//a reference returned by setTimeout. Useful for when we want clearTimeout()
|
||||
var newSongTimeoutId = null;
|
||||
|
||||
|
@ -40,449 +39,545 @@ var onAirOffIterations = 0;
|
|||
var nextSongPrepare = true;
|
||||
var nextShowPrepare = true;
|
||||
|
||||
function secondsTimer(){
|
||||
/* This function constantly calls itself every 'uiUpdateInterval'
|
||||
* micro-seconds and is responsible for updating the UI. */
|
||||
if (localRemoteTimeOffset !== null){
|
||||
var date = new Date();
|
||||
approximateServerTime = date.getTime() - localRemoteTimeOffset;
|
||||
updateProgressBarValue();
|
||||
updatePlaybar();
|
||||
controlOnAirLight();
|
||||
controlSwitchLight();
|
||||
}
|
||||
setTimeout(secondsTimer, uiUpdateInterval);
|
||||
function secondsTimer() {
|
||||
/* This function constantly calls itself every 'uiUpdateInterval'
|
||||
* micro-seconds and is responsible for updating the UI. */
|
||||
if (localRemoteTimeOffset !== null) {
|
||||
var date = new Date();
|
||||
approximateServerTime = date.getTime() - localRemoteTimeOffset;
|
||||
updateProgressBarValue();
|
||||
updatePlaybar();
|
||||
controlOnAirLight();
|
||||
controlSwitchLight();
|
||||
}
|
||||
setTimeout(secondsTimer, uiUpdateInterval);
|
||||
}
|
||||
|
||||
function newSongStart(){
|
||||
nextSongPrepare = true;
|
||||
if (nextSong.type == 'track') {
|
||||
currentSong = nextSong;
|
||||
nextSong = null;
|
||||
}
|
||||
function newSongStart() {
|
||||
nextSongPrepare = true;
|
||||
if (nextSong.type == "track") {
|
||||
currentSong = nextSong;
|
||||
nextSong = null;
|
||||
}
|
||||
}
|
||||
|
||||
function nextShowStart(){
|
||||
nextShowPrepare = true;
|
||||
currentShow[0] = nextShow.shift();
|
||||
function nextShowStart() {
|
||||
nextShowPrepare = true;
|
||||
currentShow[0] = nextShow.shift();
|
||||
}
|
||||
|
||||
/* Called every "uiUpdateInterval" mseconds. */
|
||||
function updateProgressBarValue(){
|
||||
var showPercentDone = 0;
|
||||
if (currentShow.length > 0){
|
||||
showPercentDone = (approximateServerTime - currentShow[0].showStartPosixTime)/currentShow[0].showLengthMs*100;
|
||||
if (showPercentDone < 0 || showPercentDone > 100){
|
||||
showPercentDone = 0;
|
||||
currentShow = new Array();
|
||||
currentSong = null;
|
||||
}
|
||||
function updateProgressBarValue() {
|
||||
var showPercentDone = 0;
|
||||
if (currentShow.length > 0) {
|
||||
showPercentDone =
|
||||
((approximateServerTime - currentShow[0].showStartPosixTime) /
|
||||
currentShow[0].showLengthMs) *
|
||||
100;
|
||||
if (showPercentDone < 0 || showPercentDone > 100) {
|
||||
showPercentDone = 0;
|
||||
currentShow = new Array();
|
||||
currentSong = null;
|
||||
}
|
||||
$('#progress-show').attr("style", "width:"+showPercentDone+"%");
|
||||
}
|
||||
$("#progress-show").attr("style", "width:" + showPercentDone + "%");
|
||||
|
||||
var songPercentDone = 0;
|
||||
var scheduled_play_div = $("#scheduled_play_div");
|
||||
var scheduled_play_line_to_switch = scheduled_play_div.parent().find(".line-to-switch");
|
||||
var songPercentDone = 0;
|
||||
var scheduled_play_div = $("#scheduled_play_div");
|
||||
var scheduled_play_line_to_switch = scheduled_play_div
|
||||
.parent()
|
||||
.find(".line-to-switch");
|
||||
|
||||
if (currentSong !== null){
|
||||
var songElapsedTime = 0;
|
||||
songPercentDone = (approximateServerTime - currentSong.songStartPosixTime)/currentSong.songLengthMs*100;
|
||||
songElapsedTime = approximateServerTime - currentSong.songStartPosixTime;
|
||||
if (songPercentDone < 0) {
|
||||
songPercentDone = 0;
|
||||
//currentSong = null;
|
||||
} else if (songPercentDone > 100) {
|
||||
songPercentDone = 100;
|
||||
} else {
|
||||
if ((currentSong.media_item_played == true && currentShow.length > 0) || (songElapsedTime < 5000 && currentShow[0].record != 1)) {
|
||||
scheduled_play_line_to_switch.attr("class", "line-to-switch on");
|
||||
scheduled_play_div.addClass("ready");
|
||||
scheduled_play_source = true;
|
||||
}
|
||||
else{
|
||||
scheduled_play_source = false;
|
||||
scheduled_play_line_to_switch.attr("class", "line-to-switch off");
|
||||
scheduled_play_div.removeClass("ready");
|
||||
}
|
||||
$('#progress-show').attr("class", "progress-show");
|
||||
}
|
||||
if (currentSong !== null) {
|
||||
var songElapsedTime = 0;
|
||||
songPercentDone =
|
||||
((approximateServerTime - currentSong.songStartPosixTime) /
|
||||
currentSong.songLengthMs) *
|
||||
100;
|
||||
songElapsedTime = approximateServerTime - currentSong.songStartPosixTime;
|
||||
if (songPercentDone < 0) {
|
||||
songPercentDone = 0;
|
||||
//currentSong = null;
|
||||
} else if (songPercentDone > 100) {
|
||||
songPercentDone = 100;
|
||||
} else {
|
||||
if (
|
||||
(currentSong.media_item_played == true && currentShow.length > 0) ||
|
||||
(songElapsedTime < 5000 && currentShow[0].record != 1)
|
||||
) {
|
||||
scheduled_play_line_to_switch.attr("class", "line-to-switch on");
|
||||
scheduled_play_div.addClass("ready");
|
||||
scheduled_play_source = true;
|
||||
} else {
|
||||
scheduled_play_source = false;
|
||||
scheduled_play_line_to_switch.attr("class", "line-to-switch off");
|
||||
scheduled_play_div.removeClass("ready");
|
||||
$('#progress-show').attr("class", "progress-show-error");
|
||||
}
|
||||
$("#progress-show").attr("class", "progress-show");
|
||||
}
|
||||
$('#progress-bar').attr("style", "width:"+songPercentDone+"%");
|
||||
} else {
|
||||
scheduled_play_source = false;
|
||||
scheduled_play_line_to_switch.attr("class", "line-to-switch off");
|
||||
scheduled_play_div.removeClass("ready");
|
||||
$("#progress-show").attr("class", "progress-show-error");
|
||||
}
|
||||
$("#progress-bar").attr("style", "width:" + songPercentDone + "%");
|
||||
}
|
||||
|
||||
function updatePlaybar(){
|
||||
/* Column 0 update */
|
||||
if (previousSong !== null){
|
||||
$('#previous').text(previousSong.name+",");
|
||||
$('#prev-length').text(convertToHHMMSSmm(previousSong.songLengthMs));
|
||||
}else{
|
||||
$('#previous').empty();
|
||||
$('#prev-length').empty();
|
||||
}
|
||||
function updatePlaybar() {
|
||||
/* Column 0 update */
|
||||
if (previousSong !== null) {
|
||||
$("#previous").text(previousSong.name + ",");
|
||||
$("#prev-length").text(convertToHHMMSSmm(previousSong.songLengthMs));
|
||||
} else {
|
||||
$("#previous").empty();
|
||||
$("#prev-length").empty();
|
||||
}
|
||||
|
||||
if (currentSong !== null && !master_dj_on_air && !live_dj_on_air){
|
||||
if (currentSong.record == "1") {
|
||||
$('#current').html("<span style='color:red; font-weight:bold'>"+$.i18n._("Recording:")+"</span>"+currentSong.name+",");
|
||||
} else {
|
||||
$('#current').text(currentSong.name+",");
|
||||
if (currentSong.metadata && currentSong.metadata.artwork_data) {
|
||||
|
||||
var check_current_song = Cookies.get('current_track');
|
||||
var loaded = Cookies.get('loaded');
|
||||
|
||||
if (check_current_song != currentSong.name) {
|
||||
$('#now-playing-artwork_containter').html("<img height='75' width='75' class'artwork' src='"+ currentSong.metadata.artwork_data +"' />");
|
||||
Cookies.remove('current_track');
|
||||
Cookies.set('current_track', currentSong.name);
|
||||
}
|
||||
// makes sure it stays updated with current track if page loads
|
||||
if (loaded != UNIQID) {
|
||||
Cookies.remove('current_track');
|
||||
Cookies.remove('loaded');
|
||||
Cookies.set('loaded', UNIQID);
|
||||
}
|
||||
}
|
||||
}
|
||||
}else{
|
||||
if (master_dj_on_air) {
|
||||
if (showName) {
|
||||
$('#current').html($.i18n._("Current")+": <span style='color:red; font-weight:bold'>"+showName+" - "+$.i18n._("Master Stream")+"</span>");
|
||||
} else {
|
||||
$('#current').html($.i18n._("Current")+": <span style='color:red; font-weight:bold'>"+$.i18n._("Master Stream")+"</span>");
|
||||
}
|
||||
} else if (live_dj_on_air) {
|
||||
if (showName) {
|
||||
$('#current').html($.i18n._("Current")+": <span style='color:red; font-weight:bold'>"+showName+" - "+$.i18n._("Live Stream")+"</span>");
|
||||
} else {
|
||||
$('#current').html($.i18n._("Current")+": <span style='color:red; font-weight:bold'>"+$.i18n._("Live Stream")+"</span>");
|
||||
}
|
||||
} else {
|
||||
$('#current').html($.i18n._("Current")+": <span style='color:red; font-weight:bold'>"+$.i18n._("Nothing Scheduled")+"</span>");
|
||||
}
|
||||
}
|
||||
|
||||
if (nextSong !== null){
|
||||
$('#next').text(nextSong.name+",");
|
||||
$('#next-length').text(convertToHHMMSSmm(nextSong.songLengthMs));
|
||||
}else{
|
||||
$('#next').empty();
|
||||
$('#next-length').empty();
|
||||
}
|
||||
|
||||
$('#start').empty();
|
||||
$('#end').empty();
|
||||
$('#time-elapsed').empty();
|
||||
$('#time-remaining').empty();
|
||||
$('#song-length').empty();
|
||||
if (currentSong !== null && !master_dj_on_air && !live_dj_on_air){
|
||||
$('#start').text(currentSong.starts.split(' ')[1]);
|
||||
$('#end').text(currentSong.ends.split(' ')[1]);
|
||||
|
||||
/* Get rid of the millisecond accuracy so that the second counters for both
|
||||
* show and song change at the same time. */
|
||||
var songStartRoughly = parseInt(Math.round(currentSong.songStartPosixTime/1000), 10)*1000;
|
||||
var songEndRoughly = parseInt(Math.round(currentSong.songEndPosixTime/1000), 10)*1000;
|
||||
|
||||
$('#time-elapsed').text(convertToHHMMSS(approximateServerTime - songStartRoughly));
|
||||
$('#time-remaining').text(convertToHHMMSS(songEndRoughly - approximateServerTime));
|
||||
$('#song-length').text(convertToHHMMSS(currentSong.songLengthMs));
|
||||
}
|
||||
/* Column 1 update */
|
||||
$('#playlist').text($.i18n._("Current Show:"));
|
||||
var recElem = $('.recording-show');
|
||||
if (currentShow.length > 0){
|
||||
$('#playlist').text(currentShow[0].name);
|
||||
(currentShow[0].record == "1") ? recElem.show(): recElem.hide();
|
||||
if (currentSong !== null && !master_dj_on_air && !live_dj_on_air) {
|
||||
if (currentSong.record == "1") {
|
||||
$("#current").html(
|
||||
"<span style='color:red; font-weight:bold'>" +
|
||||
$.i18n._("Recording:") +
|
||||
"</span>" +
|
||||
currentSong.name +
|
||||
","
|
||||
);
|
||||
} else {
|
||||
recElem.hide();
|
||||
}
|
||||
$("#current").text(currentSong.name + ",");
|
||||
if (currentSong.metadata && currentSong.metadata.artwork_data) {
|
||||
var check_current_song = Cookies.get("current_track");
|
||||
var loaded = Cookies.get("loaded");
|
||||
|
||||
$('#show-length').empty();
|
||||
if (currentShow.length > 0){
|
||||
$('#show-length').text(convertDateToHHMM(currentShow[0].showStartPosixTime) + " - " + convertDateToHHMM(currentShow[0].showEndPosixTime));
|
||||
if (check_current_song != currentSong.name) {
|
||||
$("#now-playing-artwork_containter").html(
|
||||
"<img height='75' width='75' class'artwork' src='" +
|
||||
currentSong.metadata.artwork_data +
|
||||
"' />"
|
||||
);
|
||||
Cookies.remove("current_track");
|
||||
Cookies.set("current_track", currentSong.name);
|
||||
}
|
||||
// makes sure it stays updated with current track if page loads
|
||||
if (loaded != UNIQID) {
|
||||
Cookies.remove("current_track");
|
||||
Cookies.remove("loaded");
|
||||
Cookies.set("loaded", UNIQID);
|
||||
}
|
||||
}
|
||||
}
|
||||
} else {
|
||||
if (master_dj_on_air) {
|
||||
if (showName) {
|
||||
$("#current").html(
|
||||
$.i18n._("Current") +
|
||||
": <span style='color:red; font-weight:bold'>" +
|
||||
showName +
|
||||
" - " +
|
||||
$.i18n._("Master Stream") +
|
||||
"</span>"
|
||||
);
|
||||
} else {
|
||||
$("#current").html(
|
||||
$.i18n._("Current") +
|
||||
": <span style='color:red; font-weight:bold'>" +
|
||||
$.i18n._("Master Stream") +
|
||||
"</span>"
|
||||
);
|
||||
}
|
||||
} else if (live_dj_on_air) {
|
||||
if (showName) {
|
||||
$("#current").html(
|
||||
$.i18n._("Current") +
|
||||
": <span style='color:red; font-weight:bold'>" +
|
||||
showName +
|
||||
" - " +
|
||||
$.i18n._("Live Stream") +
|
||||
"</span>"
|
||||
);
|
||||
} else {
|
||||
$("#current").html(
|
||||
$.i18n._("Current") +
|
||||
": <span style='color:red; font-weight:bold'>" +
|
||||
$.i18n._("Live Stream") +
|
||||
"</span>"
|
||||
);
|
||||
}
|
||||
} else {
|
||||
$("#current").html(
|
||||
$.i18n._("Current") +
|
||||
": <span style='color:red; font-weight:bold'>" +
|
||||
$.i18n._("Nothing Scheduled") +
|
||||
"</span>"
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
/* Column 2 update */
|
||||
$('#time').text(convertDateToHHMMSS(approximateServerTime));
|
||||
if (nextSong !== null) {
|
||||
$("#next").text(nextSong.name + ",");
|
||||
$("#next-length").text(convertToHHMMSSmm(nextSong.songLengthMs));
|
||||
} else {
|
||||
$("#next").empty();
|
||||
$("#next-length").empty();
|
||||
}
|
||||
|
||||
$("#start").empty();
|
||||
$("#end").empty();
|
||||
$("#time-elapsed").empty();
|
||||
$("#time-remaining").empty();
|
||||
$("#song-length").empty();
|
||||
if (currentSong !== null && !master_dj_on_air && !live_dj_on_air) {
|
||||
$("#start").text(currentSong.starts.split(" ")[1]);
|
||||
$("#end").text(currentSong.ends.split(" ")[1]);
|
||||
|
||||
/* Get rid of the millisecond accuracy so that the second counters for both
|
||||
* show and song change at the same time. */
|
||||
var songStartRoughly =
|
||||
parseInt(Math.round(currentSong.songStartPosixTime / 1000), 10) * 1000;
|
||||
var songEndRoughly =
|
||||
parseInt(Math.round(currentSong.songEndPosixTime / 1000), 10) * 1000;
|
||||
|
||||
$("#time-elapsed").text(
|
||||
convertToHHMMSS(approximateServerTime - songStartRoughly)
|
||||
);
|
||||
$("#time-remaining").text(
|
||||
convertToHHMMSS(songEndRoughly - approximateServerTime)
|
||||
);
|
||||
$("#song-length").text(convertToHHMMSS(currentSong.songLengthMs));
|
||||
}
|
||||
/* Column 1 update */
|
||||
$("#playlist").text($.i18n._("Current Show:"));
|
||||
var recElem = $(".recording-show");
|
||||
if (currentShow.length > 0) {
|
||||
$("#playlist").text(currentShow[0].name);
|
||||
currentShow[0].record == "1" ? recElem.show() : recElem.hide();
|
||||
} else {
|
||||
recElem.hide();
|
||||
}
|
||||
|
||||
$("#show-length").empty();
|
||||
if (currentShow.length > 0) {
|
||||
$("#show-length").text(
|
||||
convertDateToHHMM(currentShow[0].showStartPosixTime) +
|
||||
" - " +
|
||||
convertDateToHHMM(currentShow[0].showEndPosixTime)
|
||||
);
|
||||
}
|
||||
|
||||
/* Column 2 update */
|
||||
$("#time").text(convertDateToHHMMSS(approximateServerTime));
|
||||
}
|
||||
|
||||
function calcAdditionalData(currentItem){
|
||||
currentItem.songStartPosixTime = convertDateToPosixTime(currentItem.starts);
|
||||
currentItem.songEndPosixTime = convertDateToPosixTime(currentItem.ends);
|
||||
currentItem.songLengthMs = currentItem.songEndPosixTime - currentItem.songStartPosixTime;
|
||||
function calcAdditionalData(currentItem) {
|
||||
currentItem.songStartPosixTime = convertDateToPosixTime(currentItem.starts);
|
||||
currentItem.songEndPosixTime = convertDateToPosixTime(currentItem.ends);
|
||||
currentItem.songLengthMs =
|
||||
currentItem.songEndPosixTime - currentItem.songStartPosixTime;
|
||||
}
|
||||
|
||||
function calcAdditionalShowData(show){
|
||||
if (show.length > 0){
|
||||
show[0].showStartPosixTime = convertDateToPosixTime(show[0].start_timestamp);
|
||||
show[0].showEndPosixTime = convertDateToPosixTime(show[0].end_timestamp);
|
||||
show[0].showLengthMs = show[0].showEndPosixTime - show[0].showStartPosixTime;
|
||||
}
|
||||
function calcAdditionalShowData(show) {
|
||||
if (show.length > 0) {
|
||||
show[0].showStartPosixTime = convertDateToPosixTime(
|
||||
show[0].start_timestamp
|
||||
);
|
||||
show[0].showEndPosixTime = convertDateToPosixTime(show[0].end_timestamp);
|
||||
show[0].showLengthMs =
|
||||
show[0].showEndPosixTime - show[0].showStartPosixTime;
|
||||
}
|
||||
}
|
||||
|
||||
function calculateTimeToNextSong() {
|
||||
if (approximateServerTime === null) {
|
||||
return;
|
||||
}
|
||||
if (approximateServerTime === null) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (newSongTimeoutId !== null) {
|
||||
/* We have a previous timeout set, let's unset it */
|
||||
clearTimeout(newSongTimeoutId);
|
||||
newSongTimeoutId = null;
|
||||
}
|
||||
if (newSongTimeoutId !== null) {
|
||||
/* We have a previous timeout set, let's unset it */
|
||||
clearTimeout(newSongTimeoutId);
|
||||
newSongTimeoutId = null;
|
||||
}
|
||||
|
||||
var diff = nextSong.songStartPosixTime - approximateServerTime;
|
||||
if (diff < 0) diff=0;
|
||||
nextSongPrepare = false;
|
||||
newSongTimeoutId= setTimeout(newSongStart, diff);
|
||||
var diff = nextSong.songStartPosixTime - approximateServerTime;
|
||||
if (diff < 0) diff = 0;
|
||||
nextSongPrepare = false;
|
||||
newSongTimeoutId = setTimeout(newSongStart, diff);
|
||||
}
|
||||
|
||||
function calculateTimeToNextShow() {
|
||||
if (approximateServerTime === null) {
|
||||
return;
|
||||
}
|
||||
if (approximateServerTime === null) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (newShowTimeoutId !== null) {
|
||||
/* We have a previous timeout set, let's unset it */
|
||||
clearTimeout(newShowTimeoutId);
|
||||
newShowTimeoutId = null;
|
||||
}
|
||||
if (newShowTimeoutId !== null) {
|
||||
/* We have a previous timeout set, let's unset it */
|
||||
clearTimeout(newShowTimeoutId);
|
||||
newShowTimeoutId = null;
|
||||
}
|
||||
|
||||
var diff = nextShow[0].showStartPosixTime - approximateServerTime;
|
||||
if (diff < 0) diff=0;
|
||||
nextShowPrepare = false;
|
||||
newShowTimeoutId= setTimeout(nextShowStart, diff);
|
||||
var diff = nextShow[0].showStartPosixTime - approximateServerTime;
|
||||
if (diff < 0) diff = 0;
|
||||
nextShowPrepare = false;
|
||||
newShowTimeoutId = setTimeout(nextShowStart, diff);
|
||||
}
|
||||
|
||||
function parseItems(obj){
|
||||
previousSong = obj.previous;
|
||||
currentSong = obj.current;
|
||||
nextSong = obj.next;
|
||||
function parseItems(obj) {
|
||||
previousSong = obj.previous;
|
||||
currentSong = obj.current;
|
||||
nextSong = obj.next;
|
||||
|
||||
if (previousSong !== null) {
|
||||
calcAdditionalData(previousSong);
|
||||
}
|
||||
if (currentSong !== null) {
|
||||
calcAdditionalData(currentSong);
|
||||
}
|
||||
if (nextSong !== null) {
|
||||
calcAdditionalData(nextSong);
|
||||
calculateTimeToNextSong();
|
||||
}
|
||||
if (previousSong !== null) {
|
||||
calcAdditionalData(previousSong);
|
||||
}
|
||||
if (currentSong !== null) {
|
||||
calcAdditionalData(currentSong);
|
||||
}
|
||||
if (nextSong !== null) {
|
||||
calcAdditionalData(nextSong);
|
||||
calculateTimeToNextSong();
|
||||
}
|
||||
|
||||
currentShow = new Array();
|
||||
if (obj.currentShow.length > 0) {
|
||||
calcAdditionalShowData(obj.currentShow);
|
||||
currentShow = obj.currentShow;
|
||||
}
|
||||
currentShow = new Array();
|
||||
if (obj.currentShow.length > 0) {
|
||||
calcAdditionalShowData(obj.currentShow);
|
||||
currentShow = obj.currentShow;
|
||||
}
|
||||
|
||||
nextShow = new Array();
|
||||
if (obj.nextShow.length > 0) {
|
||||
calcAdditionalShowData(obj.nextShow);
|
||||
nextShow = obj.nextShow;
|
||||
calculateTimeToNextShow();
|
||||
}
|
||||
nextShow = new Array();
|
||||
if (obj.nextShow.length > 0) {
|
||||
calcAdditionalShowData(obj.nextShow);
|
||||
nextShow = obj.nextShow;
|
||||
calculateTimeToNextShow();
|
||||
}
|
||||
|
||||
|
||||
var schedulePosixTime = convertDateToPosixTime(obj.schedulerTime);
|
||||
var date = new Date();
|
||||
localRemoteTimeOffset = date.getTime() - schedulePosixTime;
|
||||
var schedulePosixTime = convertDateToPosixTime(obj.schedulerTime);
|
||||
var date = new Date();
|
||||
localRemoteTimeOffset = date.getTime() - schedulePosixTime;
|
||||
}
|
||||
|
||||
function parseSourceStatus(obj){
|
||||
var live_div = $("#live_dj_div");
|
||||
var master_div = $("#master_dj_div");
|
||||
var live_li = live_div.parent();
|
||||
var master_li = master_div.parent();
|
||||
function parseSourceStatus(obj) {
|
||||
var live_div = $("#live_dj_div");
|
||||
var master_div = $("#master_dj_div");
|
||||
var live_li = live_div.parent();
|
||||
var master_li = master_div.parent();
|
||||
|
||||
if(obj.live_dj_source == false){
|
||||
live_li.find(".line-to-switch").attr("class", "line-to-switch off");
|
||||
live_div.removeClass("ready");
|
||||
}else{
|
||||
live_li.find(".line-to-switch").attr("class", "line-to-switch on");
|
||||
live_div.addClass("ready");
|
||||
}
|
||||
if (obj.live_dj_source == false) {
|
||||
live_li.find(".line-to-switch").attr("class", "line-to-switch off");
|
||||
live_div.removeClass("ready");
|
||||
} else {
|
||||
live_li.find(".line-to-switch").attr("class", "line-to-switch on");
|
||||
live_div.addClass("ready");
|
||||
}
|
||||
|
||||
if(obj.master_dj_source == false){
|
||||
master_li.find(".line-to-switch").attr("class", "line-to-switch off");
|
||||
master_div.removeClass("ready");
|
||||
}else{
|
||||
master_li.find(".line-to-switch").attr("class", "line-to-switch on");
|
||||
master_div.addClass("ready");
|
||||
}
|
||||
if (obj.master_dj_source == false) {
|
||||
master_li.find(".line-to-switch").attr("class", "line-to-switch off");
|
||||
master_div.removeClass("ready");
|
||||
} else {
|
||||
master_li.find(".line-to-switch").attr("class", "line-to-switch on");
|
||||
master_div.addClass("ready");
|
||||
}
|
||||
}
|
||||
|
||||
function parseSwitchStatus(obj){
|
||||
function parseSwitchStatus(obj) {
|
||||
if (obj.live_dj_source == "on") {
|
||||
live_dj_on_air = true;
|
||||
} else {
|
||||
live_dj_on_air = false;
|
||||
}
|
||||
|
||||
if(obj.live_dj_source == "on"){
|
||||
live_dj_on_air = true;
|
||||
}else{
|
||||
live_dj_on_air = false;
|
||||
}
|
||||
if (obj.master_dj_source == "on") {
|
||||
master_dj_on_air = true;
|
||||
} else {
|
||||
master_dj_on_air = false;
|
||||
}
|
||||
|
||||
if(obj.master_dj_source == "on"){
|
||||
master_dj_on_air = true;
|
||||
}else{
|
||||
master_dj_on_air = false;
|
||||
}
|
||||
if (obj.scheduled_play == "on") {
|
||||
scheduled_play_on_air = true;
|
||||
} else {
|
||||
scheduled_play_on_air = false;
|
||||
}
|
||||
|
||||
if(obj.scheduled_play == "on"){
|
||||
scheduled_play_on_air = true;
|
||||
}else{
|
||||
scheduled_play_on_air = false;
|
||||
}
|
||||
var scheduled_play_switch = $("#scheduled_play.source-switch-button");
|
||||
var live_dj_switch = $("#live_dj.source-switch-button");
|
||||
var master_dj_switch = $("#master_dj.source-switch-button");
|
||||
|
||||
var scheduled_play_switch = $("#scheduled_play.source-switch-button");
|
||||
var live_dj_switch = $("#live_dj.source-switch-button");
|
||||
var master_dj_switch = $("#master_dj.source-switch-button");
|
||||
scheduled_play_switch.find("span").html(obj.scheduled_play);
|
||||
if (scheduled_play_on_air) {
|
||||
scheduled_play_switch.addClass("active");
|
||||
} else {
|
||||
scheduled_play_switch.removeClass("active");
|
||||
}
|
||||
|
||||
scheduled_play_switch.find("span").html(obj.scheduled_play);
|
||||
if(scheduled_play_on_air){
|
||||
scheduled_play_switch.addClass("active");
|
||||
}else{
|
||||
scheduled_play_switch.removeClass("active");
|
||||
}
|
||||
live_dj_switch.find("span").html(obj.live_dj_source);
|
||||
if (live_dj_on_air) {
|
||||
live_dj_switch.addClass("active");
|
||||
} else {
|
||||
live_dj_switch.removeClass("active");
|
||||
}
|
||||
|
||||
live_dj_switch.find("span").html(obj.live_dj_source);
|
||||
if(live_dj_on_air){
|
||||
live_dj_switch.addClass("active");
|
||||
}else{
|
||||
live_dj_switch.removeClass("active");
|
||||
}
|
||||
|
||||
master_dj_switch.find("span").html(obj.master_dj_source)
|
||||
if(master_dj_on_air){
|
||||
master_dj_switch.addClass("active");
|
||||
}else{
|
||||
master_dj_switch.removeClass("active");
|
||||
}
|
||||
master_dj_switch.find("span").html(obj.master_dj_source);
|
||||
if (master_dj_on_air) {
|
||||
master_dj_switch.addClass("active");
|
||||
} else {
|
||||
master_dj_switch.removeClass("active");
|
||||
}
|
||||
}
|
||||
|
||||
function controlOnAirLight(){
|
||||
if ((scheduled_play_on_air && scheduled_play_source) || live_dj_on_air || master_dj_on_air) {
|
||||
$('#on-air-info').attr("class", "on-air-info on");
|
||||
onAirOffIterations = 0;
|
||||
} else if (onAirOffIterations < 20) {
|
||||
//if less than 4 seconds have gone by (< 20 executions of this function)
|
||||
//then keep the ON-AIR light on. Only after at least 3 seconds have gone by,
|
||||
//should we be allowed to turn it off. This is to stop the light from temporarily turning
|
||||
//off between tracks: CC-3725
|
||||
onAirOffIterations++;
|
||||
} else {
|
||||
$('#on-air-info').attr("class", "on-air-info off");
|
||||
}
|
||||
function controlOnAirLight() {
|
||||
if (
|
||||
(scheduled_play_on_air && scheduled_play_source) ||
|
||||
live_dj_on_air ||
|
||||
master_dj_on_air
|
||||
) {
|
||||
$("#on-air-info").attr("class", "on-air-info on");
|
||||
onAirOffIterations = 0;
|
||||
} else if (onAirOffIterations < 20) {
|
||||
//if less than 4 seconds have gone by (< 20 executions of this function)
|
||||
//then keep the ON-AIR light on. Only after at least 3 seconds have gone by,
|
||||
//should we be allowed to turn it off. This is to stop the light from temporarily turning
|
||||
//off between tracks: CC-3725
|
||||
onAirOffIterations++;
|
||||
} else {
|
||||
$("#on-air-info").attr("class", "on-air-info off");
|
||||
}
|
||||
}
|
||||
|
||||
function controlSwitchLight(){
|
||||
var live_li= $("#live_dj_div").parent();
|
||||
var master_li = $("#master_dj_div").parent();
|
||||
var scheduled_play_li = $("#scheduled_play_div").parent();
|
||||
function controlSwitchLight() {
|
||||
var live_li = $("#live_dj_div").parent();
|
||||
var master_li = $("#master_dj_div").parent();
|
||||
var scheduled_play_li = $("#scheduled_play_div").parent();
|
||||
|
||||
if((scheduled_play_on_air && scheduled_play_source) && !live_dj_on_air && !master_dj_on_air){
|
||||
scheduled_play_li.find(".line-to-on-air").attr("class", "line-to-on-air on");
|
||||
live_li.find(".line-to-on-air").attr("class", "line-to-on-air off");
|
||||
master_li.find(".line-to-on-air").attr("class", "line-to-on-air off");
|
||||
}else if(live_dj_on_air && !master_dj_on_air){
|
||||
scheduled_play_li.find(".line-to-on-air").attr("class", "line-to-on-air off");
|
||||
live_li.find(".line-to-on-air").attr("class", "line-to-on-air on");
|
||||
master_li.find(".line-to-on-air").attr("class", "line-to-on-air off");
|
||||
}else if(master_dj_on_air){
|
||||
scheduled_play_li.find(".line-to-on-air").attr("class", "line-to-on-air off");
|
||||
live_li.find(".line-to-on-air").attr("class", "line-to-on-air off");
|
||||
master_li.find(".line-to-on-air").attr("class", "line-to-on-air on");
|
||||
}else{
|
||||
scheduled_play_li.find(".line-to-on-air").attr("class", "line-to-on-air off");
|
||||
live_li.find(".line-to-on-air").attr("class", "line-to-on-air off");
|
||||
master_li.find(".line-to-on-air").attr("class", "line-to-on-air off");
|
||||
}
|
||||
if (
|
||||
scheduled_play_on_air &&
|
||||
scheduled_play_source &&
|
||||
!live_dj_on_air &&
|
||||
!master_dj_on_air
|
||||
) {
|
||||
scheduled_play_li
|
||||
.find(".line-to-on-air")
|
||||
.attr("class", "line-to-on-air on");
|
||||
live_li.find(".line-to-on-air").attr("class", "line-to-on-air off");
|
||||
master_li.find(".line-to-on-air").attr("class", "line-to-on-air off");
|
||||
} else if (live_dj_on_air && !master_dj_on_air) {
|
||||
scheduled_play_li
|
||||
.find(".line-to-on-air")
|
||||
.attr("class", "line-to-on-air off");
|
||||
live_li.find(".line-to-on-air").attr("class", "line-to-on-air on");
|
||||
master_li.find(".line-to-on-air").attr("class", "line-to-on-air off");
|
||||
} else if (master_dj_on_air) {
|
||||
scheduled_play_li
|
||||
.find(".line-to-on-air")
|
||||
.attr("class", "line-to-on-air off");
|
||||
live_li.find(".line-to-on-air").attr("class", "line-to-on-air off");
|
||||
master_li.find(".line-to-on-air").attr("class", "line-to-on-air on");
|
||||
} else {
|
||||
scheduled_play_li
|
||||
.find(".line-to-on-air")
|
||||
.attr("class", "line-to-on-air off");
|
||||
live_li.find(".line-to-on-air").attr("class", "line-to-on-air off");
|
||||
master_li.find(".line-to-on-air").attr("class", "line-to-on-air off");
|
||||
}
|
||||
}
|
||||
|
||||
function getScheduleFromServer(){
|
||||
$.ajax({ url: baseUrl+"Schedule/get-current-playlist/format/json",
|
||||
dataType:"json",
|
||||
success:function(data){
|
||||
parseItems(data.entries);
|
||||
parseSourceStatus(data.source_status);
|
||||
parseSwitchStatus(data.switch_status);
|
||||
showName = data.show_name;
|
||||
}, error:function(jqXHR, textStatus, errorThrown){}});
|
||||
function getScheduleFromServer() {
|
||||
$.ajax({
|
||||
url: baseUrl + "Schedule/get-current-playlist/format/json",
|
||||
dataType: "json",
|
||||
success: function (data) {
|
||||
parseItems(data.entries);
|
||||
parseSourceStatus(data.source_status);
|
||||
parseSwitchStatus(data.switch_status);
|
||||
showName = data.show_name;
|
||||
},
|
||||
error: function (jqXHR, textStatus, errorThrown) {},
|
||||
});
|
||||
}
|
||||
|
||||
function setupQtip(){
|
||||
var qtipElem = $('#about-link');
|
||||
function setupQtip() {
|
||||
var qtipElem = $("#about-link");
|
||||
|
||||
if (qtipElem.length > 0){
|
||||
qtipElem.qtip({
|
||||
content: $('#about-txt').html(),
|
||||
show: 'mouseover',
|
||||
hide: { when: 'mouseout', fixed: true },
|
||||
position: {
|
||||
corner: {
|
||||
target: 'center',
|
||||
tooltip: 'topRight'
|
||||
}
|
||||
},
|
||||
style: {
|
||||
border: {
|
||||
width: 0,
|
||||
radius: 4
|
||||
},
|
||||
name: 'light' // Use the default light style
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
function setSwitchListener(ele){
|
||||
var sourcename = $(ele).attr('id');
|
||||
var status_span = $(ele).find("span");
|
||||
var status = status_span.html();
|
||||
$.get(baseUrl+"Dashboard/switch-source/format/json/sourcename/"+sourcename+"/status/"+status, function(data){
|
||||
if(data.error){
|
||||
alert(data.error);
|
||||
}else{
|
||||
if(data.status == "ON"){
|
||||
$(ele).addClass("active");
|
||||
}else{
|
||||
$(ele).removeClass("active");
|
||||
}
|
||||
status_span.html(data.status);
|
||||
}
|
||||
if (qtipElem.length > 0) {
|
||||
qtipElem.qtip({
|
||||
content: $("#about-txt").html(),
|
||||
show: "mouseover",
|
||||
hide: { when: "mouseout", fixed: true },
|
||||
position: {
|
||||
corner: {
|
||||
target: "center",
|
||||
tooltip: "topRight",
|
||||
},
|
||||
},
|
||||
style: {
|
||||
border: {
|
||||
width: 0,
|
||||
radius: 4,
|
||||
},
|
||||
name: "light", // Use the default light style
|
||||
},
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
function kickSource(ele){
|
||||
var sourcename = $(ele).attr('id');
|
||||
|
||||
$.get(baseUrl+"Dashboard/disconnect-source/format/json/sourcename/"+sourcename, function(data){
|
||||
if(data.error){
|
||||
alert(data.error);
|
||||
function setSwitchListener(ele) {
|
||||
var sourcename = $(ele).attr("id");
|
||||
var status_span = $(ele).find("span");
|
||||
var status = status_span.html();
|
||||
$.get(
|
||||
baseUrl +
|
||||
"Dashboard/switch-source/format/json/sourcename/" +
|
||||
sourcename +
|
||||
"/status/" +
|
||||
status,
|
||||
function (data) {
|
||||
if (data.error) {
|
||||
alert(data.error);
|
||||
} else {
|
||||
if (data.status == "ON") {
|
||||
$(ele).addClass("active");
|
||||
} else {
|
||||
$(ele).removeClass("active");
|
||||
}
|
||||
});
|
||||
status_span.html(data.status);
|
||||
}
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
function kickSource(ele) {
|
||||
var sourcename = $(ele).attr("id");
|
||||
|
||||
$.get(
|
||||
baseUrl +
|
||||
"Dashboard/disconnect-source/format/json/sourcename/" +
|
||||
sourcename,
|
||||
function (data) {
|
||||
if (data.error) {
|
||||
alert(data.error);
|
||||
}
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
var stream_window = null;
|
||||
|
||||
function init() {
|
||||
//begin producer "thread"
|
||||
setInterval(getScheduleFromServer, serverUpdateInterval);
|
||||
//begin producer "thread"
|
||||
setInterval(getScheduleFromServer, serverUpdateInterval);
|
||||
|
||||
//begin consumer "thread"
|
||||
secondsTimer();
|
||||
//begin consumer "thread"
|
||||
secondsTimer();
|
||||
|
||||
setupQtip();
|
||||
setupQtip();
|
||||
|
||||
$('.listen-control-button').click(function() {
|
||||
if (stream_window == null || stream_window.closed)
|
||||
stream_window=window.open(baseUrl+"Dashboard/stream-player", 'name', 'width=400,height=158');
|
||||
stream_window.focus();
|
||||
return false;
|
||||
});
|
||||
$(".listen-control-button").click(function () {
|
||||
if (stream_window == null || stream_window.closed)
|
||||
stream_window = window.open(
|
||||
baseUrl + "Dashboard/stream-player",
|
||||
"name",
|
||||
"width=400,height=158"
|
||||
);
|
||||
stream_window.focus();
|
||||
return false;
|
||||
});
|
||||
}
|
||||
|
||||
/* We never retrieve the user's password from the db
|
||||
|
@ -491,40 +586,39 @@ function init() {
|
|||
* field. Therefore, we fill the password field with 6 x's
|
||||
*/
|
||||
function setCurrentUserPseudoPassword() {
|
||||
$('#cu_password').val("xxxxxx");
|
||||
$('#cu_passwordVerify').val("xxxxxx");
|
||||
$("#cu_password").val("xxxxxx");
|
||||
$("#cu_passwordVerify").val("xxxxxx");
|
||||
}
|
||||
|
||||
/*$(window).resize(function() {
|
||||
*//* If we don't do this, the menu can stay hidden after resizing *//*
|
||||
*/ /* If we don't do this, the menu can stay hidden after resizing */ /*
|
||||
if ($(this).width() > 970) {
|
||||
$("#nav .responsive-menu").show();
|
||||
}
|
||||
});*/
|
||||
|
||||
$(document).ready(function() {
|
||||
if ($('#master-panel').length > 0)
|
||||
init();
|
||||
if ($('.errors').length === 0) {
|
||||
setCurrentUserPseudoPassword();
|
||||
}
|
||||
$(document).ready(function () {
|
||||
if ($("#master-panel").length > 0) init();
|
||||
if ($(".errors").length === 0) {
|
||||
setCurrentUserPseudoPassword();
|
||||
}
|
||||
|
||||
$('body').on('click','#current-user', function() {
|
||||
$.ajax({
|
||||
url: baseUrl+'user/edit-user/format/json'
|
||||
});
|
||||
$("body").on("click", "#current-user", function () {
|
||||
$.ajax({
|
||||
url: baseUrl + "user/edit-user/format/json",
|
||||
});
|
||||
});
|
||||
|
||||
$('body').on('click', '#cu_save_user', function() {
|
||||
Cookies.set('airtime_locale', $('#cu_locale').val(), {path: '/'});
|
||||
});
|
||||
$("body").on("click", "#cu_save_user", function () {
|
||||
Cookies.set("airtime_locale", $("#cu_locale").val(), { path: "/" });
|
||||
});
|
||||
|
||||
// When the 'Listen' button is clicked we set the width
|
||||
// of the share button to the width of the 'Live Stream'
|
||||
// text. This differs depending on the language setting
|
||||
$('#popup-link').css('width', $('.jp-container h1').css('width'));
|
||||
// When the 'Listen' button is clicked we set the width
|
||||
// of the share button to the width of the 'Live Stream'
|
||||
// text. This differs depending on the language setting
|
||||
$("#popup-link").css("width", $(".jp-container h1").css("width"));
|
||||
|
||||
/*$('#menu-btn').click(function() {
|
||||
/*$('#menu-btn').click(function() {
|
||||
$('#nav .responsive-menu').slideToggle();
|
||||
});*/
|
||||
});
|
||||
|
|
|
@ -1,232 +1,213 @@
|
|||
/* 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;
|
||||
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("-");
|
||||
function getDateFromString(time) {
|
||||
var date = time.split("-");
|
||||
|
||||
if (date.length != 3){
|
||||
return null;
|
||||
}
|
||||
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);
|
||||
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);
|
||||
if (isNaN(year) || isNaN(month) || isNaN(day)) {
|
||||
return null;
|
||||
}
|
||||
|
||||
return new Date(year, month, day);
|
||||
}
|
||||
|
||||
function convertSecondsToDaysHoursMinutesSeconds(seconds){
|
||||
if (seconds < 0)
|
||||
seconds = 0;
|
||||
function convertSecondsToDaysHoursMinutesSeconds(seconds) {
|
||||
if (seconds < 0) seconds = 0;
|
||||
|
||||
seconds = parseInt(seconds, 10);
|
||||
seconds = parseInt(seconds, 10);
|
||||
|
||||
var days = parseInt(seconds / 86400);
|
||||
seconds -= days*86400;
|
||||
var days = parseInt(seconds / 86400);
|
||||
seconds -= days * 86400;
|
||||
|
||||
var hours = parseInt(seconds / 3600);
|
||||
seconds -= hours*3600;
|
||||
var hours = parseInt(seconds / 3600);
|
||||
seconds -= hours * 3600;
|
||||
|
||||
var minutes = parseInt(seconds / 60);
|
||||
seconds -= minutes*60;
|
||||
var minutes = parseInt(seconds / 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
|
||||
* the format HH:MM:SS */
|
||||
function convertToHHMMSS(timeInMS){
|
||||
var time = parseInt(timeInMS);
|
||||
function convertToHHMMSS(timeInMS) {
|
||||
var time = parseInt(timeInMS);
|
||||
|
||||
var hours = parseInt(time / 3600000);
|
||||
time -= 3600000*hours;
|
||||
var hours = parseInt(time / 3600000);
|
||||
time -= 3600000 * hours;
|
||||
|
||||
var minutes = parseInt(time / 60000);
|
||||
time -= 60000*minutes;
|
||||
var minutes = parseInt(time / 60000);
|
||||
time -= 60000 * minutes;
|
||||
|
||||
var seconds = parseInt(time / 1000);
|
||||
var seconds = parseInt(time / 1000);
|
||||
|
||||
hours = hours.toString();
|
||||
minutes = minutes.toString();
|
||||
seconds = seconds.toString();
|
||||
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;
|
||||
return hours + ":" + minutes + ":" + seconds;
|
||||
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;
|
||||
}
|
||||
|
||||
function convertToHHMMSSmm(timeInMS){
|
||||
var time = parseInt(timeInMS);
|
||||
function convertToHHMMSSmm(timeInMS) {
|
||||
var time = parseInt(timeInMS);
|
||||
|
||||
var hours = parseInt(time / 3600000);
|
||||
time -= 3600000*hours;
|
||||
var hours = parseInt(time / 3600000);
|
||||
time -= 3600000 * hours;
|
||||
|
||||
var minutes = parseInt(time / 60000);
|
||||
time -= 60000*minutes;
|
||||
var minutes = parseInt(time / 60000);
|
||||
time -= 60000 * minutes;
|
||||
|
||||
var seconds = parseInt(time / 1000);
|
||||
time -= 1000*seconds;
|
||||
var seconds = parseInt(time / 1000);
|
||||
time -= 1000 * seconds;
|
||||
|
||||
var ms = parseInt(time);
|
||||
var ms = parseInt(time);
|
||||
|
||||
hours = hours.toString();
|
||||
minutes = minutes.toString();
|
||||
seconds = seconds.toString();
|
||||
ms = ms.toString();
|
||||
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 (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 (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;
|
||||
if (hours == "00") return minutes + ":" + seconds + "." + ms;
|
||||
else return hours + ":" + minutes + ":" + seconds + "." + ms;
|
||||
}
|
||||
|
||||
function convertDateToHHMM(epochTime){
|
||||
var d = new Date(epochTime);
|
||||
function convertDateToHHMM(epochTime) {
|
||||
var d = new Date(epochTime);
|
||||
|
||||
var hours = d.getUTCHours().toString();
|
||||
var minutes = d.getUTCMinutes().toString();
|
||||
var hours = d.getUTCHours().toString();
|
||||
var minutes = d.getUTCMinutes().toString();
|
||||
|
||||
if (hours.length == 1)
|
||||
hours = "0" + hours;
|
||||
if (minutes.length == 1)
|
||||
minutes = "0" + minutes;
|
||||
if (hours.length == 1) hours = "0" + hours;
|
||||
if (minutes.length == 1) minutes = "0" + minutes;
|
||||
|
||||
return hours + ":" + minutes;
|
||||
return hours + ":" + minutes;
|
||||
}
|
||||
|
||||
function convertDateToHHMMSS(epochTime){
|
||||
var d = new Date(epochTime);
|
||||
function convertDateToHHMMSS(epochTime) {
|
||||
var d = new Date(epochTime);
|
||||
|
||||
var hours = d.getUTCHours().toString();
|
||||
var minutes = d.getUTCMinutes().toString();
|
||||
var seconds = d.getUTCSeconds().toString();
|
||||
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;
|
||||
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){
|
||||
function convertDateToPosixTime(s) {
|
||||
var datetime = s.split(" ");
|
||||
|
||||
var datetime = s.split(" ");
|
||||
var date = datetime[0].split("-");
|
||||
var time = datetime[1].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;
|
||||
|
||||
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];
|
||||
|
||||
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);
|
||||
return Date.UTC(year, month - 1, day, hour, minute, sec, msec);
|
||||
}
|
||||
|
||||
function getFileExt(filename){
|
||||
return filename.split('.').pop();
|
||||
function getFileExt(filename) {
|
||||
return filename.split(".").pop();
|
||||
}
|
||||
|
||||
function resizeImg(ele, targetWidth, targetHeight){
|
||||
var img = $(ele);
|
||||
function resizeImg(ele, targetWidth, targetHeight) {
|
||||
var img = $(ele);
|
||||
|
||||
var width = ele.width;
|
||||
var height = ele.height;
|
||||
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" );
|
||||
}
|
||||
// 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);
|
||||
function resizeToMaxHeight(ele, targetHeight) {
|
||||
var img = $(ele);
|
||||
|
||||
var width = ele.width;
|
||||
var height = ele.height;
|
||||
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");
|
||||
}
|
||||
// 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 http://stackoverflow.com/questions/123999/how-to-tell-if-a-dom-element-is-visible-in-the-current-viewport/#7557433 */
|
||||
function isInView(el) {
|
||||
//special bonus for those using jQuery
|
||||
if (typeof jQuery === "function" && el instanceof jQuery) {
|
||||
el = el[0];
|
||||
}
|
||||
//special bonus for those using jQuery
|
||||
if (typeof jQuery === "function" && el instanceof jQuery) {
|
||||
el = el[0];
|
||||
}
|
||||
|
||||
var rect = el.getBoundingClientRect();
|
||||
var rect = el.getBoundingClientRect();
|
||||
|
||||
return (
|
||||
return (
|
||||
rect.top >= 0 &&
|
||||
rect.left >= 0 &&
|
||||
rect.bottom <= (window.innerHeight || document.documentElement.clientHeight) && /*or $(window).height() */
|
||||
rect.right <= (window.innerWidth || document.documentElement.clientWidth) /*or $(window).width() */
|
||||
);
|
||||
rect.bottom <=
|
||||
(window.innerHeight ||
|
||||
document.documentElement.clientHeight) /*or $(window).height() */ &&
|
||||
rect.right <=
|
||||
(window.innerWidth ||
|
||||
document.documentElement.clientWidth) /*or $(window).width() */
|
||||
);
|
||||
}
|
||||
|
|
|
@ -2,149 +2,165 @@
|
|||
* Get the tooltip message to be displayed
|
||||
*/
|
||||
function getContent() {
|
||||
var link = getLatestLink();
|
||||
var hasPatch = getHasPatch();
|
||||
var hasMinor = getHasMinor();
|
||||
var hasMajor = getHasMajor();
|
||||
var hasMultiMajor = getHasMultiMajor();
|
||||
var isPreRelease = getIsPreRelease();
|
||||
var link = getLatestLink();
|
||||
var hasPatch = getHasPatch();
|
||||
var hasMinor = getHasMinor();
|
||||
var hasMajor = getHasMajor();
|
||||
var hasMultiMajor = getHasMultiMajor();
|
||||
var isPreRelease = getIsPreRelease();
|
||||
|
||||
var msg = "";
|
||||
// See file legacy/application/views/helpers/VersionNotify.php for more info
|
||||
if(isUpToDate()) {
|
||||
msg = $.i18n._("You are running the latest version");
|
||||
} else {
|
||||
msg = $.i18n._("New version available: ") + link + '<ul>';
|
||||
if (isPreRelease) {
|
||||
msg += '<li>'+$.i18n._("You have a pre-release version of LibreTime intalled.");
|
||||
}
|
||||
if (hasPatch) {
|
||||
msg += '<li>'+$.i18n._("A patch update for your LibreTime installation is available.");
|
||||
}
|
||||
if (hasMinor) {
|
||||
msg += '<li>'+$.i18n._("A feature update for your LibreTime installation is available.");
|
||||
}
|
||||
if (hasMajor && !hasMultiMajor) {
|
||||
msg += '<li>'+$.i18n._("A major update for your LibreTime installation is available.");
|
||||
}
|
||||
if (hasMultiMajor) {
|
||||
msg += '<li>'+$.i18n._("Multiple major updates for LibreTime installation are available. Please upgrade as soon as possible.");
|
||||
}
|
||||
msg += '</ul>';
|
||||
var msg = "";
|
||||
// See file legacy/application/views/helpers/VersionNotify.php for more info
|
||||
if (isUpToDate()) {
|
||||
msg = $.i18n._("You are running the latest version");
|
||||
} else {
|
||||
msg = $.i18n._("New version available: ") + link + "<ul>";
|
||||
if (isPreRelease) {
|
||||
msg +=
|
||||
"<li>" +
|
||||
$.i18n._("You have a pre-release version of LibreTime intalled.");
|
||||
}
|
||||
if (hasPatch) {
|
||||
msg +=
|
||||
"<li>" +
|
||||
$.i18n._(
|
||||
"A patch update for your LibreTime installation is available."
|
||||
);
|
||||
}
|
||||
if (hasMinor) {
|
||||
msg +=
|
||||
"<li>" +
|
||||
$.i18n._(
|
||||
"A feature update for your LibreTime installation is available."
|
||||
);
|
||||
}
|
||||
if (hasMajor && !hasMultiMajor) {
|
||||
msg +=
|
||||
"<li>" +
|
||||
$.i18n._(
|
||||
"A major update for your LibreTime installation is available."
|
||||
);
|
||||
}
|
||||
if (hasMultiMajor) {
|
||||
msg +=
|
||||
"<li>" +
|
||||
$.i18n._(
|
||||
"Multiple major updates for LibreTime installation are available. Please upgrade as soon as possible."
|
||||
);
|
||||
}
|
||||
msg += "</ul>";
|
||||
}
|
||||
|
||||
return msg;
|
||||
return msg;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get if patch is available
|
||||
*/
|
||||
function getHasPatch() {
|
||||
return versionNotifyInfo.hasPatch;
|
||||
|
||||
return versionNotifyInfo.hasPatch;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get if minor update is available
|
||||
*/
|
||||
function getHasMinor() {
|
||||
return versionNotifyInfo.hasMinor;
|
||||
return versionNotifyInfo.hasMinor;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get if major update is available
|
||||
*/
|
||||
function getHasMajor() {
|
||||
return versionNotifyInfo.hasMajor;
|
||||
return versionNotifyInfo.hasMajor;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get if multiple major updates are available
|
||||
*/
|
||||
function getHasMultiMajor() {
|
||||
return versionNotifyInfo.hasMultiMajor;
|
||||
return versionNotifyInfo.hasMultiMajor;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get if pre-release was installed
|
||||
*/
|
||||
function getIsPreRelease() {
|
||||
return versionNotifyInfo.isPreRelease;
|
||||
return versionNotifyInfo.isPreRelease;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Get the current version
|
||||
*/
|
||||
function getCurrentVersion() {
|
||||
return versionNotifyInfo.current;
|
||||
return versionNotifyInfo.current;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the latest version
|
||||
*/
|
||||
function getLatestVersion() {
|
||||
return versionNotifyInfo.latest;
|
||||
return versionNotifyInfo.latest;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the download link to latest release in HTML
|
||||
*/
|
||||
function getLatestLink() {
|
||||
return "<a href='' onclick='openLatestLink();'>" + getLatestVersion() + "</a>";
|
||||
return (
|
||||
"<a href='' onclick='openLatestLink();'>" + getLatestVersion() + "</a>"
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns true if current version is up to date
|
||||
*/
|
||||
function isUpToDate() {
|
||||
return !getHasPatch() && !getHasMinor() && !getHasMajor();
|
||||
return !getHasPatch() && !getHasMinor() && !getHasMajor();
|
||||
}
|
||||
|
||||
/**
|
||||
* Opens the link in a new window
|
||||
*/
|
||||
function openLatestLink() {
|
||||
window.open(versionNotifyInfo.link);
|
||||
window.open(versionNotifyInfo.link);
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets up the tooltip for version notification
|
||||
*/
|
||||
function setupVersionQtip(){
|
||||
var qtipElem = $('#version-icon');
|
||||
if (qtipElem.length > 0){
|
||||
qtipElem.qtip({
|
||||
id: 'version',
|
||||
content: {
|
||||
text: getContent(),
|
||||
title: {
|
||||
text: getCurrentVersion(),
|
||||
button: isUpToDate() ? false : true
|
||||
}
|
||||
},
|
||||
hide: {
|
||||
event: isUpToDate() ? 'mouseleave' : 'unfocus'
|
||||
},
|
||||
position: {
|
||||
my: "top right",
|
||||
at: "bottom left"
|
||||
},
|
||||
style: {
|
||||
border: {
|
||||
width: 0,
|
||||
radius: 4
|
||||
},
|
||||
classes: "ui-tooltip-dark ui-tooltip-rounded"
|
||||
}
|
||||
});
|
||||
}
|
||||
function setupVersionQtip() {
|
||||
var qtipElem = $("#version-icon");
|
||||
if (qtipElem.length > 0) {
|
||||
qtipElem.qtip({
|
||||
id: "version",
|
||||
content: {
|
||||
text: getContent(),
|
||||
title: {
|
||||
text: getCurrentVersion(),
|
||||
button: isUpToDate() ? false : true,
|
||||
},
|
||||
},
|
||||
hide: {
|
||||
event: isUpToDate() ? "mouseleave" : "unfocus",
|
||||
},
|
||||
position: {
|
||||
my: "top right",
|
||||
at: "bottom left",
|
||||
},
|
||||
style: {
|
||||
border: {
|
||||
width: 0,
|
||||
radius: 4,
|
||||
},
|
||||
classes: "ui-tooltip-dark ui-tooltip-rounded",
|
||||
},
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
$(document).ready(function() {
|
||||
if($('#version-icon').length > 0) {
|
||||
setupVersionQtip();
|
||||
}
|
||||
$(document).ready(function () {
|
||||
if ($("#version-icon").length > 0) {
|
||||
setupVersionQtip();
|
||||
}
|
||||
});
|
||||
|
|
|
@ -1,183 +1,204 @@
|
|||
var AIRTIME = (function(AIRTIME) {
|
||||
var mod;
|
||||
var AIRTIME = (function (AIRTIME) {
|
||||
var mod;
|
||||
|
||||
if (AIRTIME.library === undefined) {
|
||||
AIRTIME.library = {};
|
||||
if (AIRTIME.library === undefined) {
|
||||
AIRTIME.library = {};
|
||||
}
|
||||
|
||||
mod = AIRTIME.library;
|
||||
|
||||
mod.checkAddButton = function () {
|
||||
var selected = mod.getChosenItemsLength(),
|
||||
sortable = $(".spl_sortable:visible"),
|
||||
check = false,
|
||||
blockType = $("input[name=sp_type]:checked", "#smart-block-form").val();
|
||||
|
||||
// make sure audioclips are selected and a playlist or static block is currently open.
|
||||
// static blocks have value of 0
|
||||
// dynamic blocks have value of 1
|
||||
if (selected !== 0 && (sortable.length !== 0 || blockType === "0")) {
|
||||
check = true;
|
||||
}
|
||||
|
||||
mod = AIRTIME.library;
|
||||
if (check === true) {
|
||||
AIRTIME.button.enableButton("btn-group #library-plus", false);
|
||||
} else {
|
||||
AIRTIME.button.disableButton("btn-group #library-plus", false);
|
||||
}
|
||||
|
||||
mod.checkAddButton = function() {
|
||||
var objType = $(".obj_type").val(),
|
||||
btnText;
|
||||
if (objType === "playlist") {
|
||||
btnText = " " + $.i18n._("Add to current playlist");
|
||||
} else if (objType === "block") {
|
||||
btnText = " " + $.i18n._("Add to current smart block");
|
||||
} else {
|
||||
btnText = " " + $.i18n._("Add to current playlist");
|
||||
}
|
||||
AIRTIME.library.changeAddButtonText(
|
||||
$(".btn-group #library-plus #lib-plus-text"),
|
||||
btnText
|
||||
);
|
||||
};
|
||||
|
||||
var selected = mod.getChosenItemsLength(),
|
||||
sortable = $('.spl_sortable:visible'),
|
||||
check = false,
|
||||
blockType = $('input[name=sp_type]:checked', '#smart-block-form').val();
|
||||
mod.fnRowCallback = function (nRow, aData, iDisplayIndex, iDisplayIndexFull) {
|
||||
var $nRow = $(nRow);
|
||||
if (aData.ftype === "audioclip") {
|
||||
$nRow.addClass("lib-audio");
|
||||
$image = $nRow.find("td.library_type");
|
||||
if (!isAudioSupported(aData.mime)) {
|
||||
$image.html('<span class="ui-icon ui-icon-locked"></span>');
|
||||
aData.image = '<span class="ui-icon ui-icon-locked"></span>';
|
||||
}
|
||||
} else if (aData.ftype === "stream") {
|
||||
$nRow.addClass("lib-stream");
|
||||
} else if (aData.ftype === "block") {
|
||||
$nRow.addClass("lib-block");
|
||||
} else {
|
||||
$nRow.addClass("lib-pl");
|
||||
}
|
||||
|
||||
// make sure audioclips are selected and a playlist or static block is currently open.
|
||||
// static blocks have value of 0
|
||||
// dynamic blocks have value of 1
|
||||
if (selected !== 0 && (sortable.length !== 0 || blockType === "0")) {
|
||||
check = true;
|
||||
$nRow
|
||||
.attr("id", aData["tr_id"])
|
||||
.data("aData", aData)
|
||||
.data("screen", "playlist");
|
||||
|
||||
if (aData["bl_type"] !== undefined) {
|
||||
$nRow.attr("bl_type", aData["bl_type"]);
|
||||
}
|
||||
};
|
||||
|
||||
mod.fnDrawCallback = function () {
|
||||
mod.redrawChosen();
|
||||
mod.checkToolBarIcons();
|
||||
|
||||
$(
|
||||
"#library_display tr.lib-audio, tr.lib-stream, tr.lib-pl, tr.lib-block"
|
||||
).draggable({
|
||||
helper: function () {
|
||||
var $el = $(this),
|
||||
selected = mod.getChosenAudioFilesLength(),
|
||||
container,
|
||||
message,
|
||||
li = $(".side_playlist ul[id='spl_sortable'] li:first"),
|
||||
width = li.width(),
|
||||
height = 55;
|
||||
if (width > 798) width = 798;
|
||||
|
||||
// dragging an element that has an unselected
|
||||
// checkbox.
|
||||
if (mod.isChosenItem($el) === false) {
|
||||
selected++;
|
||||
}
|
||||
|
||||
if (check === true) {
|
||||
AIRTIME.button.enableButton("btn-group #library-plus", false);
|
||||
if (selected === 1) {
|
||||
message = $.i18n._("Adding 1 Item");
|
||||
} else {
|
||||
AIRTIME.button.disableButton("btn-group #library-plus", false);
|
||||
message = sprintf($.i18n._("Adding %s Items"), selected);
|
||||
}
|
||||
|
||||
var objType = $('.obj_type').val(),
|
||||
btnText;
|
||||
if (objType === 'playlist') {
|
||||
btnText = ' '+$.i18n._('Add to current playlist');
|
||||
} else if (objType === 'block') {
|
||||
btnText = ' '+$.i18n._('Add to current smart block');
|
||||
} else {
|
||||
btnText = ' '+$.i18n._('Add to current playlist');
|
||||
}
|
||||
AIRTIME.library.changeAddButtonText($('.btn-group #library-plus #lib-plus-text'), btnText);
|
||||
};
|
||||
container = $('<div class="helper"/>')
|
||||
.append("<li/>")
|
||||
.find("li")
|
||||
.addClass("ui-state-default")
|
||||
.append("<div/>")
|
||||
.find("div")
|
||||
.addClass("list-item-container")
|
||||
.append(message)
|
||||
.end()
|
||||
.width(width)
|
||||
.height(height)
|
||||
.end();
|
||||
|
||||
mod.fnRowCallback = function(nRow, aData, iDisplayIndex, iDisplayIndexFull) {
|
||||
var $nRow = $(nRow);
|
||||
if (aData.ftype === "audioclip") {
|
||||
$nRow.addClass("lib-audio");
|
||||
$image = $nRow.find('td.library_type');
|
||||
if (!isAudioSupported(aData.mime)) {
|
||||
$image.html('<span class="ui-icon ui-icon-locked"></span>');
|
||||
aData.image = '<span class="ui-icon ui-icon-locked"></span>';
|
||||
}
|
||||
} else if (aData.ftype === "stream") {
|
||||
$nRow.addClass("lib-stream");
|
||||
} else if (aData.ftype === "block") {
|
||||
$nRow.addClass("lib-block");
|
||||
} else {
|
||||
$nRow.addClass("lib-pl");
|
||||
return container;
|
||||
},
|
||||
cursor: "pointer",
|
||||
cursorAt: {
|
||||
top: 30,
|
||||
left: 100,
|
||||
},
|
||||
connectToSortable: ".spl_sortable",
|
||||
});
|
||||
};
|
||||
|
||||
mod.dblClickAdd = function (data, type) {
|
||||
var i,
|
||||
aMediaIds = [];
|
||||
|
||||
// process selected files/playlists.
|
||||
aMediaIds.push(new Array(data.id, data.ftype));
|
||||
|
||||
// check if a playlist/block is open before adding items
|
||||
if (
|
||||
$('input[id="obj_type"]').val() == "playlist" ||
|
||||
$('input[id="obj_type"]').val() == "block"
|
||||
) {
|
||||
AIRTIME.playlist.fnAddItems(aMediaIds, undefined, "after");
|
||||
}
|
||||
};
|
||||
|
||||
mod.setupLibraryToolbar = function () {
|
||||
var $toolbar = $(".lib-content .fg-toolbar:first");
|
||||
|
||||
mod.createToolbarButtons();
|
||||
|
||||
$toolbar.append($menu);
|
||||
|
||||
// add to playlist button
|
||||
$toolbar
|
||||
.find(".icon-plus")
|
||||
.parent()
|
||||
.click(function () {
|
||||
if (AIRTIME.button.isDisabled("btn-group #library-plus") === true) {
|
||||
return;
|
||||
}
|
||||
|
||||
$nRow.attr("id", aData["tr_id"]).data("aData", aData).data("screen",
|
||||
"playlist");
|
||||
|
||||
if (aData["bl_type"] !== undefined) {
|
||||
$nRow.attr("bl_type", aData["bl_type"]);
|
||||
}
|
||||
};
|
||||
|
||||
mod.fnDrawCallback = function() {
|
||||
|
||||
mod.redrawChosen();
|
||||
mod.checkToolBarIcons();
|
||||
|
||||
$('#library_display tr.lib-audio, tr.lib-stream, tr.lib-pl, tr.lib-block')
|
||||
.draggable(
|
||||
{
|
||||
helper : function() {
|
||||
|
||||
var $el = $(this), selected = mod
|
||||
.getChosenAudioFilesLength(), container, message, li = $(".side_playlist ul[id='spl_sortable'] li:first"),
|
||||
width = li.width(), height = 55;
|
||||
if (width > 798) width = 798;
|
||||
|
||||
// dragging an element that has an unselected
|
||||
// checkbox.
|
||||
if (mod.isChosenItem($el) === false) {
|
||||
selected++;
|
||||
}
|
||||
|
||||
if (selected === 1) {
|
||||
message = $.i18n._("Adding 1 Item");
|
||||
} else {
|
||||
message = sprintf($.i18n._("Adding %s Items"), selected);
|
||||
}
|
||||
|
||||
container = $('<div class="helper"/>').append(
|
||||
"<li/>").find("li").addClass(
|
||||
"ui-state-default").append("<div/>")
|
||||
.find("div").addClass(
|
||||
"list-item-container").append(
|
||||
message).end().width(width)
|
||||
.height(height).end();
|
||||
|
||||
return container;
|
||||
},
|
||||
cursor : 'pointer',
|
||||
cursorAt: {
|
||||
top: 30,
|
||||
left: 100
|
||||
},
|
||||
connectToSortable : '.spl_sortable'
|
||||
});
|
||||
};
|
||||
|
||||
mod.dblClickAdd = function(data, type) {
|
||||
var i, aMediaIds = [];
|
||||
var aData = AIRTIME.library.getSelectedData(),
|
||||
i,
|
||||
temp,
|
||||
length,
|
||||
aMediaIds = [];
|
||||
|
||||
// process selected files/playlists.
|
||||
aMediaIds.push(new Array(data.id, data.ftype));
|
||||
|
||||
// check if a playlist/block is open before adding items
|
||||
if ($('input[id="obj_type"]').val() == 'playlist'
|
||||
|| $('input[id="obj_type"]').val() == 'block') {
|
||||
AIRTIME.playlist.fnAddItems(aMediaIds, undefined, 'after');
|
||||
for (i = 0, length = aData.length; i < length; i++) {
|
||||
temp = aData[i];
|
||||
if (
|
||||
temp.ftype === "audioclip" ||
|
||||
temp.ftype === "block" ||
|
||||
(temp.ftype === "stream" && $(".obj_type").val() === "playlist")
|
||||
) {
|
||||
aMediaIds.push(new Array(temp.id, temp.ftype));
|
||||
}
|
||||
}
|
||||
};
|
||||
if (aMediaIds.length > 0) {
|
||||
AIRTIME.playlist.fnAddItems(aMediaIds, undefined, "after");
|
||||
} else {
|
||||
if ($(".obj_type").val() == "block") {
|
||||
alert($.i18n._("You can only add tracks to smart blocks."));
|
||||
} else if ($(".obj_type").val() == "playlist") {
|
||||
alert(
|
||||
$.i18n._(
|
||||
"You can only add tracks, smart blocks, and webstreams to playlists."
|
||||
)
|
||||
);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
mod.setupLibraryToolbar = function() {
|
||||
var $toolbar = $(".lib-content .fg-toolbar:first");
|
||||
// delete from library.
|
||||
$toolbar
|
||||
.find(".icon-trash")
|
||||
.parent()
|
||||
.click(function () {
|
||||
if (AIRTIME.button.isDisabled("icon-trash") === true) {
|
||||
return;
|
||||
}
|
||||
|
||||
mod.createToolbarButtons();
|
||||
AIRTIME.library.fnDeleteSelectedItems();
|
||||
});
|
||||
|
||||
$toolbar.append($menu);
|
||||
mod.createToolbarDropDown();
|
||||
};
|
||||
|
||||
|
||||
// add to playlist button
|
||||
$toolbar
|
||||
.find('.icon-plus').parent()
|
||||
.click(function() {
|
||||
|
||||
if (AIRTIME.button.isDisabled('btn-group #library-plus') === true) {
|
||||
return;
|
||||
}
|
||||
|
||||
var aData = AIRTIME.library.getSelectedData(), i, temp, length, aMediaIds = [];
|
||||
|
||||
// process selected files/playlists.
|
||||
for (i = 0, length = aData.length; i < length; i++) {
|
||||
temp = aData[i];
|
||||
if (temp.ftype === "audioclip"
|
||||
|| temp.ftype === "block"
|
||||
|| (temp.ftype === "stream" && $(
|
||||
".obj_type").val() === "playlist")) {
|
||||
aMediaIds.push(new Array(temp.id,
|
||||
temp.ftype));
|
||||
}
|
||||
}
|
||||
if (aMediaIds.length > 0) {
|
||||
AIRTIME.playlist.fnAddItems(aMediaIds,
|
||||
undefined, 'after');
|
||||
} else {
|
||||
if ($('.obj_type').val() == 'block') {
|
||||
alert($.i18n._('You can only add tracks to smart blocks.'));
|
||||
} else if ($('.obj_type').val() == 'playlist') {
|
||||
alert($.i18n._('You can only add tracks, smart blocks, and webstreams to playlists.'));
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
// delete from library.
|
||||
$toolbar.find('.icon-trash').parent().click(function() {
|
||||
|
||||
if (AIRTIME.button.isDisabled('icon-trash') === true) {
|
||||
return;
|
||||
}
|
||||
|
||||
AIRTIME.library.fnDeleteSelectedItems();
|
||||
});
|
||||
|
||||
mod.createToolbarDropDown();
|
||||
};
|
||||
|
||||
return AIRTIME;
|
||||
|
||||
}(AIRTIME || {}));
|
||||
return AIRTIME;
|
||||
})(AIRTIME || {});
|
||||
|
|
|
@ -1,391 +1,439 @@
|
|||
var AIRTIME = (function(AIRTIME) {
|
||||
var mod;
|
||||
var AIRTIME = (function (AIRTIME) {
|
||||
var mod;
|
||||
|
||||
if (AIRTIME.library === undefined) {
|
||||
AIRTIME.library = {};
|
||||
if (AIRTIME.library === undefined) {
|
||||
AIRTIME.library = {};
|
||||
}
|
||||
|
||||
mod = AIRTIME.library;
|
||||
|
||||
mod.checkAddButton = function () {
|
||||
var selected = mod.getChosenItemsLength(),
|
||||
$cursor = $("tr.sb-selected"),
|
||||
check = false,
|
||||
shows = $("tr.sb-header"),
|
||||
current = $("tr.sb-current-show"),
|
||||
// TODO: this is an ugly way of doing this... we should find a more robust way of checking which view we're in.
|
||||
btnText =
|
||||
window.location.href.toLowerCase().indexOf("schedule") > -1
|
||||
? $.i18n._("Add to show")
|
||||
: $.i18n._("Add to next show");
|
||||
|
||||
// make sure library items are selected and a cursor is selected.
|
||||
if (selected !== 0) {
|
||||
check = true;
|
||||
}
|
||||
|
||||
mod = AIRTIME.library;
|
||||
var sortable = $(".spl_sortable");
|
||||
if ($("#show_builder_table").is(":visible")) {
|
||||
if (shows.length === 0) {
|
||||
check = false;
|
||||
}
|
||||
|
||||
mod.checkAddButton = function() {
|
||||
var selected = mod.getChosenItemsLength(), $cursor = $('tr.sb-selected'), check = false,
|
||||
shows = $('tr.sb-header'), current = $('tr.sb-current-show'),
|
||||
// TODO: this is an ugly way of doing this... we should find a more robust way of checking which view we're in.
|
||||
btnText = (window.location.href.toLowerCase().indexOf("schedule") > -1) ? $.i18n._('Add to show') : $.i18n._('Add to next show');
|
||||
|
||||
// make sure library items are selected and a cursor is selected.
|
||||
if (selected !== 0) {
|
||||
check = true;
|
||||
}
|
||||
|
||||
var sortable = $(".spl_sortable");
|
||||
if ($("#show_builder_table").is(":visible")) {
|
||||
if (shows.length === 0) {
|
||||
check = false;
|
||||
}
|
||||
|
||||
if ($cursor.length !== 0) {
|
||||
btnText = $.i18n._('Add after selected items');
|
||||
} else if (current.length !== 0) {
|
||||
btnText = $.i18n._('Add to current show');
|
||||
}
|
||||
} else if (sortable.length > 0 && sortable.is(":visible")) {
|
||||
var objType = $('.active-tab .obj_type').val();
|
||||
if (objType === 'block') {
|
||||
btnText = $.i18n._('Add to current smart block');
|
||||
} else {
|
||||
btnText = $.i18n._('Add to current playlist');
|
||||
}
|
||||
} else {
|
||||
check = false;
|
||||
}
|
||||
|
||||
if (check) {
|
||||
AIRTIME.button.enableButton("btn-group #library-plus", false);
|
||||
} else {
|
||||
AIRTIME.button.disableButton("btn-group #library-plus", false);
|
||||
}
|
||||
|
||||
AIRTIME.library.changeAddButtonText($('.btn-group #library-plus #lib-plus-text'), btnText);
|
||||
};
|
||||
|
||||
mod.fnRowCallback = function(nRow, aData, iDisplayIndex, iDisplayIndexFull) {
|
||||
var $nRow = $(nRow);
|
||||
|
||||
if (aData.ftype === "audioclip") {
|
||||
$nRow.addClass("lib-audio");
|
||||
$image = $nRow.find('td.library_type');
|
||||
if (!isAudioSupported(aData.mime)) {
|
||||
$image.html('<span class="ui-icon ui-icon-locked"></span>');
|
||||
aData.image = '<span class="ui-icon ui-icon-locked"></span>';
|
||||
}
|
||||
} else if (aData.ftype === "stream") {
|
||||
$nRow.addClass("lib-stream");
|
||||
} else {
|
||||
$nRow.addClass("lib-pl");
|
||||
}
|
||||
|
||||
$nRow.attr("id", aData["tr_id"]).data("aData", aData).data("screen",
|
||||
"timeline");
|
||||
};
|
||||
|
||||
/**
|
||||
* Draw a placeholder for the given table to show if it has no data.
|
||||
*
|
||||
* @param {Object} table jQuery object containing the table DOM node
|
||||
*/
|
||||
mod.drawEmptyPlaceholder = function (table) {
|
||||
var opts;
|
||||
if (table instanceof AIRTIME.widgets.Table) {
|
||||
opts = table.getEmptyPlaceholder();
|
||||
table = table.getDatatable();
|
||||
if (!table) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
var emptyRow = table.find('tr:has(td.dataTables_empty)'),
|
||||
wrapper = table.closest(".dataTables_wrapper"),
|
||||
libEmpty = wrapper.find('.empty_placeholder');
|
||||
if (emptyRow.length > 0) {
|
||||
emptyRow.hide();
|
||||
var mediaType = parseInt($('.media_type_selector.selected').data('selection-id')),
|
||||
img = wrapper.find('.empty_placeholder_image');
|
||||
if (!opts && isNaN(mediaType)) {
|
||||
return;
|
||||
}
|
||||
// Remove all classes for when we change between empty media types
|
||||
img.removeClass(function() { return $(this).attr("class"); });
|
||||
|
||||
if (opts) {
|
||||
img.addClass("empty_placeholder_image " + opts.iconClass);
|
||||
wrapper.find('.empty_placeholder_text').html(opts.html);
|
||||
} else {
|
||||
opts = AIRTIME.library.placeholder(mediaType);
|
||||
img.addClass("empty_placeholder_image icon-white " + opts.icon);
|
||||
wrapper.find('.empty_placeholder_text').html(
|
||||
$.i18n._("You haven't added any " + opts.media)
|
||||
+ "<br/>" + $.i18n._(opts.subtext)
|
||||
+ "<br/><a target='_blank' href='" + opts.href + "'>" + $.i18n._("Learn about " + opts.media) + "</a>"
|
||||
);
|
||||
}
|
||||
|
||||
libEmpty.show();
|
||||
} else {
|
||||
libEmpty.hide();
|
||||
}
|
||||
};
|
||||
|
||||
mod.fnDrawCallback = function fnLibDrawCallback() {
|
||||
var table = $('#library_display'),
|
||||
cb = table.find('th[class*="checkbox"]');
|
||||
if (cb.find("input").length == 0) {
|
||||
cb.append("<input id='super-checkbox' type='checkbox'>");
|
||||
}
|
||||
|
||||
mod.redrawChosen();
|
||||
mod.checkToolBarIcons();
|
||||
|
||||
mod.drawEmptyPlaceholder(table);
|
||||
|
||||
var sortable;
|
||||
|
||||
if ($("#show_builder_table").is(":visible")) {
|
||||
sortable = "#show_builder_table";
|
||||
} else {
|
||||
sortable = ".active-tab .spl_sortable";
|
||||
}
|
||||
|
||||
$('#library_display tr[class*="lib-"]')
|
||||
.draggable(
|
||||
{
|
||||
helper: function () {
|
||||
|
||||
var $el = $(this), selected = mod
|
||||
.getChosenItemsLength(), container, thead = $("#show_builder_table thead"), colspan = thead
|
||||
.find("th").length, width = $el.width(), message;
|
||||
|
||||
// dragging an element that has an unselected
|
||||
// checkbox.
|
||||
if (mod.isChosenItem($el) === false) {
|
||||
selected++;
|
||||
}
|
||||
|
||||
if (selected === 1) {
|
||||
message = $.i18n._("Adding 1 Item");
|
||||
} else {
|
||||
message = sprintf($.i18n._("Adding %s Items"), selected);
|
||||
}
|
||||
|
||||
container = $('<div/>').attr('id',
|
||||
'draggingContainer').append('<tr/>')
|
||||
.find("tr").append('<td/>').find("td")
|
||||
.attr("colspan", colspan).width(width)
|
||||
.addClass("ui-state-highlight").append(
|
||||
message).end().end();
|
||||
|
||||
return container;
|
||||
},
|
||||
create: function(event, ui) {
|
||||
$(this).draggable("option", "cursorAt", {
|
||||
top: 20,
|
||||
left: Math.floor($(this).outerWidth() / 2)
|
||||
});
|
||||
},
|
||||
tolerance: 'pointer',
|
||||
cursor: 'move',
|
||||
distance: 25, // min-distance for dragging
|
||||
connectToSortable: sortable
|
||||
});
|
||||
};
|
||||
|
||||
mod.dblClickAdd = function(data, type) {
|
||||
var i, length, temp, aMediaIds = [], aSchedIds = [], aData = [];
|
||||
|
||||
if ($("#show_builder_table").is(":visible")) {
|
||||
// process selected files/playlists.
|
||||
aMediaIds.push({
|
||||
"id": data.id,
|
||||
"type": type
|
||||
});
|
||||
|
||||
$("#show_builder_table tr.sb-selected").each(function (i, el) {
|
||||
aData.push($(el).data("aData"));
|
||||
});
|
||||
|
||||
// process selected schedule rows to add media after.
|
||||
for (i = 0, length = aData.length; i < length; i++) {
|
||||
temp = aData[i];
|
||||
aSchedIds.push({
|
||||
"id": temp.id,
|
||||
"instance": temp.instance,
|
||||
"timestamp": temp.timestamp
|
||||
});
|
||||
}
|
||||
|
||||
if (aSchedIds.length == 0) {
|
||||
if (!addToCurrentOrNext(aSchedIds)) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
AIRTIME.showbuilder.fnAdd(aMediaIds, aSchedIds);
|
||||
} else {
|
||||
// process selected files/playlists.
|
||||
aMediaIds.push(new Array(data.id, data.ftype));
|
||||
|
||||
// check if a playlist/block is open before adding items
|
||||
if ($('.active-tab .obj_type').val() == 'playlist'
|
||||
|| $('.active-tab .obj_type').val() == 'block') {
|
||||
AIRTIME.playlist.fnAddItems(aMediaIds, undefined, 'after');
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
function addToCurrentOrNext(arr) {
|
||||
var el;
|
||||
// Add to the end of the current or next show by getting the footer
|
||||
el = $(".sb-footer.sb-future:first");
|
||||
var data = el.prev().data("aData");
|
||||
|
||||
if (data === undefined) {
|
||||
alert($.i18n._("Cannot schedule outside a show.\nTry creating a show first."));
|
||||
return false;
|
||||
}
|
||||
|
||||
arr.push({
|
||||
"id" : data.id,
|
||||
"instance" : data.instance,
|
||||
"timestamp" : data.timestamp
|
||||
});
|
||||
|
||||
if (!isInView(el)) {
|
||||
$('.dataTables_scrolling.sb-padded').animate({
|
||||
scrollTop: el.offset().top
|
||||
}, 0);
|
||||
}
|
||||
|
||||
return true;
|
||||
if ($cursor.length !== 0) {
|
||||
btnText = $.i18n._("Add after selected items");
|
||||
} else if (current.length !== 0) {
|
||||
btnText = $.i18n._("Add to current show");
|
||||
}
|
||||
} else if (sortable.length > 0 && sortable.is(":visible")) {
|
||||
var objType = $(".active-tab .obj_type").val();
|
||||
if (objType === "block") {
|
||||
btnText = $.i18n._("Add to current smart block");
|
||||
} else {
|
||||
btnText = $.i18n._("Add to current playlist");
|
||||
}
|
||||
} else {
|
||||
check = false;
|
||||
}
|
||||
|
||||
mod.addToSchedule = function (selected) {
|
||||
console.log(selected);
|
||||
var aMediaIds = [], aSchedIds = [], aData = [];
|
||||
if (check) {
|
||||
AIRTIME.button.enableButton("btn-group #library-plus", false);
|
||||
} else {
|
||||
AIRTIME.button.disableButton("btn-group #library-plus", false);
|
||||
}
|
||||
|
||||
$.each(selected, function () {
|
||||
aMediaIds.push({
|
||||
"id": this.id,
|
||||
"type": this.ftype
|
||||
});
|
||||
});
|
||||
AIRTIME.library.changeAddButtonText(
|
||||
$(".btn-group #library-plus #lib-plus-text"),
|
||||
btnText
|
||||
);
|
||||
};
|
||||
|
||||
// process selected files/playlists.
|
||||
$("#show_builder_table").find("tr.sb-selected").each(function (i, el) {
|
||||
aData.push($(el).data("aData"));
|
||||
});
|
||||
mod.fnRowCallback = function (nRow, aData, iDisplayIndex, iDisplayIndexFull) {
|
||||
var $nRow = $(nRow);
|
||||
|
||||
// process selected schedule rows to add media after.
|
||||
$.each(aData, function () {
|
||||
aSchedIds.push({
|
||||
"id": this.id,
|
||||
"instance": this.instance,
|
||||
"timestamp": this.timestamp
|
||||
});
|
||||
});
|
||||
if (aData.ftype === "audioclip") {
|
||||
$nRow.addClass("lib-audio");
|
||||
$image = $nRow.find("td.library_type");
|
||||
if (!isAudioSupported(aData.mime)) {
|
||||
$image.html('<span class="ui-icon ui-icon-locked"></span>');
|
||||
aData.image = '<span class="ui-icon ui-icon-locked"></span>';
|
||||
}
|
||||
} else if (aData.ftype === "stream") {
|
||||
$nRow.addClass("lib-stream");
|
||||
} else {
|
||||
$nRow.addClass("lib-pl");
|
||||
}
|
||||
|
||||
if (aSchedIds.length == 0) {
|
||||
if (!addToCurrentOrNext(aSchedIds)) {
|
||||
return;
|
||||
}
|
||||
$nRow
|
||||
.attr("id", aData["tr_id"])
|
||||
.data("aData", aData)
|
||||
.data("screen", "timeline");
|
||||
};
|
||||
|
||||
/**
|
||||
* Draw a placeholder for the given table to show if it has no data.
|
||||
*
|
||||
* @param {Object} table jQuery object containing the table DOM node
|
||||
*/
|
||||
mod.drawEmptyPlaceholder = function (table) {
|
||||
var opts;
|
||||
if (table instanceof AIRTIME.widgets.Table) {
|
||||
opts = table.getEmptyPlaceholder();
|
||||
table = table.getDatatable();
|
||||
if (!table) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
var emptyRow = table.find("tr:has(td.dataTables_empty)"),
|
||||
wrapper = table.closest(".dataTables_wrapper"),
|
||||
libEmpty = wrapper.find(".empty_placeholder");
|
||||
if (emptyRow.length > 0) {
|
||||
emptyRow.hide();
|
||||
var mediaType = parseInt(
|
||||
$(".media_type_selector.selected").data("selection-id")
|
||||
),
|
||||
img = wrapper.find(".empty_placeholder_image");
|
||||
if (!opts && isNaN(mediaType)) {
|
||||
return;
|
||||
}
|
||||
// Remove all classes for when we change between empty media types
|
||||
img.removeClass(function () {
|
||||
return $(this).attr("class");
|
||||
});
|
||||
|
||||
if (opts) {
|
||||
img.addClass("empty_placeholder_image " + opts.iconClass);
|
||||
wrapper.find(".empty_placeholder_text").html(opts.html);
|
||||
} else {
|
||||
opts = AIRTIME.library.placeholder(mediaType);
|
||||
img.addClass("empty_placeholder_image icon-white " + opts.icon);
|
||||
wrapper
|
||||
.find(".empty_placeholder_text")
|
||||
.html(
|
||||
$.i18n._("You haven't added any " + opts.media) +
|
||||
"<br/>" +
|
||||
$.i18n._(opts.subtext) +
|
||||
"<br/><a target='_blank' href='" +
|
||||
opts.href +
|
||||
"'>" +
|
||||
$.i18n._("Learn about " + opts.media) +
|
||||
"</a>"
|
||||
);
|
||||
}
|
||||
|
||||
libEmpty.show();
|
||||
} else {
|
||||
libEmpty.hide();
|
||||
}
|
||||
};
|
||||
|
||||
mod.fnDrawCallback = function fnLibDrawCallback() {
|
||||
var table = $("#library_display"),
|
||||
cb = table.find('th[class*="checkbox"]');
|
||||
if (cb.find("input").length == 0) {
|
||||
cb.append("<input id='super-checkbox' type='checkbox'>");
|
||||
}
|
||||
|
||||
mod.redrawChosen();
|
||||
mod.checkToolBarIcons();
|
||||
|
||||
mod.drawEmptyPlaceholder(table);
|
||||
|
||||
var sortable;
|
||||
|
||||
if ($("#show_builder_table").is(":visible")) {
|
||||
sortable = "#show_builder_table";
|
||||
} else {
|
||||
sortable = ".active-tab .spl_sortable";
|
||||
}
|
||||
|
||||
$('#library_display tr[class*="lib-"]').draggable({
|
||||
helper: function () {
|
||||
var $el = $(this),
|
||||
selected = mod.getChosenItemsLength(),
|
||||
container,
|
||||
thead = $("#show_builder_table thead"),
|
||||
colspan = thead.find("th").length,
|
||||
width = $el.width(),
|
||||
message;
|
||||
|
||||
// dragging an element that has an unselected
|
||||
// checkbox.
|
||||
if (mod.isChosenItem($el) === false) {
|
||||
selected++;
|
||||
}
|
||||
|
||||
AIRTIME.showbuilder.fnAdd(aMediaIds, aSchedIds);
|
||||
};
|
||||
|
||||
mod.setupLibraryToolbar = function() {
|
||||
var $toolbar = $(".lib-content .fg-toolbar:first");
|
||||
|
||||
mod.createToolbarButtons();
|
||||
//mod.moveSearchBarToHeader();
|
||||
$("#advanced_search").click(function(e) {
|
||||
e.stopPropagation();
|
||||
});
|
||||
|
||||
if (localStorage.getItem('user-type') != 'G') {
|
||||
$toolbar.append($menu);
|
||||
// add to timeline button
|
||||
$toolbar
|
||||
.find('#library-plus')
|
||||
.click(
|
||||
function () {
|
||||
|
||||
if (AIRTIME.button.isDisabled('btn-group #library-plus') === true) {
|
||||
return;
|
||||
}
|
||||
|
||||
var selected = AIRTIME.library.getSelectedData(), aMediaIds = [];
|
||||
|
||||
if ($("#show_builder_table").is(":visible")) {
|
||||
mod.addToSchedule(selected);
|
||||
} else {
|
||||
$.each(selected, function () {
|
||||
aMediaIds.push([this.id, this.ftype]);
|
||||
});
|
||||
|
||||
// check if a playlist/block is open before adding items
|
||||
if ($('.active-tab .obj_type').val() == 'playlist'
|
||||
|| $('.active-tab .obj_type').val() == 'block') {
|
||||
AIRTIME.playlist.fnAddItems(aMediaIds, undefined, 'after');
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
$toolbar.find('#publish-btn').click(function () {
|
||||
if (AIRTIME.button.isDisabled('btn-group #publish-btn') === true) {
|
||||
return;
|
||||
}
|
||||
|
||||
var selected = $(".lib-selected");
|
||||
|
||||
selected.each(function (i, el) {
|
||||
var data = $(el).data("aData");
|
||||
AIRTIME.publish.openPublishDialog(data.id);
|
||||
});
|
||||
});
|
||||
|
||||
// delete from library.
|
||||
$toolbar.find('#sb-delete').click(function () {
|
||||
if (AIRTIME.button.isDisabled('btn-group #sb-delete') === true) {
|
||||
return;
|
||||
}
|
||||
|
||||
AIRTIME.library.fnDeleteSelectedItems();
|
||||
});
|
||||
|
||||
$toolbar.find('#sb-new').click(function () {
|
||||
if (AIRTIME.button.isDisabled('btn-group #sb-new') === true) {
|
||||
return;
|
||||
}
|
||||
|
||||
var selection = $(".media_type_selector.selected").data("selection-id");
|
||||
|
||||
if (selection == AIRTIME.library.MediaTypeIntegerEnum.PLAYLIST) {
|
||||
AIRTIME.playlist.fnNew();
|
||||
} else if (selection == AIRTIME.library.MediaTypeIntegerEnum.BLOCK) {
|
||||
AIRTIME.playlist.fnNewBlock();
|
||||
} else if (selection == AIRTIME.library.MediaTypeIntegerEnum.WEBSTREAM) {
|
||||
AIRTIME.playlist.fnWsNew();
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
$toolbar.find('#sb-edit').click(function () {
|
||||
if (AIRTIME.button.isDisabled('btn-group #sb-edit') === true) {
|
||||
return;
|
||||
}
|
||||
|
||||
var selected = $(".lib-selected");
|
||||
|
||||
selected.each(function (i, el) {
|
||||
var data = $(el).data("aData");
|
||||
|
||||
if (data.ftype === "audioclip") {
|
||||
$.get(baseUrl + "library/edit-file-md/id/" + data.id, {format: "json"}, function (json) {
|
||||
AIRTIME.playlist.fileMdEdit(json, data.tr_id);
|
||||
//buildEditMetadataDialog(json);
|
||||
});
|
||||
} else if (data.ftype === "playlist" || data.ftype === "block") {
|
||||
AIRTIME.playlist.fnEdit(data, baseUrl + 'playlist/edit');
|
||||
AIRTIME.playlist.validatePlaylistElements();
|
||||
} else if (data.ftype === "stream") {
|
||||
AIRTIME.playlist.fnEdit(data, baseUrl + 'webstream/edit');
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
mod.createToolbarDropDown();
|
||||
if (selected === 1) {
|
||||
message = $.i18n._("Adding 1 Item");
|
||||
} else {
|
||||
message = sprintf($.i18n._("Adding %s Items"), selected);
|
||||
}
|
||||
};
|
||||
|
||||
return AIRTIME;
|
||||
container = $("<div/>")
|
||||
.attr("id", "draggingContainer")
|
||||
.append("<tr/>")
|
||||
.find("tr")
|
||||
.append("<td/>")
|
||||
.find("td")
|
||||
.attr("colspan", colspan)
|
||||
.width(width)
|
||||
.addClass("ui-state-highlight")
|
||||
.append(message)
|
||||
.end()
|
||||
.end();
|
||||
|
||||
}(AIRTIME || {}));
|
||||
return container;
|
||||
},
|
||||
create: function (event, ui) {
|
||||
$(this).draggable("option", "cursorAt", {
|
||||
top: 20,
|
||||
left: Math.floor($(this).outerWidth() / 2),
|
||||
});
|
||||
},
|
||||
tolerance: "pointer",
|
||||
cursor: "move",
|
||||
distance: 25, // min-distance for dragging
|
||||
connectToSortable: sortable,
|
||||
});
|
||||
};
|
||||
|
||||
mod.dblClickAdd = function (data, type) {
|
||||
var i,
|
||||
length,
|
||||
temp,
|
||||
aMediaIds = [],
|
||||
aSchedIds = [],
|
||||
aData = [];
|
||||
|
||||
if ($("#show_builder_table").is(":visible")) {
|
||||
// process selected files/playlists.
|
||||
aMediaIds.push({
|
||||
id: data.id,
|
||||
type: type,
|
||||
});
|
||||
|
||||
$("#show_builder_table tr.sb-selected").each(function (i, el) {
|
||||
aData.push($(el).data("aData"));
|
||||
});
|
||||
|
||||
// process selected schedule rows to add media after.
|
||||
for (i = 0, length = aData.length; i < length; i++) {
|
||||
temp = aData[i];
|
||||
aSchedIds.push({
|
||||
id: temp.id,
|
||||
instance: temp.instance,
|
||||
timestamp: temp.timestamp,
|
||||
});
|
||||
}
|
||||
|
||||
if (aSchedIds.length == 0) {
|
||||
if (!addToCurrentOrNext(aSchedIds)) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
AIRTIME.showbuilder.fnAdd(aMediaIds, aSchedIds);
|
||||
} else {
|
||||
// process selected files/playlists.
|
||||
aMediaIds.push(new Array(data.id, data.ftype));
|
||||
|
||||
// check if a playlist/block is open before adding items
|
||||
if (
|
||||
$(".active-tab .obj_type").val() == "playlist" ||
|
||||
$(".active-tab .obj_type").val() == "block"
|
||||
) {
|
||||
AIRTIME.playlist.fnAddItems(aMediaIds, undefined, "after");
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
function addToCurrentOrNext(arr) {
|
||||
var el;
|
||||
// Add to the end of the current or next show by getting the footer
|
||||
el = $(".sb-footer.sb-future:first");
|
||||
var data = el.prev().data("aData");
|
||||
|
||||
if (data === undefined) {
|
||||
alert(
|
||||
$.i18n._("Cannot schedule outside a show.\nTry creating a show first.")
|
||||
);
|
||||
return false;
|
||||
}
|
||||
|
||||
arr.push({
|
||||
id: data.id,
|
||||
instance: data.instance,
|
||||
timestamp: data.timestamp,
|
||||
});
|
||||
|
||||
if (!isInView(el)) {
|
||||
$(".dataTables_scrolling.sb-padded").animate(
|
||||
{
|
||||
scrollTop: el.offset().top,
|
||||
},
|
||||
0
|
||||
);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
mod.addToSchedule = function (selected) {
|
||||
console.log(selected);
|
||||
var aMediaIds = [],
|
||||
aSchedIds = [],
|
||||
aData = [];
|
||||
|
||||
$.each(selected, function () {
|
||||
aMediaIds.push({
|
||||
id: this.id,
|
||||
type: this.ftype,
|
||||
});
|
||||
});
|
||||
|
||||
// process selected files/playlists.
|
||||
$("#show_builder_table")
|
||||
.find("tr.sb-selected")
|
||||
.each(function (i, el) {
|
||||
aData.push($(el).data("aData"));
|
||||
});
|
||||
|
||||
// process selected schedule rows to add media after.
|
||||
$.each(aData, function () {
|
||||
aSchedIds.push({
|
||||
id: this.id,
|
||||
instance: this.instance,
|
||||
timestamp: this.timestamp,
|
||||
});
|
||||
});
|
||||
|
||||
if (aSchedIds.length == 0) {
|
||||
if (!addToCurrentOrNext(aSchedIds)) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
AIRTIME.showbuilder.fnAdd(aMediaIds, aSchedIds);
|
||||
};
|
||||
|
||||
mod.setupLibraryToolbar = function () {
|
||||
var $toolbar = $(".lib-content .fg-toolbar:first");
|
||||
|
||||
mod.createToolbarButtons();
|
||||
//mod.moveSearchBarToHeader();
|
||||
$("#advanced_search").click(function (e) {
|
||||
e.stopPropagation();
|
||||
});
|
||||
|
||||
if (localStorage.getItem("user-type") != "G") {
|
||||
$toolbar.append($menu);
|
||||
// add to timeline button
|
||||
$toolbar.find("#library-plus").click(function () {
|
||||
if (AIRTIME.button.isDisabled("btn-group #library-plus") === true) {
|
||||
return;
|
||||
}
|
||||
|
||||
var selected = AIRTIME.library.getSelectedData(),
|
||||
aMediaIds = [];
|
||||
|
||||
if ($("#show_builder_table").is(":visible")) {
|
||||
mod.addToSchedule(selected);
|
||||
} else {
|
||||
$.each(selected, function () {
|
||||
aMediaIds.push([this.id, this.ftype]);
|
||||
});
|
||||
|
||||
// check if a playlist/block is open before adding items
|
||||
if (
|
||||
$(".active-tab .obj_type").val() == "playlist" ||
|
||||
$(".active-tab .obj_type").val() == "block"
|
||||
) {
|
||||
AIRTIME.playlist.fnAddItems(aMediaIds, undefined, "after");
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
$toolbar.find("#publish-btn").click(function () {
|
||||
if (AIRTIME.button.isDisabled("btn-group #publish-btn") === true) {
|
||||
return;
|
||||
}
|
||||
|
||||
var selected = $(".lib-selected");
|
||||
|
||||
selected.each(function (i, el) {
|
||||
var data = $(el).data("aData");
|
||||
AIRTIME.publish.openPublishDialog(data.id);
|
||||
});
|
||||
});
|
||||
|
||||
// delete from library.
|
||||
$toolbar.find("#sb-delete").click(function () {
|
||||
if (AIRTIME.button.isDisabled("btn-group #sb-delete") === true) {
|
||||
return;
|
||||
}
|
||||
|
||||
AIRTIME.library.fnDeleteSelectedItems();
|
||||
});
|
||||
|
||||
$toolbar.find("#sb-new").click(function () {
|
||||
if (AIRTIME.button.isDisabled("btn-group #sb-new") === true) {
|
||||
return;
|
||||
}
|
||||
|
||||
var selection = $(".media_type_selector.selected").data("selection-id");
|
||||
|
||||
if (selection == AIRTIME.library.MediaTypeIntegerEnum.PLAYLIST) {
|
||||
AIRTIME.playlist.fnNew();
|
||||
} else if (selection == AIRTIME.library.MediaTypeIntegerEnum.BLOCK) {
|
||||
AIRTIME.playlist.fnNewBlock();
|
||||
} else if (
|
||||
selection == AIRTIME.library.MediaTypeIntegerEnum.WEBSTREAM
|
||||
) {
|
||||
AIRTIME.playlist.fnWsNew();
|
||||
}
|
||||
});
|
||||
|
||||
$toolbar.find("#sb-edit").click(function () {
|
||||
if (AIRTIME.button.isDisabled("btn-group #sb-edit") === true) {
|
||||
return;
|
||||
}
|
||||
|
||||
var selected = $(".lib-selected");
|
||||
|
||||
selected.each(function (i, el) {
|
||||
var data = $(el).data("aData");
|
||||
|
||||
if (data.ftype === "audioclip") {
|
||||
$.get(
|
||||
baseUrl + "library/edit-file-md/id/" + data.id,
|
||||
{ format: "json" },
|
||||
function (json) {
|
||||
AIRTIME.playlist.fileMdEdit(json, data.tr_id);
|
||||
//buildEditMetadataDialog(json);
|
||||
}
|
||||
);
|
||||
} else if (data.ftype === "playlist" || data.ftype === "block") {
|
||||
AIRTIME.playlist.fnEdit(data, baseUrl + "playlist/edit");
|
||||
AIRTIME.playlist.validatePlaylistElements();
|
||||
} else if (data.ftype === "stream") {
|
||||
AIRTIME.playlist.fnEdit(data, baseUrl + "webstream/edit");
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
mod.createToolbarDropDown();
|
||||
}
|
||||
};
|
||||
|
||||
return AIRTIME;
|
||||
})(AIRTIME || {});
|
||||
|
|
File diff suppressed because it is too large
Load diff
|
@ -1,219 +1,237 @@
|
|||
$(document).ready(function () {
|
||||
var uploadProgress;
|
||||
var self = this;
|
||||
self.uploadFilter = "all";
|
||||
|
||||
var uploadProgress;
|
||||
var self = this;
|
||||
self.uploadFilter = "all";
|
||||
self.IMPORT_STATUS_CODES = {
|
||||
0: { message: $.i18n._("Successfully imported") },
|
||||
1: { message: $.i18n._("Pending import") },
|
||||
2: { message: $.i18n._("Import failed.") },
|
||||
UNKNOWN: { message: $.i18n._("Unknown") },
|
||||
};
|
||||
if (Object.freeze) {
|
||||
Object.freeze(self.IMPORT_STATUS_CODES);
|
||||
}
|
||||
|
||||
self.IMPORT_STATUS_CODES = {
|
||||
0: {message: $.i18n._("Successfully imported")},
|
||||
1: {message: $.i18n._("Pending import")},
|
||||
2: {message: $.i18n._("Import failed.")},
|
||||
UNKNOWN: {message: $.i18n._("Unknown")}
|
||||
};
|
||||
if (Object.freeze) {
|
||||
Object.freeze(self.IMPORT_STATUS_CODES);
|
||||
Dropzone.options.addMediaDropzone = {
|
||||
url: "/rest/media",
|
||||
//clickable: false,
|
||||
acceptedFiles: acceptedMimeTypes.join(),
|
||||
addRemoveLinks: true,
|
||||
dictRemoveFile: $.i18n._("Remove"),
|
||||
maxFilesize: LIBRETIME_PLUPLOAD_MAX_FILE_SIZE, //Megabytes
|
||||
init: function () {
|
||||
this.on("sending", function (file, xhr, data) {
|
||||
data.append("csrf_token", $("#csrf").val());
|
||||
});
|
||||
|
||||
this.on("addedfile", function (file, xhr, data) {
|
||||
var el = $(file.previewElement);
|
||||
uploadProgress = true;
|
||||
el.find(".dz-remove").prependTo(el.find(".dz-details"));
|
||||
el.find(".dz-error-message").appendTo(el.find(".dz-error-mark"));
|
||||
});
|
||||
|
||||
this.on("success", function (file, xhr, data) {
|
||||
//Refresh the upload table:
|
||||
self.recentUploadsTable.fnDraw(); //Only works because we're using bServerSide
|
||||
//In DataTables 1.10 and greater, we can use .fnAjaxReload()
|
||||
});
|
||||
|
||||
this.on("queuecomplete", function () {
|
||||
uploadProgress = false;
|
||||
});
|
||||
},
|
||||
};
|
||||
|
||||
$(window).bind("beforeunload", function () {
|
||||
if (uploadProgress) {
|
||||
return sprintf(
|
||||
$.i18n._(
|
||||
"You are currently uploading files. %sGoing to another screen will cancel the upload process. %sAre you sure you want to leave the page?"
|
||||
),
|
||||
"\n",
|
||||
"\n"
|
||||
);
|
||||
}
|
||||
});
|
||||
|
||||
self.renderImportStatus = function (data, type, full) {
|
||||
if (typeof data !== "number") {
|
||||
console.log("Invalid data type for the import_status.");
|
||||
return;
|
||||
}
|
||||
var statusStr = self.IMPORT_STATUS_CODES.UNKNOWN.message;
|
||||
var importStatusCode = data;
|
||||
if (self.IMPORT_STATUS_CODES[importStatusCode]) {
|
||||
statusStr = self.IMPORT_STATUS_CODES[importStatusCode].message;
|
||||
}
|
||||
|
||||
Dropzone.options.addMediaDropzone = {
|
||||
url: '/rest/media',
|
||||
//clickable: false,
|
||||
acceptedFiles: acceptedMimeTypes.join(),
|
||||
addRemoveLinks: true,
|
||||
dictRemoveFile: $.i18n._("Remove"),
|
||||
maxFilesize:LIBRETIME_PLUPLOAD_MAX_FILE_SIZE, //Megabytes
|
||||
init: function () {
|
||||
this.on("sending", function (file, xhr, data) {
|
||||
data.append("csrf_token", $("#csrf").val());
|
||||
});
|
||||
return statusStr;
|
||||
};
|
||||
|
||||
this.on("addedfile", function (file, xhr, data) {
|
||||
var el = $(file.previewElement);
|
||||
uploadProgress = true;
|
||||
el.find(".dz-remove").prependTo(el.find(".dz-details"));
|
||||
el.find(".dz-error-message").appendTo(el.find(".dz-error-mark"));
|
||||
});
|
||||
self.renderFileActions = function (data, type, full) {
|
||||
if (full.import_status == 0) {
|
||||
return (
|
||||
'<a class="deleteFileAction">' +
|
||||
$.i18n._("Delete from Library") +
|
||||
"</a>"
|
||||
);
|
||||
} else if (full.import_status == 1) {
|
||||
//No actions for pending files
|
||||
return $.i18n._("N/A");
|
||||
} else {
|
||||
//Failed downloads
|
||||
return '<a class="deleteFileAction">' + $.i18n._("Clear") + "</a>";
|
||||
}
|
||||
};
|
||||
|
||||
this.on("success", function (file, xhr, data) {
|
||||
//Refresh the upload table:
|
||||
self.recentUploadsTable.fnDraw(); //Only works because we're using bServerSide
|
||||
//In DataTables 1.10 and greater, we can use .fnAjaxReload()
|
||||
});
|
||||
$("#recent_uploads_table").on("click", "a.deleteFileAction", function () {
|
||||
//Grab the file object for the row that was clicked.
|
||||
// Some tips from the DataTables forums:
|
||||
// fnGetData is used to get the object behind the row - you can also use
|
||||
// fnGetPosition if you need to get the index instead
|
||||
file = $("#recent_uploads_table")
|
||||
.dataTable()
|
||||
.fnGetData($(this).closest("tr")[0]);
|
||||
|
||||
this.on("queuecomplete", function() {
|
||||
uploadProgress = false;
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
$(window).bind('beforeunload', function () {
|
||||
if (uploadProgress) {
|
||||
return sprintf($.i18n._("You are currently uploading files. %sGoing to another screen will cancel the upload process. %sAre you sure you want to leave the page?"),
|
||||
"\n", "\n");
|
||||
}
|
||||
$.ajax({
|
||||
type: "DELETE",
|
||||
url: "rest/media/" + file.id + "?csrf_token=" + $("#csrf").attr("value"),
|
||||
success: function (resp) {
|
||||
self.recentUploadsTable.fnDraw();
|
||||
},
|
||||
error: function () {
|
||||
alert(
|
||||
$.i18n._(
|
||||
"Error: The file could not be deleted. Please try again later."
|
||||
)
|
||||
);
|
||||
},
|
||||
});
|
||||
});
|
||||
|
||||
self.renderImportStatus = function (data, type, full) {
|
||||
if (typeof data !== "number") {
|
||||
console.log("Invalid data type for the import_status.");
|
||||
return;
|
||||
}
|
||||
var statusStr = self.IMPORT_STATUS_CODES.UNKNOWN.message;
|
||||
var importStatusCode = data;
|
||||
if (self.IMPORT_STATUS_CODES[importStatusCode]) {
|
||||
statusStr = self.IMPORT_STATUS_CODES[importStatusCode].message;
|
||||
}
|
||||
|
||||
return statusStr;
|
||||
};
|
||||
|
||||
self.renderFileActions = function (data, type, full) {
|
||||
if (full.import_status == 0) {
|
||||
return '<a class="deleteFileAction">' + $.i18n._('Delete from Library') + '</a>';
|
||||
} else if (full.import_status == 1) {
|
||||
//No actions for pending files
|
||||
return $.i18n._('N/A');
|
||||
} else { //Failed downloads
|
||||
return '<a class="deleteFileAction">' + $.i18n._('Clear') + '</a>';
|
||||
}
|
||||
};
|
||||
|
||||
$("#recent_uploads_table").on("click", "a.deleteFileAction", function () {
|
||||
//Grab the file object for the row that was clicked.
|
||||
// Some tips from the DataTables forums:
|
||||
// fnGetData is used to get the object behind the row - you can also use
|
||||
// fnGetPosition if you need to get the index instead
|
||||
file = $("#recent_uploads_table").dataTable().fnGetData($(this).closest("tr")[0]);
|
||||
|
||||
$.ajax({
|
||||
type: 'DELETE',
|
||||
url: 'rest/media/' + file.id + "?csrf_token=" + $("#csrf").attr('value'),
|
||||
success: function (resp) {
|
||||
self.recentUploadsTable.fnDraw();
|
||||
},
|
||||
error: function () {
|
||||
alert($.i18n._("Error: The file could not be deleted. Please try again later."));
|
||||
self.setupRecentUploadsTable = function () {
|
||||
return $("#recent_uploads_table").dataTable({
|
||||
bJQueryUI: true,
|
||||
bProcessing: false,
|
||||
bServerSide: true,
|
||||
sAjaxSource: "/plupload/recent-uploads/format/json",
|
||||
sAjaxDataProp: "files",
|
||||
bSearchable: false,
|
||||
bInfo: true,
|
||||
//"sScrollY": "200px",
|
||||
bFilter: false,
|
||||
bSort: false,
|
||||
//"sDom": '<"H">frtip<"F"l>',
|
||||
sDom: '<"dataTables_scrolling"frt><"F"lip>',
|
||||
bPaginate: true,
|
||||
sPaginationType: "full_numbers",
|
||||
oLanguage: getDatatablesStrings({
|
||||
sEmptyTable: $.i18n._("No files have been uploaded yet."),
|
||||
sInfoEmpty: $.i18n._("Showing 0 to 0 of 0 uploads"),
|
||||
sInfo: $.i18n._("Showing _START_ to _END_ of _TOTAL_ uploads"),
|
||||
sInfoFiltered: $.i18n._("(filtered from _MAX_ total uploads)"),
|
||||
}),
|
||||
aoColumns: [
|
||||
{ mData: "artist_name", sTitle: $.i18n._("Creator") },
|
||||
{ mData: "track_title", sTitle: $.i18n._("Title") },
|
||||
{
|
||||
mData: "import_status",
|
||||
sTitle: $.i18n._("Import Status"),
|
||||
mRender: self.renderImportStatus,
|
||||
},
|
||||
{ mData: "utime", sTitle: $.i18n._("Uploaded") },
|
||||
{
|
||||
mData: "id",
|
||||
sTitle: $.i18n._("Actions"),
|
||||
mRender: self.renderFileActions,
|
||||
},
|
||||
],
|
||||
fnServerData: function (sSource, aoData, fnCallback) {
|
||||
/* Add some extra data to the sender */
|
||||
aoData.push({ name: "uploadFilter", value: self.uploadFilter });
|
||||
$.getJSON(sSource, aoData, function (json) {
|
||||
fnCallback(json);
|
||||
if (json.files) {
|
||||
var areAnyFileImportsPending = false;
|
||||
for (var i = 0; i < json.files.length; i++) {
|
||||
//console.log(file);
|
||||
var file = json.files[i];
|
||||
if (file.import_status == 1) {
|
||||
areAnyFileImportsPending = true;
|
||||
}
|
||||
}
|
||||
|
||||
if (areAnyFileImportsPending) {
|
||||
//alert("pending uploads, starting refresh on timer");
|
||||
self.startRefreshingRecentUploads();
|
||||
} else if (self.isRecentUploadsRefreshTimerActive) {
|
||||
self.stopRefreshingRecentUploads();
|
||||
self.recentUploadsTable.fnDraw();
|
||||
}
|
||||
|
||||
// Update usability hint - in common.js
|
||||
getUsabilityHint();
|
||||
}
|
||||
});
|
||||
},
|
||||
});
|
||||
};
|
||||
|
||||
self.setupRecentUploadsTable = function () {
|
||||
return $("#recent_uploads_table").dataTable({
|
||||
"bJQueryUI": true,
|
||||
"bProcessing": false,
|
||||
"bServerSide": true,
|
||||
"sAjaxSource": '/plupload/recent-uploads/format/json',
|
||||
"sAjaxDataProp": 'files',
|
||||
"bSearchable": false,
|
||||
"bInfo": true,
|
||||
//"sScrollY": "200px",
|
||||
"bFilter": false,
|
||||
"bSort": false,
|
||||
//"sDom": '<"H">frtip<"F"l>',
|
||||
"sDom": '<"dataTables_scrolling"frt><"F"lip>',
|
||||
"bPaginate": true,
|
||||
"sPaginationType": "full_numbers",
|
||||
"oLanguage": getDatatablesStrings({
|
||||
"sEmptyTable": $.i18n._("No files have been uploaded yet."),
|
||||
"sInfoEmpty": $.i18n._("Showing 0 to 0 of 0 uploads"),
|
||||
"sInfo": $.i18n._("Showing _START_ to _END_ of _TOTAL_ uploads"),
|
||||
"sInfoFiltered": $.i18n._("(filtered from _MAX_ total uploads)"),
|
||||
}),
|
||||
"aoColumns": [
|
||||
{"mData": "artist_name", "sTitle": $.i18n._("Creator")},
|
||||
{"mData": "track_title", "sTitle": $.i18n._("Title")},
|
||||
{
|
||||
"mData": "import_status", "sTitle": $.i18n._("Import Status"),
|
||||
"mRender": self.renderImportStatus
|
||||
},
|
||||
{"mData": "utime", "sTitle": $.i18n._("Uploaded")},
|
||||
{
|
||||
"mData": "id", "sTitle": $.i18n._("Actions"),
|
||||
"mRender": self.renderFileActions
|
||||
}
|
||||
],
|
||||
"fnServerData": function (sSource, aoData, fnCallback) {
|
||||
/* Add some extra data to the sender */
|
||||
aoData.push({"name": "uploadFilter", "value": self.uploadFilter});
|
||||
$.getJSON(sSource, aoData, function (json) {
|
||||
fnCallback(json);
|
||||
if (json.files) {
|
||||
var areAnyFileImportsPending = false;
|
||||
for (var i = 0; i < json.files.length; i++) {
|
||||
//console.log(file);
|
||||
var file = json.files[i];
|
||||
if (file.import_status == 1) {
|
||||
areAnyFileImportsPending = true;
|
||||
}
|
||||
}
|
||||
$("#recent_uploads").addTitles("td");
|
||||
|
||||
if (areAnyFileImportsPending) {
|
||||
//alert("pending uploads, starting refresh on timer");
|
||||
self.startRefreshingRecentUploads();
|
||||
} else if (self.isRecentUploadsRefreshTimerActive) {
|
||||
self.stopRefreshingRecentUploads();
|
||||
self.recentUploadsTable.fnDraw();
|
||||
}
|
||||
self.isRecentUploadsRefreshTimerActive = false;
|
||||
|
||||
// Update usability hint - in common.js
|
||||
getUsabilityHint();
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
$("#recent_uploads").addTitles("td");
|
||||
self.startRefreshingRecentUploads = function () {
|
||||
if (!self.isRecentUploadsRefreshTimerActive) {
|
||||
//Prevent multiple timers from running
|
||||
self.recentUploadsRefreshTimer = setInterval(function () {
|
||||
self.recentUploadsTable.fnDraw();
|
||||
}, 3000);
|
||||
self.isRecentUploadsRefreshTimerActive = true;
|
||||
}
|
||||
};
|
||||
|
||||
self.stopRefreshingRecentUploads = function () {
|
||||
clearInterval(self.recentUploadsRefreshTimer);
|
||||
self.isRecentUploadsRefreshTimerActive = false;
|
||||
};
|
||||
|
||||
self.startRefreshingRecentUploads = function () {
|
||||
if (!self.isRecentUploadsRefreshTimerActive) { //Prevent multiple timers from running
|
||||
self.recentUploadsRefreshTimer = setInterval(function() {
|
||||
self.recentUploadsTable.fnDraw();
|
||||
}, 3000);
|
||||
self.isRecentUploadsRefreshTimerActive = true;
|
||||
}
|
||||
};
|
||||
$("#upload_status_all").click(function () {
|
||||
if (self.uploadFilter !== "all") {
|
||||
self.uploadFilter = "all";
|
||||
self.recentUploadsTable.fnPageChange(0).fnDraw();
|
||||
}
|
||||
});
|
||||
$("#upload_status_pending").click(function () {
|
||||
if (self.uploadFilter !== "pending") {
|
||||
self.uploadFilter = "pending";
|
||||
self.recentUploadsTable.fnPageChange(0).fnDraw();
|
||||
}
|
||||
});
|
||||
$("#upload_status_failed").click(function () {
|
||||
if (self.uploadFilter !== "failed") {
|
||||
self.uploadFilter = "failed";
|
||||
self.recentUploadsTable.fnPageChange(0).fnDraw();
|
||||
}
|
||||
});
|
||||
|
||||
self.stopRefreshingRecentUploads = function () {
|
||||
clearInterval(self.recentUploadsRefreshTimer);
|
||||
self.isRecentUploadsRefreshTimerActive = false;
|
||||
};
|
||||
//Create the recent uploads table.
|
||||
self.recentUploadsTable = self.setupRecentUploadsTable();
|
||||
|
||||
$("#upload_status_all").click(function () {
|
||||
if (self.uploadFilter !== "all") {
|
||||
self.uploadFilter = "all";
|
||||
self.recentUploadsTable.fnPageChange(0).fnDraw();
|
||||
}
|
||||
});
|
||||
$("#upload_status_pending").click(function () {
|
||||
if (self.uploadFilter !== "pending") {
|
||||
self.uploadFilter = "pending";
|
||||
self.recentUploadsTable.fnPageChange(0).fnDraw();
|
||||
}
|
||||
});
|
||||
$("#upload_status_failed").click(function () {
|
||||
if (self.uploadFilter !== "failed") {
|
||||
self.uploadFilter = "failed";
|
||||
self.recentUploadsTable.fnPageChange(0).fnDraw();
|
||||
}
|
||||
});
|
||||
//$("#recent_uploads_table.div.fg-toolbar").prepend('<b>Custom tool bar! Text/images etc.</b>');
|
||||
|
||||
//Create the recent uploads table.
|
||||
self.recentUploadsTable = self.setupRecentUploadsTable();
|
||||
|
||||
//$("#recent_uploads_table.div.fg-toolbar").prepend('<b>Custom tool bar! Text/images etc.</b>');
|
||||
|
||||
$("#select_type").on("change",function(){
|
||||
var ttValue = $("#select_type").val();
|
||||
var ttText = $('#select_type option[value="'+ttValue+'"]').text();
|
||||
if (ttValue != ""){
|
||||
$("#upload_type").text(" " + ttText);
|
||||
$("#upload_type").css("color", "#ff611f");
|
||||
} else {
|
||||
$("#upload_type").text(" Tracks");
|
||||
$("#upload_type").css("color", "#ffffff");
|
||||
}
|
||||
Cookies.set('tt_upload', ttValue);
|
||||
});
|
||||
$("#select_type").on("change", function () {
|
||||
var ttValue = $("#select_type").val();
|
||||
var ttText = $('#select_type option[value="' + ttValue + '"]').text();
|
||||
if (ttValue != "") {
|
||||
$("#upload_type").text(" " + ttText);
|
||||
$("#upload_type").css("color", "#ff611f");
|
||||
} else {
|
||||
$("#upload_type").text(" Tracks");
|
||||
$("#upload_type").css("color", "#ffffff");
|
||||
}
|
||||
Cookies.set("tt_upload", ttValue);
|
||||
});
|
||||
});
|
||||
|
|
File diff suppressed because it is too large
Load diff
|
@ -1,114 +1,128 @@
|
|||
|
||||
var AIRTIME = (function (AIRTIME) {
|
||||
var mod;
|
||||
var mod;
|
||||
|
||||
if (AIRTIME.publish === undefined) {
|
||||
AIRTIME.publish = {};
|
||||
}
|
||||
if (AIRTIME.publish === undefined) {
|
||||
AIRTIME.publish = {};
|
||||
}
|
||||
|
||||
mod = AIRTIME.publish;
|
||||
mod = AIRTIME.publish;
|
||||
|
||||
var endpoint = 'rest/media/';
|
||||
var dialogUrl = 'library/publish-dialog';
|
||||
var PUBLISH_APP_NAME = 'publish';
|
||||
var endpoint = "rest/media/";
|
||||
var dialogUrl = "library/publish-dialog";
|
||||
var PUBLISH_APP_NAME = "publish";
|
||||
|
||||
//AngularJS app
|
||||
var publishApp = angular.module(PUBLISH_APP_NAME, [])
|
||||
.controller('Publish', function ($sce, $scope, $http, mediaId, tab) {
|
||||
$scope.publishData = {};
|
||||
var sourceInterval;
|
||||
//AngularJS app
|
||||
var publishApp = angular
|
||||
.module(PUBLISH_APP_NAME, [])
|
||||
.controller("Publish", function ($sce, $scope, $http, mediaId, tab) {
|
||||
$scope.publishData = {};
|
||||
var sourceInterval;
|
||||
|
||||
tab.contents.on("click", "input[type='checkbox']", function () {
|
||||
var noSourcesChecked = true;
|
||||
$.each(tab.contents.find("input[type='checkbox']"), function () {
|
||||
if ($(this).is(":checked")) {
|
||||
noSourcesChecked = false;
|
||||
}
|
||||
});
|
||||
tab.contents.find(".publish-btn").prop("disabled", noSourcesChecked);
|
||||
tab.contents.on("click", "input[type='checkbox']", function () {
|
||||
var noSourcesChecked = true;
|
||||
$.each(tab.contents.find("input[type='checkbox']"), function () {
|
||||
if ($(this).is(":checked")) {
|
||||
noSourcesChecked = false;
|
||||
}
|
||||
});
|
||||
tab.contents.find(".publish-btn").prop("disabled", noSourcesChecked);
|
||||
});
|
||||
|
||||
function fetchSourceData() {
|
||||
var csrfToken = jQuery("#csrf").val();
|
||||
$http
|
||||
.get(endpoint + mediaId, { csrf_token: csrfToken })
|
||||
.success(function (json) {
|
||||
$scope.media = json;
|
||||
tab.setName($scope.media.track_title);
|
||||
});
|
||||
|
||||
// Get an object containing all sources, their translated labels,
|
||||
// and their publication state for the file with the given ID
|
||||
$http
|
||||
.get(endpoint + mediaId + "/publish-sources", {
|
||||
csrf_token: csrfToken,
|
||||
})
|
||||
.success(function (json) {
|
||||
$scope.sources = { toPublish: [], published: [] };
|
||||
$.each(json, function () {
|
||||
if (Math.abs(this.status) == 1) {
|
||||
$scope.sources.published.push(this);
|
||||
} else {
|
||||
$scope.sources.toPublish.push(this);
|
||||
}
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
function fetchSourceData() {
|
||||
var csrfToken = jQuery("#csrf").val();
|
||||
$http.get(endpoint + mediaId, {csrf_token: csrfToken})
|
||||
.success(function (json) {
|
||||
$scope.media = json;
|
||||
tab.setName($scope.media.track_title);
|
||||
});
|
||||
function init() {
|
||||
fetchSourceData();
|
||||
sourceInterval = setInterval(function () {
|
||||
fetchSourceData();
|
||||
}, 5000);
|
||||
|
||||
// Get an object containing all sources, their translated labels,
|
||||
// and their publication state for the file with the given ID
|
||||
$http.get(endpoint + mediaId + '/publish-sources', {csrf_token: csrfToken})
|
||||
.success(function (json) {
|
||||
$scope.sources = { toPublish: [], published: []};
|
||||
$.each(json, function () {
|
||||
if (Math.abs(this.status) == 1) {
|
||||
$scope.sources.published.push(this);
|
||||
} else {
|
||||
$scope.sources.toPublish.push(this);
|
||||
}
|
||||
});
|
||||
});
|
||||
}
|
||||
tab.assignOnCloseHandler(function () {
|
||||
clearInterval(sourceInterval);
|
||||
$scope.$destroy();
|
||||
});
|
||||
}
|
||||
|
||||
function init() {
|
||||
fetchSourceData();
|
||||
sourceInterval = setInterval(function() {
|
||||
fetchSourceData();
|
||||
}, 5000);
|
||||
$scope.openEditDialog = function () {
|
||||
var uid = AIRTIME.library.MediaTypeStringEnum.FILE + "_" + mediaId;
|
||||
$.get(
|
||||
baseUrl + "library/edit-file-md/id/" + mediaId,
|
||||
{ format: "json" },
|
||||
function (json) {
|
||||
AIRTIME.playlist.fileMdEdit(json, uid);
|
||||
}
|
||||
);
|
||||
};
|
||||
|
||||
tab.assignOnCloseHandler(function () {
|
||||
clearInterval(sourceInterval);
|
||||
$scope.$destroy();
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
$scope.openEditDialog = function() {
|
||||
var uid = AIRTIME.library.MediaTypeStringEnum.FILE + "_" + mediaId;
|
||||
$.get(baseUrl + "library/edit-file-md/id/" + mediaId, {format: "json"}, function (json) {
|
||||
AIRTIME.playlist.fileMdEdit(json, uid);
|
||||
});
|
||||
};
|
||||
|
||||
$scope.publish = function () {
|
||||
var data = {};
|
||||
jQuery.each($scope.publishData, function (k, v) {
|
||||
if (v) {
|
||||
data[k] = 'publish'; // FIXME: should be more robust
|
||||
}
|
||||
});
|
||||
|
||||
if (data && Object.keys(data).length > 0) {
|
||||
$http.put(endpoint + mediaId + '/publish', {csrf_token: jQuery("#csrf").val(), sources: data})
|
||||
.success(function () {
|
||||
tab.contents.find(".publish-btn").prop("disabled", true);
|
||||
fetchSourceData();
|
||||
$scope.publishData = {}; // Reset the publishData in case the user publishes
|
||||
// and unpublishes without closing the tab
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
$scope.remove = function (source) {
|
||||
var data = {};
|
||||
data[source] = 'unpublish'; // FIXME: should be more robust
|
||||
$http.put(endpoint + mediaId + '/publish', {csrf_token: jQuery("#csrf").val(), sources: data})
|
||||
.success(function () {
|
||||
fetchSourceData();
|
||||
});
|
||||
};
|
||||
|
||||
$scope.discard = function () {
|
||||
tab.close();
|
||||
$scope.media = {};
|
||||
};
|
||||
|
||||
init();
|
||||
$scope.publish = function () {
|
||||
var data = {};
|
||||
jQuery.each($scope.publishData, function (k, v) {
|
||||
if (v) {
|
||||
data[k] = "publish"; // FIXME: should be more robust
|
||||
}
|
||||
});
|
||||
|
||||
if (data && Object.keys(data).length > 0) {
|
||||
$http
|
||||
.put(endpoint + mediaId + "/publish", {
|
||||
csrf_token: jQuery("#csrf").val(),
|
||||
sources: data,
|
||||
})
|
||||
.success(function () {
|
||||
tab.contents.find(".publish-btn").prop("disabled", true);
|
||||
fetchSourceData();
|
||||
$scope.publishData = {}; // Reset the publishData in case the user publishes
|
||||
// and unpublishes without closing the tab
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
/*
|
||||
$scope.remove = function (source) {
|
||||
var data = {};
|
||||
data[source] = "unpublish"; // FIXME: should be more robust
|
||||
$http
|
||||
.put(endpoint + mediaId + "/publish", {
|
||||
csrf_token: jQuery("#csrf").val(),
|
||||
sources: data,
|
||||
})
|
||||
.success(function () {
|
||||
fetchSourceData();
|
||||
});
|
||||
};
|
||||
|
||||
$scope.discard = function () {
|
||||
tab.close();
|
||||
$scope.media = {};
|
||||
};
|
||||
|
||||
init();
|
||||
});
|
||||
|
||||
/*
|
||||
var selected = $("#podcast_table").find(".selected"),
|
||||
ids = [];
|
||||
var selectedData = AIRTIME.library.podcastTableWidget.getSelectedRows();
|
||||
|
@ -116,15 +130,15 @@ var AIRTIME = (function (AIRTIME) {
|
|||
ids.push(el.id);
|
||||
});*/
|
||||
|
||||
function _bootstrapAngularApp(mediaId, tab) {
|
||||
publishApp.value('mediaId', mediaId);
|
||||
publishApp.value('tab', tab);
|
||||
var wrapper = AIRTIME.tabs.getActiveTab().contents.find(".angular_wrapper");
|
||||
angular.bootstrap(wrapper.get(0), [PUBLISH_APP_NAME]);
|
||||
}
|
||||
function _bootstrapAngularApp(mediaId, tab) {
|
||||
publishApp.value("mediaId", mediaId);
|
||||
publishApp.value("tab", tab);
|
||||
var wrapper = AIRTIME.tabs.getActiveTab().contents.find(".angular_wrapper");
|
||||
angular.bootstrap(wrapper.get(0), [PUBLISH_APP_NAME]);
|
||||
}
|
||||
|
||||
mod.publishSelectedTracks = function() {
|
||||
/*
|
||||
mod.publishSelectedTracks = function () {
|
||||
/*
|
||||
_bulkAction("GET", function(json) {
|
||||
json.forEach(function(el) {
|
||||
var uid = AIRTIME.library.MediaTypeStringEnum.FILE+"_"+el.id;
|
||||
|
@ -138,18 +152,21 @@ var AIRTIME = (function (AIRTIME) {
|
|||
});
|
||||
});
|
||||
});*/
|
||||
};
|
||||
|
||||
};
|
||||
mod.openPublishDialog = function (mediaId) {
|
||||
jQuery
|
||||
.get(dialogUrl, { csrf_token: jQuery("#csrf").val() })
|
||||
.success(function (html) {
|
||||
var tab = AIRTIME.tabs.openTab(
|
||||
html,
|
||||
PUBLISH_APP_NAME + "_" + mediaId,
|
||||
null
|
||||
);
|
||||
_bootstrapAngularApp(mediaId, tab);
|
||||
});
|
||||
|
||||
mod.openPublishDialog = function(mediaId) {
|
||||
|
||||
jQuery.get(dialogUrl, { csrf_token: jQuery("#csrf").val() })
|
||||
.success(function(html) {
|
||||
var tab = AIRTIME.tabs.openTab(html, PUBLISH_APP_NAME+"_"+mediaId, null);
|
||||
_bootstrapAngularApp(mediaId, tab);
|
||||
});
|
||||
|
||||
/*
|
||||
/*
|
||||
_bulkAction("GET", function(json) {
|
||||
json.forEach(function(el) {
|
||||
var uid = AIRTIME.library.MediaTypeStringEnum.FILE+"_"+el.id;
|
||||
|
@ -162,7 +179,7 @@ var AIRTIME = (function (AIRTIME) {
|
|||
});
|
||||
});
|
||||
});*/
|
||||
};
|
||||
};
|
||||
|
||||
return AIRTIME;
|
||||
}(AIRTIME || {}));
|
||||
return AIRTIME;
|
||||
})(AIRTIME || {});
|
||||
|
|
File diff suppressed because it is too large
Load diff
|
@ -1,194 +1,229 @@
|
|||
$(document).ready(function() {
|
||||
listenerstat_content = $("#listenerstat_content")
|
||||
dateStartId = "#his_date_start",
|
||||
timeStartId = "#his_time_start",
|
||||
dateEndId = "#his_date_end",
|
||||
timeEndId = "#his_time_end";
|
||||
$(document).ready(function () {
|
||||
listenerstat_content = $("#listenerstat_content");
|
||||
(dateStartId = "#his_date_start"),
|
||||
(timeStartId = "#his_time_start"),
|
||||
(dateEndId = "#his_date_end"),
|
||||
(timeEndId = "#his_time_end");
|
||||
|
||||
// set width dynamically
|
||||
var width = $("#listenerstat_content").width();
|
||||
width = width * .91;
|
||||
$("#listenerstat_content").find("#flot_placeholder").width(width);
|
||||
$("#listenerstat_content").find("#legend").width(width);
|
||||
// set width dynamically
|
||||
var width = $("#listenerstat_content").width();
|
||||
width = width * 0.91;
|
||||
$("#listenerstat_content").find("#flot_placeholder").width(width);
|
||||
$("#listenerstat_content").find("#legend").width(width);
|
||||
|
||||
getDataAndPlot();
|
||||
getDataAndPlot();
|
||||
|
||||
listenerstat_content.find("#his_submit").click(function(){
|
||||
var oRange = AIRTIME.utilities.fnGetScheduleRange(dateStartId, timeStartId, dateEndId, timeEndId);
|
||||
var start = oRange.start;
|
||||
var end = oRange.end;
|
||||
getDataAndPlot(start, end);
|
||||
});
|
||||
listenerstat_content.find("#his_submit").click(function () {
|
||||
var oRange = AIRTIME.utilities.fnGetScheduleRange(
|
||||
dateStartId,
|
||||
timeStartId,
|
||||
dateEndId,
|
||||
timeEndId
|
||||
);
|
||||
var start = oRange.start;
|
||||
var end = oRange.end;
|
||||
getDataAndPlot(start, end);
|
||||
});
|
||||
});
|
||||
|
||||
/**
|
||||
* Toggle a spinner overlay so the user knows the page is processing
|
||||
*/
|
||||
function toggleOverlay() {
|
||||
$('#flot_placeholder').toggleClass('processing');
|
||||
$("#flot_placeholder").toggleClass("processing");
|
||||
}
|
||||
|
||||
function getDataAndPlot(startTimestamp, endTimestamp) {
|
||||
// Turn on the processing overlay
|
||||
toggleOverlay();
|
||||
// Turn on the processing overlay
|
||||
toggleOverlay();
|
||||
|
||||
// get data
|
||||
$.get(baseUrl+'Listenerstat/get-data', {start: startTimestamp, end: endTimestamp}, function(data){
|
||||
out = new Object();
|
||||
$.each(data, function(mpName, v){
|
||||
plotData = new Object();
|
||||
plotData.data = new Array();
|
||||
$.each(v, function(i, ele){
|
||||
plotData.label = mpName;
|
||||
var d = new Date(0);
|
||||
d.setUTCSeconds(ele.timestamp);
|
||||
plotData.data.push([d, ele.listener_count]);
|
||||
})
|
||||
out[mpName] = plotData;
|
||||
// get data
|
||||
$.get(
|
||||
baseUrl + "Listenerstat/get-data",
|
||||
{ start: startTimestamp, end: endTimestamp },
|
||||
function (data) {
|
||||
out = new Object();
|
||||
$.each(data, function (mpName, v) {
|
||||
plotData = new Object();
|
||||
plotData.data = new Array();
|
||||
$.each(v, function (i, ele) {
|
||||
plotData.label = mpName;
|
||||
var d = new Date(0);
|
||||
d.setUTCSeconds(ele.timestamp);
|
||||
plotData.data.push([d, ele.listener_count]);
|
||||
});
|
||||
plot(out);
|
||||
// Turn off the processing overlay
|
||||
toggleOverlay();
|
||||
})
|
||||
out[mpName] = plotData;
|
||||
});
|
||||
plot(out);
|
||||
// Turn off the processing overlay
|
||||
toggleOverlay();
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
function plot(datasets){
|
||||
var plot;
|
||||
data = null;
|
||||
function plotByChoice(doAll)
|
||||
{
|
||||
// largest date object that you can set
|
||||
firstTimestamp = new Date(8640000000000000);
|
||||
// smallest
|
||||
lastTimestamp = new Date(0);
|
||||
function plot(datasets) {
|
||||
var plot;
|
||||
data = null;
|
||||
function plotByChoice(doAll) {
|
||||
// largest date object that you can set
|
||||
firstTimestamp = new Date(8640000000000000);
|
||||
// smallest
|
||||
lastTimestamp = new Date(0);
|
||||
|
||||
data = [];
|
||||
if (doAll != null)
|
||||
{
|
||||
$.each(datasets, function(key, val) {
|
||||
if (firstTimestamp.getTime() > val.data[0][0].getTime()) {
|
||||
firstTimestamp = val.data[0][0];
|
||||
}
|
||||
if (lastTimestamp.getTime() < val.data[val.data.length-1][0].getTime()) {
|
||||
lastTimestamp = val.data[val.data.length-1][0];
|
||||
}
|
||||
data.push(val);
|
||||
});
|
||||
data = [];
|
||||
if (doAll != null) {
|
||||
$.each(datasets, function (key, val) {
|
||||
if (firstTimestamp.getTime() > val.data[0][0].getTime()) {
|
||||
firstTimestamp = val.data[0][0];
|
||||
}
|
||||
else
|
||||
{
|
||||
$('#legend .legendCB').each(
|
||||
function(){
|
||||
if (this.checked)
|
||||
{
|
||||
data.push(datasets[this.id]);
|
||||
if (firstTimestamp.getTime() > datasets[this.id].data[0][0].getTime()) {
|
||||
firstTimestamp = datasets[this.id].data[0][0];
|
||||
}
|
||||
if (lastTimestamp.getTime() < datasets[this.id].data[datasets[this.id].data.length-1][0].getTime()) {
|
||||
lastTimestamp = datasets[this.id].data[datasets[this.id].data.length-1][0];
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
data.push({label: this.id, data: []})
|
||||
}
|
||||
}
|
||||
);
|
||||
if (
|
||||
lastTimestamp.getTime() < val.data[val.data.length - 1][0].getTime()
|
||||
) {
|
||||
lastTimestamp = val.data[val.data.length - 1][0];
|
||||
}
|
||||
|
||||
numOfTicks = 10;
|
||||
tickSize = (lastTimestamp.getTime() - firstTimestamp.getTime())/1000/numOfTicks;
|
||||
|
||||
plot = $.plot($("#flot_placeholder"), data, {
|
||||
yaxis: { min: 0, tickDecimals: 0, color: '#d6d6d6', tickColor: '#d6d6d6' },
|
||||
xaxis: { mode: "time", timeformat:"%y/%m/%0d %H:%M", tickSize: [tickSize, "second"],
|
||||
color: '#d6d6d6', tickColor: '#d6d6d6' },
|
||||
grid: {
|
||||
hoverable: true,
|
||||
backgroundColor: { colors: ["#333", "#555"] }
|
||||
},
|
||||
series: {
|
||||
lines: {
|
||||
show: true,
|
||||
fill: 0.3
|
||||
},
|
||||
points: { show: true }
|
||||
},
|
||||
legend: {
|
||||
container: $('#legend'),
|
||||
noColumns: 5,
|
||||
color: '#c0c0c0',
|
||||
labelFormatter: function (label, series) {
|
||||
var cb = '<input style="float:left;" class="legendCB" type="checkbox" ';
|
||||
if (series.data.length > 0){
|
||||
cb += 'checked="true" ';
|
||||
}
|
||||
cb += 'id="'+label+'" /> ';
|
||||
cb += label;
|
||||
return cb;
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
function showTooltip(x, y, contents) {
|
||||
$('<div id="tooltip">' + contents + '</div>').css( {
|
||||
position: 'absolute',
|
||||
display: 'none',
|
||||
top: y + 5,
|
||||
left: x + 5,
|
||||
border: '1px solid #fdd',
|
||||
padding: '2px',
|
||||
'background-color': '#fee',
|
||||
opacity: 0.80
|
||||
}).appendTo("body").fadeIn(200);
|
||||
data.push(val);
|
||||
});
|
||||
} else {
|
||||
$("#legend .legendCB").each(function () {
|
||||
if (this.checked) {
|
||||
data.push(datasets[this.id]);
|
||||
if (
|
||||
firstTimestamp.getTime() > datasets[this.id].data[0][0].getTime()
|
||||
) {
|
||||
firstTimestamp = datasets[this.id].data[0][0];
|
||||
}
|
||||
if (
|
||||
lastTimestamp.getTime() <
|
||||
datasets[this.id].data[
|
||||
datasets[this.id].data.length - 1
|
||||
][0].getTime()
|
||||
) {
|
||||
lastTimestamp =
|
||||
datasets[this.id].data[datasets[this.id].data.length - 1][0];
|
||||
}
|
||||
} else {
|
||||
data.push({ label: this.id, data: [] });
|
||||
}
|
||||
|
||||
var previousPoint = null;
|
||||
$("#flot_placeholder").bind("plothover", function (event, pos, item) {
|
||||
if (item) {
|
||||
if (previousPoint != item.dataIndex) {
|
||||
previousPoint = item.dataIndex;
|
||||
|
||||
$("#tooltip").remove();
|
||||
var y = item.datapoint[1].toFixed(2);
|
||||
|
||||
showTooltip(item.pageX, item.pageY,
|
||||
sprintf($.i18n._("Listener Count on %s: %s"), item.series.label, Math.floor(y)));
|
||||
}
|
||||
}
|
||||
else {
|
||||
$("#tooltip").remove();
|
||||
previousPoint = null;
|
||||
}
|
||||
});
|
||||
|
||||
$('#legend').find("input").click(function(){setTimeout(plotByChoice,100);});
|
||||
});
|
||||
}
|
||||
|
||||
plotByChoice(true);
|
||||
oBaseDatePickerSettings = {
|
||||
dateFormat: 'yy-mm-dd',
|
||||
//i18n_months, i18n_days_short are in common.js
|
||||
monthNames: i18n_months,
|
||||
dayNamesMin: i18n_days_short,
|
||||
onSelect: function(sDate, oDatePicker) {
|
||||
$(this).datepicker( "setDate", sDate );
|
||||
numOfTicks = 10;
|
||||
tickSize =
|
||||
(lastTimestamp.getTime() - firstTimestamp.getTime()) / 1000 / numOfTicks;
|
||||
|
||||
plot = $.plot($("#flot_placeholder"), data, {
|
||||
yaxis: {
|
||||
min: 0,
|
||||
tickDecimals: 0,
|
||||
color: "#d6d6d6",
|
||||
tickColor: "#d6d6d6",
|
||||
},
|
||||
xaxis: {
|
||||
mode: "time",
|
||||
timeformat: "%y/%m/%0d %H:%M",
|
||||
tickSize: [tickSize, "second"],
|
||||
color: "#d6d6d6",
|
||||
tickColor: "#d6d6d6",
|
||||
},
|
||||
grid: {
|
||||
hoverable: true,
|
||||
backgroundColor: { colors: ["#333", "#555"] },
|
||||
},
|
||||
series: {
|
||||
lines: {
|
||||
show: true,
|
||||
fill: 0.3,
|
||||
},
|
||||
points: { show: true },
|
||||
},
|
||||
legend: {
|
||||
container: $("#legend"),
|
||||
noColumns: 5,
|
||||
color: "#c0c0c0",
|
||||
labelFormatter: function (label, series) {
|
||||
var cb =
|
||||
'<input style="float:left;" class="legendCB" type="checkbox" ';
|
||||
if (series.data.length > 0) {
|
||||
cb += 'checked="true" ';
|
||||
}
|
||||
cb += 'id="' + label + '" /> ';
|
||||
cb += label;
|
||||
return cb;
|
||||
},
|
||||
},
|
||||
});
|
||||
|
||||
function showTooltip(x, y, contents) {
|
||||
$('<div id="tooltip">' + contents + "</div>")
|
||||
.css({
|
||||
position: "absolute",
|
||||
display: "none",
|
||||
top: y + 5,
|
||||
left: x + 5,
|
||||
border: "1px solid #fdd",
|
||||
padding: "2px",
|
||||
"background-color": "#fee",
|
||||
opacity: 0.8,
|
||||
})
|
||||
.appendTo("body")
|
||||
.fadeIn(200);
|
||||
}
|
||||
|
||||
var previousPoint = null;
|
||||
$("#flot_placeholder").bind("plothover", function (event, pos, item) {
|
||||
if (item) {
|
||||
if (previousPoint != item.dataIndex) {
|
||||
previousPoint = item.dataIndex;
|
||||
|
||||
$("#tooltip").remove();
|
||||
var y = item.datapoint[1].toFixed(2);
|
||||
|
||||
showTooltip(
|
||||
item.pageX,
|
||||
item.pageY,
|
||||
sprintf(
|
||||
$.i18n._("Listener Count on %s: %s"),
|
||||
item.series.label,
|
||||
Math.floor(y)
|
||||
)
|
||||
);
|
||||
}
|
||||
};
|
||||
} else {
|
||||
$("#tooltip").remove();
|
||||
previousPoint = null;
|
||||
}
|
||||
});
|
||||
|
||||
oBaseTimePickerSettings = {
|
||||
showPeriodLabels: false,
|
||||
showCloseButton: true,
|
||||
closeButtonText: $.i18n._("Done"),
|
||||
showLeadingZero: false,
|
||||
defaultTime: '0:00',
|
||||
hourText: $.i18n._("Hour"),
|
||||
minuteText: $.i18n._("Minute")
|
||||
};
|
||||
$("#legend")
|
||||
.find("input")
|
||||
.click(function () {
|
||||
setTimeout(plotByChoice, 100);
|
||||
});
|
||||
}
|
||||
|
||||
listenerstat_content.find(dateStartId).datepicker(oBaseDatePickerSettings);
|
||||
listenerstat_content.find(timeStartId).timepicker(oBaseTimePickerSettings);
|
||||
listenerstat_content.find(dateEndId).datepicker(oBaseDatePickerSettings);
|
||||
listenerstat_content.find(timeEndId).timepicker(oBaseTimePickerSettings);
|
||||
plotByChoice(true);
|
||||
oBaseDatePickerSettings = {
|
||||
dateFormat: "yy-mm-dd",
|
||||
//i18n_months, i18n_days_short are in common.js
|
||||
monthNames: i18n_months,
|
||||
dayNamesMin: i18n_days_short,
|
||||
onSelect: function (sDate, oDatePicker) {
|
||||
$(this).datepicker("setDate", sDate);
|
||||
},
|
||||
};
|
||||
|
||||
oBaseTimePickerSettings = {
|
||||
showPeriodLabels: false,
|
||||
showCloseButton: true,
|
||||
closeButtonText: $.i18n._("Done"),
|
||||
showLeadingZero: false,
|
||||
defaultTime: "0:00",
|
||||
hourText: $.i18n._("Hour"),
|
||||
minuteText: $.i18n._("Minute"),
|
||||
};
|
||||
|
||||
listenerstat_content.find(dateStartId).datepicker(oBaseDatePickerSettings);
|
||||
listenerstat_content.find(timeStartId).timepicker(oBaseTimePickerSettings);
|
||||
listenerstat_content.find(dateEndId).datepicker(oBaseDatePickerSettings);
|
||||
listenerstat_content.find(timeEndId).timepicker(oBaseTimePickerSettings);
|
||||
}
|
||||
|
|
|
@ -1,127 +1,171 @@
|
|||
$(document).ready(function() {
|
||||
showlistenerstat_content = $("#showlistenerstat_content")
|
||||
dateStartId = "#his_date_start",
|
||||
timeStartId = "#his_time_start",
|
||||
dateEndId = "#his_date_end",
|
||||
timeEndId = "#his_time_end",
|
||||
show_id = "#his_show_filter";
|
||||
$(document).ready(function () {
|
||||
showlistenerstat_content = $("#showlistenerstat_content");
|
||||
(dateStartId = "#his_date_start"),
|
||||
(timeStartId = "#his_time_start"),
|
||||
(dateEndId = "#his_date_end"),
|
||||
(timeEndId = "#his_time_end"),
|
||||
(show_id = "#his_show_filter");
|
||||
|
||||
// set width dynamically
|
||||
var width = $("#showlistenerstat_content").width();
|
||||
width = width * .91;
|
||||
addDatePicker();
|
||||
// set width dynamically
|
||||
var width = $("#showlistenerstat_content").width();
|
||||
width = width * 0.91;
|
||||
addDatePicker();
|
||||
|
||||
showlistenerstat_content.find("#his_submit").click(function(){
|
||||
// var show_id = $("#sb_show_filter").val();
|
||||
var oRange = AIRTIME.utilities.fnGetScheduleRange(dateStartId, timeStartId, dateEndId, timeEndId);
|
||||
var start = oRange.start;
|
||||
var end = oRange.end;
|
||||
showListenerDataTable();
|
||||
});
|
||||
showlistenerstat_content.find("#his_submit").click(function () {
|
||||
// var show_id = $("#sb_show_filter").val();
|
||||
var oRange = AIRTIME.utilities.fnGetScheduleRange(
|
||||
dateStartId,
|
||||
timeStartId,
|
||||
dateEndId,
|
||||
timeEndId
|
||||
);
|
||||
var start = oRange.start;
|
||||
var end = oRange.end;
|
||||
showListenerDataTable();
|
||||
});
|
||||
});
|
||||
|
||||
function getShowData(startTimestamp, endTimestamp, show_id) {
|
||||
// get data
|
||||
$.get(baseUrl+'Listenerstat/get-all-show-data', {start: startTimestamp, end: endTimestamp }, function(data) {
|
||||
return data;
|
||||
});
|
||||
// get data
|
||||
$.get(
|
||||
baseUrl + "Listenerstat/get-all-show-data",
|
||||
{ start: startTimestamp, end: endTimestamp },
|
||||
function (data) {
|
||||
return data;
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
function addDatePicker() {
|
||||
oBaseDatePickerSettings = {
|
||||
dateFormat: "yy-mm-dd",
|
||||
//i18n_months, i18n_days_short are in common.js
|
||||
monthNames: i18n_months,
|
||||
dayNamesMin: i18n_days_short,
|
||||
onSelect: function (sDate, oDatePicker) {
|
||||
$(this).datepicker("setDate", sDate);
|
||||
},
|
||||
onClose: validateTimeRange,
|
||||
};
|
||||
oBaseTimePickerSettings = {
|
||||
showPeriodLabels: false,
|
||||
showCloseButton: true,
|
||||
closeButtonText: $.i18n._("Done"),
|
||||
showLeadingZero: false,
|
||||
defaultTime: "0:00",
|
||||
hourText: $.i18n._("Hour"),
|
||||
minuteText: $.i18n._("Minute"),
|
||||
onClose: validateTimeRange,
|
||||
};
|
||||
|
||||
oBaseDatePickerSettings = {
|
||||
dateFormat: 'yy-mm-dd',
|
||||
//i18n_months, i18n_days_short are in common.js
|
||||
monthNames: i18n_months,
|
||||
dayNamesMin: i18n_days_short,
|
||||
onSelect: function(sDate, oDatePicker) {
|
||||
$(this).datepicker( "setDate", sDate );
|
||||
},
|
||||
onClose: validateTimeRange
|
||||
};
|
||||
oBaseTimePickerSettings = {
|
||||
showPeriodLabels: false,
|
||||
showCloseButton: true,
|
||||
closeButtonText: $.i18n._("Done"),
|
||||
showLeadingZero: false,
|
||||
defaultTime: '0:00',
|
||||
hourText: $.i18n._("Hour"),
|
||||
minuteText: $.i18n._("Minute"),
|
||||
onClose: validateTimeRange
|
||||
};
|
||||
|
||||
showlistenerstat_content.find(dateStartId).datepicker(oBaseDatePickerSettings).blur(validateTimeRange());
|
||||
showlistenerstat_content.find(timeStartId).timepicker(oBaseTimePickerSettings).blur(validateTimeRange());
|
||||
showlistenerstat_content.find(dateEndId).datepicker(oBaseDatePickerSettings).blur(validateTimeRange());
|
||||
showlistenerstat_content.find(timeEndId).timepicker(oBaseTimePickerSettings).blur(validateTimeRange());
|
||||
showlistenerstat_content
|
||||
.find(dateStartId)
|
||||
.datepicker(oBaseDatePickerSettings)
|
||||
.blur(validateTimeRange());
|
||||
showlistenerstat_content
|
||||
.find(timeStartId)
|
||||
.timepicker(oBaseTimePickerSettings)
|
||||
.blur(validateTimeRange());
|
||||
showlistenerstat_content
|
||||
.find(dateEndId)
|
||||
.datepicker(oBaseDatePickerSettings)
|
||||
.blur(validateTimeRange());
|
||||
showlistenerstat_content
|
||||
.find(timeEndId)
|
||||
.timepicker(oBaseTimePickerSettings)
|
||||
.blur(validateTimeRange());
|
||||
}
|
||||
|
||||
function getStartEnd() {
|
||||
|
||||
return AIRTIME.utilities.fnGetScheduleRange(dateStartId, timeStartId, dateEndId, timeEndId);
|
||||
return AIRTIME.utilities.fnGetScheduleRange(
|
||||
dateStartId,
|
||||
timeStartId,
|
||||
dateEndId,
|
||||
timeEndId
|
||||
);
|
||||
}
|
||||
|
||||
function validateTimeRange() {
|
||||
var oRange,
|
||||
inputs = $('.date_form > input'),
|
||||
error_window = $('.error_window'),
|
||||
start, end;
|
||||
var oRange,
|
||||
inputs = $(".date_form > input"),
|
||||
error_window = $(".error_window"),
|
||||
start,
|
||||
end;
|
||||
|
||||
oRange = AIRTIME.utilities.fnGetScheduleRange(dateStartId, timeStartId, dateEndId, timeEndId);
|
||||
oRange = AIRTIME.utilities.fnGetScheduleRange(
|
||||
dateStartId,
|
||||
timeStartId,
|
||||
dateEndId,
|
||||
timeEndId
|
||||
);
|
||||
|
||||
start = oRange.start;
|
||||
end = oRange.end;
|
||||
start = oRange.start;
|
||||
end = oRange.end;
|
||||
|
||||
if (end >= start) {
|
||||
error_window.removeClass('error');
|
||||
$('.error_window').html('');
|
||||
}
|
||||
else {
|
||||
error_window.addClass('error');
|
||||
console.log('bad')
|
||||
$('.error_window').html('Your start date time is after your end date time');
|
||||
}
|
||||
if (end >= start) {
|
||||
error_window.removeClass("error");
|
||||
$(".error_window").html("");
|
||||
} else {
|
||||
error_window.addClass("error");
|
||||
console.log("bad");
|
||||
$(".error_window").html("Your start date time is after your end date time");
|
||||
}
|
||||
|
||||
return {
|
||||
start: start,
|
||||
end: end,
|
||||
isValid: end >= start
|
||||
};
|
||||
return {
|
||||
start: start,
|
||||
end: end,
|
||||
isValid: end >= start,
|
||||
};
|
||||
}
|
||||
|
||||
function showListenerDataTable() {
|
||||
var oRange = AIRTIME.utilities.fnGetScheduleRange(dateStartId, timeStartId, dateEndId, timeEndId);
|
||||
var start = oRange.start;
|
||||
var lengthMenu = [[10, 25, 50, 100, 500, -1], [10, 25, 50, 100, 500, $.i18n._("All")]];
|
||||
var end = oRange.end;
|
||||
var sDom = 'l<"dt-process-rel"r><"H"T><"dataTables_scrolling"t><"F"ip>';
|
||||
var show_id = $("#sb_show_filter").val();
|
||||
var dt = $('#show_stats_datatable');
|
||||
info = getStartEnd();
|
||||
dt.dataTable({
|
||||
"aoColumns": [
|
||||
/* first name */ {"sName": "show", "mDataProp": "show"},
|
||||
/* air date */ {"sName": "time", "mDataProp": "time"},
|
||||
/* last name */ {"sName": "average_number_of_listeners", "mDataProp": "average_number_of_listeners"},
|
||||
/* last name */ {"sName": "maximum_number_of_listeners", "mDataProp": "maximum_number_of_listeners"}],
|
||||
"sAjaxSource": baseUrl+'Listenerstat/get-all-show-data',
|
||||
"sAjaxDataProp": "",
|
||||
"bDestroy": true,
|
||||
"aLengthMenu": lengthMenu,
|
||||
"iDisplayLength": 25,
|
||||
"sPaginationType": "full_numbers",
|
||||
"bJQueryUI": true,
|
||||
"bAutoWidth": true,
|
||||
"sDom": sDom,
|
||||
"fnServerData": function ( sSource, aoData, fnCallback ) {
|
||||
aoData.push({"start": start, "end": end});
|
||||
$.ajax( {
|
||||
"dataType": 'json',
|
||||
"type": "POST",
|
||||
"url": sSource,
|
||||
"data": {"start": start, "end": end},
|
||||
"success": fnCallback
|
||||
} );
|
||||
},
|
||||
});
|
||||
var oRange = AIRTIME.utilities.fnGetScheduleRange(
|
||||
dateStartId,
|
||||
timeStartId,
|
||||
dateEndId,
|
||||
timeEndId
|
||||
);
|
||||
var start = oRange.start;
|
||||
var lengthMenu = [
|
||||
[10, 25, 50, 100, 500, -1],
|
||||
[10, 25, 50, 100, 500, $.i18n._("All")],
|
||||
];
|
||||
var end = oRange.end;
|
||||
var sDom = 'l<"dt-process-rel"r><"H"T><"dataTables_scrolling"t><"F"ip>';
|
||||
var show_id = $("#sb_show_filter").val();
|
||||
var dt = $("#show_stats_datatable");
|
||||
info = getStartEnd();
|
||||
dt.dataTable({
|
||||
aoColumns: [
|
||||
/* first name */ { sName: "show", mDataProp: "show" },
|
||||
/* air date */ { sName: "time", mDataProp: "time" },
|
||||
/* last name */ {
|
||||
sName: "average_number_of_listeners",
|
||||
mDataProp: "average_number_of_listeners",
|
||||
},
|
||||
/* last name */ {
|
||||
sName: "maximum_number_of_listeners",
|
||||
mDataProp: "maximum_number_of_listeners",
|
||||
},
|
||||
],
|
||||
sAjaxSource: baseUrl + "Listenerstat/get-all-show-data",
|
||||
sAjaxDataProp: "",
|
||||
bDestroy: true,
|
||||
aLengthMenu: lengthMenu,
|
||||
iDisplayLength: 25,
|
||||
sPaginationType: "full_numbers",
|
||||
bJQueryUI: true,
|
||||
bAutoWidth: true,
|
||||
sDom: sDom,
|
||||
fnServerData: function (sSource, aoData, fnCallback) {
|
||||
aoData.push({ start: start, end: end });
|
||||
$.ajax({
|
||||
dataType: "json",
|
||||
type: "POST",
|
||||
url: sSource,
|
||||
data: { start: start, end: end },
|
||||
success: fnCallback,
|
||||
});
|
||||
},
|
||||
});
|
||||
}
|
||||
|
|
|
@ -1,9 +1,9 @@
|
|||
$(window).load(function() {
|
||||
$("#username").focus();
|
||||
$(window).load(function () {
|
||||
$("#username").focus();
|
||||
});
|
||||
|
||||
$(document).ready(function() {
|
||||
$("#submit").click(function() {
|
||||
Cookies.set('airtime_locale', $('#locale').val(), {path: '/'});
|
||||
});
|
||||
$(document).ready(function () {
|
||||
$("#submit").click(function () {
|
||||
Cookies.set("airtime_locale", $("#locale").val(), { path: "/" });
|
||||
});
|
||||
});
|
||||
|
|
|
@ -1,17 +1,16 @@
|
|||
$(document).ready(function() {
|
||||
$(document).ready(function () {
|
||||
var dialog = $("#lang-timezone-popup");
|
||||
|
||||
var dialog = $("#lang-timezone-popup");
|
||||
|
||||
dialog.dialog({
|
||||
autoOpen: false,
|
||||
width: 500,
|
||||
resizable: false,
|
||||
modal: true,
|
||||
closeOnEscape: false,
|
||||
position:['center','center'],
|
||||
dialogClass: 'no-close',
|
||||
buttons: [
|
||||
/* Testing removing the Not Now button for higher engagement
|
||||
dialog.dialog({
|
||||
autoOpen: false,
|
||||
width: 500,
|
||||
resizable: false,
|
||||
modal: true,
|
||||
closeOnEscape: false,
|
||||
position: ["center", "center"],
|
||||
dialogClass: "no-close",
|
||||
buttons: [
|
||||
/* Testing removing the Not Now button for higher engagement
|
||||
{
|
||||
id: "setup-later",
|
||||
text: $.i18n._("Not Now"),
|
||||
|
@ -20,32 +19,32 @@ $(document).ready(function() {
|
|||
$(this).dialog("close");
|
||||
}
|
||||
},*/
|
||||
{
|
||||
id: "help_airtime",
|
||||
text: $.i18n._("OK"),
|
||||
"class": "btn",
|
||||
click: function() {
|
||||
$("#lang-timezone-form").submit();
|
||||
}
|
||||
}
|
||||
]
|
||||
});
|
||||
{
|
||||
id: "help_airtime",
|
||||
text: $.i18n._("OK"),
|
||||
class: "btn",
|
||||
click: function () {
|
||||
$("#lang-timezone-form").submit();
|
||||
},
|
||||
},
|
||||
],
|
||||
});
|
||||
|
||||
var language = window.navigator.userLanguage || window.navigator.language;
|
||||
if (language === undefined) {
|
||||
language = "en_CA";
|
||||
}
|
||||
language = language.replace("-", "_");
|
||||
$("#setup_language").val(language);
|
||||
var language = window.navigator.userLanguage || window.navigator.language;
|
||||
if (language === undefined) {
|
||||
language = "en_CA";
|
||||
}
|
||||
language = language.replace("-", "_");
|
||||
$("#setup_language").val(language);
|
||||
|
||||
dayjs.extend(utc)
|
||||
dayjs.extend(timezone)
|
||||
dayjs.extend(utc);
|
||||
dayjs.extend(timezone);
|
||||
|
||||
var timezone_name = dayjs.tz.guess();
|
||||
if (timezone_name === undefined) {
|
||||
timezone_name = "America/Toronto";
|
||||
}
|
||||
$("#setup_timezone").val(timezone_name);
|
||||
var timezone_name = dayjs.tz.guess();
|
||||
if (timezone_name === undefined) {
|
||||
timezone_name = "America/Toronto";
|
||||
}
|
||||
$("#setup_timezone").val(timezone_name);
|
||||
|
||||
dialog.dialog('open');
|
||||
dialog.dialog("open");
|
||||
});
|
||||
|
|
|
@ -1,175 +1,177 @@
|
|||
$(document).ready(function(){
|
||||
|
||||
function doNotShowPopup(){
|
||||
$.get(baseUrl+"Usersettings/donotshowregistrationpopup", {format:"json"});
|
||||
}
|
||||
|
||||
var dialog = $("#register_popup");
|
||||
|
||||
dialog.dialog({
|
||||
autoOpen: false,
|
||||
width: 500,
|
||||
resizable: false,
|
||||
modal: true,
|
||||
position:['center',50],
|
||||
close: doNotShowPopup,
|
||||
buttons: [
|
||||
{
|
||||
id: "remind_me",
|
||||
text: $.i18n._("Remind me in 1 week"),
|
||||
"class": "btn",
|
||||
click: function() {
|
||||
var url = baseUrl+'Usersettings/remindme';
|
||||
$.ajax({
|
||||
url: url,
|
||||
data: {format:"json"}
|
||||
});
|
||||
$(this).dialog("close");
|
||||
}
|
||||
},
|
||||
{
|
||||
id: "remind_never",
|
||||
text: $.i18n._("Remind me never"),
|
||||
"class": "btn",
|
||||
click: function() {
|
||||
var url =baseUrl+'Usersettings/remindme-never';
|
||||
$.ajax({
|
||||
url: url,
|
||||
data: {format:"json"}
|
||||
});
|
||||
$(this).dialog("close");
|
||||
}
|
||||
},
|
||||
{
|
||||
id: "help_airtime",
|
||||
text: sprintf($.i18n._("Yes, help %s"), PRODUCT_NAME),
|
||||
"class": "btn",
|
||||
click: function() {
|
||||
$("#register-form").submit();
|
||||
}
|
||||
}
|
||||
]
|
||||
$(document).ready(function () {
|
||||
function doNotShowPopup() {
|
||||
$.get(baseUrl + "Usersettings/donotshowregistrationpopup", {
|
||||
format: "json",
|
||||
});
|
||||
}
|
||||
|
||||
var dialog = $("#register_popup");
|
||||
|
||||
dialog.dialog({
|
||||
autoOpen: false,
|
||||
width: 500,
|
||||
resizable: false,
|
||||
modal: true,
|
||||
position: ["center", 50],
|
||||
close: doNotShowPopup,
|
||||
buttons: [
|
||||
{
|
||||
id: "remind_me",
|
||||
text: $.i18n._("Remind me in 1 week"),
|
||||
class: "btn",
|
||||
click: function () {
|
||||
var url = baseUrl + "Usersettings/remindme";
|
||||
$.ajax({
|
||||
url: url,
|
||||
data: { format: "json" },
|
||||
});
|
||||
$(this).dialog("close");
|
||||
},
|
||||
},
|
||||
{
|
||||
id: "remind_never",
|
||||
text: $.i18n._("Remind me never"),
|
||||
class: "btn",
|
||||
click: function () {
|
||||
var url = baseUrl + "Usersettings/remindme-never";
|
||||
$.ajax({
|
||||
url: url,
|
||||
data: { format: "json" },
|
||||
});
|
||||
$(this).dialog("close");
|
||||
},
|
||||
},
|
||||
{
|
||||
id: "help_airtime",
|
||||
text: sprintf($.i18n._("Yes, help %s"), PRODUCT_NAME),
|
||||
class: "btn",
|
||||
click: function () {
|
||||
$("#register-form").submit();
|
||||
},
|
||||
},
|
||||
],
|
||||
});
|
||||
|
||||
var button = $("#help_airtime");
|
||||
|
||||
if ($("#link_to_terms_and_condition").length > 0) {
|
||||
button.removeAttr("disabled").removeClass("ui-state-disabled");
|
||||
} else {
|
||||
button.attr("disabled", "disabled").addClass("ui-state-disabled");
|
||||
}
|
||||
dialog.dialog("open");
|
||||
|
||||
$(".collapsible-header")
|
||||
.live("click", function () {
|
||||
$(this).next().toggle("fast");
|
||||
$(this).toggleClass("close");
|
||||
return false;
|
||||
})
|
||||
.next()
|
||||
.hide();
|
||||
|
||||
$("#SupportFeedback").live("click", function () {
|
||||
var pub = $("#Publicise");
|
||||
var privacy = $("#Privacy");
|
||||
var button = $("#help_airtime");
|
||||
|
||||
if($("#link_to_terms_and_condition").length > 0 ){
|
||||
button.removeAttr('disabled').removeClass('ui-state-disabled');
|
||||
}else{
|
||||
button.attr('disabled', 'disabled' ).addClass('ui-state-disabled');
|
||||
if (!$(this).is(":checked")) {
|
||||
pub.removeAttr("checked");
|
||||
pub.attr("disabled", true);
|
||||
$("#public-info").hide();
|
||||
button.attr("disabled", "disabled").addClass("ui-state-disabled");
|
||||
} else {
|
||||
pub.removeAttr("disabled");
|
||||
if (privacy.length == 0 || privacy.is(":checked")) {
|
||||
button.removeAttr("disabled").removeClass("ui-state-disabled");
|
||||
}
|
||||
}
|
||||
dialog.dialog('open');
|
||||
});
|
||||
|
||||
|
||||
$('.collapsible-header').live('click',function() {
|
||||
$(this).next().toggle('fast');
|
||||
$(this).toggleClass("close");
|
||||
return false;
|
||||
}).next().hide();
|
||||
|
||||
$("#SupportFeedback").live('click', function(){
|
||||
var pub = $("#Publicise");
|
||||
var privacy = $("#Privacy");
|
||||
var button = $("#help_airtime");
|
||||
if( !$(this).is(':checked') ){
|
||||
pub.removeAttr("checked");
|
||||
pub.attr("disabled", true);
|
||||
$("#public-info").hide();
|
||||
button.attr('disabled', 'disabled' ).addClass('ui-state-disabled');
|
||||
}else{
|
||||
pub.removeAttr("disabled");
|
||||
if(privacy.length == 0 || privacy.is(':checked')){
|
||||
button.removeAttr('disabled').removeClass('ui-state-disabled');
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
var promote = $("#Publicise");
|
||||
promote.live('click', function(){
|
||||
if($(this).is(':checked')){
|
||||
$("#public-info").show();
|
||||
}else{
|
||||
$("#public-info").hide();
|
||||
}
|
||||
});
|
||||
if( promote.is(":checked")){
|
||||
$("#public-info").show();
|
||||
var promote = $("#Publicise");
|
||||
promote.live("click", function () {
|
||||
if ($(this).is(":checked")) {
|
||||
$("#public-info").show();
|
||||
} else {
|
||||
$("#public-info").hide();
|
||||
}
|
||||
});
|
||||
if (promote.is(":checked")) {
|
||||
$("#public-info").show();
|
||||
}
|
||||
|
||||
$("#Privacy").live('click', function(){
|
||||
var support = $("#SupportFeedback");
|
||||
var button = $("#help_airtime");
|
||||
if($(this).is(':checked') && support.is(':checked')){
|
||||
button.removeAttr('disabled').removeClass('ui-state-disabled');
|
||||
}else{
|
||||
button.attr('disabled', 'disabled' ).addClass('ui-state-disabled');
|
||||
}
|
||||
});
|
||||
|
||||
if($("#SupportFeedback").is(':checked') && ($("#Privacy").length == 0 || $("#Privacy").is(':checked'))){
|
||||
button.removeAttr('disabled').removeClass('ui-state-disabled');
|
||||
}else{
|
||||
button.attr('disabled', 'disabled' ).addClass('ui-state-disabled');
|
||||
$("#Privacy").live("click", function () {
|
||||
var support = $("#SupportFeedback");
|
||||
var button = $("#help_airtime");
|
||||
if ($(this).is(":checked") && support.is(":checked")) {
|
||||
button.removeAttr("disabled").removeClass("ui-state-disabled");
|
||||
} else {
|
||||
button.attr("disabled", "disabled").addClass("ui-state-disabled");
|
||||
}
|
||||
});
|
||||
|
||||
$('.toggle legend').live('click',function() {
|
||||
$('.toggle').toggleClass('closed');
|
||||
return false;
|
||||
});
|
||||
if (
|
||||
$("#SupportFeedback").is(":checked") &&
|
||||
($("#Privacy").length == 0 || $("#Privacy").is(":checked"))
|
||||
) {
|
||||
button.removeAttr("disabled").removeClass("ui-state-disabled");
|
||||
} else {
|
||||
button.attr("disabled", "disabled").addClass("ui-state-disabled");
|
||||
}
|
||||
|
||||
$("#Logo").live('change', function(ev){
|
||||
var content, res, logoEl;
|
||||
$(".toggle legend").live("click", function () {
|
||||
$(".toggle").toggleClass("closed");
|
||||
return false;
|
||||
});
|
||||
|
||||
content = $(this).val();
|
||||
res = content.match(/(jpg|jpeg|png|gif)$/gi);
|
||||
logoEl = $("#Logo-element");
|
||||
$("#Logo").live("change", function (ev) {
|
||||
var content, res, logoEl;
|
||||
|
||||
//not an accepted image extension.
|
||||
if (!res) {
|
||||
var ul, li;
|
||||
content = $(this).val();
|
||||
res = content.match(/(jpg|jpeg|png|gif)$/gi);
|
||||
logoEl = $("#Logo-element");
|
||||
|
||||
ul = logoEl.find('.errors');
|
||||
li = $("<li/>").append($.i18n._("Image must be one of jpg, jpeg, png, or gif"));
|
||||
//not an accepted image extension.
|
||||
if (!res) {
|
||||
var ul, li;
|
||||
|
||||
//errors ul has already been created.
|
||||
if (ul.length > 0) {
|
||||
ul.empty()
|
||||
.append(li);
|
||||
}
|
||||
else {
|
||||
logoEl
|
||||
.append('<ul class="errors"></ul>')
|
||||
.find(".errors")
|
||||
.append(li);
|
||||
}
|
||||
ul = logoEl.find(".errors");
|
||||
li = $("<li/>").append(
|
||||
$.i18n._("Image must be one of jpg, jpeg, png, or gif")
|
||||
);
|
||||
|
||||
$(this).val("");
|
||||
}
|
||||
else {
|
||||
logoEl.find(".errors").remove();
|
||||
}
|
||||
});
|
||||
//errors ul has already been created.
|
||||
if (ul.length > 0) {
|
||||
ul.empty().append(li);
|
||||
} else {
|
||||
logoEl.append('<ul class="errors"></ul>').find(".errors").append(li);
|
||||
}
|
||||
|
||||
$(this).val("");
|
||||
} else {
|
||||
logoEl.find(".errors").remove();
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
function resizeImg(ele, targetWidth, targetHeight){
|
||||
var img = $(ele);
|
||||
function resizeImg(ele, targetWidth, targetHeight) {
|
||||
var img = $(ele);
|
||||
|
||||
var width = ele.width;
|
||||
var height = ele.height;
|
||||
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);
|
||||
}else if( width < height && height > targetHeight){
|
||||
var ratio = targetHeight/height;
|
||||
img.css("height", targetHeight+"px");
|
||||
var newWidth = width * ratio;
|
||||
img.css("width", newWidth);
|
||||
}else if( width == height && width > targetWidth){
|
||||
img.css("height", targetHeight+"px");
|
||||
img.css("width", targetWidth+"px" );
|
||||
}
|
||||
// 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);
|
||||
} else if (width < height && height > targetHeight) {
|
||||
var ratio = targetHeight / height;
|
||||
img.css("height", targetHeight + "px");
|
||||
var newWidth = width * ratio;
|
||||
img.css("width", newWidth);
|
||||
} else if (width == height && width > targetWidth) {
|
||||
img.css("height", targetHeight + "px");
|
||||
img.css("width", targetWidth + "px");
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,93 +1,90 @@
|
|||
function updateEmbedSrcParams()
|
||||
{
|
||||
var $embedCodeParams = "?";
|
||||
var $streamMode = getStreamMode();
|
||||
if ($streamMode == "manual") {
|
||||
var $stream = $("input[name=player_stream_url]:radio:checked").val();
|
||||
$embedCodeParams += "stream="+$stream;
|
||||
} else if ($streamMode == "auto") {
|
||||
$embedCodeParams += "stream=auto";
|
||||
}
|
||||
function updateEmbedSrcParams() {
|
||||
var $embedCodeParams = "?";
|
||||
var $streamMode = getStreamMode();
|
||||
if ($streamMode == "manual") {
|
||||
var $stream = $("input[name=player_stream_url]:radio:checked").val();
|
||||
$embedCodeParams += "stream=" + $stream;
|
||||
} else if ($streamMode == "auto") {
|
||||
$embedCodeParams += "stream=auto";
|
||||
}
|
||||
|
||||
$embedCodeParams += "&title="+getPlayerTitle();
|
||||
$embedCodeParams += "&title=" + getPlayerTitle();
|
||||
|
||||
$embedCodeParams += "\"";
|
||||
$embedCodeParams += '"';
|
||||
|
||||
$("textarea[name=player_embed_src]").val(function(index, value) {
|
||||
return value.replace(/\?.*?"/, $embedCodeParams);
|
||||
});
|
||||
$("textarea[name=player_embed_src]").val(function (index, value) {
|
||||
return value.replace(/\?.*?"/, $embedCodeParams);
|
||||
});
|
||||
|
||||
updatePlayerIframeSrc($("textarea[name=player_embed_src]").val());
|
||||
updatePlayerIframeSrc($("textarea[name=player_embed_src]").val());
|
||||
}
|
||||
|
||||
function updatePlayerIframeSrc(iframe_text) {
|
||||
var $player_iframe = $("#player_form iframe");
|
||||
var player_iframe_src = iframe_text.match(/http.*?"/)[0].slice(0, -1);
|
||||
$player_iframe.attr('src', player_iframe_src);
|
||||
var $player_iframe = $("#player_form iframe");
|
||||
var player_iframe_src = iframe_text.match(/http.*?"/)[0].slice(0, -1);
|
||||
$player_iframe.attr("src", player_iframe_src);
|
||||
}
|
||||
|
||||
function getStreamMode() {
|
||||
return $("input[name=player_stream_mode]:radio:checked").val();
|
||||
return $("input[name=player_stream_mode]:radio:checked").val();
|
||||
}
|
||||
|
||||
function getPlayerTitle() {
|
||||
return $("input[name=player_title]").val();
|
||||
return $("input[name=player_title]").val();
|
||||
}
|
||||
|
||||
$(document).ready(function() {
|
||||
$(document).ready(function () {
|
||||
$("#player_stream_url-element").hide();
|
||||
|
||||
$("#player_stream_url-element").hide();
|
||||
// stream mode change event
|
||||
$("#player_stream_mode-element").change(function () {
|
||||
var $streamMode = getStreamMode();
|
||||
|
||||
// stream mode change event
|
||||
$("#player_stream_mode-element").change(function() {
|
||||
var $streamMode = getStreamMode();
|
||||
if ($streamMode == "auto") {
|
||||
$("#player_stream_url-element").hide();
|
||||
} else if ($streamMode == "manual") {
|
||||
$("#player_stream_url-element").show();
|
||||
|
||||
if ($streamMode == "auto") {
|
||||
$("#player_stream_url-element").hide();
|
||||
|
||||
} else if ($streamMode == "manual") {
|
||||
$("#player_stream_url-element").show();
|
||||
|
||||
$("input[name=player_stream_url]").each(function(i, obj) {
|
||||
if ($(this).parent().text().toLowerCase().indexOf("opus") >= 0) {
|
||||
$(this).attr("disabled", "disabled");
|
||||
}
|
||||
});
|
||||
$("input[name=player_stream_url]").each(function (i, obj) {
|
||||
if ($(this).parent().text().toLowerCase().indexOf("opus") >= 0) {
|
||||
$(this).attr("disabled", "disabled");
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
updateEmbedSrcParams();
|
||||
});
|
||||
updateEmbedSrcParams();
|
||||
});
|
||||
|
||||
// stream url change event
|
||||
$("#player_stream_url-element").change(function() {
|
||||
updateEmbedSrcParams();
|
||||
});
|
||||
// stream url change event
|
||||
$("#player_stream_url-element").change(function () {
|
||||
updateEmbedSrcParams();
|
||||
});
|
||||
|
||||
// display title checkbox change event
|
||||
$("#player_display_title").change(function() {
|
||||
if ($(this).prop("checked")) {
|
||||
$("#player_title-label").show();
|
||||
$("#player_title-element").show();
|
||||
} else {
|
||||
$("#player_title-label").hide();
|
||||
$("#player_title-element").hide();
|
||||
}
|
||||
updateEmbedSrcParams();
|
||||
});
|
||||
// display title checkbox change event
|
||||
$("#player_display_title").change(function () {
|
||||
if ($(this).prop("checked")) {
|
||||
$("#player_title-label").show();
|
||||
$("#player_title-element").show();
|
||||
} else {
|
||||
$("#player_title-label").hide();
|
||||
$("#player_title-element").hide();
|
||||
}
|
||||
updateEmbedSrcParams();
|
||||
});
|
||||
|
||||
// title textbox change event
|
||||
// setup before functions
|
||||
var typingTimer;
|
||||
var doneTypingInterval = 3000;
|
||||
// title textbox change event
|
||||
// setup before functions
|
||||
var typingTimer;
|
||||
var doneTypingInterval = 3000;
|
||||
|
||||
// on keyup, start the countdown
|
||||
$("input[name=player_title]").keyup(function(){
|
||||
clearTimeout(typingTimer);
|
||||
typingTimer = setTimeout(updateEmbedSrcParams, doneTypingInterval);
|
||||
});
|
||||
// on keyup, start the countdown
|
||||
$("input[name=player_title]").keyup(function () {
|
||||
clearTimeout(typingTimer);
|
||||
typingTimer = setTimeout(updateEmbedSrcParams, doneTypingInterval);
|
||||
});
|
||||
|
||||
// on keydown, clear the countdown
|
||||
$("input[name=player_title]").keydown(function(){
|
||||
clearTimeout(typingTimer);
|
||||
});
|
||||
// on keydown, clear the countdown
|
||||
$("input[name=player_title]").keydown(function () {
|
||||
clearTimeout(typingTimer);
|
||||
});
|
||||
});
|
||||
|
|
|
@ -1,19 +1,37 @@
|
|||
function getRandomIdPlayer(max) {
|
||||
return "playerHtml5Libretime_"+Math.floor(Math.random() * Math.floor(max));
|
||||
return "playerHtml5Libretime_" + Math.floor(Math.random() * Math.floor(max));
|
||||
}
|
||||
|
||||
function playerhtml5_insert(settings)
|
||||
{
|
||||
atp='';
|
||||
if(settings.autoplay==true) atp='autoplay';
|
||||
if(settings.forceHTTPS==true&&settings.url.indexOf('https')==-1) settings.url=settings.url.replace(/http/g, 'https');
|
||||
if(settings.replacePort!=''&&settings.replacePort!=false&&settings.replacePort!='false')
|
||||
{
|
||||
if(settings.replacePortTo!='') settings.replacePortTo=':'+settings.replacePortTo;
|
||||
settings.url=settings.url.replace(':'+settings.replacePort, settings.replacePortTo);
|
||||
}
|
||||
if(settings.codec=='mp3') settings.codec='mpeg';
|
||||
document.getElementById('html5player_skin').innerHTML += '<div id="div_'+settings.elementId+'" style="" ><audio loop controls id="'+settings.elementId+'" src="'+settings.url+'" '+atp+' type="audio/'+settings.codec+'" >'
|
||||
+'Ihr Browser unterstützt das Element <code>audio</code> nicht.'
|
||||
+'<\/audio><\/div>';
|
||||
function playerhtml5_insert(settings) {
|
||||
atp = "";
|
||||
if (settings.autoplay == true) atp = "autoplay";
|
||||
if (settings.forceHTTPS == true && settings.url.indexOf("https") == -1)
|
||||
settings.url = settings.url.replace(/http/g, "https");
|
||||
if (
|
||||
settings.replacePort != "" &&
|
||||
settings.replacePort != false &&
|
||||
settings.replacePort != "false"
|
||||
) {
|
||||
if (settings.replacePortTo != "")
|
||||
settings.replacePortTo = ":" + settings.replacePortTo;
|
||||
settings.url = settings.url.replace(
|
||||
":" + settings.replacePort,
|
||||
settings.replacePortTo
|
||||
);
|
||||
}
|
||||
if (settings.codec == "mp3") settings.codec = "mpeg";
|
||||
document.getElementById("html5player_skin").innerHTML +=
|
||||
'<div id="div_' +
|
||||
settings.elementId +
|
||||
'" style="" ><audio loop controls id="' +
|
||||
settings.elementId +
|
||||
'" src="' +
|
||||
settings.url +
|
||||
'" ' +
|
||||
atp +
|
||||
' type="audio/' +
|
||||
settings.codec +
|
||||
'" >' +
|
||||
"Ihr Browser unterstützt das Element <code>audio</code> nicht." +
|
||||
"</audio></div>";
|
||||
}
|
||||
|
|
File diff suppressed because it is too large
Load diff
|
@ -1,167 +1,170 @@
|
|||
var AIRTIME = (function(AIRTIME) {
|
||||
var mod;
|
||||
var $templateDiv;
|
||||
var $templateList;
|
||||
var $fileMDList;
|
||||
var AIRTIME = (function (AIRTIME) {
|
||||
var mod;
|
||||
var $templateDiv;
|
||||
var $templateList;
|
||||
var $fileMDList;
|
||||
|
||||
if (AIRTIME.itemTemplate === undefined) {
|
||||
AIRTIME.itemTemplate = {};
|
||||
if (AIRTIME.itemTemplate === undefined) {
|
||||
AIRTIME.itemTemplate = {};
|
||||
}
|
||||
mod = AIRTIME.itemTemplate;
|
||||
|
||||
//config: name, type, filemd, required
|
||||
function createTemplateLi(config) {
|
||||
var templateRequired =
|
||||
"<li " +
|
||||
"data-name='<%= name %>' " +
|
||||
"data-type='<%= type %>' " +
|
||||
"data-filemd='<%= filemd %>'" +
|
||||
"data-label='<%= label %>'" +
|
||||
"class='<%= (filemd) ? 'field_filemd' : 'field_other' %>'" +
|
||||
">" +
|
||||
"<span><%= label %></span>" +
|
||||
"<span><%= type %></span>" +
|
||||
"</li>";
|
||||
|
||||
var templateOptional =
|
||||
"<li " +
|
||||
"data-name='<%= name %>' " +
|
||||
"data-type='<%= type %>' " +
|
||||
"data-filemd='<%= filemd %>'" +
|
||||
"data-label='<%= label %>'" +
|
||||
"class='<%= (filemd) ? 'field_filemd' : 'field_other' %>'" +
|
||||
">" +
|
||||
"<span><%= label %></span>" +
|
||||
"<span><%= type %></span>" +
|
||||
"<span class='template_item_remove'><i class='icon icon-trash'></i></span>" +
|
||||
"</li>";
|
||||
|
||||
var template =
|
||||
config.required === true ? templateRequired : templateOptional;
|
||||
|
||||
template = _.template(template);
|
||||
var $li = $(template(config));
|
||||
|
||||
return $li;
|
||||
}
|
||||
|
||||
//taken from
|
||||
//http://stackoverflow.com/questions/1349404/generate-a-string-of-5-random-characters-in-javascript
|
||||
function randomString(len, charSet) {
|
||||
//can only use small letters to avoid DB query problems.
|
||||
charSet = charSet || "abcdefghijklmnopqrstuvwxyz";
|
||||
var randomString = "";
|
||||
for (var i = 0; i < len; i++) {
|
||||
var randomPoz = Math.floor(Math.random() * charSet.length);
|
||||
randomString += charSet.substring(randomPoz, randomPoz + 1);
|
||||
}
|
||||
mod = AIRTIME.itemTemplate;
|
||||
return randomString;
|
||||
}
|
||||
|
||||
//config: name, type, filemd, required
|
||||
function createTemplateLi(config) {
|
||||
|
||||
var templateRequired =
|
||||
"<li " +
|
||||
"data-name='<%= name %>' " +
|
||||
"data-type='<%= type %>' " +
|
||||
"data-filemd='<%= filemd %>'" +
|
||||
"data-label='<%= label %>'" +
|
||||
"class='<%= (filemd) ? 'field_filemd' : 'field_other' %>'" +
|
||||
">" +
|
||||
"<span><%= label %></span>" +
|
||||
"<span><%= type %></span>" +
|
||||
"</li>";
|
||||
|
||||
var templateOptional =
|
||||
"<li " +
|
||||
"data-name='<%= name %>' " +
|
||||
"data-type='<%= type %>' " +
|
||||
"data-filemd='<%= filemd %>'" +
|
||||
"data-label='<%= label %>'" +
|
||||
"class='<%= (filemd) ? 'field_filemd' : 'field_other' %>'" +
|
||||
">" +
|
||||
"<span><%= label %></span>" +
|
||||
"<span><%= type %></span>" +
|
||||
"<span class='template_item_remove'><i class='icon icon-trash'></i></span>" +
|
||||
"</li>";
|
||||
|
||||
var template = (config.required) === true ? templateRequired : templateOptional;
|
||||
|
||||
template = _.template(template);
|
||||
var $li = $(template(config));
|
||||
|
||||
return $li;
|
||||
}
|
||||
|
||||
//taken from
|
||||
//http://stackoverflow.com/questions/1349404/generate-a-string-of-5-random-characters-in-javascript
|
||||
function randomString(len, charSet) {
|
||||
//can only use small letters to avoid DB query problems.
|
||||
charSet = charSet || 'abcdefghijklmnopqrstuvwxyz';
|
||||
var randomString = '';
|
||||
for (var i = 0; i < len; i++) {
|
||||
var randomPoz = Math.floor(Math.random() * charSet.length);
|
||||
randomString += charSet.substring(randomPoz,randomPoz+1);
|
||||
}
|
||||
return randomString;
|
||||
}
|
||||
|
||||
function addField(config) {
|
||||
|
||||
$templateList.append(createTemplateLi(config));
|
||||
}
|
||||
|
||||
function getFieldData($el) {
|
||||
|
||||
return {
|
||||
name: $el.data("name"),
|
||||
type: $el.data("type"),
|
||||
label: $el.data("label"),
|
||||
isFileMd: $el.data("filemd")
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
mod.onReady = function() {
|
||||
|
||||
$templateDiv = $("#configure_item_template");
|
||||
$templateList = $(".template_item_list");
|
||||
$fileMDList = $(".template_file_md");
|
||||
|
||||
$fileMDList.on("click", "i.icon-plus", function(){
|
||||
|
||||
var $li = $(this).parents("li");
|
||||
var config = {
|
||||
name: $li.data("name"),
|
||||
type: $li.data("type"),
|
||||
label: $li.data("label"),
|
||||
filemd: true,
|
||||
required: false
|
||||
};
|
||||
|
||||
addField(config);
|
||||
$li.remove();
|
||||
});
|
||||
|
||||
$templateList.sortable();
|
||||
|
||||
$templateDiv.on("click", ".template_item_remove", function() {
|
||||
$(this).parents("li").remove();
|
||||
});
|
||||
|
||||
$templateDiv.on("click", ".template_item_add button", function() {
|
||||
var $div = $(this).parents("div.template_item_add"),
|
||||
$input = $div.find("input"),
|
||||
label = $input.val(),
|
||||
name;
|
||||
|
||||
$input.val("");
|
||||
//create a string name that will work for all languages.
|
||||
name = randomString(10);
|
||||
|
||||
var config = {
|
||||
name: name,
|
||||
label: label,
|
||||
type: $div.find("select").val(),
|
||||
filemd: false,
|
||||
required: false
|
||||
};
|
||||
|
||||
addField(config);
|
||||
});
|
||||
|
||||
function updateTemplate(template_id, isDefault) {
|
||||
var url = baseUrl+"Playouthistorytemplate/update-template/format/json";
|
||||
var data = {};
|
||||
var $lis, $li;
|
||||
var i, len;
|
||||
var templateName;
|
||||
|
||||
templateName = $("#template_name").val();
|
||||
$lis = $templateList.children();
|
||||
|
||||
for (i = 0, len = $lis.length; i < len; i++) {
|
||||
$li = $($lis[i]);
|
||||
|
||||
data[i] = getFieldData($li);
|
||||
}
|
||||
|
||||
$.post(url, {'id': template_id, 'name': templateName, 'fields': data, 'setDefault': isDefault}, function(json) {
|
||||
var x;
|
||||
});
|
||||
}
|
||||
|
||||
$templateDiv.on("click", "#template_item_save", function(){
|
||||
var template_id = $(this).data("template");
|
||||
|
||||
updateTemplate(template_id, false);
|
||||
});
|
||||
|
||||
$templateDiv.on("click", "#template_set_default", function() {
|
||||
var $btn = $(this),
|
||||
template_id = $btn.data("template"),
|
||||
url = baseUrl+"Playouthistorytemplate/set-template-default/format/json";
|
||||
|
||||
$btn.remove();
|
||||
$.post(url, {id: template_id});
|
||||
});
|
||||
function addField(config) {
|
||||
$templateList.append(createTemplateLi(config));
|
||||
}
|
||||
|
||||
function getFieldData($el) {
|
||||
return {
|
||||
name: $el.data("name"),
|
||||
type: $el.data("type"),
|
||||
label: $el.data("label"),
|
||||
isFileMd: $el.data("filemd"),
|
||||
};
|
||||
}
|
||||
|
||||
return AIRTIME;
|
||||
mod.onReady = function () {
|
||||
$templateDiv = $("#configure_item_template");
|
||||
$templateList = $(".template_item_list");
|
||||
$fileMDList = $(".template_file_md");
|
||||
|
||||
}(AIRTIME || {}));
|
||||
$fileMDList.on("click", "i.icon-plus", function () {
|
||||
var $li = $(this).parents("li");
|
||||
var config = {
|
||||
name: $li.data("name"),
|
||||
type: $li.data("type"),
|
||||
label: $li.data("label"),
|
||||
filemd: true,
|
||||
required: false,
|
||||
};
|
||||
|
||||
addField(config);
|
||||
$li.remove();
|
||||
});
|
||||
|
||||
$templateList.sortable();
|
||||
|
||||
$templateDiv.on("click", ".template_item_remove", function () {
|
||||
$(this).parents("li").remove();
|
||||
});
|
||||
|
||||
$templateDiv.on("click", ".template_item_add button", function () {
|
||||
var $div = $(this).parents("div.template_item_add"),
|
||||
$input = $div.find("input"),
|
||||
label = $input.val(),
|
||||
name;
|
||||
|
||||
$input.val("");
|
||||
//create a string name that will work for all languages.
|
||||
name = randomString(10);
|
||||
|
||||
var config = {
|
||||
name: name,
|
||||
label: label,
|
||||
type: $div.find("select").val(),
|
||||
filemd: false,
|
||||
required: false,
|
||||
};
|
||||
|
||||
addField(config);
|
||||
});
|
||||
|
||||
function updateTemplate(template_id, isDefault) {
|
||||
var url = baseUrl + "Playouthistorytemplate/update-template/format/json";
|
||||
var data = {};
|
||||
var $lis, $li;
|
||||
var i, len;
|
||||
var templateName;
|
||||
|
||||
templateName = $("#template_name").val();
|
||||
$lis = $templateList.children();
|
||||
|
||||
for (i = 0, len = $lis.length; i < len; i++) {
|
||||
$li = $($lis[i]);
|
||||
|
||||
data[i] = getFieldData($li);
|
||||
}
|
||||
|
||||
$.post(
|
||||
url,
|
||||
{
|
||||
id: template_id,
|
||||
name: templateName,
|
||||
fields: data,
|
||||
setDefault: isDefault,
|
||||
},
|
||||
function (json) {
|
||||
var x;
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
$templateDiv.on("click", "#template_item_save", function () {
|
||||
var template_id = $(this).data("template");
|
||||
|
||||
updateTemplate(template_id, false);
|
||||
});
|
||||
|
||||
$templateDiv.on("click", "#template_set_default", function () {
|
||||
var $btn = $(this),
|
||||
template_id = $btn.data("template"),
|
||||
url =
|
||||
baseUrl + "Playouthistorytemplate/set-template-default/format/json";
|
||||
|
||||
$btn.remove();
|
||||
$.post(url, { id: template_id });
|
||||
});
|
||||
};
|
||||
|
||||
return AIRTIME;
|
||||
})(AIRTIME || {});
|
||||
|
||||
$(document).ready(AIRTIME.itemTemplate.onReady);
|
||||
|
|
File diff suppressed because it is too large
Load diff
|
@ -1,102 +1,114 @@
|
|||
var AIRTIME = (function(AIRTIME) {
|
||||
var mod;
|
||||
var $historyTemplate;
|
||||
var AIRTIME = (function (AIRTIME) {
|
||||
var mod;
|
||||
var $historyTemplate;
|
||||
|
||||
if (AIRTIME.template === undefined) {
|
||||
AIRTIME.template = {};
|
||||
}
|
||||
mod = AIRTIME.template;
|
||||
if (AIRTIME.template === undefined) {
|
||||
AIRTIME.template = {};
|
||||
}
|
||||
mod = AIRTIME.template;
|
||||
|
||||
function createItemLi(id, name, configured) {
|
||||
function createItemLi(id, name, configured) {
|
||||
var editUrl =
|
||||
baseUrl + "Playouthistorytemplate/configure-template/id/" + id;
|
||||
var defaultUrl =
|
||||
baseUrl +
|
||||
"Playouthistorytemplate/set-template-default/format/json/id/" +
|
||||
id;
|
||||
var removeUrl =
|
||||
baseUrl + "Playouthistorytemplate/delete-template/format/json/id/" + id;
|
||||
|
||||
var editUrl = baseUrl+"Playouthistorytemplate/configure-template/id/"+id;
|
||||
var defaultUrl = baseUrl+"Playouthistorytemplate/set-template-default/format/json/id/"+id;
|
||||
var removeUrl = baseUrl+"Playouthistorytemplate/delete-template/format/json/id/"+id;
|
||||
var itemConfigured =
|
||||
"<li class='template_configured' data-template='<%= id %>' data-name='<%= name %>'>" +
|
||||
"<a href='<%= editUrl %>' class='template_name'><%= name %></a>" +
|
||||
"<i class='icon icon-ok'></i>" +
|
||||
"</li>";
|
||||
|
||||
var itemConfigured =
|
||||
"<li class='template_configured' data-template='<%= id %>' data-name='<%= name %>'>" +
|
||||
"<a href='<%= editUrl %>' class='template_name'><%= name %></a>" +
|
||||
"<i class='icon icon-ok'></i>" +
|
||||
"</li>";
|
||||
var item =
|
||||
"<li data-template='<%= id %>' data-name='<%= name %>'>" +
|
||||
"<a href='<%= editUrl %>' class='template_name'><%= name %></a>" +
|
||||
"<a href='<%= removeUrl %>' class='template_remove'><i class='icon icon-trash'></i></a>" +
|
||||
"<a href='<%= defaultUrl %>' class='template_default'>" +
|
||||
$.i18n._("Set Default") +
|
||||
"</a>" +
|
||||
"</li>";
|
||||
|
||||
var item =
|
||||
"<li data-template='<%= id %>' data-name='<%= name %>'>" +
|
||||
"<a href='<%= editUrl %>' class='template_name'><%= name %></a>" +
|
||||
"<a href='<%= removeUrl %>' class='template_remove'><i class='icon icon-trash'></i></a>" +
|
||||
"<a href='<%= defaultUrl %>' class='template_default'>" + $.i18n._('Set Default') + "</a>" +
|
||||
"</li>";
|
||||
var template = configured === true ? itemConfigured : item;
|
||||
|
||||
var template = (configured) === true ? itemConfigured : item;
|
||||
var template = _.template(template);
|
||||
|
||||
var template = _.template(template);
|
||||
var $li = $(
|
||||
template({
|
||||
id: id,
|
||||
name: name,
|
||||
editUrl: editUrl,
|
||||
defaultUrl: defaultUrl,
|
||||
removeUrl: removeUrl,
|
||||
})
|
||||
);
|
||||
|
||||
var $li = $(template({id: id, name: name, editUrl: editUrl, defaultUrl: defaultUrl, removeUrl: removeUrl}));
|
||||
return $li;
|
||||
}
|
||||
|
||||
return $li;
|
||||
mod.onReady = function () {
|
||||
$historyTemplate = $("#history_template");
|
||||
|
||||
$historyTemplate.on("click", ".template_remove", function (ev) {
|
||||
ev.preventDefault();
|
||||
|
||||
var $a = $(this);
|
||||
var url = $a.attr("href");
|
||||
$a.parents("li").remove();
|
||||
|
||||
$.post(url, function () {
|
||||
var x;
|
||||
});
|
||||
});
|
||||
|
||||
$historyTemplate.on("click", ".template_default", function (ev) {
|
||||
ev.preventDefault();
|
||||
|
||||
var $a = $(this);
|
||||
var url = $a.attr("href");
|
||||
var $oldLi, $newLi;
|
||||
|
||||
$oldLi = $a.parents("ul").find("li.template_configured");
|
||||
$newLi = $a.parents("li");
|
||||
|
||||
$oldLi.replaceWith(
|
||||
createItemLi($oldLi.data("template"), $oldLi.data("name"), false)
|
||||
);
|
||||
$newLi.replaceWith(
|
||||
createItemLi($newLi.data("template"), $newLi.data("name"), true)
|
||||
);
|
||||
|
||||
$.post(url, function () {
|
||||
var x;
|
||||
});
|
||||
});
|
||||
|
||||
function createTemplate(type) {
|
||||
var createUrl = baseUrl + "Playouthistorytemplate/create-template";
|
||||
|
||||
$.post(createUrl, { format: "json", type: type }, function (json) {
|
||||
if (json.error !== undefined) {
|
||||
alert(json.error);
|
||||
return;
|
||||
}
|
||||
|
||||
window.location.href = json.url;
|
||||
});
|
||||
}
|
||||
|
||||
mod.onReady = function() {
|
||||
$historyTemplate.on("click", "#new_item_template", function () {
|
||||
createTemplate("item");
|
||||
});
|
||||
|
||||
$historyTemplate = $("#history_template");
|
||||
$historyTemplate.on("click", "#new_file_template", function () {
|
||||
createTemplate("file");
|
||||
});
|
||||
};
|
||||
|
||||
$historyTemplate.on("click", ".template_remove", function(ev) {
|
||||
|
||||
ev.preventDefault();
|
||||
|
||||
var $a = $(this);
|
||||
var url = $a.attr("href");
|
||||
$a.parents("li").remove();
|
||||
|
||||
$.post(url, function(){
|
||||
var x;
|
||||
});
|
||||
});
|
||||
|
||||
$historyTemplate.on("click", ".template_default", function(ev) {
|
||||
|
||||
ev.preventDefault();
|
||||
|
||||
var $a = $(this);
|
||||
var url = $a.attr("href");
|
||||
var $oldLi, $newLi;
|
||||
|
||||
$oldLi = $a.parents("ul").find("li.template_configured");
|
||||
$newLi = $a.parents("li");
|
||||
|
||||
$oldLi.replaceWith(createItemLi($oldLi.data('template'), $oldLi.data('name'), false));
|
||||
$newLi.replaceWith(createItemLi($newLi.data('template'), $newLi.data('name'), true));
|
||||
|
||||
$.post(url, function(){
|
||||
var x;
|
||||
});
|
||||
});
|
||||
|
||||
function createTemplate(type) {
|
||||
|
||||
var createUrl = baseUrl+"Playouthistorytemplate/create-template";
|
||||
|
||||
$.post(createUrl, {format: "json", type: type}, function(json) {
|
||||
|
||||
if (json.error !== undefined) {
|
||||
alert(json.error);
|
||||
return;
|
||||
}
|
||||
|
||||
window.location.href = json.url;
|
||||
});
|
||||
}
|
||||
|
||||
$historyTemplate.on("click", "#new_item_template", function() {
|
||||
createTemplate("item");
|
||||
});
|
||||
|
||||
$historyTemplate.on("click", "#new_file_template", function() {
|
||||
createTemplate("file");
|
||||
});
|
||||
};
|
||||
|
||||
return AIRTIME;
|
||||
|
||||
}(AIRTIME || {}));
|
||||
return AIRTIME;
|
||||
})(AIRTIME || {});
|
||||
|
||||
$(document).ready(AIRTIME.template.onReady);
|
||||
|
|
|
@ -1,129 +1,153 @@
|
|||
function setWatchedDirEvents() {
|
||||
$("#storageFolder-selection").serverBrowser({
|
||||
onSelect: function (path) {
|
||||
$("#storageFolder").val(path);
|
||||
},
|
||||
onLoad: function () {
|
||||
return $("#storageFolder").val();
|
||||
},
|
||||
width: 500,
|
||||
height: 250,
|
||||
position: ["center", "center"],
|
||||
//knownPaths: [{text:'Desktop', image:'desktop.png', path:'/home'}],
|
||||
knownPaths: [],
|
||||
imageUrl: "img/icons/",
|
||||
systemImageUrl: baseUrl + "css/img/",
|
||||
handlerUrl: baseUrl + "Preference/server-browse/format/json",
|
||||
title: $.i18n._("Choose Storage Folder"),
|
||||
basePath: "",
|
||||
requestMethod: "POST",
|
||||
});
|
||||
|
||||
$('#storageFolder-selection').serverBrowser({
|
||||
onSelect: function(path) {
|
||||
$('#storageFolder').val(path);
|
||||
},
|
||||
onLoad: function() {
|
||||
return $('#storageFolder').val();
|
||||
},
|
||||
width: 500,
|
||||
height: 250,
|
||||
position: ['center', 'center'],
|
||||
//knownPaths: [{text:'Desktop', image:'desktop.png', path:'/home'}],
|
||||
knownPaths: [],
|
||||
imageUrl: 'img/icons/',
|
||||
systemImageUrl: baseUrl+'css/img/',
|
||||
handlerUrl: baseUrl+'Preference/server-browse/format/json',
|
||||
title: $.i18n._('Choose Storage Folder'),
|
||||
basePath: '',
|
||||
requestMethod: 'POST',
|
||||
});
|
||||
$("#watchedFolder-selection").serverBrowser({
|
||||
onSelect: function (path) {
|
||||
$("#watchedFolder").val(path);
|
||||
},
|
||||
onLoad: function () {
|
||||
return $("#watchedFolder").val();
|
||||
},
|
||||
width: 500,
|
||||
height: 250,
|
||||
position: ["center", "center"],
|
||||
//knownPaths: [{text:'Desktop', image:'desktop.png', path:'/home'}],
|
||||
knownPaths: [],
|
||||
imageUrl: "img/icons/",
|
||||
systemImageUrl: baseUrl + "css/img/",
|
||||
handlerUrl: baseUrl + "Preference/server-browse/format/json",
|
||||
title: $.i18n._("Choose Folder to Watch"),
|
||||
basePath: "",
|
||||
requestMethod: "POST",
|
||||
});
|
||||
|
||||
$('#watchedFolder-selection').serverBrowser({
|
||||
onSelect: function(path) {
|
||||
$('#watchedFolder').val(path);
|
||||
},
|
||||
onLoad: function() {
|
||||
return $('#watchedFolder').val();
|
||||
},
|
||||
width: 500,
|
||||
height: 250,
|
||||
position: ['center', 'center'],
|
||||
//knownPaths: [{text:'Desktop', image:'desktop.png', path:'/home'}],
|
||||
knownPaths: [],
|
||||
imageUrl: 'img/icons/',
|
||||
systemImageUrl: baseUrl+'css/img/',
|
||||
handlerUrl: baseUrl+'Preference/server-browse/format/json',
|
||||
title: $.i18n._('Choose Folder to Watch'),
|
||||
basePath: '',
|
||||
requestMethod: 'POST',
|
||||
});
|
||||
$("#storageFolder-ok").click(function () {
|
||||
var url, chosen;
|
||||
|
||||
$('#storageFolder-ok').click(function(){
|
||||
var url, chosen;
|
||||
if (
|
||||
confirm(
|
||||
sprintf(
|
||||
$.i18n._(
|
||||
"Are you sure you want to change the storage folder?\nThis will remove the files from your %s library!"
|
||||
),
|
||||
PRODUCT_NAME
|
||||
)
|
||||
)
|
||||
) {
|
||||
url = baseUrl + "Preference/change-stor-directory";
|
||||
chosen = $("#storageFolder").val();
|
||||
|
||||
if(confirm(sprintf($.i18n._("Are you sure you want to change the storage folder?\nThis will remove the files from your %s library!"), PRODUCT_NAME))){
|
||||
url = baseUrl+"Preference/change-stor-directory";
|
||||
chosen = $('#storageFolder').val();
|
||||
$.post(
|
||||
url,
|
||||
{ format: "json", dir: chosen, element: "storageFolder" },
|
||||
|
||||
$.post(url,
|
||||
{format: "json", dir: chosen, element: "storageFolder"},
|
||||
|
||||
function(json) {
|
||||
$("#watched-folder-section").empty();
|
||||
$("#watched-folder-section").append(json.subform);
|
||||
setWatchedDirEvents();
|
||||
});
|
||||
}
|
||||
else {
|
||||
$('#storageFolder').val("");
|
||||
function (json) {
|
||||
$("#watched-folder-section").empty();
|
||||
$("#watched-folder-section").append(json.subform);
|
||||
setWatchedDirEvents();
|
||||
}
|
||||
);
|
||||
} else {
|
||||
$("#storageFolder").val("");
|
||||
}
|
||||
});
|
||||
|
||||
$("#watchedFolder-ok").click(function () {
|
||||
var url, chosen;
|
||||
|
||||
url = baseUrl + "Preference/reload-watch-directory";
|
||||
chosen = $("#watchedFolder").val();
|
||||
|
||||
$.post(
|
||||
url,
|
||||
{ format: "json", dir: chosen, element: "watchedFolder" },
|
||||
|
||||
function (json) {
|
||||
$("#watched-folder-section").empty();
|
||||
$("#watched-folder-section").append(
|
||||
"<h2>" + $.i18n._("Manage Media Folders") + "</h2>"
|
||||
);
|
||||
$("#watched-folder-section").append(json.subform);
|
||||
setWatchedDirEvents();
|
||||
}
|
||||
);
|
||||
});
|
||||
|
||||
$(".selected-item")
|
||||
.find(".ui-icon-refresh")
|
||||
.click(function () {
|
||||
var folder = $(this).prev().text();
|
||||
$.get(baseUrl + "Preference/rescan-watch-directory", {
|
||||
format: "json",
|
||||
dir: folder,
|
||||
});
|
||||
});
|
||||
|
||||
$('#watchedFolder-ok').click(function(){
|
||||
var url, chosen;
|
||||
$(".selected-item")
|
||||
.find(".ui-icon-close")
|
||||
.click(function () {
|
||||
if (
|
||||
confirm($.i18n._("Are you sure you want to remove the watched folder?"))
|
||||
) {
|
||||
var row = $(this).parent();
|
||||
var folder = row.find("#folderPath").text();
|
||||
|
||||
url = baseUrl+"Preference/reload-watch-directory";
|
||||
chosen = $('#watchedFolder').val();
|
||||
url = baseUrl + "Preference/remove-watch-directory";
|
||||
|
||||
$.post(url,
|
||||
{format: "json", dir: chosen, element: "watchedFolder"},
|
||||
$.post(
|
||||
url,
|
||||
{ format: "json", dir: folder },
|
||||
|
||||
function(json) {
|
||||
$("#watched-folder-section").empty();
|
||||
$("#watched-folder-section").append("<h2>"+$.i18n._("Manage Media Folders")+"</h2>");
|
||||
$("#watched-folder-section").append(json.subform);
|
||||
setWatchedDirEvents();
|
||||
});
|
||||
});
|
||||
|
||||
$('.selected-item').find('.ui-icon-refresh').click(function(){
|
||||
var folder = $(this).prev().text();
|
||||
$.get(baseUrl+"Preference/rescan-watch-directory", {format: "json", dir: folder});
|
||||
});
|
||||
|
||||
$('.selected-item').find('.ui-icon-close').click(function(){
|
||||
if(confirm($.i18n._("Are you sure you want to remove the watched folder?"))){
|
||||
var row = $(this).parent();
|
||||
var folder = row.find('#folderPath').text();
|
||||
|
||||
url = baseUrl+"Preference/remove-watch-directory";
|
||||
|
||||
$.post(url,
|
||||
{format: "json", dir: folder},
|
||||
|
||||
function(json) {
|
||||
$("#watched-folder-section").empty();
|
||||
$("#watched-folder-section").append("<h2>"+$.i18n._("Manage Media Folders")+"</h2>");
|
||||
$("#watched-folder-section").append(json.subform);
|
||||
setWatchedDirEvents();
|
||||
});
|
||||
}
|
||||
function (json) {
|
||||
$("#watched-folder-section").empty();
|
||||
$("#watched-folder-section").append(
|
||||
"<h2>" + $.i18n._("Manage Media Folders") + "</h2>"
|
||||
);
|
||||
$("#watched-folder-section").append(json.subform);
|
||||
setWatchedDirEvents();
|
||||
}
|
||||
);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
$(document).ready(function() {
|
||||
|
||||
setWatchedDirEvents();
|
||||
$(".ui-icon-alert").qtip({
|
||||
content: {
|
||||
text: $.i18n._("This path is currently not accessible.")
|
||||
},
|
||||
position:{
|
||||
adjust: {
|
||||
resize: true,
|
||||
method: "flip flip"
|
||||
},
|
||||
at: "right center",
|
||||
my: "left top",
|
||||
viewport: $(window)
|
||||
},
|
||||
style: {
|
||||
classes: "ui-tooltip-dark"
|
||||
},
|
||||
show: 'mouseover',
|
||||
hide: 'mouseout'
|
||||
});
|
||||
|
||||
$(document).ready(function () {
|
||||
setWatchedDirEvents();
|
||||
$(".ui-icon-alert").qtip({
|
||||
content: {
|
||||
text: $.i18n._("This path is currently not accessible."),
|
||||
},
|
||||
position: {
|
||||
adjust: {
|
||||
resize: true,
|
||||
method: "flip flip",
|
||||
},
|
||||
at: "right center",
|
||||
my: "left top",
|
||||
viewport: $(window),
|
||||
},
|
||||
style: {
|
||||
classes: "ui-tooltip-dark",
|
||||
},
|
||||
show: "mouseover",
|
||||
hide: "mouseout",
|
||||
});
|
||||
});
|
||||
|
|
|
@ -1,146 +1,155 @@
|
|||
function showErrorSections() {
|
||||
var selector = $("[id$=-settings]");
|
||||
selector.each(function(i) {
|
||||
var el = $(this);
|
||||
var errors = el.find(".errors");
|
||||
if (errors.length > 0) {
|
||||
el.show();
|
||||
$(window).scrollTop(errors.position().top);
|
||||
}
|
||||
});
|
||||
var selector = $("[id$=-settings]");
|
||||
selector.each(function (i) {
|
||||
var el = $(this);
|
||||
var errors = el.find(".errors");
|
||||
if (errors.length > 0) {
|
||||
el.show();
|
||||
$(window).scrollTop(errors.position().top);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
function setConfigureMailServerListener() {
|
||||
var configMailServer = $("#configureMailServer");
|
||||
configMailServer.click(function(event){
|
||||
setMailServerInputReadonly();
|
||||
});
|
||||
var configMailServer = $("#configureMailServer");
|
||||
configMailServer.click(function (event) {
|
||||
setMailServerInputReadonly();
|
||||
});
|
||||
|
||||
var msRequiresAuth = $("#msRequiresAuth");
|
||||
msRequiresAuth.click(function(event){
|
||||
setMsAuthenticationFieldsReadonly($(this));
|
||||
});
|
||||
var msRequiresAuth = $("#msRequiresAuth");
|
||||
msRequiresAuth.click(function (event) {
|
||||
setMsAuthenticationFieldsReadonly($(this));
|
||||
});
|
||||
}
|
||||
|
||||
function setEnableSystemEmailsListener() {
|
||||
var enableSystemEmails = $("#enableSystemEmail");
|
||||
enableSystemEmails.click(function(event){
|
||||
setSystemFromEmailReadonly();
|
||||
});
|
||||
var enableSystemEmails = $("#enableSystemEmail");
|
||||
enableSystemEmails.click(function (event) {
|
||||
setSystemFromEmailReadonly();
|
||||
});
|
||||
}
|
||||
|
||||
function setPodcastAutoSmartblockReadonly() {
|
||||
var disablePodcastAutomSmartblock = $("#podcastAutoSmartblock-0");
|
||||
var enablePodcastAutomSmartblock = $("#podcastAutoSmartblock-1");
|
||||
var podcastOverride = $("#podcastAlbumOverride-1");
|
||||
if ($(podcastOverride).is(':checked')) {
|
||||
enablePodcastAutomSmartblock.removeAttr("readonly");
|
||||
} else {
|
||||
disablePodcastAutomSmartblock.prop("checked", true);
|
||||
disablePodcastAutomSmartblock.attr("readonly","readonly");
|
||||
enablePodcastAutomSmartblock.attr("readonly","readonly");
|
||||
}
|
||||
var disablePodcastAutomSmartblock = $("#podcastAutoSmartblock-0");
|
||||
var enablePodcastAutomSmartblock = $("#podcastAutoSmartblock-1");
|
||||
var podcastOverride = $("#podcastAlbumOverride-1");
|
||||
if ($(podcastOverride).is(":checked")) {
|
||||
enablePodcastAutomSmartblock.removeAttr("readonly");
|
||||
} else {
|
||||
disablePodcastAutomSmartblock.prop("checked", true);
|
||||
disablePodcastAutomSmartblock.attr("readonly", "readonly");
|
||||
enablePodcastAutomSmartblock.attr("readonly", "readonly");
|
||||
}
|
||||
}
|
||||
|
||||
function setSystemFromEmailReadonly() {
|
||||
var enableSystemEmails = $("#enableSystemEmail");
|
||||
var systemFromEmail = $("#systemEmail");
|
||||
if ($(enableSystemEmails).is(':checked')) {
|
||||
systemFromEmail.removeAttr("readonly");
|
||||
} else {
|
||||
systemFromEmail.attr("readonly", "readonly");
|
||||
}
|
||||
var enableSystemEmails = $("#enableSystemEmail");
|
||||
var systemFromEmail = $("#systemEmail");
|
||||
if ($(enableSystemEmails).is(":checked")) {
|
||||
systemFromEmail.removeAttr("readonly");
|
||||
} else {
|
||||
systemFromEmail.attr("readonly", "readonly");
|
||||
}
|
||||
}
|
||||
|
||||
function setMailServerInputReadonly() {
|
||||
var configMailServer = $("#configureMailServer");
|
||||
var mailServer = $("#mailServer");
|
||||
var port = $("#port");
|
||||
var requiresAuthCB = $("#msRequiresAuth");
|
||||
var configMailServer = $("#configureMailServer");
|
||||
var mailServer = $("#mailServer");
|
||||
var port = $("#port");
|
||||
var requiresAuthCB = $("#msRequiresAuth");
|
||||
|
||||
if (configMailServer.is(':checked')) {
|
||||
mailServer.removeAttr("readonly");
|
||||
port.removeAttr("readonly");
|
||||
requiresAuthCB.parent().show();
|
||||
} else {
|
||||
mailServer.attr("readonly", "readonly");
|
||||
port.attr("readonly", "readonly");
|
||||
requiresAuthCB.parent().hide();
|
||||
}
|
||||
if (configMailServer.is(":checked")) {
|
||||
mailServer.removeAttr("readonly");
|
||||
port.removeAttr("readonly");
|
||||
requiresAuthCB.parent().show();
|
||||
} else {
|
||||
mailServer.attr("readonly", "readonly");
|
||||
port.attr("readonly", "readonly");
|
||||
requiresAuthCB.parent().hide();
|
||||
}
|
||||
|
||||
setMsAuthenticationFieldsReadonly(requiresAuthCB);
|
||||
setMsAuthenticationFieldsReadonly(requiresAuthCB);
|
||||
}
|
||||
|
||||
function setTuneInSettingsListener() {
|
||||
var enableTunein = $("#enable_tunein");
|
||||
enableTunein.click(function(event){
|
||||
setTuneInSettingsReadonly();
|
||||
});
|
||||
var enableTunein = $("#enable_tunein");
|
||||
enableTunein.click(function (event) {
|
||||
setTuneInSettingsReadonly();
|
||||
});
|
||||
}
|
||||
|
||||
function setTuneInSettingsReadonly() {
|
||||
var enableTunein = $("#enable_tunein");
|
||||
var stationId = $("#tunein_station_id");
|
||||
var partnerKey = $("#tunein_partner_key");
|
||||
var partnerId = $("#tunein_partner_id");
|
||||
var enableTunein = $("#enable_tunein");
|
||||
var stationId = $("#tunein_station_id");
|
||||
var partnerKey = $("#tunein_partner_key");
|
||||
var partnerId = $("#tunein_partner_id");
|
||||
|
||||
if (enableTunein.is(':checked')) {
|
||||
stationId.removeAttr("readonly");
|
||||
partnerKey.removeAttr("readonly");
|
||||
partnerId.removeAttr("readonly");
|
||||
} else {
|
||||
stationId.attr("readonly", "readonly");
|
||||
partnerKey.attr("readonly", "readonly");
|
||||
partnerId.attr("readonly", "readonly");
|
||||
}
|
||||
if (enableTunein.is(":checked")) {
|
||||
stationId.removeAttr("readonly");
|
||||
partnerKey.removeAttr("readonly");
|
||||
partnerId.removeAttr("readonly");
|
||||
} else {
|
||||
stationId.attr("readonly", "readonly");
|
||||
partnerKey.attr("readonly", "readonly");
|
||||
partnerId.attr("readonly", "readonly");
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* Enable/disable mail server authentication fields
|
||||
*/
|
||||
function setMsAuthenticationFieldsReadonly(ele) {
|
||||
var email = $("#email");
|
||||
var password = $("#ms_password");
|
||||
var configureMailServer = $("#configureMailServer");
|
||||
var email = $("#email");
|
||||
var password = $("#ms_password");
|
||||
var configureMailServer = $("#configureMailServer");
|
||||
|
||||
if (ele.is(':checked') && configureMailServer.is(':checked')) {
|
||||
email.removeAttr("readonly");
|
||||
password.removeAttr("readonly");
|
||||
} else if (ele.not(':checked') || configureMailServer.not(':checked')) {
|
||||
email.attr("readonly", "readonly");
|
||||
password.attr("readonly", "readonly");
|
||||
}
|
||||
if (ele.is(":checked") && configureMailServer.is(":checked")) {
|
||||
email.removeAttr("readonly");
|
||||
password.removeAttr("readonly");
|
||||
} else if (ele.not(":checked") || configureMailServer.not(":checked")) {
|
||||
email.attr("readonly", "readonly");
|
||||
password.attr("readonly", "readonly");
|
||||
}
|
||||
}
|
||||
|
||||
function removeLogo() {
|
||||
$.post(baseUrl+'preference/remove-logo', {'csrf_token' : $('#csrf').val()}, function(json){
|
||||
// Reload without resubmitting the form
|
||||
location.href = location.href.replace(location.hash,"");
|
||||
});
|
||||
$.post(
|
||||
baseUrl + "preference/remove-logo",
|
||||
{ csrf_token: $("#csrf").val() },
|
||||
function (json) {
|
||||
// Reload without resubmitting the form
|
||||
location.href = location.href.replace(location.hash, "");
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
function deleteAllFiles() {
|
||||
var resp = confirm($.i18n._("Are you sure you want to delete all the tracks in your library?"))
|
||||
if (resp) {
|
||||
$.post(baseUrl+'preference/delete-all-files', {'csrf_token' : $('#csrf').val()}, function(json){
|
||||
location.reload();
|
||||
});
|
||||
}
|
||||
var resp = confirm(
|
||||
$.i18n._("Are you sure you want to delete all the tracks in your library?")
|
||||
);
|
||||
if (resp) {
|
||||
$.post(
|
||||
baseUrl + "preference/delete-all-files",
|
||||
{ csrf_token: $("#csrf").val() },
|
||||
function (json) {
|
||||
location.reload();
|
||||
}
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
$(document).ready(function() {
|
||||
$(document).ready(function () {
|
||||
$(".collapsible-header").live("click", function () {
|
||||
$(this).next().toggle("fast");
|
||||
$(this).toggleClass("closed");
|
||||
return false;
|
||||
});
|
||||
|
||||
$('.collapsible-header').live('click',function() {
|
||||
$(this).next().toggle('fast');
|
||||
$(this).toggleClass("closed");
|
||||
return false;
|
||||
});
|
||||
if ($("#tunein-settings").find(".errors").length > 0) {
|
||||
$(".collapsible-content#tunein-settings").show();
|
||||
}
|
||||
|
||||
if ($("#tunein-settings").find(".errors").length > 0) {
|
||||
$(".collapsible-content#tunein-settings").show();
|
||||
}
|
||||
|
||||
/* No longer using AJAX for this form. Zend + our code makes it needlessly hard to deal with. -- Albert
|
||||
/* No longer using AJAX for this form. Zend + our code makes it needlessly hard to deal with. -- Albert
|
||||
$('#pref_save').live('click', function() {
|
||||
var data = $('#pref_form').serialize();
|
||||
var url = baseUrl+'Preference/index';
|
||||
|
@ -155,43 +164,43 @@ $(document).ready(function() {
|
|||
});
|
||||
});*/
|
||||
|
||||
// when an image is uploaded, preview it to the user
|
||||
var logo = $("#stationLogo"),
|
||||
preview = $("#logo-img");
|
||||
logo.change(function(e) {
|
||||
if (this.files && this.files[0]) {
|
||||
preview.show();
|
||||
var reader = new FileReader(); // browser compatibility?
|
||||
reader.onload = function (e) {
|
||||
console.log("Reader loaded");
|
||||
preview.attr('src', e.target.result);
|
||||
};
|
||||
// when an image is uploaded, preview it to the user
|
||||
var logo = $("#stationLogo"),
|
||||
preview = $("#logo-img");
|
||||
logo.change(function (e) {
|
||||
if (this.files && this.files[0]) {
|
||||
preview.show();
|
||||
var reader = new FileReader(); // browser compatibility?
|
||||
reader.onload = function (e) {
|
||||
console.log("Reader loaded");
|
||||
preview.attr("src", e.target.result);
|
||||
};
|
||||
|
||||
// check image size so we don't crash the page trying to render
|
||||
if (validateImage(this.files[0], logo)) {
|
||||
// read the image data as though it were a data URI
|
||||
reader.readAsDataURL(this.files[0]);
|
||||
} else {
|
||||
// remove the file element data
|
||||
$(this).val('').replaceWith($(this).clone(true));
|
||||
preview.hide();
|
||||
}
|
||||
} else {
|
||||
preview.hide();
|
||||
}
|
||||
});
|
||||
|
||||
if (preview.attr('src').indexOf('images/') > -1) {
|
||||
$("#logo-remove-btn").hide();
|
||||
// check image size so we don't crash the page trying to render
|
||||
if (validateImage(this.files[0], logo)) {
|
||||
// read the image data as though it were a data URI
|
||||
reader.readAsDataURL(this.files[0]);
|
||||
} else {
|
||||
// remove the file element data
|
||||
$(this).val("").replaceWith($(this).clone(true));
|
||||
preview.hide();
|
||||
}
|
||||
} else {
|
||||
preview.hide();
|
||||
}
|
||||
});
|
||||
|
||||
showErrorSections();
|
||||
if (preview.attr("src").indexOf("images/") > -1) {
|
||||
$("#logo-remove-btn").hide();
|
||||
}
|
||||
|
||||
setMailServerInputReadonly();
|
||||
setPodcastAutoSmartblockReadonly();
|
||||
setSystemFromEmailReadonly();
|
||||
setConfigureMailServerListener();
|
||||
setEnableSystemEmailsListener();
|
||||
setTuneInSettingsReadonly();
|
||||
setTuneInSettingsListener();
|
||||
showErrorSections();
|
||||
|
||||
setMailServerInputReadonly();
|
||||
setPodcastAutoSmartblockReadonly();
|
||||
setSystemFromEmailReadonly();
|
||||
setConfigureMailServerListener();
|
||||
setEnableSystemEmailsListener();
|
||||
setTuneInSettingsReadonly();
|
||||
setTuneInSettingsListener();
|
||||
});
|
||||
|
|
File diff suppressed because it is too large
Load diff
File diff suppressed because it is too large
Load diff
File diff suppressed because it is too large
Load diff
File diff suppressed because it is too large
Load diff
File diff suppressed because it is too large
Load diff
|
@ -1,376 +1,382 @@
|
|||
AIRTIME = (function(AIRTIME) {
|
||||
AIRTIME = (function (AIRTIME) {
|
||||
var viewport,
|
||||
$lib,
|
||||
$libWrapper,
|
||||
$builder,
|
||||
$fs,
|
||||
widgetHeight,
|
||||
screenWidth,
|
||||
resizeTimeout,
|
||||
oBaseDatePickerSettings,
|
||||
oBaseTimePickerSettings,
|
||||
oRange,
|
||||
dateStartId = "#sb_date_start",
|
||||
timeStartId = "#sb_time_start",
|
||||
dateEndId = "#sb_date_end",
|
||||
timeEndId = "#sb_time_end",
|
||||
mod;
|
||||
|
||||
var viewport,
|
||||
$lib,
|
||||
$libWrapper,
|
||||
$builder,
|
||||
$fs,
|
||||
widgetHeight,
|
||||
screenWidth,
|
||||
resizeTimeout,
|
||||
oBaseDatePickerSettings,
|
||||
oBaseTimePickerSettings,
|
||||
oRange,
|
||||
dateStartId = "#sb_date_start",
|
||||
timeStartId = "#sb_time_start",
|
||||
dateEndId = "#sb_date_end",
|
||||
timeEndId = "#sb_time_end",
|
||||
mod;
|
||||
if (AIRTIME.builderMain === undefined) {
|
||||
AIRTIME.builderMain = {};
|
||||
}
|
||||
mod = AIRTIME.builderMain;
|
||||
|
||||
if (AIRTIME.builderMain === undefined) {
|
||||
AIRTIME.builderMain = {};
|
||||
oBaseDatePickerSettings = {
|
||||
dateFormat: "yy-mm-dd",
|
||||
//i18n_months, i18n_days_short are in common.js
|
||||
monthNames: i18n_months,
|
||||
dayNamesMin: i18n_days_short,
|
||||
onClick: function (sDate, oDatePicker) {
|
||||
$(this).datepicker("setDate", sDate);
|
||||
},
|
||||
onClose: validateTimeRange,
|
||||
};
|
||||
|
||||
oBaseTimePickerSettings = {
|
||||
showPeriodLabels: false,
|
||||
showCloseButton: true,
|
||||
closeButtonText: $.i18n._("Done"),
|
||||
showLeadingZero: false,
|
||||
defaultTime: "0:00",
|
||||
hourText: $.i18n._("Hour"),
|
||||
minuteText: $.i18n._("Minute"),
|
||||
onClose: validateTimeRange,
|
||||
};
|
||||
|
||||
function setWidgetSize() {
|
||||
viewport = AIRTIME.utilities.findViewportDimensions();
|
||||
widgetHeight = viewport.height - 180;
|
||||
screenWidth = Math.floor(viewport.width - 50);
|
||||
|
||||
var libTableHeight = widgetHeight - 175,
|
||||
builderTableHeight = widgetHeight - 95,
|
||||
oTable;
|
||||
|
||||
if ($fs.is(":visible")) {
|
||||
builderTableHeight = builderTableHeight - 40;
|
||||
}
|
||||
mod = AIRTIME.builderMain;
|
||||
|
||||
oBaseDatePickerSettings = {
|
||||
dateFormat: 'yy-mm-dd',
|
||||
//i18n_months, i18n_days_short are in common.js
|
||||
monthNames: i18n_months,
|
||||
dayNamesMin: i18n_days_short,
|
||||
onClick: function(sDate, oDatePicker) {
|
||||
$(this).datepicker( "setDate", sDate );
|
||||
//set the heights of the main widgets.
|
||||
$builder //.height(widgetHeight)
|
||||
.find(".dataTables_scrolling")
|
||||
//.css("max-height", builderTableHeight)
|
||||
.end();
|
||||
//.width(screenWidth);
|
||||
|
||||
$lib //.height(widgetHeight)
|
||||
.find(".dataTables_scrolling")
|
||||
//.css("max-height", libTableHeight)
|
||||
.end();
|
||||
|
||||
if ($lib.filter(":visible").length > 0) {
|
||||
//$lib.width(Math.floor(screenWidth * 0.47));
|
||||
|
||||
$builder //.width(Math.floor(screenWidth * 0.47))
|
||||
.find("#sb_edit")
|
||||
.remove()
|
||||
.end()
|
||||
.find("#sb_date_start")
|
||||
.css("margin-left", 0)
|
||||
.end();
|
||||
|
||||
oTable = $("#show_builder_table").dataTable();
|
||||
//oTable.fnDraw();
|
||||
}
|
||||
}
|
||||
|
||||
function showSearchSubmit() {
|
||||
var fn,
|
||||
op,
|
||||
oTable = $("#show_builder_table").dataTable(),
|
||||
check;
|
||||
|
||||
check = validateTimeRange();
|
||||
|
||||
if (check.isValid) {
|
||||
//reset timestamp value since input values could have changed.
|
||||
AIRTIME.showbuilder.resetTimestamp();
|
||||
|
||||
fn = oTable.fnSettings().fnServerData;
|
||||
fn.start = check.start;
|
||||
fn.end = check.end;
|
||||
|
||||
op = $("div.sb-options-form");
|
||||
if (op.is(":visible")) {
|
||||
if (fn.ops === undefined) {
|
||||
fn.ops = {};
|
||||
}
|
||||
fn.ops.showFilter = op.find("#sb_show_filter").val();
|
||||
// Hacky?
|
||||
fn.ops.myShows = fn.ops.showFilter == -1 ? 1 : 0;
|
||||
}
|
||||
|
||||
oTable.fnDraw();
|
||||
}
|
||||
}
|
||||
|
||||
function highlightMediaTypeSelector() {
|
||||
$(".media_type_selector:first").addClass("highlight");
|
||||
var selected;
|
||||
if (location.hash === "") {
|
||||
location.hash = "tracks";
|
||||
selected = $("a[href$='#tracks']");
|
||||
} else {
|
||||
selected = $("a[href$='" + location.hash + "']");
|
||||
}
|
||||
|
||||
selected.parent().addClass("selected");
|
||||
$("#library_filter").text(selected.text());
|
||||
|
||||
$(window).on("hashchange", function () {
|
||||
var selected = $("a[href$='" + location.hash + "']"),
|
||||
dashboardLink = $(".media_type_selector:first"),
|
||||
tableType;
|
||||
|
||||
if (
|
||||
selected.parent().data("selection-id") ==
|
||||
AIRTIME.library.MediaTypeIntegerEnum.PODCAST
|
||||
) {
|
||||
tableType = AIRTIME.library.DataTableTypeEnum.PODCAST;
|
||||
} else {
|
||||
tableType = AIRTIME.library.DataTableTypeEnum.LIBRARY;
|
||||
}
|
||||
|
||||
dashboardLink.find("a").attr("href", selected.attr("href"));
|
||||
AIRTIME.library.selectNone();
|
||||
$(".media_type_selector").each(function () {
|
||||
$(this).removeClass("selected");
|
||||
});
|
||||
selected.parent().addClass("selected");
|
||||
AIRTIME.library.setCurrentTable(tableType);
|
||||
$("#library_filter").text(selected.text());
|
||||
// Highlight the dashboard link
|
||||
dashboardLink.addClass("highlight");
|
||||
});
|
||||
}
|
||||
|
||||
mod.onReady = function () {
|
||||
// Normally we would just use audio/*, but it includes file types that we can't handle (like .m4a)
|
||||
// We initialize the acceptedMimeTypes variable in Bootstrap so we don't have to duplicate the list
|
||||
Dropzone.options.content = {
|
||||
url: "/rest/media",
|
||||
clickable: false,
|
||||
acceptedFiles: acceptedMimeTypes.join(),
|
||||
init: function () {
|
||||
this.on("sending", function (file, xhr, data) {
|
||||
data.append("csrf_token", $("#csrf").val());
|
||||
});
|
||||
},
|
||||
dictDefaultMessage: "",
|
||||
createImageThumbnails: false,
|
||||
previewTemplate: '<div style="display:none"></div>',
|
||||
};
|
||||
|
||||
// define module vars.
|
||||
$lib = $("#library_content");
|
||||
$builder = $("#show_builder");
|
||||
$fs = $builder.find("fieldset");
|
||||
|
||||
//Highlight the media type selector we're currently on.
|
||||
highlightMediaTypeSelector();
|
||||
|
||||
// always re-show builder if dashboard button was clicked
|
||||
$(".media_type_selector:first").on("click", function () {
|
||||
$builder.show();
|
||||
AIRTIME.tabs.openScheduleTab();
|
||||
});
|
||||
|
||||
/*
|
||||
* Icon hover states for search.
|
||||
*/
|
||||
$builder.on("mouseenter", ".sb-timerange .ui-button", function (ev) {
|
||||
$(this).addClass("ui-state-hover");
|
||||
});
|
||||
$builder.on("mouseleave", ".sb-timerange .ui-button", function (ev) {
|
||||
$(this).removeClass("ui-state-hover");
|
||||
});
|
||||
|
||||
$builder
|
||||
.find(dateStartId)
|
||||
.datepicker(oBaseDatePickerSettings)
|
||||
.blur(validateTimeRange);
|
||||
|
||||
$builder
|
||||
.find(timeStartId)
|
||||
.timepicker(oBaseTimePickerSettings)
|
||||
.blur(validateTimeRange);
|
||||
|
||||
$builder
|
||||
.find(dateEndId)
|
||||
.datepicker(oBaseDatePickerSettings)
|
||||
.blur(validateTimeRange);
|
||||
|
||||
$builder
|
||||
.find(timeEndId)
|
||||
.timepicker(oBaseTimePickerSettings)
|
||||
.blur(validateTimeRange);
|
||||
|
||||
oRange = AIRTIME.utilities.fnGetScheduleRange(
|
||||
dateStartId,
|
||||
timeStartId,
|
||||
dateEndId,
|
||||
timeEndId
|
||||
);
|
||||
AIRTIME.showbuilder.fnServerData.start = oRange.start;
|
||||
AIRTIME.showbuilder.fnServerData.end = oRange.end;
|
||||
|
||||
//the user might not have the library on the page (guest user)
|
||||
if (AIRTIME.library !== undefined) {
|
||||
AIRTIME.library.libraryInit();
|
||||
}
|
||||
|
||||
AIRTIME.showbuilder.builderDataTable();
|
||||
setWidgetSize();
|
||||
|
||||
$libWrapper = $lib.find("#library_display_wrapper");
|
||||
//$builder.find('.dataTables_scrolling').css("max-height",
|
||||
// widgetHeight - 95);
|
||||
|
||||
$builder.on("click", "#sb_submit", showSearchSubmit);
|
||||
|
||||
$builder.on("click", "#sb_edit", function (ev) {
|
||||
var schedTable = $("#show_builder_table").dataTable();
|
||||
|
||||
// reset timestamp to redraw the cursors.
|
||||
AIRTIME.showbuilder.resetTimestamp();
|
||||
|
||||
$lib.show().width(Math.floor(screenWidth * 0.48));
|
||||
|
||||
$builder
|
||||
.width(Math.floor(screenWidth * 0.48))
|
||||
.find("#sb_edit")
|
||||
.remove()
|
||||
.end()
|
||||
.find("#sb_date_start")
|
||||
.css("margin-left", 0)
|
||||
.end();
|
||||
|
||||
schedTable.fnDraw();
|
||||
|
||||
$.ajax({
|
||||
url: baseUrl + "usersettings/set-now-playing-screen-settings",
|
||||
type: "POST",
|
||||
data: {
|
||||
settings: {
|
||||
library: true,
|
||||
},
|
||||
format: "json",
|
||||
},
|
||||
onClose: validateTimeRange
|
||||
};
|
||||
dataType: "json",
|
||||
success: function () {},
|
||||
});
|
||||
});
|
||||
|
||||
oBaseTimePickerSettings = {
|
||||
showPeriodLabels: false,
|
||||
showCloseButton: true,
|
||||
closeButtonText: $.i18n._("Done"),
|
||||
showLeadingZero: false,
|
||||
defaultTime: '0:00',
|
||||
hourText: $.i18n._("Hour"),
|
||||
minuteText: $.i18n._("Minute"),
|
||||
onClose: validateTimeRange
|
||||
};
|
||||
$lib.on("click", "#sb_lib_close", function () {
|
||||
var schedTable = $("#show_builder_table").dataTable();
|
||||
|
||||
function setWidgetSize() {
|
||||
viewport = AIRTIME.utilities.findViewportDimensions();
|
||||
widgetHeight = viewport.height - 180;
|
||||
screenWidth = Math.floor(viewport.width - 50);
|
||||
$lib.hide();
|
||||
$builder
|
||||
.width(screenWidth)
|
||||
.find(".sb-timerange")
|
||||
.find("#sb_date_start")
|
||||
.css("margin-left", 30)
|
||||
.end()
|
||||
.end();
|
||||
|
||||
var libTableHeight = widgetHeight - 175,
|
||||
builderTableHeight = widgetHeight - 95,
|
||||
oTable;
|
||||
schedTable.fnDraw();
|
||||
|
||||
if ($fs.is(':visible')) {
|
||||
builderTableHeight = builderTableHeight - 40;
|
||||
}
|
||||
$.ajax({
|
||||
url: baseUrl + "usersettings/set-now-playing-screen-settings",
|
||||
type: "POST",
|
||||
data: {
|
||||
settings: {
|
||||
library: false,
|
||||
},
|
||||
format: "json",
|
||||
},
|
||||
dataType: "json",
|
||||
success: function () {},
|
||||
});
|
||||
});
|
||||
|
||||
//set the heights of the main widgets.
|
||||
$builder//.height(widgetHeight)
|
||||
.find(".dataTables_scrolling")
|
||||
//.css("max-height", builderTableHeight)
|
||||
.end();
|
||||
//.width(screenWidth);
|
||||
$builder.find("legend").click(function (ev, item) {
|
||||
if ($fs.hasClass("closed")) {
|
||||
$fs.removeClass("closed");
|
||||
//$builder.find('.dataTables_scrolling').css(
|
||||
// "max-height", widgetHeight - 150);
|
||||
} else {
|
||||
$fs.addClass("closed");
|
||||
|
||||
$lib//.height(widgetHeight)
|
||||
.find(".dataTables_scrolling")
|
||||
//.css("max-height", libTableHeight)
|
||||
.end();
|
||||
// set defaults for the options.
|
||||
$fs.find("select").val(0);
|
||||
$fs.find('input[type="checkbox"]').attr("checked", false);
|
||||
//$builder.find('.dataTables_scrolling').css(
|
||||
// "max-height", widgetHeight - 110);
|
||||
}
|
||||
});
|
||||
|
||||
if ($lib.filter(':visible').length > 0) {
|
||||
// set click event for all my shows checkbox.
|
||||
$builder.on("click", "#sb_my_shows", function (ev) {
|
||||
if ($(this).is(":checked")) {
|
||||
$(ev.delegateTarget).find("#sb_show_filter").val(0);
|
||||
}
|
||||
|
||||
//$lib.width(Math.floor(screenWidth * 0.47));
|
||||
showSearchSubmit();
|
||||
});
|
||||
|
||||
$builder//.width(Math.floor(screenWidth * 0.47))
|
||||
.find("#sb_edit")
|
||||
.remove()
|
||||
.end()
|
||||
.find("#sb_date_start")
|
||||
.css("margin-left", 0)
|
||||
.end();
|
||||
//set select event for choosing a show.
|
||||
$builder.on("change", "#sb_show_filter", function (ev) {
|
||||
if ($(this).val() !== 0) {
|
||||
$(ev.delegateTarget).find("#sb_my_shows").attr("checked", false);
|
||||
}
|
||||
|
||||
oTable = $('#show_builder_table').dataTable();
|
||||
//oTable.fnDraw();
|
||||
}
|
||||
}
|
||||
showSearchSubmit();
|
||||
});
|
||||
|
||||
function showSearchSubmit() {
|
||||
var fn,
|
||||
op,
|
||||
oTable = $('#show_builder_table').dataTable(),
|
||||
check;
|
||||
function checkScheduleUpdates() {
|
||||
var data = {},
|
||||
oTable = $("#show_builder_table").dataTable(),
|
||||
fn = oTable.fnSettings().fnServerData,
|
||||
start = fn.start,
|
||||
end = fn.end;
|
||||
|
||||
check = validateTimeRange();
|
||||
data["format"] = "json";
|
||||
data["start"] = start;
|
||||
data["end"] = end;
|
||||
data["timestamp"] = AIRTIME.showbuilder.getTimestamp();
|
||||
data["instances"] = AIRTIME.showbuilder.getShowInstances();
|
||||
|
||||
if (check.isValid) {
|
||||
//reset timestamp value since input values could have changed.
|
||||
AIRTIME.showbuilder.resetTimestamp();
|
||||
|
||||
fn = oTable.fnSettings().fnServerData;
|
||||
fn.start = check.start;
|
||||
fn.end = check.end;
|
||||
|
||||
op = $("div.sb-options-form");
|
||||
if (op.is(":visible")) {
|
||||
|
||||
if (fn.ops === undefined) {
|
||||
fn.ops = {};
|
||||
}
|
||||
fn.ops.showFilter = op.find("#sb_show_filter").val();
|
||||
// Hacky?
|
||||
fn.ops.myShows = (fn.ops.showFilter == -1) ? 1 : 0;
|
||||
}
|
||||
if (fn.hasOwnProperty("ops")) {
|
||||
data["myShows"] = fn.ops.myShows;
|
||||
data["showFilter"] = fn.ops.showFilter;
|
||||
data["showInstanceFilter"] = fn.ops.showInstanceFilter;
|
||||
}
|
||||
|
||||
$.ajax({
|
||||
dataType: "json",
|
||||
type: "GET",
|
||||
url: baseUrl + "showbuilder/check-builder-feed",
|
||||
data: data,
|
||||
success: function (json) {
|
||||
if (json.update === true) {
|
||||
oTable.fnDraw();
|
||||
}
|
||||
}
|
||||
setTimeout(checkScheduleUpdates, 5000);
|
||||
},
|
||||
});
|
||||
|
||||
//check if the timeline view needs updating.
|
||||
setTimeout(checkScheduleUpdates, 5000);
|
||||
}
|
||||
};
|
||||
|
||||
function highlightMediaTypeSelector()
|
||||
{
|
||||
$(".media_type_selector:first").addClass("highlight");
|
||||
var selected;
|
||||
if (location.hash === "") {
|
||||
location.hash = "tracks";
|
||||
selected = $("a[href$='#tracks']");
|
||||
} else {
|
||||
selected = $("a[href$='"+location.hash+"']");
|
||||
}
|
||||
mod.onResize = function () {
|
||||
clearTimeout(resizeTimeout);
|
||||
resizeTimeout = setTimeout(setWidgetSize, 100);
|
||||
};
|
||||
|
||||
selected.parent().addClass("selected");
|
||||
$("#library_filter").text(selected.text());
|
||||
|
||||
$(window).on('hashchange', function() {
|
||||
var selected = $("a[href$='"+location.hash+"']"),
|
||||
dashboardLink = $(".media_type_selector:first"),
|
||||
tableType;
|
||||
|
||||
if (selected.parent().data("selection-id") == AIRTIME.library.MediaTypeIntegerEnum.PODCAST) {
|
||||
tableType = AIRTIME.library.DataTableTypeEnum.PODCAST;
|
||||
} else {
|
||||
tableType = AIRTIME.library.DataTableTypeEnum.LIBRARY;
|
||||
}
|
||||
|
||||
dashboardLink.find("a").attr("href", selected.attr("href"));
|
||||
AIRTIME.library.selectNone();
|
||||
$(".media_type_selector").each(function () {
|
||||
$(this).removeClass("selected");
|
||||
});
|
||||
selected.parent().addClass("selected");
|
||||
AIRTIME.library.setCurrentTable(tableType);
|
||||
$("#library_filter").text(selected.text());
|
||||
// Highlight the dashboard link
|
||||
dashboardLink.addClass("highlight");
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
mod.onReady = function() {
|
||||
// Normally we would just use audio/*, but it includes file types that we can't handle (like .m4a)
|
||||
// We initialize the acceptedMimeTypes variable in Bootstrap so we don't have to duplicate the list
|
||||
Dropzone.options.content = {
|
||||
url:'/rest/media',
|
||||
clickable: false,
|
||||
acceptedFiles: acceptedMimeTypes.join(),
|
||||
init: function () {
|
||||
this.on("sending", function (file, xhr, data) {
|
||||
data.append("csrf_token", $("#csrf").val());
|
||||
});
|
||||
},
|
||||
dictDefaultMessage: '',
|
||||
createImageThumbnails: false,
|
||||
previewTemplate : '<div style="display:none"></div>'
|
||||
};
|
||||
|
||||
// define module vars.
|
||||
$lib = $("#library_content");
|
||||
$builder = $("#show_builder");
|
||||
$fs = $builder.find('fieldset');
|
||||
|
||||
//Highlight the media type selector we're currently on.
|
||||
highlightMediaTypeSelector();
|
||||
|
||||
// always re-show builder if dashboard button was clicked
|
||||
$('.media_type_selector:first').on('click', function() {
|
||||
$builder.show();
|
||||
AIRTIME.tabs.openScheduleTab();
|
||||
});
|
||||
|
||||
/*
|
||||
* Icon hover states for search.
|
||||
*/
|
||||
$builder.on("mouseenter", ".sb-timerange .ui-button", function(ev) {
|
||||
$(this).addClass("ui-state-hover");
|
||||
});
|
||||
$builder.on("mouseleave", ".sb-timerange .ui-button", function(ev) {
|
||||
$(this).removeClass("ui-state-hover");
|
||||
});
|
||||
|
||||
$builder.find(dateStartId)
|
||||
.datepicker(oBaseDatePickerSettings)
|
||||
.blur(validateTimeRange);
|
||||
|
||||
$builder.find(timeStartId)
|
||||
.timepicker(oBaseTimePickerSettings)
|
||||
.blur(validateTimeRange);
|
||||
|
||||
$builder.find(dateEndId)
|
||||
.datepicker(oBaseDatePickerSettings)
|
||||
.blur(validateTimeRange);
|
||||
|
||||
$builder.find(timeEndId)
|
||||
.timepicker(oBaseTimePickerSettings)
|
||||
.blur(validateTimeRange);
|
||||
|
||||
|
||||
oRange = AIRTIME.utilities.fnGetScheduleRange(dateStartId, timeStartId,
|
||||
dateEndId, timeEndId);
|
||||
AIRTIME.showbuilder.fnServerData.start = oRange.start;
|
||||
AIRTIME.showbuilder.fnServerData.end = oRange.end;
|
||||
|
||||
//the user might not have the library on the page (guest user)
|
||||
if (AIRTIME.library !== undefined) {
|
||||
AIRTIME.library.libraryInit();
|
||||
}
|
||||
|
||||
AIRTIME.showbuilder.builderDataTable();
|
||||
setWidgetSize();
|
||||
|
||||
$libWrapper = $lib.find("#library_display_wrapper");
|
||||
//$builder.find('.dataTables_scrolling').css("max-height",
|
||||
// widgetHeight - 95);
|
||||
|
||||
$builder.on("click", "#sb_submit", showSearchSubmit);
|
||||
|
||||
$builder.on("click", "#sb_edit", function(ev) {
|
||||
var schedTable = $("#show_builder_table").dataTable();
|
||||
|
||||
// reset timestamp to redraw the cursors.
|
||||
AIRTIME.showbuilder.resetTimestamp();
|
||||
|
||||
$lib.show().width(Math.floor(screenWidth * 0.48));
|
||||
|
||||
$builder.width(Math.floor(screenWidth * 0.48)).find("#sb_edit")
|
||||
.remove().end().find("#sb_date_start")
|
||||
.css("margin-left", 0).end();
|
||||
|
||||
schedTable.fnDraw();
|
||||
|
||||
$.ajax( {
|
||||
url : baseUrl+"usersettings/set-now-playing-screen-settings",
|
||||
type : "POST",
|
||||
data : {
|
||||
settings : {
|
||||
library : true
|
||||
},
|
||||
format : "json"
|
||||
},
|
||||
dataType : "json",
|
||||
success : function() {
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
$lib.on("click", "#sb_lib_close", function() {
|
||||
var schedTable = $("#show_builder_table").dataTable();
|
||||
|
||||
$lib.hide();
|
||||
$builder.width(screenWidth).find(".sb-timerange").find("#sb_date_start").css("margin-left", 30)
|
||||
.end().end();
|
||||
|
||||
schedTable.fnDraw();
|
||||
|
||||
$.ajax( {
|
||||
url : baseUrl+"usersettings/set-now-playing-screen-settings",
|
||||
type : "POST",
|
||||
data : {
|
||||
settings : {
|
||||
library : false
|
||||
},
|
||||
format : "json"
|
||||
},
|
||||
dataType : "json",
|
||||
success : function() {
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
$builder.find('legend').click(
|
||||
function(ev, item) {
|
||||
|
||||
if ($fs.hasClass("closed")) {
|
||||
|
||||
$fs.removeClass("closed");
|
||||
//$builder.find('.dataTables_scrolling').css(
|
||||
// "max-height", widgetHeight - 150);
|
||||
} else {
|
||||
$fs.addClass("closed");
|
||||
|
||||
// set defaults for the options.
|
||||
$fs.find('select').val(0);
|
||||
$fs.find('input[type="checkbox"]').attr("checked",
|
||||
false);
|
||||
//$builder.find('.dataTables_scrolling').css(
|
||||
// "max-height", widgetHeight - 110);
|
||||
}
|
||||
});
|
||||
|
||||
// set click event for all my shows checkbox.
|
||||
$builder.on("click", "#sb_my_shows", function(ev) {
|
||||
|
||||
if ($(this).is(':checked')) {
|
||||
$(ev.delegateTarget).find('#sb_show_filter').val(0);
|
||||
}
|
||||
|
||||
showSearchSubmit();
|
||||
});
|
||||
|
||||
//set select event for choosing a show.
|
||||
$builder.on("change", '#sb_show_filter', function(ev) {
|
||||
|
||||
if ($(this).val() !== 0) {
|
||||
$(ev.delegateTarget).find('#sb_my_shows')
|
||||
.attr("checked", false);
|
||||
}
|
||||
|
||||
showSearchSubmit();
|
||||
|
||||
});
|
||||
|
||||
function checkScheduleUpdates() {
|
||||
var data = {}, oTable = $('#show_builder_table').dataTable(), fn = oTable
|
||||
.fnSettings().fnServerData, start = fn.start, end = fn.end;
|
||||
|
||||
data["format"] = "json";
|
||||
data["start"] = start;
|
||||
data["end"] = end;
|
||||
data["timestamp"] = AIRTIME.showbuilder.getTimestamp();
|
||||
data["instances"] = AIRTIME.showbuilder.getShowInstances();
|
||||
|
||||
if (fn.hasOwnProperty("ops")) {
|
||||
data["myShows"] = fn.ops.myShows;
|
||||
data["showFilter"] = fn.ops.showFilter;
|
||||
data["showInstanceFilter"] = fn.ops.showInstanceFilter;
|
||||
}
|
||||
|
||||
$.ajax( {
|
||||
"dataType" : "json",
|
||||
"type" : "GET",
|
||||
"url" : baseUrl+"showbuilder/check-builder-feed",
|
||||
"data" : data,
|
||||
"success" : function(json) {
|
||||
if (json.update === true) {
|
||||
oTable.fnDraw();
|
||||
}
|
||||
setTimeout(checkScheduleUpdates, 5000);
|
||||
}
|
||||
});
|
||||
|
||||
//check if the timeline view needs updating.
|
||||
setTimeout(checkScheduleUpdates, 5000);
|
||||
}
|
||||
};
|
||||
|
||||
mod.onResize = function() {
|
||||
|
||||
clearTimeout(resizeTimeout);
|
||||
resizeTimeout = setTimeout(setWidgetSize, 100);
|
||||
};
|
||||
|
||||
return AIRTIME;
|
||||
|
||||
} (AIRTIME || {}));
|
||||
return AIRTIME;
|
||||
})(AIRTIME || {});
|
||||
|
||||
$(document).ready(AIRTIME.builderMain.onReady);
|
||||
$(window).resize(AIRTIME.builderMain.onResize);
|
||||
|
|
|
@ -1,426 +1,446 @@
|
|||
var AIRTIME = (function(AIRTIME){
|
||||
/**
|
||||
* AIRTIME module namespace object
|
||||
*/
|
||||
var mod,
|
||||
/**
|
||||
* Tab counter to use as unique tab IDs that can be
|
||||
* retrieved from the DOM
|
||||
*
|
||||
* @type {number}
|
||||
*/
|
||||
$tabCount = 0,
|
||||
/**
|
||||
* Map of Tab IDs (by tabCount) to object UIDs so
|
||||
* Tabs can be referenced either by ID (from the DOM)
|
||||
* or by UID (from object data)
|
||||
*
|
||||
* @type {{}}
|
||||
*/
|
||||
$tabMap = {},
|
||||
/**
|
||||
* Map of object UIDs to currently open Tab objects
|
||||
*
|
||||
* @type {{}}
|
||||
*/
|
||||
$openTabs = {},
|
||||
/**
|
||||
* The currently active (open) Tab object
|
||||
*
|
||||
* @type {Tab}
|
||||
*/
|
||||
$activeTab,
|
||||
/**
|
||||
* Singleton object used to reference the schedule tab
|
||||
*
|
||||
* @type {ScheduleTab}
|
||||
*/
|
||||
$scheduleTab;
|
||||
var AIRTIME = (function (AIRTIME) {
|
||||
/**
|
||||
* AIRTIME module namespace object
|
||||
*/
|
||||
var mod,
|
||||
/**
|
||||
* Tab counter to use as unique tab IDs that can be
|
||||
* retrieved from the DOM
|
||||
*
|
||||
* @type {number}
|
||||
*/
|
||||
$tabCount = 0,
|
||||
/**
|
||||
* Map of Tab IDs (by tabCount) to object UIDs so
|
||||
* Tabs can be referenced either by ID (from the DOM)
|
||||
* or by UID (from object data)
|
||||
*
|
||||
* @type {{}}
|
||||
*/
|
||||
$tabMap = {},
|
||||
/**
|
||||
* Map of object UIDs to currently open Tab objects
|
||||
*
|
||||
* @type {{}}
|
||||
*/
|
||||
$openTabs = {},
|
||||
/**
|
||||
* The currently active (open) Tab object
|
||||
*
|
||||
* @type {Tab}
|
||||
*/
|
||||
$activeTab,
|
||||
/**
|
||||
* Singleton object used to reference the schedule tab
|
||||
*
|
||||
* @type {ScheduleTab}
|
||||
*/
|
||||
$scheduleTab;
|
||||
|
||||
if (AIRTIME.tabs === undefined) {
|
||||
AIRTIME.tabs = {};
|
||||
}
|
||||
mod = AIRTIME.tabs;
|
||||
if (AIRTIME.tabs === undefined) {
|
||||
AIRTIME.tabs = {};
|
||||
}
|
||||
mod = AIRTIME.tabs;
|
||||
|
||||
/* #####################################################
|
||||
/* #####################################################
|
||||
Object Initialization and Functions
|
||||
##################################################### */
|
||||
|
||||
/**
|
||||
* Tab object constructor
|
||||
*
|
||||
* @param {string} html the HTML to render as the tab contents
|
||||
* @param {string} uid the unique ID for the tab. Uses the values in
|
||||
* AIRTIME.library.MediaTypeStringEnum and the object ID
|
||||
* to create a string of the form TYPE_ID.
|
||||
* @returns {Tab} the created Tab object
|
||||
* @constructor
|
||||
*/
|
||||
var Tab = function(html, uid) {
|
||||
var self = this;
|
||||
/**
|
||||
* Tab object constructor
|
||||
*
|
||||
* @param {string} html the HTML to render as the tab contents
|
||||
* @param {string} uid the unique ID for the tab. Uses the values in
|
||||
* AIRTIME.library.MediaTypeStringEnum and the object ID
|
||||
* to create a string of the form TYPE_ID.
|
||||
* @returns {Tab} the created Tab object
|
||||
* @constructor
|
||||
*/
|
||||
var Tab = function (html, uid) {
|
||||
var self = this;
|
||||
|
||||
AIRTIME.library.selectNone();
|
||||
AIRTIME.library.selectNone();
|
||||
|
||||
var existingTab = $openTabs[uid];
|
||||
if (existingTab) {
|
||||
existingTab.switchTo();
|
||||
return existingTab;
|
||||
}
|
||||
self.id = ++$tabCount;
|
||||
self.uid = uid;
|
||||
var existingTab = $openTabs[uid];
|
||||
if (existingTab) {
|
||||
existingTab.switchTo();
|
||||
return existingTab;
|
||||
}
|
||||
self.id = ++$tabCount;
|
||||
self.uid = uid;
|
||||
|
||||
// TODO: clean this up a bit and use js instead of strings to create elements
|
||||
var wrapper = "<div data-tab-id='" + self.id + "' id='pl-tab-content-" + self.id + "' class='side_playlist pl-content'><div class='editor_pane_wrapper'></div></div>",
|
||||
t = $("#show_builder").append(wrapper).find("#pl-tab-content-" + self.id),
|
||||
pane = $(".editor_pane_wrapper:last").append(html),
|
||||
name = pane.find("#track_title").length > 0 ? pane.find("#track_title").val() + $.i18n._(" - Metadata Editor")
|
||||
: pane.find(".playlist_name_display").val(),
|
||||
tab =
|
||||
"<li data-tab-id='" + self.id + "' id='pl-tab-" + self.id + "' role='presentation' class='active'>" +
|
||||
"<a href='javascript:void(0)'>" +
|
||||
"<span class='tab-name'>" + name + "</span>" +
|
||||
"<span href='#' class='lib_pl_close icon-remove'></span>" +
|
||||
"</a>" +
|
||||
"</li>",
|
||||
tabs = $(".nav.nav-tabs");
|
||||
// TODO: clean this up a bit and use js instead of strings to create elements
|
||||
var wrapper =
|
||||
"<div data-tab-id='" +
|
||||
self.id +
|
||||
"' id='pl-tab-content-" +
|
||||
self.id +
|
||||
"' class='side_playlist pl-content'><div class='editor_pane_wrapper'></div></div>",
|
||||
t = $("#show_builder")
|
||||
.append(wrapper)
|
||||
.find("#pl-tab-content-" + self.id),
|
||||
pane = $(".editor_pane_wrapper:last").append(html),
|
||||
name =
|
||||
pane.find("#track_title").length > 0
|
||||
? pane.find("#track_title").val() + $.i18n._(" - Metadata Editor")
|
||||
: pane.find(".playlist_name_display").val(),
|
||||
tab =
|
||||
"<li data-tab-id='" +
|
||||
self.id +
|
||||
"' id='pl-tab-" +
|
||||
self.id +
|
||||
"' role='presentation' class='active'>" +
|
||||
"<a href='javascript:void(0)'>" +
|
||||
"<span class='tab-name'>" +
|
||||
name +
|
||||
"</span>" +
|
||||
"<span href='#' class='lib_pl_close icon-remove'></span>" +
|
||||
"</a>" +
|
||||
"</li>",
|
||||
tabs = $(".nav.nav-tabs");
|
||||
|
||||
$(".nav.nav-tabs li").removeClass("active");
|
||||
tabs.append(tab);
|
||||
$(".nav.nav-tabs li").removeClass("active");
|
||||
tabs.append(tab);
|
||||
|
||||
var newTab = $("#pl-tab-" + self.id);
|
||||
var newTab = $("#pl-tab-" + self.id);
|
||||
|
||||
self.wrapper = pane;
|
||||
self.contents = t;
|
||||
self.tab = newTab;
|
||||
self.wrapper = pane;
|
||||
self.contents = t;
|
||||
self.tab = newTab;
|
||||
|
||||
$openTabs[uid] = self;
|
||||
$tabMap[self.id] = uid;
|
||||
$openTabs[uid] = self;
|
||||
$tabMap[self.id] = uid;
|
||||
|
||||
self._init();
|
||||
self._init();
|
||||
self.switchTo();
|
||||
return self;
|
||||
};
|
||||
|
||||
/**
|
||||
* Private initialization function for Tab objects
|
||||
*
|
||||
* Assigns default action handlers to the tab DOM element
|
||||
*
|
||||
* @private
|
||||
*/
|
||||
Tab.prototype._init = function () {
|
||||
var self = this;
|
||||
self.assignTabClickHandler(function (e) {
|
||||
if (!$(this).hasClass("active")) {
|
||||
self.switchTo();
|
||||
return self;
|
||||
};
|
||||
}
|
||||
});
|
||||
|
||||
/**
|
||||
* Private initialization function for Tab objects
|
||||
*
|
||||
* Assigns default action handlers to the tab DOM element
|
||||
*
|
||||
* @private
|
||||
*/
|
||||
Tab.prototype._init = function() {
|
||||
var self = this;
|
||||
self.assignTabClickHandler(function(e) {
|
||||
if (!$(this).hasClass('active')) {
|
||||
self.switchTo();
|
||||
}
|
||||
});
|
||||
self.assignTabCloseClickHandler(function (e) {
|
||||
e.preventDefault();
|
||||
e.stopPropagation();
|
||||
$(this).unbind("click"); // Prevent repeated clicks in quick succession from closing multiple tabs
|
||||
|
||||
self.assignTabCloseClickHandler(function(e) {
|
||||
e.preventDefault();
|
||||
e.stopPropagation();
|
||||
$(this).unbind("click"); // Prevent repeated clicks in quick succession from closing multiple tabs
|
||||
// We need to update the text on the add button
|
||||
AIRTIME.library.checkAddButton();
|
||||
// We also need to run the draw callback to update how dragged items are drawn
|
||||
AIRTIME.library.fnDrawCallback();
|
||||
self.close();
|
||||
});
|
||||
|
||||
// We need to update the text on the add button
|
||||
AIRTIME.library.checkAddButton();
|
||||
// We also need to run the draw callback to update how dragged items are drawn
|
||||
AIRTIME.library.fnDrawCallback();
|
||||
self.close();
|
||||
});
|
||||
self.contents.on("click", ".toggle-editor-form", function (event) {
|
||||
self.contents.find(".inner_editor_wrapper").slideToggle(200);
|
||||
var buttonIcon = $(this).find(".icon-white");
|
||||
buttonIcon.toggleClass("icon-chevron-up");
|
||||
buttonIcon.toggleClass("icon-chevron-down");
|
||||
});
|
||||
};
|
||||
|
||||
self.contents.on("click", ".toggle-editor-form", function(event) {
|
||||
self.contents.find(".inner_editor_wrapper").slideToggle(200);
|
||||
var buttonIcon = $(this).find('.icon-white');
|
||||
buttonIcon.toggleClass('icon-chevron-up');
|
||||
buttonIcon.toggleClass('icon-chevron-down');
|
||||
});
|
||||
};
|
||||
/**
|
||||
* Internal destructor. Can be assigned via assignOnCloseHandler
|
||||
*
|
||||
* @private
|
||||
*/
|
||||
Tab.prototype._destroy = function () {};
|
||||
|
||||
/**
|
||||
* Internal destructor. Can be assigned via assignOnCloseHandler
|
||||
*
|
||||
* @private
|
||||
*/
|
||||
Tab.prototype._destroy = function () {};
|
||||
/**
|
||||
* Assign the given function f as the click handler for the tab
|
||||
*
|
||||
* @param {function} f the function to call when the tab is clicked
|
||||
*/
|
||||
Tab.prototype.assignTabClickHandler = function (f) {
|
||||
var self = this;
|
||||
self.tab.unbind("click").on("click", function (e) {
|
||||
// Always close on middle mouse press
|
||||
if (e.which == 2) {
|
||||
// Simulate a click on the close tab button so any
|
||||
// additional on-close behaviour is executed
|
||||
self.tab.find(".lib_pl_close").click();
|
||||
return;
|
||||
}
|
||||
f();
|
||||
});
|
||||
};
|
||||
|
||||
/**
|
||||
* Assign the given function f as the click handler for the tab
|
||||
*
|
||||
* @param {function} f the function to call when the tab is clicked
|
||||
*/
|
||||
Tab.prototype.assignTabClickHandler = function(f) {
|
||||
var self = this;
|
||||
self.tab.unbind("click").on("click", function (e) {
|
||||
// Always close on middle mouse press
|
||||
if (e.which == 2) {
|
||||
// Simulate a click on the close tab button so any
|
||||
// additional on-close behaviour is executed
|
||||
self.tab.find(".lib_pl_close").click();
|
||||
return;
|
||||
}
|
||||
f();
|
||||
});
|
||||
};
|
||||
/**
|
||||
* Assign the given function f as the click handler for the tab close button
|
||||
*
|
||||
* @param {function} f the function to call when the tab's close button is clicked
|
||||
*/
|
||||
Tab.prototype.assignTabCloseClickHandler = function (f) {
|
||||
this.tab.find(".lib_pl_close").unbind("click").click(f);
|
||||
};
|
||||
|
||||
/**
|
||||
* Assign the given function f as the click handler for the tab close button
|
||||
*
|
||||
* @param {function} f the function to call when the tab's close button is clicked
|
||||
*/
|
||||
Tab.prototype.assignTabCloseClickHandler = function(f) {
|
||||
this.tab.find(".lib_pl_close").unbind("click").click(f);
|
||||
};
|
||||
/**
|
||||
* Assign an implicit destructor
|
||||
*
|
||||
* @param {function} fn function to run when this Tab is destroyed
|
||||
*/
|
||||
Tab.prototype.assignOnCloseHandler = function (fn) {
|
||||
this._destroy = fn;
|
||||
};
|
||||
|
||||
/**
|
||||
* Assign an implicit destructor
|
||||
*
|
||||
* @param {function} fn function to run when this Tab is destroyed
|
||||
*/
|
||||
Tab.prototype.assignOnCloseHandler = function (fn) {
|
||||
this._destroy = fn;
|
||||
};
|
||||
/**
|
||||
* Open this tab in the right-hand pane and set it as the currently active tab
|
||||
*/
|
||||
Tab.prototype.switchTo = function () {
|
||||
var self = this;
|
||||
$activeTab.contents.hide().removeClass("active-tab");
|
||||
self.contents.addClass("active-tab").show();
|
||||
|
||||
/**
|
||||
* Open this tab in the right-hand pane and set it as the currently active tab
|
||||
*/
|
||||
Tab.prototype.switchTo = function() {
|
||||
var self = this;
|
||||
$activeTab.contents.hide().removeClass("active-tab");
|
||||
self.contents.addClass("active-tab").show();
|
||||
$activeTab.tab.removeClass("active");
|
||||
self.tab.addClass("active");
|
||||
|
||||
$activeTab.tab.removeClass("active");
|
||||
self.tab.addClass("active");
|
||||
mod.updateActiveTab();
|
||||
|
||||
mod.updateActiveTab();
|
||||
// In case we're adding a tab that wraps to the next row
|
||||
// It's better to call this here so we don't have to call it in multiple places
|
||||
mod.onResize();
|
||||
return this; // For chaining
|
||||
};
|
||||
|
||||
// In case we're adding a tab that wraps to the next row
|
||||
// It's better to call this here so we don't have to call it in multiple places
|
||||
mod.onResize();
|
||||
return this; // For chaining
|
||||
};
|
||||
/**
|
||||
* Close the tab. Switches to the nearest open tab, prioritizing the
|
||||
* more recent (rightmost) tabs
|
||||
*/
|
||||
Tab.prototype.close = function () {
|
||||
var self = this;
|
||||
|
||||
/**
|
||||
* Close the tab. Switches to the nearest open tab, prioritizing the
|
||||
* more recent (rightmost) tabs
|
||||
*/
|
||||
Tab.prototype.close = function() {
|
||||
var self = this;
|
||||
var ascTabs = Object.keys($openTabs).sort(function (a, b) {
|
||||
return a - b;
|
||||
}),
|
||||
pos = ascTabs.indexOf(self.uid),
|
||||
toTab =
|
||||
pos < ascTabs.length - 1
|
||||
? $openTabs[ascTabs[++pos]]
|
||||
: $openTabs[ascTabs[--pos]];
|
||||
delete $openTabs[self.uid]; // Remove this tab from the open tab array
|
||||
delete $tabMap[self.id]; // Remove this tab from the internal tab mapping
|
||||
|
||||
var ascTabs = Object.keys($openTabs).sort(function(a, b){return a-b}),
|
||||
pos = ascTabs.indexOf(self.uid),
|
||||
toTab = pos < ascTabs.length-1 ? $openTabs[ascTabs[++pos]] : $openTabs[ascTabs[--pos]];
|
||||
delete $openTabs[self.uid]; // Remove this tab from the open tab array
|
||||
delete $tabMap[self.id]; // Remove this tab from the internal tab mapping
|
||||
// Remove the relevant DOM elements (the tab and its contents)
|
||||
if (self.uid !== 0) {
|
||||
self.tab.remove();
|
||||
self.contents.remove();
|
||||
} else {
|
||||
// only hide scheduled shows tab so we can still interact with it.
|
||||
self.tab.hide();
|
||||
self.contents.hide();
|
||||
}
|
||||
|
||||
// Remove the relevant DOM elements (the tab and its contents)
|
||||
if (self.uid !== 0) {
|
||||
self.tab.remove();
|
||||
self.contents.remove();
|
||||
} else {
|
||||
// only hide scheduled shows tab so we can still interact with it.
|
||||
self.tab.hide();
|
||||
self.contents.hide();
|
||||
}
|
||||
if (self.isActive() && toTab) {
|
||||
// Closing the current tab, otherwise we don't need to switch tabs
|
||||
toTab.switchTo();
|
||||
} else {
|
||||
mod.onResize();
|
||||
}
|
||||
|
||||
if (Object.keys($openTabs).length < 1) {
|
||||
$("#show_builder").hide();
|
||||
}
|
||||
|
||||
if (self.isActive() && toTab) { // Closing the current tab, otherwise we don't need to switch tabs
|
||||
toTab.switchTo();
|
||||
} else {
|
||||
mod.onResize();
|
||||
}
|
||||
self._destroy();
|
||||
};
|
||||
|
||||
if (Object.keys($openTabs).length < 1) {
|
||||
$('#show_builder').hide();
|
||||
}
|
||||
/**
|
||||
* Set the visible Tab name to the given string
|
||||
*
|
||||
* @param {string} name the name to set
|
||||
*/
|
||||
Tab.prototype.setName = function (name) {
|
||||
this.tab.find(".tab-name").text(name);
|
||||
return this; // For chaining
|
||||
};
|
||||
|
||||
self._destroy();
|
||||
};
|
||||
/**
|
||||
* Check if the Tab object is the currently active (open) Tab
|
||||
*
|
||||
* @returns {boolean} true if the Tab is the currently active Tab
|
||||
*/
|
||||
Tab.prototype.isActive = function () {
|
||||
return this.contents.get(0) == $activeTab.contents.get(0);
|
||||
};
|
||||
|
||||
/**
|
||||
* Set the visible Tab name to the given string
|
||||
*
|
||||
* @param {string} name the name to set
|
||||
*/
|
||||
Tab.prototype.setName = function(name) {
|
||||
this.tab.find(".tab-name").text(name);
|
||||
return this; // For chaining
|
||||
};
|
||||
/**
|
||||
* ScheduledTab object constructor
|
||||
*
|
||||
* The schedule tab is present in the DOM already on load, and we
|
||||
* need to be able to reference it in the same way as other tabs
|
||||
* (to avoid duplication and confusion) so we define it statically
|
||||
*
|
||||
* @constructor
|
||||
*/
|
||||
var ScheduleTab = function () {
|
||||
var self = this,
|
||||
uid = 0,
|
||||
tab = $("#schedule-tab"),
|
||||
pane = $("#show_builder"),
|
||||
contents = pane.find(".outer-datatable-wrapper");
|
||||
self.id = 0;
|
||||
self.uid = uid;
|
||||
|
||||
/**
|
||||
* Check if the Tab object is the currently active (open) Tab
|
||||
*
|
||||
* @returns {boolean} true if the Tab is the currently active Tab
|
||||
*/
|
||||
Tab.prototype.isActive = function() {
|
||||
return this.contents.get(0) == $activeTab.contents.get(0);
|
||||
};
|
||||
tab.data("tab-id", self.id);
|
||||
|
||||
/**
|
||||
* ScheduledTab object constructor
|
||||
*
|
||||
* The schedule tab is present in the DOM already on load, and we
|
||||
* need to be able to reference it in the same way as other tabs
|
||||
* (to avoid duplication and confusion) so we define it statically
|
||||
*
|
||||
* @constructor
|
||||
*/
|
||||
var ScheduleTab = function() {
|
||||
var self = this, uid = 0,
|
||||
tab = $("#schedule-tab"),
|
||||
pane = $("#show_builder"),
|
||||
contents = pane.find(".outer-datatable-wrapper");
|
||||
self.id = 0;
|
||||
self.uid = uid;
|
||||
self.wrapper = pane;
|
||||
self.contents = contents;
|
||||
self.tab = tab;
|
||||
|
||||
tab.data("tab-id", self.id);
|
||||
self.assignTabClickHandler(function (e) {
|
||||
if (!self.isActive()) {
|
||||
self.switchTo();
|
||||
}
|
||||
});
|
||||
|
||||
self.wrapper = pane;
|
||||
self.contents = contents;
|
||||
self.tab = tab;
|
||||
self.assignTabCloseClickHandler(function (e) {
|
||||
self.close();
|
||||
});
|
||||
|
||||
self.assignTabClickHandler(function(e) {
|
||||
if (!self.isActive()) {
|
||||
self.switchTo();
|
||||
}
|
||||
});
|
||||
$openTabs[uid] = self;
|
||||
$tabMap[self.id] = uid;
|
||||
};
|
||||
/**
|
||||
* Subclass the Tab object
|
||||
* @type {Tab}
|
||||
*/
|
||||
ScheduleTab.prototype = Object.create(Tab.prototype);
|
||||
ScheduleTab.prototype.constructor = ScheduleTab;
|
||||
|
||||
self.assignTabCloseClickHandler(function(e) {
|
||||
self.close();
|
||||
});
|
||||
|
||||
$openTabs[uid] = self;
|
||||
$tabMap[self.id] = uid;
|
||||
};
|
||||
/**
|
||||
* Subclass the Tab object
|
||||
* @type {Tab}
|
||||
*/
|
||||
ScheduleTab.prototype = Object.create(Tab.prototype);
|
||||
ScheduleTab.prototype.constructor = ScheduleTab;
|
||||
|
||||
/* #####################################################
|
||||
/* #####################################################
|
||||
Module Functions
|
||||
##################################################### */
|
||||
|
||||
/**
|
||||
* Initialize the singleton ScheduleTab object on startup
|
||||
*/
|
||||
mod.initScheduleTab = function() {
|
||||
$scheduleTab = new ScheduleTab();
|
||||
$activeTab = $scheduleTab;
|
||||
};
|
||||
/**
|
||||
* Initialize the singleton ScheduleTab object on startup
|
||||
*/
|
||||
mod.initScheduleTab = function () {
|
||||
$scheduleTab = new ScheduleTab();
|
||||
$activeTab = $scheduleTab;
|
||||
};
|
||||
|
||||
/**
|
||||
* Create a new Tab object and open it in the ShowBuilder pane
|
||||
*
|
||||
* @param {string} html the HTML to render as the tab contents
|
||||
* @param {string} uid the unique ID for the tab. Uses the values in
|
||||
* AIRTIME.library.MediaTypeStringEnum and the object ID
|
||||
* @param {function} callback an optional callback function to call once the
|
||||
* Tab object is initialized
|
||||
* @returns {Tab} the created Tab object
|
||||
*/
|
||||
mod.openTab = function(html, uid, callback) {
|
||||
$('#show_builder').show();
|
||||
var newTab = new Tab(html, uid);
|
||||
if (callback) callback(newTab);
|
||||
return newTab;
|
||||
};
|
||||
/**
|
||||
* Create a new Tab object and open it in the ShowBuilder pane
|
||||
*
|
||||
* @param {string} html the HTML to render as the tab contents
|
||||
* @param {string} uid the unique ID for the tab. Uses the values in
|
||||
* AIRTIME.library.MediaTypeStringEnum and the object ID
|
||||
* @param {function} callback an optional callback function to call once the
|
||||
* Tab object is initialized
|
||||
* @returns {Tab} the created Tab object
|
||||
*/
|
||||
mod.openTab = function (html, uid, callback) {
|
||||
$("#show_builder").show();
|
||||
var newTab = new Tab(html, uid);
|
||||
if (callback) callback(newTab);
|
||||
return newTab;
|
||||
};
|
||||
|
||||
/**
|
||||
* open the schedule tab if if was closed
|
||||
*
|
||||
* @returns {Tab}
|
||||
*/
|
||||
mod.openScheduleTab = function() {
|
||||
var $scheduleTab = this.getScheduleTab();
|
||||
$('#show_builder').show();
|
||||
$openTabs[0] = $scheduleTab;
|
||||
$scheduleTab.tab.show();
|
||||
$scheduleTab.contents.show();
|
||||
$scheduleTab.switchTo();
|
||||
$scheduleTab.assignTabCloseClickHandler(function(e) {
|
||||
$scheduleTab.close();
|
||||
});
|
||||
};
|
||||
|
||||
/**
|
||||
* Updates the currently active tab
|
||||
*
|
||||
* Called when the user switches tabs for any reason
|
||||
*
|
||||
* NOTE: this function updates the currently active playlist
|
||||
* as a side-effect, which is necessary for playlist tabs
|
||||
* but not for other types of tabs... would be good to
|
||||
* get rid of this dependency at some point
|
||||
*/
|
||||
mod.updateActiveTab = function() {
|
||||
var t = $(".nav.nav-tabs .active");
|
||||
$activeTab = mod.get(t.data("tab-id"));
|
||||
if (!$activeTab) $activeTab = $scheduleTab;
|
||||
if ($activeTab.contents.hasClass("pl-content")) {
|
||||
AIRTIME.playlist.setCurrent($activeTab.contents);
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* Get the ScheduleTab object
|
||||
*
|
||||
* @returns {ScheduleTab}
|
||||
*/
|
||||
mod.getScheduleTab = function() {
|
||||
return $scheduleTab;
|
||||
};
|
||||
|
||||
/**
|
||||
* Get the currently active (open) Tab object
|
||||
*
|
||||
* @returns {Tab} the currently active tab
|
||||
*/
|
||||
mod.getActiveTab = function() {
|
||||
return $activeTab;
|
||||
};
|
||||
|
||||
/**
|
||||
* Given a tab id, get the corresponding Tab object
|
||||
*
|
||||
* @param {int|string} id the tab or object ID of the Tab to retrieve
|
||||
* @returns {Tab|undefined} the Tab object with the given ID, or undefined
|
||||
* if no Tab with the given ID exists
|
||||
*/
|
||||
mod.get = function(id) {
|
||||
return $.isNumeric(id) ? $openTabs[$tabMap[id]] : $openTabs[id];
|
||||
};
|
||||
|
||||
/**
|
||||
* Adjust the margins on the right-hand pane when we have multiple rows of tabs
|
||||
*/
|
||||
mod.onResize = function() {
|
||||
var h = $(".panel-header .nav").height();
|
||||
$(".pl-content").css("margin-top", h + 5); // 8px extra for padding
|
||||
$("#show_builder_table_wrapper").css("top", h + 5);
|
||||
};
|
||||
|
||||
/**
|
||||
* Expose the Tab object so it can be subclassed
|
||||
*
|
||||
* @type {Function}
|
||||
*/
|
||||
mod.Tab = Tab;
|
||||
|
||||
return AIRTIME;
|
||||
|
||||
}(AIRTIME || {}));
|
||||
|
||||
$(document).ready(function() {
|
||||
var sb = $("#show_builder");
|
||||
// Add text scrolling to tab names
|
||||
sb.addTitles(".tab-name");
|
||||
sb.find(".nav.nav-tabs").sortable({
|
||||
containment: "parent",
|
||||
distance: 25
|
||||
/**
|
||||
* open the schedule tab if if was closed
|
||||
*
|
||||
* @returns {Tab}
|
||||
*/
|
||||
mod.openScheduleTab = function () {
|
||||
var $scheduleTab = this.getScheduleTab();
|
||||
$("#show_builder").show();
|
||||
$openTabs[0] = $scheduleTab;
|
||||
$scheduleTab.tab.show();
|
||||
$scheduleTab.contents.show();
|
||||
$scheduleTab.switchTo();
|
||||
$scheduleTab.assignTabCloseClickHandler(function (e) {
|
||||
$scheduleTab.close();
|
||||
});
|
||||
// Initialize the ScheduleTab
|
||||
AIRTIME.tabs.initScheduleTab();
|
||||
};
|
||||
|
||||
/**
|
||||
* Updates the currently active tab
|
||||
*
|
||||
* Called when the user switches tabs for any reason
|
||||
*
|
||||
* NOTE: this function updates the currently active playlist
|
||||
* as a side-effect, which is necessary for playlist tabs
|
||||
* but not for other types of tabs... would be good to
|
||||
* get rid of this dependency at some point
|
||||
*/
|
||||
mod.updateActiveTab = function () {
|
||||
var t = $(".nav.nav-tabs .active");
|
||||
$activeTab = mod.get(t.data("tab-id"));
|
||||
if (!$activeTab) $activeTab = $scheduleTab;
|
||||
if ($activeTab.contents.hasClass("pl-content")) {
|
||||
AIRTIME.playlist.setCurrent($activeTab.contents);
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* Get the ScheduleTab object
|
||||
*
|
||||
* @returns {ScheduleTab}
|
||||
*/
|
||||
mod.getScheduleTab = function () {
|
||||
return $scheduleTab;
|
||||
};
|
||||
|
||||
/**
|
||||
* Get the currently active (open) Tab object
|
||||
*
|
||||
* @returns {Tab} the currently active tab
|
||||
*/
|
||||
mod.getActiveTab = function () {
|
||||
return $activeTab;
|
||||
};
|
||||
|
||||
/**
|
||||
* Given a tab id, get the corresponding Tab object
|
||||
*
|
||||
* @param {int|string} id the tab or object ID of the Tab to retrieve
|
||||
* @returns {Tab|undefined} the Tab object with the given ID, or undefined
|
||||
* if no Tab with the given ID exists
|
||||
*/
|
||||
mod.get = function (id) {
|
||||
return $.isNumeric(id) ? $openTabs[$tabMap[id]] : $openTabs[id];
|
||||
};
|
||||
|
||||
/**
|
||||
* Adjust the margins on the right-hand pane when we have multiple rows of tabs
|
||||
*/
|
||||
mod.onResize = function () {
|
||||
var h = $(".panel-header .nav").height();
|
||||
$(".pl-content").css("margin-top", h + 5); // 8px extra for padding
|
||||
$("#show_builder_table_wrapper").css("top", h + 5);
|
||||
};
|
||||
|
||||
/**
|
||||
* Expose the Tab object so it can be subclassed
|
||||
*
|
||||
* @type {Function}
|
||||
*/
|
||||
mod.Tab = Tab;
|
||||
|
||||
return AIRTIME;
|
||||
})(AIRTIME || {});
|
||||
|
||||
$(document).ready(function () {
|
||||
var sb = $("#show_builder");
|
||||
// Add text scrolling to tab names
|
||||
sb.addTitles(".tab-name");
|
||||
sb.find(".nav.nav-tabs").sortable({
|
||||
containment: "parent",
|
||||
distance: 25,
|
||||
});
|
||||
// Initialize the ScheduleTab
|
||||
AIRTIME.tabs.initScheduleTab();
|
||||
});
|
||||
$(window).resize(AIRTIME.tabs.onResize);
|
||||
|
|
|
@ -1,79 +1,101 @@
|
|||
function generatePartitions(partitions){
|
||||
function generatePartitions(partitions) {
|
||||
var rowTemplate =
|
||||
'<tr class="partition-info">' +
|
||||
'<td><span class="strong">' +
|
||||
$.i18n._("Disk") +
|
||||
" #%s</span>" +
|
||||
'<ul id="watched-dir-list-%s">' +
|
||||
"</ul>" +
|
||||
"</td>" +
|
||||
"<td>%sGB of %sGB</td>" +
|
||||
'<td colspan="3">' +
|
||||
'<div class="big">' +
|
||||
'<div class="diskspace" style="width:%s%%;">' +
|
||||
"</div>" +
|
||||
"</div>" +
|
||||
"<div>%s%% " +
|
||||
$.i18n._("in use") +
|
||||
"</div>" +
|
||||
"</td>" +
|
||||
"</tr>";
|
||||
|
||||
var rowTemplate =
|
||||
'<tr class="partition-info">'+
|
||||
'<td><span class="strong">'+$.i18n._("Disk")+' #%s</span>'+
|
||||
'<ul id="watched-dir-list-%s">'+
|
||||
'</ul>'+
|
||||
'</td>'+
|
||||
'<td>%sGB of %sGB</td>'+
|
||||
'<td colspan="3">'+
|
||||
'<div class="big">'+
|
||||
'<div class="diskspace" style="width:%s%%;">'+
|
||||
'</div>'+
|
||||
'</div>'+
|
||||
'<div>%s%% '+$.i18n._("in use")+'</div>'+
|
||||
'</td>'+
|
||||
'</tr>';
|
||||
$(".partition-info").remove();
|
||||
var lastElement = $("#partitions");
|
||||
for (var i = 0; i < partitions.length; i++) {
|
||||
var spaceUsed = partitions[i].totalSpace - partitions[i].totalFreeSpace;
|
||||
var totalSpace = partitions[i].totalSpace;
|
||||
var percUsed = sprintf("%01.1f", (spaceUsed / totalSpace) * 100);
|
||||
|
||||
$(".partition-info").remove();
|
||||
var lastElement = $('#partitions');
|
||||
for (var i=0; i<partitions.length; i++){
|
||||
var spaceUsed = partitions[i].totalSpace-partitions[i].totalFreeSpace;
|
||||
var totalSpace = partitions[i].totalSpace;
|
||||
var percUsed = sprintf("%01.1f", spaceUsed/totalSpace*100);
|
||||
var spaceUsedGb = sprintf("%01.1f", spaceUsed / Math.pow(2, 30));
|
||||
var totalSpaceGb = sprintf("%01.1f", totalSpace / Math.pow(2, 30));
|
||||
|
||||
var spaceUsedGb = sprintf("%01.1f", spaceUsed/Math.pow(2, 30));
|
||||
var totalSpaceGb = sprintf("%01.1f", totalSpace/Math.pow(2, 30));
|
||||
var row = sprintf(
|
||||
rowTemplate,
|
||||
i + 1,
|
||||
i,
|
||||
spaceUsedGb,
|
||||
totalSpaceGb,
|
||||
percUsed,
|
||||
percUsed
|
||||
);
|
||||
var tr = $(row);
|
||||
lastElement.after(tr);
|
||||
|
||||
var row = sprintf(rowTemplate, i+1, i, spaceUsedGb, totalSpaceGb, percUsed, percUsed);
|
||||
var tr = $(row);
|
||||
lastElement.after(tr);
|
||||
|
||||
if (partitions[i].dirs){
|
||||
var watched_dirs_ul = $('#watched-dir-list-'+i);
|
||||
for (var j=0; j<partitions[i].dirs.length; j++){
|
||||
watched_dirs_ul.append('<li>'+partitions[i].dirs[j]+'</li>');
|
||||
}
|
||||
}
|
||||
lastElement = tr;
|
||||
if (partitions[i].dirs) {
|
||||
var watched_dirs_ul = $("#watched-dir-list-" + i);
|
||||
for (var j = 0; j < partitions[i].dirs.length; j++) {
|
||||
watched_dirs_ul.append("<li>" + partitions[i].dirs[j] + "</li>");
|
||||
}
|
||||
}
|
||||
|
||||
lastElement = tr;
|
||||
}
|
||||
}
|
||||
|
||||
function success(data, textStatus, jqXHR){
|
||||
var services = data.status.services;
|
||||
function success(data, textStatus, jqXHR) {
|
||||
var services = data.status.services;
|
||||
|
||||
for (var key in services) {
|
||||
var s = services[key];
|
||||
if (s) {
|
||||
var children = $("#"+s.name).children();
|
||||
$(children[0]).text(s.name);
|
||||
for (var key in services) {
|
||||
var s = services[key];
|
||||
if (s) {
|
||||
var children = $("#" + s.name).children();
|
||||
$(children[0]).text(s.name);
|
||||
|
||||
var status_class = "not-available-icon";
|
||||
if (s.status == 0){
|
||||
status_class = "checked-icon";
|
||||
} else if (s.status == 1) {
|
||||
status_class = "warning-icon";
|
||||
}
|
||||
var status_class = "not-available-icon";
|
||||
if (s.status == 0) {
|
||||
status_class = "checked-icon";
|
||||
} else if (s.status == 1) {
|
||||
status_class = "warning-icon";
|
||||
}
|
||||
|
||||
$($(children[1]).children()[0]).attr("class", status_class);
|
||||
$(children[2]).text(sprintf('%(days)sd %(hours)sh %(minutes)sm %(seconds)ss', convertSecondsToDaysHoursMinutesSeconds(s.uptime_seconds)));
|
||||
$(children[3]).text(s.cpu_perc);
|
||||
$(children[4]).text(sprintf('%01.1fMB (%s)', parseInt(s.memory_kb)/1000, s.memory_perc));
|
||||
}
|
||||
$($(children[1]).children()[0]).attr("class", status_class);
|
||||
$(children[2]).text(
|
||||
sprintf(
|
||||
"%(days)sd %(hours)sh %(minutes)sm %(seconds)ss",
|
||||
convertSecondsToDaysHoursMinutesSeconds(s.uptime_seconds)
|
||||
)
|
||||
);
|
||||
$(children[3]).text(s.cpu_perc);
|
||||
$(children[4]).text(
|
||||
sprintf("%01.1fMB (%s)", parseInt(s.memory_kb) / 1000, s.memory_perc)
|
||||
);
|
||||
}
|
||||
if (data.status.partitions){
|
||||
generatePartitions(data.status.partitions);
|
||||
}
|
||||
setTimeout(function(){updateStatus(false);}, 5000);
|
||||
}
|
||||
if (data.status.partitions) {
|
||||
generatePartitions(data.status.partitions);
|
||||
}
|
||||
setTimeout(function () {
|
||||
updateStatus(false);
|
||||
}, 5000);
|
||||
}
|
||||
|
||||
function updateStatus(getDiskInfo){
|
||||
$.getJSON( baseUrl+"api/status/format/json/diskinfo/"+getDiskInfo, null, success);
|
||||
|
||||
function updateStatus(getDiskInfo) {
|
||||
$.getJSON(
|
||||
baseUrl + "api/status/format/json/diskinfo/" + getDiskInfo,
|
||||
null,
|
||||
success
|
||||
);
|
||||
}
|
||||
|
||||
$(document).ready(function() {
|
||||
updateStatus(true);
|
||||
$(document).ready(function () {
|
||||
updateStatus(true);
|
||||
});
|
||||
|
|
|
@ -1,151 +1,190 @@
|
|||
function populateForm(entries) {
|
||||
$(".errors").remove();
|
||||
$(".success").remove();
|
||||
|
||||
function populateForm(entries){
|
||||
$("#tracktype_id").val(entries.id);
|
||||
$("#code").val(entries.code);
|
||||
$("#type_name").val(entries.type_name);
|
||||
$("#description").val(entries.description);
|
||||
|
||||
$('.errors').remove();
|
||||
$('.success').remove();
|
||||
if (entries.visibility) {
|
||||
var visibility_value = 1;
|
||||
} else {
|
||||
var visibility_value = 0;
|
||||
}
|
||||
$("#visibility").val(visibility_value);
|
||||
|
||||
$('#tracktype_id').val(entries.id);
|
||||
$('#code').val(entries.code);
|
||||
$('#type_name').val(entries.type_name);
|
||||
$('#description').val(entries.description);
|
||||
|
||||
if (entries.visibility) {
|
||||
var visibility_value = 1;
|
||||
} else {
|
||||
var visibility_value = 0;
|
||||
}
|
||||
$('#visibility').val(visibility_value);
|
||||
|
||||
if (entries.id.length != 0){
|
||||
$('#code').attr('readonly', 'readonly');
|
||||
} else {
|
||||
$('#code').removeAttr('readonly');
|
||||
}
|
||||
if (entries.id.length != 0) {
|
||||
$("#code").attr("readonly", "readonly");
|
||||
} else {
|
||||
$("#code").removeAttr("readonly");
|
||||
}
|
||||
}
|
||||
|
||||
function rowClickCallback(row_id){
|
||||
$.ajax({ url: baseUrl+'Tracktype/get-tracktype-data/id/'+ row_id +'/format/json', dataType:"json", success:function(data){
|
||||
populateForm(data.entries);
|
||||
$("#tracktype_details").css("visibility", "visible");
|
||||
}});
|
||||
function rowClickCallback(row_id) {
|
||||
$.ajax({
|
||||
url: baseUrl + "Tracktype/get-tracktype-data/id/" + row_id + "/format/json",
|
||||
dataType: "json",
|
||||
success: function (data) {
|
||||
populateForm(data.entries);
|
||||
$("#tracktype_details").css("visibility", "visible");
|
||||
},
|
||||
});
|
||||
}
|
||||
|
||||
function removeTracktypeCallback(row_id, nRow) {
|
||||
if (confirm($.i18n._("Are you sure you want to delete this tracktype?"))) {
|
||||
$.ajax({
|
||||
url: baseUrl + 'Tracktype/remove-tracktype/id/' + row_id + '/format/json',
|
||||
dataType: "text",
|
||||
success: function (data) {
|
||||
var o = $('#tracktypes_datatable').dataTable().fnDeleteRow(nRow);
|
||||
}
|
||||
});
|
||||
}
|
||||
if (confirm($.i18n._("Are you sure you want to delete this tracktype?"))) {
|
||||
$.ajax({
|
||||
url: baseUrl + "Tracktype/remove-tracktype/id/" + row_id + "/format/json",
|
||||
dataType: "text",
|
||||
success: function (data) {
|
||||
var o = $("#tracktypes_datatable").dataTable().fnDeleteRow(nRow);
|
||||
},
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
function rowCallback( nRow, aData, iDisplayIndex ){
|
||||
$(nRow).click(function(){rowClickCallback(aData['id'])});
|
||||
if( aData['delete'] != "self"){
|
||||
$('td:eq(4)', nRow).append( '<span class="ui-icon ui-icon-closethick"></span>').children('span').click(function(e){e.stopPropagation(); removeTracktypeCallback(aData['id'], nRow)});
|
||||
}else{
|
||||
$('td:eq(4)', nRow).empty().append( '<span class="ui-icon ui-icon-closethick"></span>').children('span').click(function(e){e.stopPropagation(); alert("Can't delete yourself!")});
|
||||
}
|
||||
function rowCallback(nRow, aData, iDisplayIndex) {
|
||||
$(nRow).click(function () {
|
||||
rowClickCallback(aData["id"]);
|
||||
});
|
||||
if (aData["delete"] != "self") {
|
||||
$("td:eq(4)", nRow)
|
||||
.append('<span class="ui-icon ui-icon-closethick"></span>')
|
||||
.children("span")
|
||||
.click(function (e) {
|
||||
e.stopPropagation();
|
||||
removeTracktypeCallback(aData["id"], nRow);
|
||||
});
|
||||
} else {
|
||||
$("td:eq(4)", nRow)
|
||||
.empty()
|
||||
.append('<span class="ui-icon ui-icon-closethick"></span>')
|
||||
.children("span")
|
||||
.click(function (e) {
|
||||
e.stopPropagation();
|
||||
alert("Can't delete yourself!");
|
||||
});
|
||||
}
|
||||
|
||||
if ( aData['visibility'] == "1" ) {
|
||||
$('td:eq(3)', nRow).html( $.i18n._('Enabled') );
|
||||
} else {
|
||||
$('td:eq(3)', nRow).html( $.i18n._('Disabled') );
|
||||
}
|
||||
if (aData["visibility"] == "1") {
|
||||
$("td:eq(3)", nRow).html($.i18n._("Enabled"));
|
||||
} else {
|
||||
$("td:eq(3)", nRow).html($.i18n._("Disabled"));
|
||||
}
|
||||
|
||||
return nRow;
|
||||
return nRow;
|
||||
}
|
||||
|
||||
function populateTracktypeTable() {
|
||||
var dt = $('#tracktypes_datatable');
|
||||
dt.dataTable( {
|
||||
"bProcessing": true,
|
||||
"bServerSide": true,
|
||||
"sAjaxSource": baseUrl+"Tracktype/get-tracktype-data-table-info/format/json",
|
||||
"fnServerData": function ( sSource, aoData, fnCallback ) {
|
||||
$.ajax( {
|
||||
"dataType": 'json',
|
||||
"type": "POST",
|
||||
"url": sSource,
|
||||
"data": aoData,
|
||||
"success": fnCallback
|
||||
} );
|
||||
},
|
||||
"fnRowCallback": rowCallback,
|
||||
"aoColumns": [
|
||||
/* Id */ { "sName": "id", "bSearchable": false, "bVisible": false, "mDataProp": "id" },
|
||||
/* code */ { "sName": "code", "mDataProp": "code" },
|
||||
/* type_name */ { "sName": "type_name", "mDataProp": "type_name" },
|
||||
/* description */ { "sName": "description", "mDataProp": "description" },
|
||||
/* visibility */ { "sName": "visibility", "bSearchable": false, "mDataProp": "visibility" },
|
||||
/* del button */ { "sName": "null as delete", "bSearchable": false, "bSortable": false, "mDataProp": "delete"}
|
||||
],
|
||||
"bJQueryUI": true,
|
||||
"bAutoWidth": false,
|
||||
"bLengthChange": false,
|
||||
"oLanguage": getDatatablesStrings({
|
||||
"sEmptyTable": $.i18n._("No track types were found."),
|
||||
"sEmptyTable": $.i18n._("No track types found"),
|
||||
"sZeroRecords": $.i18n._("No matching track types found"),
|
||||
"sInfo": $.i18n._("Showing _START_ to _END_ of _TOTAL_ track types"),
|
||||
"sInfoEmpty": $.i18n._("Showing 0 to 0 of 0 track types"),
|
||||
"sInfoFiltered": $.i18n._("(filtered from _MAX_ total track types)"),
|
||||
}),
|
||||
"sDom": '<"H"lf<"dt-process-rel"r>><"#tracktype_list_inner_wrapper"t><"F"ip>'
|
||||
});
|
||||
var dt = $("#tracktypes_datatable");
|
||||
dt.dataTable({
|
||||
bProcessing: true,
|
||||
bServerSide: true,
|
||||
sAjaxSource:
|
||||
baseUrl + "Tracktype/get-tracktype-data-table-info/format/json",
|
||||
fnServerData: function (sSource, aoData, fnCallback) {
|
||||
$.ajax({
|
||||
dataType: "json",
|
||||
type: "POST",
|
||||
url: sSource,
|
||||
data: aoData,
|
||||
success: fnCallback,
|
||||
});
|
||||
},
|
||||
fnRowCallback: rowCallback,
|
||||
aoColumns: [
|
||||
/* Id */ {
|
||||
sName: "id",
|
||||
bSearchable: false,
|
||||
bVisible: false,
|
||||
mDataProp: "id",
|
||||
},
|
||||
/* code */ { sName: "code", mDataProp: "code" },
|
||||
/* type_name */ { sName: "type_name", mDataProp: "type_name" },
|
||||
/* description */ { sName: "description", mDataProp: "description" },
|
||||
/* visibility */ {
|
||||
sName: "visibility",
|
||||
bSearchable: false,
|
||||
mDataProp: "visibility",
|
||||
},
|
||||
/* del button */ {
|
||||
sName: "null as delete",
|
||||
bSearchable: false,
|
||||
bSortable: false,
|
||||
mDataProp: "delete",
|
||||
},
|
||||
],
|
||||
bJQueryUI: true,
|
||||
bAutoWidth: false,
|
||||
bLengthChange: false,
|
||||
oLanguage: getDatatablesStrings({
|
||||
sEmptyTable: $.i18n._("No track types were found."),
|
||||
sEmptyTable: $.i18n._("No track types found"),
|
||||
sZeroRecords: $.i18n._("No matching track types found"),
|
||||
sInfo: $.i18n._("Showing _START_ to _END_ of _TOTAL_ track types"),
|
||||
sInfoEmpty: $.i18n._("Showing 0 to 0 of 0 track types"),
|
||||
sInfoFiltered: $.i18n._("(filtered from _MAX_ total track types)"),
|
||||
}),
|
||||
sDom: '<"H"lf<"dt-process-rel"r>><"#tracktype_list_inner_wrapper"t><"F"ip>',
|
||||
});
|
||||
}
|
||||
|
||||
function sizeFormElements() {
|
||||
$("dt[id$='label']").addClass('tracktype-form-label');
|
||||
$("dd[id$='element']").addClass('tracktype-form-element');
|
||||
$("dt[id$='label']").addClass("tracktype-form-label");
|
||||
$("dd[id$='element']").addClass("tracktype-form-element");
|
||||
}
|
||||
|
||||
function initTracktypeData() {
|
||||
var visibility = $('#visibility');
|
||||
var visibility = $("#visibility");
|
||||
|
||||
var table = $("#tracktypes_datable");//.DataTable();
|
||||
$('.datatable tbody').on( 'click', 'tr', function () {
|
||||
$(this).parent().find('tr.selected').removeClass('selected');
|
||||
$(this).addClass('selected');
|
||||
} );
|
||||
var table = $("#tracktypes_datable"); //.DataTable();
|
||||
$(".datatable tbody").on("click", "tr", function () {
|
||||
$(this).parent().find("tr.selected").removeClass("selected");
|
||||
$(this).addClass("selected");
|
||||
});
|
||||
|
||||
$('#button').click( function () {
|
||||
table.row('.selected').remove().draw( false );
|
||||
} );
|
||||
$("#button").click(function () {
|
||||
table.row(".selected").remove().draw(false);
|
||||
});
|
||||
|
||||
var newTracktype = {code:"", type_name:"", description:"", visibility:"1", id:""};
|
||||
var newTracktype = {
|
||||
code: "",
|
||||
type_name: "",
|
||||
description: "",
|
||||
visibility: "1",
|
||||
id: "",
|
||||
};
|
||||
|
||||
$('#add_tracktype_button').live('click', function(){
|
||||
populateForm(newTracktype);
|
||||
$("#tracktype_details").css("visibility", "visible");
|
||||
});
|
||||
$("#add_tracktype_button").live("click", function () {
|
||||
populateForm(newTracktype);
|
||||
$("#tracktype_details").css("visibility", "visible");
|
||||
});
|
||||
}
|
||||
|
||||
$(document).ready(function() {
|
||||
$(document).ready(function () {
|
||||
populateTracktypeTable();
|
||||
initTracktypeData();
|
||||
|
||||
populateTracktypeTable();
|
||||
initTracktypeData();
|
||||
$("#save_tracktype").live("click", function () {
|
||||
var data = $("#tracktype_form").serialize();
|
||||
var url = baseUrl + "Tracktype/add-tracktype";
|
||||
|
||||
$('#save_tracktype').live('click', function(){
|
||||
var data = $('#tracktype_form').serialize();
|
||||
var url = baseUrl+'Tracktype/add-tracktype';
|
||||
|
||||
$.post(url, {format: "json", data: data}, function(json){
|
||||
if (json.valid === "true") {
|
||||
$('#content').empty().append(json.html);
|
||||
populateTracktypeTable();
|
||||
init(); // Reinitialize
|
||||
} else {
|
||||
//if form is invalid we only need to redraw the form
|
||||
$('#tracktype_form').empty().append($(json.html).find('#tracktype_form').children());
|
||||
}
|
||||
setTimeout(removeSuccessMsg, 5000);
|
||||
sizeFormElements();
|
||||
});
|
||||
$.post(url, { format: "json", data: data }, function (json) {
|
||||
if (json.valid === "true") {
|
||||
$("#content").empty().append(json.html);
|
||||
populateTracktypeTable();
|
||||
init(); // Reinitialize
|
||||
} else {
|
||||
//if form is invalid we only need to redraw the form
|
||||
$("#tracktype_form")
|
||||
.empty()
|
||||
.append($(json.html).find("#tracktype_form").children());
|
||||
}
|
||||
setTimeout(removeSuccessMsg, 5000);
|
||||
sizeFormElements();
|
||||
});
|
||||
});
|
||||
|
||||
sizeFormElements();
|
||||
sizeFormElements();
|
||||
});
|
||||
|
|
|
@ -1,258 +1,314 @@
|
|||
function populateForm(entries){
|
||||
//$('#user_details').show();
|
||||
function populateForm(entries) {
|
||||
//$('#user_details').show();
|
||||
|
||||
$('.errors').remove();
|
||||
$('.success').remove();
|
||||
$(".errors").remove();
|
||||
$(".success").remove();
|
||||
|
||||
if (entries.type === 'S')
|
||||
{
|
||||
$("#user_details").hide();
|
||||
$("#user_details_superadmin_message").show();
|
||||
$('#type').attr('disabled', '1');
|
||||
} else {
|
||||
$("#user_details").show();
|
||||
$("#user_details_superadmin_message").hide();
|
||||
$('#type').removeAttr('disabled');
|
||||
}
|
||||
if (entries.type === "S") {
|
||||
$("#user_details").hide();
|
||||
$("#user_details_superadmin_message").show();
|
||||
$("#type").attr("disabled", "1");
|
||||
} else {
|
||||
$("#user_details").show();
|
||||
$("#user_details_superadmin_message").hide();
|
||||
$("#type").removeAttr("disabled");
|
||||
}
|
||||
|
||||
$('#user_id').val(entries.id);
|
||||
$('#login').val(entries.login);
|
||||
$('#first_name').val(entries.first_name);
|
||||
$('#last_name').val(entries.last_name);
|
||||
$('#type').val(entries.type);
|
||||
$('#email').val(entries.email);
|
||||
$('#cell_phone').val(entries.cell_phone);
|
||||
$('#skype').val(entries.skype_contact);
|
||||
$('#jabber').val(entries.jabber_contact);
|
||||
$("#user_id").val(entries.id);
|
||||
$("#login").val(entries.login);
|
||||
$("#first_name").val(entries.first_name);
|
||||
$("#last_name").val(entries.last_name);
|
||||
$("#type").val(entries.type);
|
||||
$("#email").val(entries.email);
|
||||
$("#cell_phone").val(entries.cell_phone);
|
||||
$("#skype").val(entries.skype_contact);
|
||||
$("#jabber").val(entries.jabber_contact);
|
||||
|
||||
if (entries.id.length != 0){
|
||||
$('#login').attr('readonly', 'readonly');
|
||||
$('#password').val("xxxxxx");
|
||||
$('#passwordVerify').val("xxxxxx");
|
||||
} else {
|
||||
$('#login').removeAttr('readonly');
|
||||
$('#password').val("");
|
||||
$('#passwordVerify').val("");
|
||||
}
|
||||
if (entries.id.length != 0) {
|
||||
$("#login").attr("readonly", "readonly");
|
||||
$("#password").val("xxxxxx");
|
||||
$("#passwordVerify").val("xxxxxx");
|
||||
} else {
|
||||
$("#login").removeAttr("readonly");
|
||||
$("#password").val("");
|
||||
$("#passwordVerify").val("");
|
||||
}
|
||||
}
|
||||
|
||||
function rowClickCallback(row_id){
|
||||
$.ajax({ url: baseUrl+'User/get-user-data/id/'+ row_id +'/format/json', dataType:"json", success:function(data){
|
||||
populateForm(data.entries);
|
||||
$("#user_details").css("visibility", "visible");
|
||||
}});
|
||||
function rowClickCallback(row_id) {
|
||||
$.ajax({
|
||||
url: baseUrl + "User/get-user-data/id/" + row_id + "/format/json",
|
||||
dataType: "json",
|
||||
success: function (data) {
|
||||
populateForm(data.entries);
|
||||
$("#user_details").css("visibility", "visible");
|
||||
},
|
||||
});
|
||||
}
|
||||
|
||||
function removeUserCallback(row_id, nRow) {
|
||||
if (confirm($.i18n._("Are you sure you want to delete this user?"))) {
|
||||
$.ajax({
|
||||
url: baseUrl + 'User/remove-user/id/' + row_id + '/format/json',
|
||||
dataType: "text",
|
||||
success: function (data) {
|
||||
var o = $('#users_datatable').dataTable().fnDeleteRow(nRow);
|
||||
}
|
||||
});
|
||||
}
|
||||
if (confirm($.i18n._("Are you sure you want to delete this user?"))) {
|
||||
$.ajax({
|
||||
url: baseUrl + "User/remove-user/id/" + row_id + "/format/json",
|
||||
dataType: "text",
|
||||
success: function (data) {
|
||||
var o = $("#users_datatable").dataTable().fnDeleteRow(nRow);
|
||||
},
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
function rowCallback( nRow, aData, iDisplayIndex ){
|
||||
$(nRow).click(function(){rowClickCallback(aData['id'])});
|
||||
if( aData['delete'] != "self"){
|
||||
$('td:eq(4)', nRow).append( '<span class="ui-icon ui-icon-closethick"></span>').children('span').click(function(e){e.stopPropagation(); removeUserCallback(aData['id'], nRow)});
|
||||
}else{
|
||||
$('td:eq(4)', nRow).empty().append( '<span class="ui-icon ui-icon-closethick"></span>').children('span').click(function(e){e.stopPropagation(); alert($.i18n._("Can't delete yourself!"))});
|
||||
}
|
||||
function rowCallback(nRow, aData, iDisplayIndex) {
|
||||
$(nRow).click(function () {
|
||||
rowClickCallback(aData["id"]);
|
||||
});
|
||||
if (aData["delete"] != "self") {
|
||||
$("td:eq(4)", nRow)
|
||||
.append('<span class="ui-icon ui-icon-closethick"></span>')
|
||||
.children("span")
|
||||
.click(function (e) {
|
||||
e.stopPropagation();
|
||||
removeUserCallback(aData["id"], nRow);
|
||||
});
|
||||
} else {
|
||||
$("td:eq(4)", nRow)
|
||||
.empty()
|
||||
.append('<span class="ui-icon ui-icon-closethick"></span>')
|
||||
.children("span")
|
||||
.click(function (e) {
|
||||
e.stopPropagation();
|
||||
alert($.i18n._("Can't delete yourself!"));
|
||||
});
|
||||
}
|
||||
|
||||
if ( aData['type'] == "A" )
|
||||
{
|
||||
$('td:eq(3)', nRow).html( $.i18n._('Admin') );
|
||||
} else if ( aData['type'] == "H" )
|
||||
{
|
||||
$('td:eq(3)', nRow).html( $.i18n._('DJ') );
|
||||
} else if ( aData['type'] == "G" )
|
||||
{
|
||||
$('td:eq(3)', nRow).html( $.i18n._('Guest') );
|
||||
} else if ( aData['type'] == "P" )
|
||||
{
|
||||
$('td:eq(3)', nRow).html( $.i18n._('Program Manager') );
|
||||
} else if ( aData['type'] == "S" )
|
||||
{
|
||||
$('td:eq(3)', nRow).html( $.i18n._('Super Admin') );
|
||||
$('td:eq(4)', nRow).html(""); //Disable deleting the super admin
|
||||
}
|
||||
if (aData["type"] == "A") {
|
||||
$("td:eq(3)", nRow).html($.i18n._("Admin"));
|
||||
} else if (aData["type"] == "H") {
|
||||
$("td:eq(3)", nRow).html($.i18n._("DJ"));
|
||||
} else if (aData["type"] == "G") {
|
||||
$("td:eq(3)", nRow).html($.i18n._("Guest"));
|
||||
} else if (aData["type"] == "P") {
|
||||
$("td:eq(3)", nRow).html($.i18n._("Program Manager"));
|
||||
} else if (aData["type"] == "S") {
|
||||
$("td:eq(3)", nRow).html($.i18n._("Super Admin"));
|
||||
$("td:eq(4)", nRow).html(""); //Disable deleting the super admin
|
||||
}
|
||||
|
||||
return nRow;
|
||||
return nRow;
|
||||
}
|
||||
|
||||
function populateUserTable() {
|
||||
var dt = $('#users_datatable');
|
||||
dt.dataTable( {
|
||||
"bProcessing": true,
|
||||
"bServerSide": true,
|
||||
"sAjaxSource": baseUrl+"User/get-user-data-table-info/format/json",
|
||||
"fnServerData": function ( sSource, aoData, fnCallback ) {
|
||||
$.ajax( {
|
||||
"dataType": 'json',
|
||||
"type": "POST",
|
||||
"url": sSource,
|
||||
"data": aoData,
|
||||
"success": fnCallback
|
||||
} );
|
||||
},
|
||||
"fnRowCallback": rowCallback,
|
||||
"aoColumns": [
|
||||
/* Id */ { "sName": "id", "bSearchable": false, "bVisible": false, "mDataProp": "id" },
|
||||
/* user name */ { "sName": "login", "mDataProp": "login" },
|
||||
/* first name */ { "sName": "first_name", "mDataProp": "first_name" },
|
||||
/* last name */ { "sName": "last_name", "mDataProp": "last_name" },
|
||||
/* user type */ { "sName": "type", "bSearchable": false, "mDataProp": "type" },
|
||||
/* del button */ { "sName": "null as delete", "bSearchable": false, "bSortable": false, "mDataProp": "delete"}
|
||||
],
|
||||
"bJQueryUI": true,
|
||||
"bAutoWidth": false,
|
||||
"bLengthChange": false,
|
||||
"oLanguage": getDatatablesStrings({
|
||||
"sEmptyTable": $.i18n._("No users were found."),
|
||||
"sEmptyTable": $.i18n._("No users found"),
|
||||
"sZeroRecords": $.i18n._("No matching users found"),
|
||||
"sInfo": $.i18n._("Showing _START_ to _END_ of _TOTAL_ users"),
|
||||
"sInfoEmpty": $.i18n._("Showing 0 to 0 of 0 users"),
|
||||
"sInfoFiltered": $.i18n._("(filtered from _MAX_ total users)"),
|
||||
}),
|
||||
"sDom": '<"H"lf<"dt-process-rel"r>><"#user_list_inner_wrapper"t><"F"ip>'
|
||||
});
|
||||
var dt = $("#users_datatable");
|
||||
dt.dataTable({
|
||||
bProcessing: true,
|
||||
bServerSide: true,
|
||||
sAjaxSource: baseUrl + "User/get-user-data-table-info/format/json",
|
||||
fnServerData: function (sSource, aoData, fnCallback) {
|
||||
$.ajax({
|
||||
dataType: "json",
|
||||
type: "POST",
|
||||
url: sSource,
|
||||
data: aoData,
|
||||
success: fnCallback,
|
||||
});
|
||||
},
|
||||
fnRowCallback: rowCallback,
|
||||
aoColumns: [
|
||||
/* Id */ {
|
||||
sName: "id",
|
||||
bSearchable: false,
|
||||
bVisible: false,
|
||||
mDataProp: "id",
|
||||
},
|
||||
/* user name */ { sName: "login", mDataProp: "login" },
|
||||
/* first name */ { sName: "first_name", mDataProp: "first_name" },
|
||||
/* last name */ { sName: "last_name", mDataProp: "last_name" },
|
||||
/* user type */ { sName: "type", bSearchable: false, mDataProp: "type" },
|
||||
/* del button */ {
|
||||
sName: "null as delete",
|
||||
bSearchable: false,
|
||||
bSortable: false,
|
||||
mDataProp: "delete",
|
||||
},
|
||||
],
|
||||
bJQueryUI: true,
|
||||
bAutoWidth: false,
|
||||
bLengthChange: false,
|
||||
oLanguage: getDatatablesStrings({
|
||||
sEmptyTable: $.i18n._("No users were found."),
|
||||
sEmptyTable: $.i18n._("No users found"),
|
||||
sZeroRecords: $.i18n._("No matching users found"),
|
||||
sInfo: $.i18n._("Showing _START_ to _END_ of _TOTAL_ users"),
|
||||
sInfoEmpty: $.i18n._("Showing 0 to 0 of 0 users"),
|
||||
sInfoFiltered: $.i18n._("(filtered from _MAX_ total users)"),
|
||||
}),
|
||||
sDom: '<"H"lf<"dt-process-rel"r>><"#user_list_inner_wrapper"t><"F"ip>',
|
||||
});
|
||||
}
|
||||
|
||||
function sizeFormElements() {
|
||||
$("dt[id$='label']").addClass('user-form-label');
|
||||
$("dd[id$='element']").addClass('user-form-element');
|
||||
$("dt[id$='label']").addClass("user-form-label");
|
||||
$("dd[id$='element']").addClass("user-form-element");
|
||||
}
|
||||
|
||||
function assignUserRightsToUserTypes() {
|
||||
//assign user-rights and id to each user type option so we can
|
||||
//display user rights for each with tipsy tooltip
|
||||
$.each($('#type').children(), function(i, opt) {
|
||||
switch ($(this).val()) {
|
||||
case 'G':
|
||||
$(this).attr('id', 'user-type-G');
|
||||
$(this).attr('user-rights',
|
||||
$.i18n._('Guests can do the following:')+'<br><br>'+
|
||||
$.i18n._('View schedule')+'<br>'+
|
||||
$.i18n._('View show content')
|
||||
);
|
||||
break;
|
||||
case 'H':
|
||||
$(this).attr('id', 'user-type-H');
|
||||
$(this).attr('user-rights',
|
||||
$.i18n._('DJs can do the following:')+'<br><br>'+
|
||||
$.i18n._('View schedule')+'<br>'+
|
||||
$.i18n._('View show content')+'<br>'+
|
||||
$.i18n._('Manage assigned show content')+'<br>'+
|
||||
$.i18n._('Import media files')+'<br>'+
|
||||
$.i18n._('Create playlists, smart blocks, and webstreams')+'<br>'+
|
||||
$.i18n._('Manage their own library content')
|
||||
);
|
||||
break;
|
||||
case 'P':
|
||||
$(this).attr('id', 'user-type-P');
|
||||
$(this).attr('user-rights',
|
||||
$.i18n._('Program Managers can do the following:')+'<br><br>'+
|
||||
$.i18n._('View schedule')+'<br>'+
|
||||
$.i18n._('View and manage show content')+'<br>'+
|
||||
$.i18n._('Schedule shows')+'<br>'+
|
||||
$.i18n._('Import media files')+'<br>'+
|
||||
$.i18n._('Create playlists, smart blocks, and webstreams')+'<br>'+
|
||||
$.i18n._('Manage all library content')
|
||||
);
|
||||
break;
|
||||
case 'A':
|
||||
$(this).attr('id', 'user-type-A');
|
||||
$(this).attr('user-rights',
|
||||
$.i18n._('Admins can do the following:')+'<br><br>'+
|
||||
$.i18n._('Manage preferences')+'<br>'+
|
||||
$.i18n._('Manage users')+'<br>'+
|
||||
$.i18n._('Manage watched folders')+'<br>'+
|
||||
$.i18n._('Send support feedback')+'<br>'+
|
||||
$.i18n._('View system status')+'<br>'+
|
||||
$.i18n._('Access playout history')+'<br>'+
|
||||
$.i18n._('View listener stats')+'<br>'+
|
||||
$.i18n._('View schedule')+'<br>'+
|
||||
$.i18n._('View and manage show content')+'<br>'+
|
||||
$.i18n._('Schedule shows')+'<br>'+
|
||||
$.i18n._('Import media files')+'<br>'+
|
||||
$.i18n._('Create playlists, smart blocks, and webstreams')+'<br>'+
|
||||
$.i18n._('Manage all library content')
|
||||
);
|
||||
break;
|
||||
}
|
||||
});
|
||||
//assign user-rights and id to each user type option so we can
|
||||
//display user rights for each with tipsy tooltip
|
||||
$.each($("#type").children(), function (i, opt) {
|
||||
switch ($(this).val()) {
|
||||
case "G":
|
||||
$(this).attr("id", "user-type-G");
|
||||
$(this).attr(
|
||||
"user-rights",
|
||||
$.i18n._("Guests can do the following:") +
|
||||
"<br><br>" +
|
||||
$.i18n._("View schedule") +
|
||||
"<br>" +
|
||||
$.i18n._("View show content")
|
||||
);
|
||||
break;
|
||||
case "H":
|
||||
$(this).attr("id", "user-type-H");
|
||||
$(this).attr(
|
||||
"user-rights",
|
||||
$.i18n._("DJs can do the following:") +
|
||||
"<br><br>" +
|
||||
$.i18n._("View schedule") +
|
||||
"<br>" +
|
||||
$.i18n._("View show content") +
|
||||
"<br>" +
|
||||
$.i18n._("Manage assigned show content") +
|
||||
"<br>" +
|
||||
$.i18n._("Import media files") +
|
||||
"<br>" +
|
||||
$.i18n._("Create playlists, smart blocks, and webstreams") +
|
||||
"<br>" +
|
||||
$.i18n._("Manage their own library content")
|
||||
);
|
||||
break;
|
||||
case "P":
|
||||
$(this).attr("id", "user-type-P");
|
||||
$(this).attr(
|
||||
"user-rights",
|
||||
$.i18n._("Program Managers can do the following:") +
|
||||
"<br><br>" +
|
||||
$.i18n._("View schedule") +
|
||||
"<br>" +
|
||||
$.i18n._("View and manage show content") +
|
||||
"<br>" +
|
||||
$.i18n._("Schedule shows") +
|
||||
"<br>" +
|
||||
$.i18n._("Import media files") +
|
||||
"<br>" +
|
||||
$.i18n._("Create playlists, smart blocks, and webstreams") +
|
||||
"<br>" +
|
||||
$.i18n._("Manage all library content")
|
||||
);
|
||||
break;
|
||||
case "A":
|
||||
$(this).attr("id", "user-type-A");
|
||||
$(this).attr(
|
||||
"user-rights",
|
||||
$.i18n._("Admins can do the following:") +
|
||||
"<br><br>" +
|
||||
$.i18n._("Manage preferences") +
|
||||
"<br>" +
|
||||
$.i18n._("Manage users") +
|
||||
"<br>" +
|
||||
$.i18n._("Manage watched folders") +
|
||||
"<br>" +
|
||||
$.i18n._("Send support feedback") +
|
||||
"<br>" +
|
||||
$.i18n._("View system status") +
|
||||
"<br>" +
|
||||
$.i18n._("Access playout history") +
|
||||
"<br>" +
|
||||
$.i18n._("View listener stats") +
|
||||
"<br>" +
|
||||
$.i18n._("View schedule") +
|
||||
"<br>" +
|
||||
$.i18n._("View and manage show content") +
|
||||
"<br>" +
|
||||
$.i18n._("Schedule shows") +
|
||||
"<br>" +
|
||||
$.i18n._("Import media files") +
|
||||
"<br>" +
|
||||
$.i18n._("Create playlists, smart blocks, and webstreams") +
|
||||
"<br>" +
|
||||
$.i18n._("Manage all library content")
|
||||
);
|
||||
break;
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
function initUserData() {
|
||||
var type = $('#type');
|
||||
var type = $("#type");
|
||||
|
||||
type.live("change", function(){
|
||||
//when the title changes on live tipsy tooltips the changes take
|
||||
//affect the next time tipsy is shown so we need to hide and re-show it
|
||||
$(this).tipsy('hide').tipsy('show');
|
||||
});
|
||||
type.live("change", function () {
|
||||
//when the title changes on live tipsy tooltips the changes take
|
||||
//affect the next time tipsy is shown so we need to hide and re-show it
|
||||
$(this).tipsy("hide").tipsy("show");
|
||||
});
|
||||
|
||||
type.tipsy({
|
||||
gravity: 'w',
|
||||
html: true,
|
||||
opacity: 0.9,
|
||||
trigger: 'manual',
|
||||
live: true,
|
||||
title: function() {
|
||||
return $('#user-type-'+$(this).val()).attr('user-rights');
|
||||
}
|
||||
});
|
||||
type.tipsy({
|
||||
gravity: "w",
|
||||
html: true,
|
||||
opacity: 0.9,
|
||||
trigger: "manual",
|
||||
live: true,
|
||||
title: function () {
|
||||
return $("#user-type-" + $(this).val()).attr("user-rights");
|
||||
},
|
||||
});
|
||||
|
||||
var table = $("#users_datable");//.DataTable();
|
||||
$('.datatable tbody').on( 'click', 'tr', function () {
|
||||
$(this).parent().find('tr.selected').removeClass('selected');
|
||||
$(this).addClass('selected');
|
||||
} );
|
||||
var table = $("#users_datable"); //.DataTable();
|
||||
$(".datatable tbody").on("click", "tr", function () {
|
||||
$(this).parent().find("tr.selected").removeClass("selected");
|
||||
$(this).addClass("selected");
|
||||
});
|
||||
|
||||
$('#button').click( function () {
|
||||
table.row('.selected').remove().draw( false );
|
||||
} );
|
||||
$("#button").click(function () {
|
||||
table.row(".selected").remove().draw(false);
|
||||
});
|
||||
|
||||
type.tipsy('show');
|
||||
type.tipsy("show");
|
||||
|
||||
var newUser = {login:"", first_name:"", last_name:"", type:"G", id:""};
|
||||
var newUser = { login: "", first_name: "", last_name: "", type: "G", id: "" };
|
||||
|
||||
$('#add_user_button').live('click', function(){
|
||||
populateForm(newUser);
|
||||
$("#user_details").css("visibility", "visible");
|
||||
});
|
||||
$("#add_user_button").live("click", function () {
|
||||
populateForm(newUser);
|
||||
$("#user_details").css("visibility", "visible");
|
||||
});
|
||||
}
|
||||
|
||||
$(document).ready(function() {
|
||||
populateUserTable();
|
||||
assignUserRightsToUserTypes();
|
||||
initUserData();
|
||||
$(document).ready(function () {
|
||||
populateUserTable();
|
||||
assignUserRightsToUserTypes();
|
||||
initUserData();
|
||||
|
||||
$('#save_user').live('click', function(){
|
||||
var data = $('#user_form').serialize();
|
||||
var url = baseUrl+'User/add-user';
|
||||
$("#save_user").live("click", function () {
|
||||
var data = $("#user_form").serialize();
|
||||
var url = baseUrl + "User/add-user";
|
||||
|
||||
$.post(url, {format: "json", data: data}, function(json){
|
||||
if (json.valid === "true") {
|
||||
$('#content').empty().append(json.html);
|
||||
populateUserTable();
|
||||
assignUserRightsToUserTypes();
|
||||
init(); // Reinitialize
|
||||
} else {
|
||||
//if form is invalid we only need to redraw the form
|
||||
$('#user_form').empty().append($(json.html).find('#user_form').children());
|
||||
$('#password').val("");
|
||||
$('#passwordVerify').val("");
|
||||
}
|
||||
setTimeout(removeSuccessMsg, 5000);
|
||||
sizeFormElements();
|
||||
});
|
||||
$.post(url, { format: "json", data: data }, function (json) {
|
||||
if (json.valid === "true") {
|
||||
$("#content").empty().append(json.html);
|
||||
populateUserTable();
|
||||
assignUserRightsToUserTypes();
|
||||
init(); // Reinitialize
|
||||
} else {
|
||||
//if form is invalid we only need to redraw the form
|
||||
$("#user_form")
|
||||
.empty()
|
||||
.append($(json.html).find("#user_form").children());
|
||||
$("#password").val("");
|
||||
$("#passwordVerify").val("");
|
||||
}
|
||||
setTimeout(removeSuccessMsg, 5000);
|
||||
sizeFormElements();
|
||||
});
|
||||
});
|
||||
|
||||
sizeFormElements();
|
||||
sizeFormElements();
|
||||
});
|
||||
|
|
|
@ -1,76 +1,80 @@
|
|||
var AIRTIME = (function(AIRTIME){
|
||||
var mod;
|
||||
var AIRTIME = (function (AIRTIME) {
|
||||
var mod;
|
||||
|
||||
if (AIRTIME.utilities === undefined) {
|
||||
AIRTIME.utilities = {};
|
||||
}
|
||||
mod = AIRTIME.utilities;
|
||||
if (AIRTIME.utilities === undefined) {
|
||||
AIRTIME.utilities = {};
|
||||
}
|
||||
mod = AIRTIME.utilities;
|
||||
|
||||
mod.findViewportDimensions = function() {
|
||||
var viewportwidth,
|
||||
viewportheight;
|
||||
mod.findViewportDimensions = function () {
|
||||
var viewportwidth, viewportheight;
|
||||
|
||||
// the more standards compliant browsers (mozilla/netscape/opera/IE7) use
|
||||
// window.innerWidth and window.innerHeight
|
||||
if (typeof window.innerWidth != 'undefined') {
|
||||
viewportwidth = window.innerWidth, viewportheight = window.innerHeight;
|
||||
}
|
||||
// IE6 in standards compliant mode (i.e. with a valid doctype as the first
|
||||
// line in the document)
|
||||
else if (typeof document.documentElement != 'undefined'
|
||||
&& typeof document.documentElement.clientWidth != 'undefined'
|
||||
&& document.documentElement.clientWidth != 0) {
|
||||
viewportwidth = document.documentElement.clientWidth;
|
||||
viewportheight = document.documentElement.clientHeight;
|
||||
}
|
||||
// older versions of IE
|
||||
else {
|
||||
viewportwidth = document.getElementsByTagName('body')[0].clientWidth;
|
||||
viewportheight = document.getElementsByTagName('body')[0].clientHeight;
|
||||
}
|
||||
// the more standards compliant browsers (mozilla/netscape/opera/IE7) use
|
||||
// window.innerWidth and window.innerHeight
|
||||
if (typeof window.innerWidth != "undefined") {
|
||||
(viewportwidth = window.innerWidth),
|
||||
(viewportheight = window.innerHeight);
|
||||
}
|
||||
// IE6 in standards compliant mode (i.e. with a valid doctype as the first
|
||||
// line in the document)
|
||||
else if (
|
||||
typeof document.documentElement != "undefined" &&
|
||||
typeof document.documentElement.clientWidth != "undefined" &&
|
||||
document.documentElement.clientWidth != 0
|
||||
) {
|
||||
viewportwidth = document.documentElement.clientWidth;
|
||||
viewportheight = document.documentElement.clientHeight;
|
||||
}
|
||||
// older versions of IE
|
||||
else {
|
||||
viewportwidth = document.getElementsByTagName("body")[0].clientWidth;
|
||||
viewportheight = document.getElementsByTagName("body")[0].clientHeight;
|
||||
}
|
||||
|
||||
return {
|
||||
width: viewportwidth,
|
||||
height: viewportheight
|
||||
};
|
||||
};
|
||||
return {
|
||||
width: viewportwidth,
|
||||
height: viewportheight,
|
||||
};
|
||||
};
|
||||
|
||||
/*
|
||||
* Returns an object containing a unix timestamp in seconds for the start/end range
|
||||
*
|
||||
* @return Object {"start", "end", "range"}
|
||||
*/
|
||||
mod.fnGetScheduleRange = function(dateStartId, timeStartId, dateEndId, timeEndId) {
|
||||
var start,
|
||||
end,
|
||||
time;
|
||||
/*
|
||||
* Returns an object containing a unix timestamp in seconds for the start/end range
|
||||
*
|
||||
* @return Object {"start", "end", "range"}
|
||||
*/
|
||||
mod.fnGetScheduleRange = function (
|
||||
dateStartId,
|
||||
timeStartId,
|
||||
dateEndId,
|
||||
timeEndId
|
||||
) {
|
||||
var start, end, time;
|
||||
|
||||
start = $(dateStartId).val();
|
||||
start = start === "" ? null : start;
|
||||
start = $(dateStartId).val();
|
||||
start = start === "" ? null : start;
|
||||
|
||||
time = $(timeStartId).val();
|
||||
time = time === "" ? "00:00" : time;
|
||||
time = $(timeStartId).val();
|
||||
time = time === "" ? "00:00" : time;
|
||||
|
||||
if (start) {
|
||||
start = start + " " + time;
|
||||
}
|
||||
if (start) {
|
||||
start = start + " " + time;
|
||||
}
|
||||
|
||||
end = $(dateEndId).val();
|
||||
end = end === "" ? null : end;
|
||||
end = $(dateEndId).val();
|
||||
end = end === "" ? null : end;
|
||||
|
||||
time = $(timeEndId).val();
|
||||
time = time === "" ? "00:00" : time;
|
||||
time = $(timeEndId).val();
|
||||
time = time === "" ? "00:00" : time;
|
||||
|
||||
if (end) {
|
||||
end = end + " " + time;
|
||||
}
|
||||
if (end) {
|
||||
end = end + " " + time;
|
||||
}
|
||||
|
||||
return {
|
||||
start: start,
|
||||
end: end
|
||||
};
|
||||
};
|
||||
return {
|
||||
start: start,
|
||||
end: end,
|
||||
};
|
||||
};
|
||||
|
||||
return AIRTIME;
|
||||
|
||||
}(AIRTIME || {}));
|
||||
return AIRTIME;
|
||||
})(AIRTIME || {});
|
||||
|
|
|
@ -2,31 +2,77 @@
|
|||
* Created by asantoni on 11/09/15.
|
||||
*/
|
||||
|
||||
$(document).ready(function () {
|
||||
var aoColumns = [
|
||||
/* Artwork */ {
|
||||
sTitle: $.i18n._("Artwork"),
|
||||
mDataProp: "artwork",
|
||||
bVisible: false,
|
||||
sClass: "library_artwork",
|
||||
sWidth: "150px",
|
||||
},
|
||||
/* Title */ {
|
||||
sTitle: $.i18n._("Title"),
|
||||
mDataProp: "track_title",
|
||||
sClass: "library_title",
|
||||
sWidth: "170px",
|
||||
},
|
||||
/* Creator */ {
|
||||
sTitle: $.i18n._("Creator"),
|
||||
mDataProp: "artist_name",
|
||||
sClass: "library_creator",
|
||||
sWidth: "160px",
|
||||
},
|
||||
/* Upload Time */ {
|
||||
sTitle: $.i18n._("Uploaded"),
|
||||
mDataProp: "utime",
|
||||
bVisible: false,
|
||||
sClass: "library_upload_time",
|
||||
sWidth: "155px",
|
||||
},
|
||||
/* Website */ {
|
||||
sTitle: $.i18n._("Website"),
|
||||
mDataProp: "info_url",
|
||||
bVisible: false,
|
||||
sClass: "library_url",
|
||||
sWidth: "150px",
|
||||
},
|
||||
/* Year */ {
|
||||
sTitle: $.i18n._("Year"),
|
||||
mDataProp: "year",
|
||||
bVisible: false,
|
||||
sClass: "library_year",
|
||||
sWidth: "60px",
|
||||
},
|
||||
];
|
||||
var ajaxSourceURL = baseUrl + "rest/media";
|
||||
|
||||
$(document).ready(function() {
|
||||
var aoColumns = [
|
||||
/* Artwork */ { "sTitle" : $.i18n._("Artwork") , "mDataProp" : "artwork" , "bVisible" : false , "sClass" : "library_artwork" , "sWidth" : "150px" },
|
||||
/* Title */ { "sTitle" : $.i18n._("Title") , "mDataProp" : "track_title" , "sClass" : "library_title" , "sWidth" : "170px" },
|
||||
/* Creator */ { "sTitle" : $.i18n._("Creator") , "mDataProp" : "artist_name" , "sClass" : "library_creator" , "sWidth" : "160px" },
|
||||
/* Upload Time */ { "sTitle" : $.i18n._("Uploaded") , "mDataProp" : "utime" , "bVisible" : false , "sClass" : "library_upload_time" , "sWidth" : "155px" },
|
||||
/* Website */ { "sTitle" : $.i18n._("Website") , "mDataProp" : "info_url" , "bVisible" : false , "sClass" : "library_url" , "sWidth" : "150px" },
|
||||
/* Year */ { "sTitle" : $.i18n._("Year") , "mDataProp" : "year" , "bVisible" : false , "sClass" : "library_year" , "sWidth" : "60px" },
|
||||
];
|
||||
var ajaxSourceURL = baseUrl+"rest/media";
|
||||
var myToolbarButtons = AIRTIME.widgets.Table.getStandardToolbarButtons();
|
||||
myToolbarButtons[
|
||||
AIRTIME.widgets.Table.TOOLBAR_BUTTON_ROLES.NEW
|
||||
].eventHandlers.click = function (e) {
|
||||
alert("New!");
|
||||
};
|
||||
myToolbarButtons[
|
||||
AIRTIME.widgets.Table.TOOLBAR_BUTTON_ROLES.EDIT
|
||||
].eventHandlers.click = function (e) {
|
||||
alert("Edit!");
|
||||
};
|
||||
myToolbarButtons[
|
||||
AIRTIME.widgets.Table.TOOLBAR_BUTTON_ROLES.DELETE
|
||||
].eventHandlers.click = function (e) {
|
||||
alert("Delete!");
|
||||
};
|
||||
|
||||
var myToolbarButtons = AIRTIME.widgets.Table.getStandardToolbarButtons();
|
||||
myToolbarButtons[AIRTIME.widgets.Table.TOOLBAR_BUTTON_ROLES.NEW].eventHandlers.click = function(e) { alert('New!'); };
|
||||
myToolbarButtons[AIRTIME.widgets.Table.TOOLBAR_BUTTON_ROLES.EDIT].eventHandlers.click = function(e) { alert('Edit!'); };
|
||||
myToolbarButtons[AIRTIME.widgets.Table.TOOLBAR_BUTTON_ROLES.DELETE].eventHandlers.click = function(e) { alert('Delete!'); };
|
||||
|
||||
|
||||
//Set up the div with id "example-table" as a datatable.
|
||||
var table = new AIRTIME.widgets.Table(
|
||||
$('#example-table'), //DOM node to create the table inside.
|
||||
true, //Enable item selection
|
||||
myToolbarButtons, //Toolbar buttons
|
||||
{ //Datatables overrides.
|
||||
'aoColumns' : aoColumns,
|
||||
'sAjaxSource' : ajaxSourceURL
|
||||
});
|
||||
//Set up the div with id "example-table" as a datatable.
|
||||
var table = new AIRTIME.widgets.Table(
|
||||
$("#example-table"), //DOM node to create the table inside.
|
||||
true, //Enable item selection
|
||||
myToolbarButtons, //Toolbar buttons
|
||||
{
|
||||
//Datatables overrides.
|
||||
aoColumns: aoColumns,
|
||||
sAjaxSource: ajaxSourceURL,
|
||||
}
|
||||
);
|
||||
});
|
||||
|
|
File diff suppressed because it is too large
Load diff
Loading…
Add table
Add a link
Reference in a new issue