Fixed issue 11979: Added message in Login_F1.html to check supported browser
authorDavid Baz Fayos <david.baz@openbravo.com>
Wed, 17 Feb 2010 00:50:20 +0100
changeset 6453 ab0bf0e61a2b
parent 6452 982eb382c6a4
child 6454 bcf6fd2138cf
Fixed issue 11979: Added message in Login_F1.html to check supported browser
src/org/openbravo/erpCommon/security/Login_F1.html
web/js/utils.js
--- a/src/org/openbravo/erpCommon/security/Login_F1.html	Tue Feb 16 22:55:57 2010 +0100
+++ b/src/org/openbravo/erpCommon/security/Login_F1.html	Wed Feb 17 00:50:20 2010 +0100
@@ -78,7 +78,11 @@
       clearForm();
     } catch (e) {}
     setWindowElementFocus('firstElement');
-    if ((!revisionControl('6434')) || (isOpsInstance() != isOpsInstanceCached())) {
+    if (!checkBrowserCompatibility()) {
+      alert("Your browser \"" +  getBrowserInfo("nameAndVersion") + "\" is not officially supported.\n\nOpenbravo has not been tested on your browser.\n\nYou can continue at your own risk or use one of these supported browsers:\n * Mozilla Firefox 3.0 or higher\n * Microsoft Internet Explorer 7.0 or higher");
+    }
+
+    if ((!revisionControl('6440')) || (isOpsInstance() != isOpsInstanceCached())) {
       alert("Your browser's cache has outdated files. Please clean it and reload the page.");
     }
   }
--- a/web/js/utils.js	Tue Feb 16 22:55:57 2010 +0100
+++ b/web/js/utils.js	Wed Feb 17 00:50:20 2010 +0100
@@ -72,7 +72,7 @@
 * Return a number that would be checked at the Login screen to know if the file is cached with the correct version
 */
 function getCurrentRevision() {
-  var number = '6434';
+  var number = '6440';
   return number;
 }
 
@@ -89,6 +89,94 @@
   }
 }
 
+/**
+* Gets information of the browser
+* @param {name} string Required - It could be "name", "version", "nameAndVersion" or "complete"
+*/
+function getBrowserInfo(param) {
+  var navUserAgent = navigator.userAgent.toUpperCase();
+  var browserName = "Unknown";
+  var browserVersion = "";
+  var browserMajorVersion = "";
+  var i=0
+  if (navUserAgent.indexOf("MSIE") >= 0) {
+    browserName = "Microsoft Internet Explorer";
+    i=navUserAgent.indexOf("MSIE")+5;
+  } else if (navUserAgent.indexOf("FIREFOX") >= 0) {
+    browserName = "Mozilla Firefox";
+    i=navUserAgent.indexOf("FIREFOX")+8;
+  } else if (navUserAgent.indexOf("ICEWEASEL") >= 0) {
+    browserName = "IceWeasel";
+    i=navUserAgent.indexOf("ICEWEASEL")+10;
+  } else if (navUserAgent.indexOf("CHROME") >= 0) {
+    browserName = "Google Chrome";
+    i=navUserAgent.indexOf("CHROME")+7;
+  } else if (navUserAgent.indexOf("OPERA") >= 0) {
+    browserName = "Opera";
+    if (navUserAgent.indexOf("VERSION") != -1) {
+      i=navUserAgent.indexOf("VERSION")+8;
+    } else {
+      i=navUserAgent.indexOf("OPERA")+6;
+    }
+  } else if (navUserAgent.indexOf("SAFARI") >= 0) {
+    browserName = "Safari";
+    if (navUserAgent.indexOf("VERSION") != -1) {
+      i=navUserAgent.indexOf("VERSION")+8;
+    } else {
+      i=navUserAgent.indexOf("SAFARI")+7;
+    }
+  } else if (navUserAgent.indexOf("NETSCAPE") >= 0) {
+    browserName = "Netscape";
+    i=navUserAgent.indexOf("NETSCAPE")+9;
+  } else if (navUserAgent.indexOf("KONQUEROR") >= 0) {
+    browserName = "Konqueror";
+    i=navUserAgent.indexOf("KONQUEROR")+10;
+  }
+  if (i!=0) {
+    while (navUserAgent.substring(i, i+1) != " " && navUserAgent.substring(i, i+1) != ";" && i < navUserAgent.length) {
+      browserVersion += navUserAgent.substring(i, i+1);
+      i++;
+    }
+  }
+  var browserNameAndVersion = browserName + " " + browserVersion;
+  browserMajorVersion = browserVersion;
+  if (browserMajorVersion.indexOf(".") != -1) {
+    browserMajorVersion = browserMajorVersion.substring(0, browserVersion.indexOf("."));
+    browserMajorVersion = parseInt(browserMajorVersion);
+  }
+  if (param == "name") {
+    return browserName;
+  } else if (param == "version") {
+    return browserVersion;
+  } else if (param == "majorVersion") {
+    return browserMajorVersion;
+  } else if (param == "nameAndVersion" || typeof param == "undefined" || param == "" || param == null) {
+    return browserNameAndVersion;
+  } else {
+    return false;
+  }
+}
+
+/**
+* Checks if the browser is a supported one
+*/
+function checkBrowserCompatibility() {
+  var browserName = getBrowserInfo("name");
+  var browserVersion = getBrowserInfo("version");
+  var browserMajorVersion = getBrowserInfo("majorVersion");
+  var isValid = false;
+  if (browserName.toUpperCase().indexOf('FIREFOX') != -1 || browserName.toUpperCase().indexOf('ICEWEASEL') != -1) {
+    if (browserMajorVersion >= 3) {
+      isValid = true;
+    }
+  } else if (browserName.toUpperCase().indexOf('INTERNET EXPLORER') != -1) {
+    if (browserMajorVersion >= 7) {
+      isValid = true;
+    }
+  }
+  return isValid;
+}
+
 
 function getObjAttribute(obj, attribute) {
   attribute = attribute.toLowerCase();