User:Manyman/global.js

/* */ /* VDA */ importScriptPage("MediaWiki:VDA.js", "vda"); $(function {    VDA.load("RV");    VDA.load("VW");    VDA.load("JFF");    VDA.load("AA");    VDA.load("CRED"); });

/* Auto-refresh */ var enableAjaxRC = false; ajaxPages = new Array("Special:RecentChanges", "Special:Watchlist", "Special:Log", "Special:Contributions"); function setCookie(c_name,value,expiredays) { var exdate=new Date exdate.setDate(exdate.getDate+expiredays) document.cookie=c_name+ "=" +escape(value) + ((expiredays==null) ? "" : ";expires="+exdate.toGMTString) } function getCookie(c_name) { if (document.cookie.length>0) { c_start=document.cookie.indexOf(c_name + "=") if (c_start!=-1) { c_start=c_start + c_name.length+1 c_end=document.cookie.indexOf(";",c_start) if (c_end==-1) c_end=document.cookie.length return unescape(document.cookie.substring(c_start,c_end)) } } return "" } function getXmlHttpRequestObject { if (window.XMLHttpRequest) { return new XMLHttpRequest; //Not Internet Explorer } else if(window.ActiveXObject) { return new ActiveXObject("Microsoft.XMLHTTP"); //Internet Explorer } else { //fail silently } } getRCDataRO = getXmlHttpRequestObject; var cr = new RegExp("\r", "gm"); var lf = new RegExp("\n", "gm"); var endText = new RegExp(' [\t\s]*?[\t\s]*? ', "mi"); var rcTimer; var rcRefresh = 15000; function preloadAJAXRC { if (skin == "monaco") { s = 1; } else { s = 0; } ajaxRCCookie = (getCookie("ajaxload-"+wgPageName)=="on") ? true:false; $('h1:first,#user_masthead_head h2').append(' Auto-refresh '); document.getElementById("ajaxRCtoggle").checked = ajaxRCCookie; if (getCookie("ajaxload-"+wgPageName)=="on") loadRCData; } function toggleRC { if (document.getElementById("ajaxRCtoggle").checked == true) { setCookie("ajaxload-"+wgPageName, "on", 30); loadRCData; } else { setCookie("ajaxload-"+wgPageName, "off", 30); clearTimeout(rcTimer); } } function loadRCData { if (getRCDataRO.readyState == 4 || getRCDataRO.readyState == 0) { getRCDataRO.open("GET", document.location.href, true); getRCDataRO.onreadystatechange = parseRCdata; getRCDataRO.send(null); } } function parseRCdata { if (getRCDataRO.readyState == 4) { textFilter = new RegExp(' .*? [\t\s]*?[\t\s]*? ', "i"); rawRCdata = getRCDataRO.responseText.replace(cr, "").replace(lf, ""); filteredRCdata = textFilter.exec(rawRCdata); updatedText = filteredRCdata[0].replace(' ', "").replace(endText, ""); document.getElementById("bodyContent").innerHTML = updatedText; rcTimer = setTimeout("loadRCData;", rcRefresh); } } if (wgAction == 'view' || wgAction == 'history') { $(document).ready(preloadAJAXRC); }

/* Quick preview */ if (skin == 'monaco' && (wgAction == 'edit' || wgAction == 'submit')) { $(document).ready(function {		var attrs = {			tabindex: 6,			accesskey: 'g',			id: 'dlQuickPreview',			title: 'Preview your changes'		};		var $button = $(' ').val('Quick preview').attr(attrs).click(function { $(this).val('Getting preview').attr('disabled', 'disabled'); var f = document.editform; $.ajax({				data: {					'wpMinoredit': f.wpMinoredit.checked,					'wpWatchthis': f.wpWatchthis.checked,					'wpStarttime': f.wpStarttime.value,					'wpEdittime': f.wpEdittime.value,					'wpAutoSummary': f.wpAutoSummary.value,					'wpEditToken': f.wpEditToken.value,					'wpSummary': 'Quick preview',					'wpTextbox1': f.wpTextbox1.value				},				dataType: 'text',				type: 'POST',				url: document.location.href.replace('&action=edit', '&action=submit') + '&wpPreview=true&live=true',				success: function(response) {					$('#wikiPreview').css('display', 'block').html(unescape(response.replace(/&gt;/g, '>').replace(/&lt;/g, '<').replace(/&amp;/g, '&').replace(/&quot;/g, '"')));					$('#dlQuickPreview').val('Quick preview').attr('disabled', null);				}			});		});		var $li = $(' ').append($button);		$('#edit_enhancements_toolbar li').eq(2).after($li);	}); } /* */