function parseQueryString(queryString, defaultParams) { const params = new URLSearchParams(queryString); console.log(params); if (!params.size) { return defaultParams; } const result = {}; for (const [key, value] of params.entries()) { result[decodeURIComponent(key)] = decodeURIComponent(value); } return result; } function getParams() { if (!window.params) { const params_hash = location.hash.replace('#', ''); window.params = parseQueryString(params_hash, { '': '' }); } return window.params; } function getRandomStr() { return `${Math.random()}`.replace('0.', ''); } function getLists() { return localStorage.getItem('lists') || { '_default': { name: '_default' } }; } function createList(listName) { let lists = getLists() if (listName === '_default') return; const listId = getRandomStr(); lists[listId] = { name: listName } localStorage.setItem('lists', JSON.stringify(lists)); }