Handle localstorage empty or failure properly
Signed-off-by: Thomas Citharel <tcit@tcit.fr>
This commit is contained in:
parent
c1ea6ae2a8
commit
7a12d98943
@ -20,7 +20,12 @@ $(document).ready(function() {
|
||||
* @param adminPoll
|
||||
*/
|
||||
function addAdminPoll(adminPoll) {
|
||||
var adminPolls = JSON.parse(localStorage.getItem('admin_polls'));
|
||||
var adminPolls = localStorage.getItem('admin_polls');
|
||||
if (adminPolls === null) {
|
||||
adminPolls = [];
|
||||
} else {
|
||||
adminPolls = JSON.parse(adminPolls);
|
||||
}
|
||||
/**
|
||||
* Test if the poll is already inside the list
|
||||
*/
|
||||
|
@ -32,7 +32,12 @@ $(document).ready(function () {
|
||||
* @param poll
|
||||
*/
|
||||
function addPoll(poll) {
|
||||
var polls = JSON.parse(localStorage.getItem('polls'));
|
||||
var polls = localStorage.getItem('polls');
|
||||
if (polls === null) {
|
||||
polls = [];
|
||||
} else {
|
||||
polls = JSON.parse(polls);
|
||||
}
|
||||
|
||||
/**
|
||||
* Test if the poll is already inside the list
|
||||
|
Loading…
Reference in New Issue
Block a user