Rename airtime_mvc/ to legacy/

This commit is contained in:
jo 2021-10-11 13:43:25 +02:00
parent f0879322c2
commit 3e18d42c8b
1316 changed files with 0 additions and 0 deletions

View file

@ -0,0 +1,530 @@
//approximate server time, because once we receive it from the server,
//there way have been a great amount of latency and it is no longer accurate.
var approximateServerTime = null;
var localRemoteTimeOffset = null;
var previousSong = null;
var currentSong = null;
var nextSong = null;
var currentShow = new Array();
var nextShow = new Array();
var showName = null;
var currentElem;
var serverUpdateInterval = 5000;
var uiUpdateInterval = 200;
var master_dj_on_air = false;
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;
//a reference returned by setTimeout. Useful for when we want clearTimeout()
var newShowTimeoutId = null;
//keep track of how many UI refreshes the ON-AIR light has been off for.
//For example, the uiUpdateInterval is every 200ms, so if onAirOffIterations
//is 25, then that means 5 seconds have gone by.
var onAirOffIterations = 0;
/* boolean flag to let us know if we should prepare to execute a function
* that flips the playlist to the next song. This flag's purpose is to
* make sure the function is only executed once*/
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 newSongStart(){
nextSongPrepare = true;
if (nextSong.type == 'track') {
currentSong = nextSong;
nextSong = null;
}
}
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;
}
}
$('#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");
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");
}
} 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();
}
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();
} 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 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 (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);
}
function calculateTimeToNextShow() {
if (approximateServerTime === null) {
return;
}
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);
}
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();
}
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();
}
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();
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");
}
}
function parseSwitchStatus(obj){
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.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");
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");
}
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 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");
}
}
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');
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);
}
});
}
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 consumer "thread"
secondsTimer();
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;
});
}
/* We never retrieve the user's password from the db
* and when we call isValid($params) the form values are cleared
* and repopulated with $params which does not have the password
* field. Therefore, we fill the password field with 6 x's
*/
function setCurrentUserPseudoPassword() {
$('#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 ($(this).width() > 970) {
$("#nav .responsive-menu").show();
}
});*/
$(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', '#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'));
/*$('#menu-btn').click(function() {
$('#nav .responsive-menu').slideToggle();
});*/
});

View file

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

View file

@ -0,0 +1,150 @@
/**
* 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 msg = "";
// See file airtime_mvc/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;
}
/**
* Get if patch is available
*/
function getHasPatch() {
return versionNotifyInfo.hasPatch;
}
/**
* Get if minor update is available
*/
function getHasMinor() {
return versionNotifyInfo.hasMinor;
}
/**
* Get if major update is available
*/
function getHasMajor() {
return versionNotifyInfo.hasMajor;
}
/**
* Get if multiple major updates are available
*/
function getHasMultiMajor() {
return versionNotifyInfo.hasMultiMajor;
}
/**
* Get if pre-release was installed
*/
function getIsPreRelease() {
return versionNotifyInfo.isPreRelease;
}
/**
* Get the current version
*/
function getCurrentVersion() {
return versionNotifyInfo.current;
}
/**
* Get the latest version
*/
function getLatestVersion() {
return versionNotifyInfo.latest;
}
/**
* Returns the download link to latest release in HTML
*/
function getLatestLink() {
return "<a href='' onclick='openLatestLink();'>" + getLatestVersion() + "</a>";
}
/**
* Returns true if current version is up to date
*/
function isUpToDate() {
return !getHasPatch() && !getHasMinor() && !getHasMajor();
}
/**
* Opens the link in a new window
*/
function openLatestLink() {
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"
}
});
}
}
$(document).ready(function() {
if($('#version-icon').length > 0) {
setupVersionQtip();
}
});