Retain URL #hash through login.

git-svn-id: https://www.unprompted.com/svn/projects/tildefriends/trunk@3189 ed5197a5-7fde-0310-b194-c3ffbd925b24
This commit is contained in:
Cory McWilliams 2016-04-07 01:30:07 +00:00
parent 3b5f123136
commit 8002ce96d6

View File

@ -29,10 +29,22 @@ function enter(event) {
function url() {
var hash = window.location.href.indexOf('#');
var question = window.location.href.indexOf('?');
var end = hash != -1 ? hash : question;
var end = -1;
if (hash != -1 && (hash < end || end == -1))
{
end = hash;
}
if (question != -1 && (question < end || end == -1))
{
end = question;
}
return end != -1 ? window.location.href.substring(0, end) : window.location.href;
}
function hash() {
return window.location.hash != "#" ? window.location.hash : "";
}
function storeTarget(target) {
$("#target").text(target || "");
}
@ -280,19 +292,19 @@ function updateLogin() {
a.setAttribute("onclick", "logoutGoogle()");
a.setAttribute("href", "#");
} else {
a.setAttribute("href", "/login/logout?return=" + encodeURIComponent(url()));
a.setAttribute("href", "/login/logout?return=" + encodeURIComponent(url() + hash()));
}
} else if (window.location.href.indexOf("?guest=1") != -1) {
window.location.href = "/login?submit=Proceed+as+Guest&return=" + encodeURIComponent(url());
window.location.href = "/login?submit=Proceed+as+Guest&return=" + encodeURIComponent(url() + hash());
} else {
window.location.href = "/login?return=" + encodeURIComponent(url());
window.location.href = "/login?return=" + encodeURIComponent(url() + hash());
}
login.appendChild(a);
}
function logoutGoogle() {
gapi.auth2.getAuthInstance().signOut().then(function() {
window.location.href = "/login/logout?return=" + encodeURIComponent(url());
window.location.href = "/login/logout?return=" + encodeURIComponent(url() + hash());
});
}