User:LOL/mmarecordcolumns.js

function rearrangeMMARecordTable { var tb = document.getElementById('wpTextbox1'); var s = tb.value;

// A 'Record' object should exist in the headings array! var RECORD_COL_NAME = 'Record'; var RESULT_COL_NAME = 'Result';

var tableStart = s.indexOf('\n{|'); var tableEnd = s.indexOf('\n|}', tableStart); if (tableStart == -1 || tableEnd == -1) { // Evil replacement of S-(start|end) s = s.replace(/\{\{ *[Ss]-start *\}\}/, '{|'); s = s.replace(/\{\{ *[Ss]-end *\}\}/, '|}'); tableStart = s.indexOf('\n{|'); tableEnd = s.indexOf('\n|}', tableStart); if (tableStart == -1 || tableEnd == -1) { alert('"{|" or "|}" not found'); return; }   }

var headings = [{name: RESULT_COL_NAME}, {name: RECORD_COL_NAME, align: 'center'}, {name: 'Opponent'}, {name: 'Method'}, {name: 'Event'}, {name: 'Date'}, {name: 'Round', align: 'center'}, {name: 'Time', align: 'center'}, {name: 'Location'}, {name: 'Notes'}];

var output = s.substring(0, tableStart) + '\n' + s.substring(tableEnd + 3); }

addOnloadHook(function {   if (document.forms.editform) {        mw.util.addPortletLink('p-tb', 'javascript:rearrangeMMARecordTable', 'MMA record columns', 't-mmarecordcolumns', 'Rearrange the columns in accordance with ', , );    } });