MediaWiki:Common.js

/* Any JavaScript here will be loaded for all users on every page load. */

// OpenSearch link addOnloadHook(open_search_links); function open_search_links { // For the moment, I'll do it by ID in a span, but in future it may be a good idea to do it by class if((document.getElementById('open_search')) && (document.getElementById('open_search').nodeName=='SPAN')) { var link=document.getElementById('open_search').childNodes[0]; if(link.addEventListener) link.addEventListener('click',add_open_search,false); else if(link.attachEvent) link.attachEvent('click',add_open_search); } }

function add_open_search(event) { if((typeof(window.external)=="object") && ((typeof(window.external.AddSearchProvider)=="unknown") || (typeof(window.external.AddSearchProvider)=="function"))) window.external.AddSearchProvider("http://strategywiki.org/w/opensearch_desc.php"); else window.alert("You will need a browser which supports OpenSearch to install this plugin, such as Mozilla Firefox."); event.preventDefault; event.returnValue=false; return false; }

// Image upload categories addOnloadHook(upload_categories); function upload_categories { if((document.getElementById('upload')) && (document.getElementById('upload').nodeName=='FORM')) { var upload_form=document.getElementById('upload'); if(upload_form.addEventListener) upload_form.addEventListener('submit',check_upload_categories,false); else if(upload_form.attachEvent) upload_form.attachEvent('submit',check_upload_categories); } }

function check_upload_categories(event) { var description=document.getElementById('wpUploadDescription').value; if((description.indexOf('[[Category')==-1) && (description.indexOf('[[category')==-1)) { window.alert('Please add some categories to the "Summary" field. Our image categorisation policy can be found at http://strategywiki.org/wiki/StrategyWiki:Images.');  event.preventDefault;  event.returnValue=false;  return false; } }

// Edit summary addOnloadHook(edit_summary); function edit_summary { if((document.getElementById('editform')) && (document.getElementById('editform').nodeName=='FORM')) { var edit_form=document.getElementById('wpSave'); if(edit_form.addEventListener) {   edit_form.addEventListener('click',check_edit_summary,false); } else if(upload_form.attachEvent) {   upload_form.attachEvent('click',check_edit_summary); } } }

function check_edit_summary(event) { var summary=document.getElementById('wpSummary').value; if(summary.length<3) { if(document.getElementById('wpEditSummaryError')) document.getElementById('wpEditSummaryError').parentNode.removeChild(document.getElementById('wpEditSummaryError')); var p=document.createElement('p'); p.appendChild(document.createTextNode('Please add a suitably descriptive edit summary, using the "Summary" field. It should summarise the changes you have made to the page.')); p.setAttribute('class','error'); p.setAttribute('id','wpEditSummaryError'); document.getElementById('editform').insertBefore(p,document.getElementById('wpSummaryLabel').nextSibling); document.getElementById('wpSummary').focus; event.preventDefault; event.returnValue=false; return false; } }

// Template:Title addOnloadHook(title_template); function title_template { if(document.getElementById('title-override')) { var title_override=document.getElementById('title-override'); document.getElementsByTagName('h1')[0].textContent=title_override.textContent; document.getElementsByTagName('title')[0].textContent=title_override.textContent+' - StrategyWiki'; document.title=title_override.textContent+' - StrategyWiki'; title_override.parentNode.removeChild(title_override); } }

// (c) dynarch.com 2003 // Author: Mihai Bazon, http://dynarch.com/mishoo/ // Javascript hack for getting transparent PNGs working in MSIE6

if (/MSIE [56].*Windows/.test(navigator.userAgent)) (function {	// fucked-up browser (Internet Explorer for Windows)	var blank = new Image;	blank.src = '/mishoo/images/blank.gif';	var imgs = document.getElementsByTagName("img");	for (var i = imgs.length; --i >= 0;) {		var img = imgs[i];		var src = img.src;		if (!/\.png$/.test(src))			continue;		var s = img.runtimeStyle;		s.width = img.offsetWidth + "px";		s.height = img.offsetHeight + "px";		s.filter = "progid:DXImageTransform.Microsoft.AlphaImageLoader(src='" + src + "',sizingMethod='scale')";		img.src = blank.src;	} });

/* */