User:FINNER/common.js

/* Rotate-c START */ var obj = document.getElementsByClassName("button-c"); var count = document.getElementsByClassName("rotate2-c");

function rotate(i) { var image = document.getElementById("image-c " + i); image.classList.remove("rotate2-c"); image.classList.add("rotate-c"); image.innerHTML += i; } function rotate2(i) { var image = document.getElementById("image-c " + i); image.classList.remove("rotate-c"); image.classList.add("rotate2-c"); image.innerHTML += i; }

for (i = 0; i < obj.length; i++) { var classes = obj[i].classList; var anchor = '' + classes; anchor = anchor.replace(/mw-customtoggle-|\s|button-c/g, ""); var span = document.getElementById("_" + anchor); var a = document.createElement("a"); a.innerHTML = span.innerHTML; a.href = "#" + anchor; span.parentNode.replaceChild(a, span); obj[i].id += "button-c " + i;   count[i].id += " " + i;    document.getElementById("button-c " + i).onclick = function { var image = document.getElementById("image-c " + i); if (image.className == 'rotate-c') { rotate2(i); } else { rotate(i); }   }; }    /* Rotate-c END */