fix error in statuspage if cookies are disabled (#912)

If cookies are disabled, the Statuspage only displays an empty ("Not connected")
This checks if the localStorage API is available and working and only uses it in this case
Also allows better backwards compatibility.
This commit is contained in:
Brother-Lal 2016-10-24 14:18:01 +02:00 committed by Matthias Schiffer
parent 30811f7f1b
commit e80f751a85
1 changed files with 13 additions and 2 deletions

View File

@ -83,7 +83,17 @@ require([ "bacon"
return a
}
if (localStorage.nodes)
var lsavailable = false
try {
localStorage.setItem("t", "t")
localStorage.removeItem("t")
lsavailable = true
} catch(e) {
lsavailable = false
}
if ( lsavailable && localStorage.nodes)
JSON.parse(localStorage.nodes).forEach(nodesBusIn.push)
nodesBus.map(".nodes").onValue(function (nodes) {
@ -92,7 +102,8 @@ require([ "bacon"
for (var k in nodes)
out.push(nodes[k])
localStorage.nodes = JSON.stringify(out)
if (lsavailable)
localStorage.nodes = JSON.stringify(out)
})
var bootstrap = Helper.getJSON(bootstrapUrl)