diff --git a/airtime_mvc/application/views/helpers/VersionNotify.php b/airtime_mvc/application/views/helpers/VersionNotify.php
index be87718a7..e4ece3df3 100644
--- a/airtime_mvc/application/views/helpers/VersionNotify.php
+++ b/airtime_mvc/application/views/helpers/VersionNotify.php
@@ -26,35 +26,31 @@ class Airtime_View_Helper_VersionNotify extends Zend_View_Helper_Abstract{
return "";
}
- // Calculate version diff
+ // Calculate major version diff;
+ // Example: if current = 1.9.5 and latest = 3.0.0, major diff = 11
// Note: algorithm assumes the number after 1st dot never goes above 9
$diff = (intval($latestMatch[1]) * 10 + intval($latestMatch[2]))
- (intval($curMatch[1]) * 10 + intval($curMatch[2]));
- // Pick icon and tooltip msg
+ // Pick icon
$bg = "/css/images/";
- $msg = "";
- $link = "" . $latest . "";
if(($diff == 0 && $current == $latest) || $diff < 0) {
// current version is up to date
$bg .= "icon_uptodate.png";
- $msg = "You are running the latest version";
} else if($diff <= 2) {
// 2 or less major versions back
$bg .= "icon_update.png";
- $msg = "New version available: " . $link;
} else if($diff == 3) {
// 3 major versions back
$bg .= "icon_update2.png";
- $msg = "This version will soon be obsolete.
Please upgrade to " . $link;
} else {
// more than 3 major versions back
$bg .= "icon_outdated.png";
- $msg = "This version is no longer supported.
Please upgrade to " . $link;
}
- $result = "
" . $msg . "
"
+ $result = "" . $diff . "
"
. "" . $current . "
"
+ . "" . $latest . "
"
. "";
return $result;
}
diff --git a/airtime_mvc/public/js/airtime/dashboard/versiontooltip.js b/airtime_mvc/public/js/airtime/dashboard/versiontooltip.js
index 0f014a5db..ab96e6759 100644
--- a/airtime_mvc/public/js/airtime/dashboard/versiontooltip.js
+++ b/airtime_mvc/public/js/airtime/dashboard/versiontooltip.js
@@ -1,19 +1,63 @@
/**
- * Get the tooltip message to be displayed,
- * which is stored inside a pair of hidden div tags
+ * Get the tooltip message to be displayed
*/
function getContent() {
- return $("#version_message").html();
+ var diff = getVersionDiff();
+ var link = getLatestLink();
+
+ var msg = "";
+ if(isUpToDate()) {
+ msg = "You are running the latest version";
+ } else if(diff <= 2) {
+ msg = "New version available: " + link;
+ } else if(diff == 3) {
+ msg = "This version will soon be obsolete.
Please upgrade to " + link;
+ } else {
+ msg = "This version is no longer supported.
Please upgrade to " + link;
+ }
+
+ return msg;
}
/**
- * Get the current version,
- * which is stored inside a pair of hidden div tags
+ * Get major version difference b/w current and latest version, in int
+ */
+function getVersionDiff() {
+ return parseInt($("#version_diff").html());
+}
+
+/**
+ * Get the current version
*/
function getCurrentVersion() {
return $("#version_current").html();
}
+/**
+ * Get the latest version
+ */
+function getLatestVersion() {
+ return $("#version_latest").html();
+}
+
+/**
+ * Returns true if current version is up to date
+ */
+function isUpToDate() {
+ var diff = getVersionDiff();
+ var current = getCurrentVersion();
+ var latest = getLatestVersion();
+ var temp = (diff == 0 && current == latest) || diff < 0;
+ return (diff == 0 && current == latest) || diff < 0;
+}
+
+/**
+ * Returns the download link to latest release in HTML
+ */
+function getLatestLink() {
+ return "" + getLatestVersion() + "";
+}
+
/**
* Sets up the tooltip for version notification
*/
@@ -26,10 +70,12 @@ function setupVersionQtip(){
text: getContent(),
title: {
text: getCurrentVersion(),
- button: true
+ button: isUpToDate() ? false : true
}
},
- hide: false, /* Don't hide on mouseout */
+ hide: {
+ event: isUpToDate() ? 'mouseleave' : 'unfocus'
+ },
position: {
my: "top right",
at: "bottom left"
@@ -46,7 +92,7 @@ function setupVersionQtip(){
}
$(document).ready(function() {
- if($('#version_message').length > 0) {
+ if($('#version_icon').length > 0) {
setupVersionQtip();
}
});
\ No newline at end of file