Commit c5464da3 by kevalbhatt

ATLAS-3752 : UI: Login js improvment

parent 21e9f2f9
...@@ -33,6 +33,17 @@ ...@@ -33,6 +33,17 @@
<title>Atlas</title> <title>Atlas</title>
<meta name="description" content="" /> <meta name="description" content="" />
<meta name="viewport" content="width=device-width" /> <meta name="viewport" content="width=device-width" />
<script type="text/javascript">
var isHtmlInPath = window.location.pathname.indexOf("index.html");
if (isHtmlInPath === -1) {
var pathname = window.location.pathname.replace(/\/[\w-]+.(jsp|html)|\/+$/ig, ''),
indexpath = pathname + "/index.html";
if (location.hash.length > 2) {
indexpath += location.hash;
}
window.location.replace(indexpath);
}
</script>
<link rel="shortcut icon" href="img/favicon.ico?bust=<%- bust %>" type="image/x-icon" /> <link rel="shortcut icon" href="img/favicon.ico?bust=<%- bust %>" type="image/x-icon" />
<link rel="icon" href="img/favicon.ico?bust=<%- bust %>" type="image/x-icon" /> <link rel="icon" href="img/favicon.ico?bust=<%- bust %>" type="image/x-icon" />
<!-- Place favicon.ico and apple-touch-icon.png in the root directory --> <!-- Place favicon.ico and apple-touch-icon.png in the root directory -->
......
...@@ -57,7 +57,7 @@ function doLogin() { ...@@ -57,7 +57,7 @@ function doLogin() {
j_username: userName, j_username: userName,
j_password: passwd j_password: passwd
}, },
url: baseUrl + "j_spring_security_check", url: baseUrl + "/j_spring_security_check",
type: "POST", type: "POST",
headers: { headers: {
"cache-control": "no-cache" "cache-control": "no-cache"
...@@ -103,18 +103,18 @@ function redirect(baseUrl) { ...@@ -103,18 +103,18 @@ function redirect(baseUrl) {
PRIMARY_UI = data["atlas.ui.default.version"]; PRIMARY_UI = data["atlas.ui.default.version"];
} }
if (PRIMARY_UI !== "v2") { if (PRIMARY_UI !== "v2") {
indexpath = "index.html"; indexpath = "/index.html";
} }
if (window.localStorage.last_ui_load === "v1") { if (window.localStorage.last_ui_load === "v1") {
indexpath = "index.html"; indexpath = "/index.html";
} else if (window.localStorage.last_ui_load === "v2") { } else if (window.localStorage.last_ui_load === "v2") {
indexpath = "/n/index.html"; indexpath = "/n/index.html";
} }
indexpath = baseUrl + indexpath;
if (location.hash.length > 2) { if (location.hash.length > 2) {
window.location.replace(indexpath + location.hash); indexpath += location.hash;
} else {
window.location.replace(indexpath);
} }
window.location.replace(indexpath);
}, },
error: function() { error: function() {
window.location.replace("index.html"); window.location.replace("index.html");
...@@ -123,20 +123,7 @@ function redirect(baseUrl) { ...@@ -123,20 +123,7 @@ function redirect(baseUrl) {
} }
function getBaseUrl() { function getBaseUrl() {
if (!window.location.origin) { return window.location.pathname.replace(/\/[\w-]+.(jsp|html)|\/+$/ig, '')
window.location.origin =
window.location.protocol + "//" + window.location.hostname + (window.location.port ? ":" + window.location.port : "");
}
var baseUrl = window.location.origin + window.location.pathname.substring(window.location.pathname.indexOf("/", 2) + 1, 0);
if (baseUrl.lastIndexOf("/") != baseUrl.length - 1) {
if (baseUrl) {
baseUrl = baseUrl + "/";
} else {
baseUrl = "/";
}
}
return baseUrl;
} }
$(function() { $(function() {
......
...@@ -33,6 +33,17 @@ ...@@ -33,6 +33,17 @@
<title>Atlas</title> <title>Atlas</title>
<meta name="description" content="" /> <meta name="description" content="" />
<meta name="viewport" content="width=device-width" /> <meta name="viewport" content="width=device-width" />
<script type="text/javascript">
var isHtmlInPath = window.location.pathname.indexOf("index.html");
if (isHtmlInPath === -1) {
var pathname = window.location.pathname.replace(/\/[\w-]+.(jsp|html)|\/+$/ig, ''),
indexpath = pathname + "/index.html";
if (location.hash.length > 2) {
indexpath += location.hash;
}
window.location.replace(indexpath);
}
</script>
<link rel="shortcut icon" href="img/favicon.ico?bust=<%- bust %>" type="image/x-icon" /> <link rel="shortcut icon" href="img/favicon.ico?bust=<%- bust %>" type="image/x-icon" />
<link rel="icon" href="img/favicon.ico?bust=<%- bust %>" type="image/x-icon" /> <link rel="icon" href="img/favicon.ico?bust=<%- bust %>" type="image/x-icon" />
<!-- Place favicon.ico and apple-touch-icon.png in the root directory --> <!-- Place favicon.ico and apple-touch-icon.png in the root directory -->
......
...@@ -57,7 +57,7 @@ function doLogin() { ...@@ -57,7 +57,7 @@ function doLogin() {
j_username: userName, j_username: userName,
j_password: passwd j_password: passwd
}, },
url: baseUrl + "j_spring_security_check", url: baseUrl + "/j_spring_security_check",
type: "POST", type: "POST",
headers: { headers: {
"cache-control": "no-cache" "cache-control": "no-cache"
...@@ -103,18 +103,18 @@ function redirect(baseUrl) { ...@@ -103,18 +103,18 @@ function redirect(baseUrl) {
PRIMARY_UI = data["atlas.ui.default.version"]; PRIMARY_UI = data["atlas.ui.default.version"];
} }
if (PRIMARY_UI !== "v2") { if (PRIMARY_UI !== "v2") {
indexpath = "index.html"; indexpath = "/index.html";
} }
if (window.localStorage.last_ui_load === "v1") { if (window.localStorage.last_ui_load === "v1") {
indexpath = "index.html"; indexpath = "/index.html";
} else if (window.localStorage.last_ui_load === "v2") { } else if (window.localStorage.last_ui_load === "v2") {
indexpath = "/n/index.html"; indexpath = "/n/index.html";
} }
indexpath = baseUrl + indexpath;
if (location.hash.length > 2) { if (location.hash.length > 2) {
window.location.replace(indexpath + location.hash); indexpath += location.hash;
} else {
window.location.replace(indexpath);
} }
window.location.replace(indexpath);
}, },
error: function() { error: function() {
window.location.replace("index.html"); window.location.replace("index.html");
...@@ -123,20 +123,7 @@ function redirect(baseUrl) { ...@@ -123,20 +123,7 @@ function redirect(baseUrl) {
} }
function getBaseUrl() { function getBaseUrl() {
if (!window.location.origin) { return window.location.pathname.replace(/\/[\w-]+.(jsp|html)|\/+$/ig, '')
window.location.origin =
window.location.protocol + "//" + window.location.hostname + (window.location.port ? ":" + window.location.port : "");
}
var baseUrl = window.location.origin + window.location.pathname.substring(window.location.pathname.indexOf("/", 2) + 1, 0);
if (baseUrl.lastIndexOf("/") != baseUrl.length - 1) {
if (baseUrl) {
baseUrl = baseUrl + "/";
} else {
baseUrl = "/";
}
}
return baseUrl;
} }
$(function() { $(function() {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment