User:The last username left/autoclose.js

/** * autoarchive.js * * Adds a "close" link to forum pages for quickly closing archiving a discussion. * Based on "autocvu.js" by Quarenon * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see . */

$(document).ready(function {	function makeLink(user) {		var li = document.createElement('li');		var a = document.createElement('a');		var div = document.createElement('div');		div.id = "CloseDiscussionDiv";		div.title = "Close Discussion";		var form = document.createElement('form');		form.action = wgScript;		var textarea = document.createElement('textarea');		textarea.name = "archiveMsg";		var submit = document.createElement('input');		submit.type = "submit";		submit.value = "Close";		form.appendChild(textarea);		form.appendChild(submit);		div.appendChild(form);		$(a).click		{			$(div).dialog({ modal: true });		}		a.title = 'Close this thread.';		a.appendChild(document.createTextNode('Close'));		li.appendChild(a);		return li;	}

// http://www.netlobo.com/url_query_string_javascript.html function getParam(name) { name = name.replace(/[\[]/, '\\\[').replace(/[\]]/, '\\\]'); var regex = new RegExp('[\\?&]' + name + '=([^&#]*)'); var results = regex.exec(window.location.href); if (results == null) { return ''; } else { return decodeURIComponent(results[1]); }	}	var closeMsg = getParam('closeMsg');

if (wgNamespaceNumber == 110 && wgPageName != "Forum:Yew_Grove") { if (wgAction == 'edit' && closeMsg) { var lineSep = (navigator.appVersion.indexOf('MSIE') != -1) ? '\r\n' : '\n'; var obj = document.getElementById('wpTextbox1'); obj.value = obj.value.replace(, ).replace(, ).append("Closed - " + closeMsg) +  + );			document.getElementById('wpSummary').value += ' Closed using AutoArchive';		}		else {			var list = document.getElementById('page_controls');			list.appendChild(makeLink);		}	} });