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

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,6 +102,7 @@ require([ "bacon"
for (var k in nodes)
out.push(nodes[k])
if (lsavailable)
localStorage.nodes = JSON.stringify(out)
})