Andrew's git
/
newtab.git
/ diff
summary
|
log
|
commit
| diff |
tree
commit
grep
author
committer
pickaxe
?
re
remember position of column titles
author
Andrew Lorimer
<andrew@lorimer.id.au>
Sat, 17 Aug 2019 01:34:04 +0000
(11:34 +1000)
committer
Andrew Lorimer
<andrew@lorimer.id.au>
Sat, 17 Aug 2019 01:34:04 +0000
(11:34 +1000)
admin.js
patch
|
blob
|
history
raw
|
patch
|
inline
| side by side (parent:
34cd772
)
diff --git
a/admin.js
b/admin.js
index 157c99091aa716c9d3093eb3da6a9ee42e29728a..ddc08c5e2aff6cd442b4ffbbb12e082c62e5e5f0 100644
(file)
--- a/
admin.js
+++ b/
admin.js
@@
-3,25
+3,23
@@
var rmspan = ["<span class='remove' id='delete-", "'>–</span>"]
document.addEventListener("DOMContentLoaded", function() {
chrome.storage.sync.get(
{"lists": [
document.addEventListener("DOMContentLoaded", function() {
chrome.storage.sync.get(
{"lists": [
- [
+ [
"General",
["Github", "https://github.com"],
["Wikipedia", "https://en.wikipedia.org"],
["Gmail", "https://mail.google.com"]
],
["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"]
],
["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"]
]
["Reddit", "https://www.reddit.com"],
["YouTube", "https://youtube.com"],
["Instagram", "https://instagram.com"]
]
- ],
-"l1name": "General",
-"l2name": "Productivity",
-"l3name": "Social"},
+ ]
+},
userListsCallback);
});
userListsCallback);
});
@@
-36,15
+34,20
@@
function columnToArray(list) {
function listToArray(list) {
var l = [];
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) {
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) {
}
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<lists["lists"].length;i++) {
var ul = document.createElement("ul");
ul.setAttribute("id", mainlist[i]);
for(var i=0;i<lists["lists"].length;i++) {
var ul = document.createElement("ul");
ul.setAttribute("id", mainlist[i]);
@@
-71,7
+74,7
@@
var userListsCallback = function(lists) {
title.insertAdjacentHTML("beforeend", "<span class='add' id='add-"+mainlist[i]+"'>+</span>");
var list = lists["lists"][i];
title.insertAdjacentHTML("beforeend", "<span class='add' id='add-"+mainlist[i]+"'>+</span>");
var list = lists["lists"][i];
- for(var j=
0
;j<lists["lists"][i].length;j++) {
+ for(var j=
1
;j<lists["lists"][i].length;j++) {
var li = document.createElement("li");
li.setAttribute("id", mainlist[i]+"-"+j);
var siteurl = list[j][1];
var li = document.createElement("li");
li.setAttribute("id", mainlist[i]+"-"+j);
var siteurl = list[j][1];
@@
-98,7
+101,6
@@
var userListsCallback = function(lists) {
};
function dragStart(e) {
};
function dragStart(e) {
- console.log("Drag started for " + this);
console.log(this);
dragSrcEl = this;
e.dataTransfer.effectAllowed = 'move';
console.log(this);
dragSrcEl = this;
e.dataTransfer.effectAllowed = 'move';
@@
-106,7
+108,6
@@
function dragStart(e) {
}
function dragOver(e) {
}
function dragOver(e) {
- console.log("Object " + this + " is ready to be placed");
if (e.preventDefault) {
e.preventDefault();
}
if (e.preventDefault) {
e.preventDefault();
}
@@
-127,11
+128,11
@@
function drop(e) {
e.stopPropagation();
}
if (dragSrcEl != this) {
e.stopPropagation();
}
if (dragSrcEl != this) {
+ console.log(mainlist);
dragSrcEl.innerHTML = this.innerHTML;
this.innerHTML = e.dataTransfer.getData('text/html');
dragSrcEl.innerHTML = this.innerHTML;
this.innerHTML = e.dataTransfer.getData('text/html');
+ save();
}
}
- console.log("Saving positions");
- save();
return false;
}
return false;
}
@@
-160,7
+161,6
@@
function listen(li) {
save();
} else {
var ul = document.getElementById(r[1]);
save();
} else {
var ul = document.getElementById(r[1]);
- console.log(ul);
if (document.querySelectorAll("#"+r[1]+" .new").length > 0) {
fields = document.querySelector("#"+r[1]+" .new .name");
fields.focus();
if (document.querySelectorAll("#"+r[1]+" .new").length > 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));
function save(l) {
var set = l || JSON.parse(JSON.stringify(mainlist));
+ console.log(set);
d = []
d = set;
console.log("Saving settings");
d = []
d = set;
console.log("Saving settings");