Skip to content

Instantly share code, notes, and snippets.

@michaelcpuckett
Created January 10, 2016 02:44
Show Gist options
  • Save michaelcpuckett/5ed5b028f4d07a097368 to your computer and use it in GitHub Desktop.
Save michaelcpuckett/5ed5b028f4d07a097368 to your computer and use it in GitHub Desktop.
check-storage-for-logged-in-from-another-tab.js
// 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