From: Andrew Lorimer Date: Sat, 17 Aug 2019 01:34:04 +0000 (+1000) Subject: remember position of column titles X-Git-Url: https://git.lorimer.id.au/newtab.git/diff_plain/8ab0160739cffe3a49acb0df853d299781ffe73e?ds=inline remember position of column titles --- diff --git a/admin.js b/admin.js index 157c990..ddc08c5 100644 --- a/admin.js +++ b/admin.js @@ -3,25 +3,23 @@ var rmspan = ["–"] document.addEventListener("DOMContentLoaded", function() { chrome.storage.sync.get( {"lists": [ - [ + ["General", ["Github", "https://github.com"], ["Wikipedia", "https://en.wikipedia.org"], ["Gmail", "https://mail.google.com"] ], - [ + ["Productivity", ["Desmos", "https://www.desmos.com/calculator"], ["Wolfram", "https://wolframalpha.com"], ["Hacker News", "https://news.ycombinator.com"] ], - [ + ["Social", ["Reddit", "https://www.reddit.com"], ["YouTube", "https://youtube.com"], ["Instagram", "https://instagram.com"] ] - ], -"l1name": "General", -"l2name": "Productivity", -"l3name": "Social"}, + ] +}, userListsCallback); }); @@ -36,15 +34,20 @@ function columnToArray(list) { function listToArray(list) { var l = []; + console.log(list); + console.log(list.getElementsByClassName('title')[0].getElementsByTagName("p")[0].textContent); + l[0] = list.getElementsByClassName('title')[0].getElementsByTagName("p")[0].textContent; var elem = list.getElementsByTagName("li"); for (var i = 0; i < elem.length; ++i) { - l[i] = [elem[i].getElementsByTagName("a")[0].innerText, elem[i].getElementsByTagName("a")[0].getAttribute("href")]; + l[i+1] = [elem[i].getElementsByTagName("a")[0].innerText, elem[i].getElementsByTagName("a")[0].getAttribute("href")]; } return l; } var userListsCallback = function(lists) { - mainlist = [lists["l1name"],lists["l2name"],lists["l3name"]] + console.log(lists); + console.log(lists['lists'][0][0]); + mainlist = [lists['lists'][0][0],lists['lists'][1][0],lists['lists'][2][0]] for(var i=0;i+"); var list = lists["lists"][i]; - for(var j=0;j 0) { fields = document.querySelector("#"+r[1]+" .new .name"); fields.focus(); @@ -228,6 +228,7 @@ function menu() { function save(l) { var set = l || JSON.parse(JSON.stringify(mainlist)); + console.log(set); d = [] d = set; console.log("Saving settings");