I have created a script to add people to an ignore list, however once I've added them there is a problem with deleting them. If I remove one user, from the array I can still add users to the ignore list. If I remove both people from the ignore list, I cannot add any more. I have a feeling it's because "ignored_users" is no longer an array?
I add people to the ignore list using this code: {all vars are set, and works}
add_to_list = {
"username" : username,
"date_added" : "\"" + day + "/" + month + "/" + year + "\"",
"description" : desc
};
ignored_users.push(add_to_list);
localStorage["ignore_list"] = JSON.stringify(ignored_users);
The array starts looking like this:
ignored_users = [{"username":"test1","date_added":"\"4/7/2013\"","description":""},{"username":"test2","date_added":"\"4/7/2013\"","description":""}]
The remove from array code looks like this:
$.each(ignored_users, function(i, person) {
if(person.username === username)
{
delete ignored_users[i];
localStorage["ignore_list"] = JSON.stringify(ignored_users);
}
}