User:Bdesham/common.js

// mark all edits as minor by default

if (mw.config.get('wgAction') == 'edit') { addOnloadHook(function {		document.getElementById('wpMinoredit').checked = true;	}); }

// make photo galleries take the entire page width

function resize_galleries { var bc = document.getElementById("bodyContent"); var width = bc.offsetWidth; var tdwidth = 155; var tdpw = Math.floor((width - 150) / tdwidth);

var tables = document.querySelectorAll('table.gallery');

if (tables.length == 0) return;

for (var tablecount = 0; tablecount < tables.length; tablecount++) { var t = tables[tablecount]; var divs = t.querySelectorAll('div.gallerybox'); while (t.firstChild) t.removeChild(t.firstChild); var tr = null; var done = 0; for (var i = 0; i < divs.length; i++) { if (done == 0) { tr = document.createElement("tr"); t.appendChild(tr); }			var td = document.createElement("td"); td.appendChild(divs[i]); tr.appendChild(td); done++; if (done > tdpw) done = 0; }	} }

addOnloadHook(resize_galleries); window.onresize = resize_galleries;