User:Foodbandlt/wikia.js/test.js

if (wgPageName == "User:Bobogoobo/Transcripts") { $(document).ready(function{   $("#toc").css("width","100%");    var wholeList = $("#toc ul");    wholeList.html(" ");    var liList = $("#toc ul li").toArray;    var x; // I could not come up with a way to do the perCol logic in one declaration. Annoying.    var tdToAppend;    var listToAppend;    $('table#toc ul').remove;    if (liList.length % 3 == 0) {      x = 0;    } else if (liList.length % 3 == 1) {      x = 2;    } else if (liList.length % 3 == 2) {      x = 1;    }    var perCol = (liList.length + x) / 3;

for (var colNum=0; colNum < 3; colNum++){ listToAppend = ""; for (var i=0+(colNum*perCol); i<(perCol*(colNum+1)); i++){ if (typeof(liList[i]) == "undefined"){break; } tempElement = ""; tempElement = document.createElement("div"); tempElement.appendChild(liList[i]); listToAppend += tempElement.innerHTML; }      tdToAppend += '     '; }

$('#toc tbody').append(' '+tdToAppend+' '); }); }