function listToArray(list) {
var l = [];
- console.log(list.getElementsByClassName('title')[0].getElementsByTagName("p")[0].textContent);
- l[0] = list.getElementsByClassName('title')[0].getElementsByTagName("p")[0].textContent;
+ console.log("looking at list:");
+ console.log(list);
+ if (editMode == true) {
+ l[0] = list.getElementsByClassName('title')[0].getElementsByTagName("input")[0].value;
+ }
+ else {
+ 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+1] = [elem[i].getElementsByTagName("a")[0].innerText, elem[i].getElementsByTagName("a")[0].getAttribute("href")];
+ if (elem[i].class == "new") {
+ continue;
+ }
+ else {
+ l[i+1] = [elem[i].getElementsByTagName("a")[0].innerText, elem[i].getElementsByTagName("a")[0].getAttribute("href")];
+ }
}
return l;
}
document.getElementById('addcol').addEventListener('click', addCol, false);
var ul = document.createElement("ul");
ul.setAttribute("id", mainlist[i]);
- ul.setAttribute('draggable', 'true');
- ul.addEventListener('dragstart', dragStart, false);
- ul.addEventListener('dragenter', dragEnter, false);
- ul.addEventListener('dragover', dragOver, false);
- ul.addEventListener('dragleave', dragLeave, false);
- ul.addEventListener('drop', drop, false);
+ ul.setAttribute('draggable', 'false'); // Draggable attribute must be set on mousedown event, otherwise any cursor movement causes dragstart()
document.getElementById("links").appendChild(ul);
var grip = document.createElement("span");
grip.setAttribute("class", "grip");
+ grip.addEventListener('mousedown', function() {
+ console.log("Drag started");
+ uls = document.getElementsByTagName("ul");
+ for (let ul of uls) {
+ ul.setAttribute("draggable", "true");
+ ul.addEventListener('dragstart', dragStart, false);
+ ul.addEventListener('dragenter', dragEnter, false);
+ ul.addEventListener('dragover', dragOver, false);
+ ul.addEventListener('dragleave', dragLeave, false);
+ ul.addEventListener('drop', drop, false);
+ }
+ });
+
+ grip.addEventListener('mouseup', function() {
+ console.log("Drag ended");
+ uls = document.getElementsByTagName("ul");
+ for (let ul of uls) {
+ ul.setAttribute("draggable", "false");
+ ul.removeEventListener('dragstart');
+ ul.removeEventListener('dragenter');
+ ul.removeEventListener('dragover');
+ ul.removeEventListener('dragleave');
+ ul.removeEventListener('drop');
+ }
+ });
var title = document.createElement("div");
title.setAttribute("class", "title");
}
function closeEdit(editbtn) {
+ editMode = false;
editbtn.style.background = "";
editbtn.innerText = "e";
addbtn = document.getElementById("addcol");
col.getElementsByClassName("grip")[0].style.display = "none";
}
save();
- editMode = false;
}
function addCol() {
var span = document.getElementById("input-"+columnToArray(li).length.toString());
var form = document.getElementById("form-"+columnToArray(li).length.toString());
span.addEventListener('click', function(event){
+ console.log("Adding item to:");
+ console.log(this);
var li = document.getElementsByClassName("new")[0]
var ul = li.parentNode;
if (li.getElementsByClassName("name")[0].value != "" && li.getElementsByClassName("url")[0].value != "" && li.getElementsByClassName("url")[0].validity.typeMismatch== false) {