Created
January 10, 2016 02:44
-
-
Save michaelcpuckett/5ed5b028f4d07a097368 to your computer and use it in GitHub Desktop.
check-storage-for-logged-in-from-another-tab.js
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// stolen from minified github source | |
function() { | |
var e, t, n; | |
if (n = null != (t = document.querySelector("meta[name=user-login]")) ? t.content : void 0, | |
null != n) { | |
e = String(!!n.length); | |
try { | |
localStorage.setItem("logged-in", e) | |
} catch (r) { | |
return | |
} | |
window.addEventListener("storage", function(t) { | |
var n; | |
if (t.storageArea === localStorage && "logged-in" === t.key && t.newValue !== e) | |
return e = t.newValue, | |
n = document.querySelector(".js-stale-session-flash"), | |
n.classList.toggle("is-signed-in", "true" === e), | |
n.classList.toggle("is-signed-out", "false" === e), | |
n.classList.remove("hidden"), | |
$.pjax.disable(), | |
$(window).on("popstate", function(e) { | |
return null != e.state.container ? location.reload() : void 0 | |
}), | |
$(document).on("submit", "form", function(e) { | |
return e.preventDefault() | |
}) | |
}) | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment