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 {
+++ /dev/null
-/* roboto-regular - latin */
-@font-face {
- font-family: 'Roboto';
- font-style: normal;
- font-weight: 400;
- src: local('Roboto'), local('Roboto-Regular'),
- url('./roboto-v15-latin-regular.woff2') format('woff2'), /* Chrome 26+, Opera 23+, Firefox 39+ */
- url('./roboto-v15-latin-regular.woff') format('woff'); /* Chrome 6+, Firefox 3.6+, IE 9+, Safari 5.1+ */
-}
-/* roboto-700 - latin */
-@font-face {
- font-family: 'Roboto';
- font-style: normal;
- font-weight: 700;
- src: local('Roboto Bold'), local('Roboto-Bold'),
- url('./roboto-v15-latin-700.woff2') format('woff2'), /* Chrome 26+, Opera 23+, Firefox 39+ */
- url('./roboto-v15-latin-700.woff') format('woff'); /* Chrome 6+, Firefox 3.6+, IE 9+, Safari 5.1+ */
-}