for(var i=0;i<lists["lists"].length;i++) {
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);
document.getElementById("links").appendChild(ul);
+ var grip = document.createElement("span");
+ grip.setAttribute("class", "grip");
+
var title = document.createElement("div");
title.setAttribute("class", "title");
+ title.appendChild(grip)
ul.appendChild(title);
var p = document.createElement("p");
var nme = list[j][0];
var img = document.createElement("img");
img.className = "icon";
- img.src = "http://www.google.com/s2/favicons?domain="+siteurl+"";
+ img.src = "https://www.google.com/s2/favicons?domain="+siteurl+"";
li.insertAdjacentHTML("beforeend", "<a class='item' href="+siteurl+"><img src="+img.src+" alt="+extractDomain(siteurl,1)+"/> "+nme+"</a>");
li.insertAdjacentHTML("beforeend", rmspan[0] + j + "-" + mainlist[i] + rmspan[1]);
ul.appendChild(li);
}
- var sortable = Sortable.create(ul, {
+ new Sortable(ul, {
group: "userlists",
+ animation: 150,
onUpdate: function (evt) {
save();
}
};
+function dragStart(e) {
+ console.log("Drag started for " + this);
+ console.log(this);
+ dragSrcEl = this;
+ e.dataTransfer.effectAllowed = 'move';
+ e.dataTransfer.setData('text/html', this.innerHTML);
+}
+
+function dragOver(e) {
+ console.log("Object " + this + " is ready to be placed");
+ if (e.preventDefault) {
+ e.preventDefault();
+ }
+ e.dataTransfer.dropEffect = 'move';
+ return false;
+}
+
+function dragEnter(e) {
+ this.classList.add('over');
+}
+
+function dragLeave(e) {
+ this.classList.remove('over');
+}
+
+function drop(e) {
+ if (e.stopPropagation); {
+ e.stopPropagation();
+ }
+ if (dragSrcEl != this) {
+ dragSrcEl.innerHTML = this.innerHTML;
+ this.innerHTML = e.dataTransfer.getData('text/html');
+ }
+ console.log("Saving positions");
+ save();
+ return false;
+}
+
+var dragSrcEl = null;
+
document.onkeyup=function(e){
var e = e || window.event; // for IE to cover IEs window event-object
fields = document.getElementsByClassName("new");
fields[fields.length-1].remove();
return false;
}
- if(e.which == 27 && fields != null) {
- fields[fields.length-1].remove();
+ if(e.which == 13 && fields.length > 0) {
+ fields[fields.length-1].getElementsByClassName("save")[0].click();
return false;
}
}
}
var li = document.createElement("li");
li.setAttribute("class", "new");
- li.insertAdjacentHTML("beforeend", "<span class='save' tabindex='3' id='input-"+columnToArray(li).length.toString()+"'>✔</span><input type='text' class='name' value='' placeholder='name' tabindex='1'><br /><input type='text' class='url' value='' placeholder='url' tabindex='2' id='form-"+columnToArray(li).length.toString()+"'>");
+ li.insertAdjacentHTML("beforeend", "<span class='save' tabindex='3' id='input-"+columnToArray(li).length.toString()+"'>✔</span><input type='text' class='name' value='' placeholder='name' tabindex='1'><br /><input type='url' spellcheck=false class='url' value='' placeholder='url' tabindex='2' id='form-"+columnToArray(li).length.toString()+"'>");
ul.appendChild(li);
var span = document.getElementById("input-"+columnToArray(li).length.toString());
var form = document.getElementById("form-"+columnToArray(li).length.toString());
span.addEventListener('click', function(event){
var li = document.getElementsByClassName("new")[0]
var ul = li.parentNode;
- if (li.getElementsByClassName("name")[0].value != "" && li.getElementsByClassName("url")[0].value != "") {
+ if (li.getElementsByClassName("name")[0].value != "" && li.getElementsByClassName("url")[0].value != "" && li.getElementsByClassName("url")[0].validity.typeMismatch== false) {
var newli = document.createElement("li");
newli.setAttribute("id",r[1]+"-"+columnToArray(ul).length.toString());
var siteurl = addhttp(li.getElementsByClassName("url")[0].value);
span.onmouseover = function() {
nme = document.getElementsByClassName("name")[0];
url = document.getElementsByClassName("url")[0];
- if (nme.value === '' || url.value === '') {
+ if (nme.value === '' || url.value === '' || url.validity.typeMismatch == true) {
this.style.background = "#bf616a";
}
else {