diff options
Diffstat (limited to 'tears.js')
-rw-r--r-- | tears.js | 36 |
1 files changed, 36 insertions, 0 deletions
@@ -121,6 +121,7 @@ function button(node, html, fun) { a.innerHTML = html; a.href = "#"; a.onclick = fun; + node.parentNode.insertBefore(document.createTextNode(" "), node.nextSibling); node.parentNode.insertBefore(a, node.nextSibling); } @@ -219,6 +220,41 @@ document.addEventListener("DOMContentLoaded", function(e) { } } } + + var form = document.getElementById('update-article'); + if(form) { + form.onsubmit = function(e) { + var stikkord = document.getElementsByName('stikkord'); + if(stikkord && stikkord[0] && !stikkord[0].value) { + stikkord[0].className = "error"; + return false; + } + } + } + + var infoboxes = document.getElementsByClassName("infobox"); + for(var i = 0; i < infoboxes.length; i++) { + Sortable.create(infoboxes[i]); + var items = infoboxes[i].getElementsByTagName('li'); + for(var j = 0; j < items.length; j++) { + if(items[j].className == "last") { + var add = document.createElement("a"); + add.textContent = "+"; + add.href = "#"; + add.onclick = additem; + items[j].appendChild(add); + } else { + var del = document.createElement("a"); + del.textContent = "x"; + del.href = "#"; + del.onclick = function(e) { + e.target.parentNode.remove(); + return false; + } + items[j].appendChild(del); + } + } + } }); |