+
+function removeItem(event) {
+
+ // Remove link in edit or normal mode
+
+ this.parentNode.outerHTML = "";
+ delete this.parentNode;
+ saveConfig();
+
+}
+
+
+function addItem(event) {
+
+ // Interface for adding a new list item to an existing category
+
+ var ul = this.parentNode.parentNode;
+ var id = ul.id;
+
+ // Check if a form has already been generated for this column
+ existing = ul.getElementsByClassName("new");
+ if (existing.length > 0) {
+ existing[0].getElementsByClassName("name")[0].focus();
+ return false;
+ }
+
+ var li = document.createElement("li");
+ li.setAttribute("class", "new");
+ li.addEventListener("keyup", formKeys);
+
+ var saveBtn = document.createElement("span");
+ saveBtn.className = "save";
+ saveBtn.tabIndex = "3";
+ saveBtn.id = "save-" + ul.id;
+ saveBtn.innerText = tick;
+ saveBtn.addEventListener("click", saveItem);
+ saveBtn.addEventListener("mouseover", saveMouseOver);
+ saveBtn.addEventListener("mouseout", saveMouseOut);
+ li.appendChild(saveBtn);
+
+ var nameInput = document.createElement("input");
+ nameInput.type = "text";
+ nameInput.className = "name";
+ nameInput.placeholder = "name";
+ nameInput.tabIndex = "1";
+ li.appendChild(nameInput);
+
+ var urlInput = document.createElement("input");
+ urlInput.type = "url";
+ urlInput.className = "url";
+ urlInput.placeholder = "url";
+ urlInput.tabIndex = "2";
+ urlInput.spellcheck = "false";
+ li.appendChild(urlInput);
+
+ ul.appendChild(li);
+ updateListeners();
+ nameInput.focus();
+
+}
+
+
+function saveItem(event) {
+
+ // Add new item to a column after pressing the save button in form
+
+ var li = this.parentNode;
+ var ul = this.parentNode.parentNode;
+ var nameField = li.getElementsByClassName("name")[0];
+ var urlField = li.getElementsByClassName("url")[0];
+
+ if (nameField.value != "" && urlField.value != "" && urlField.validity.typeMismatch== false) {
+
+ var newli = genItem(ul, nameField.value, urlField.value);
+ li.remove();
+ delete li;
+
+ ul.appendChild(newli);
+ saveConfig();
+
+ }
+ else {
+
+ if (nameField.value == "" && urlField.value == "") {
+ console.log("No data supplied, deleting form");
+ li.remove();
+ }
+ else {
+ console.log("Missing data, press Esc to delete form");