မီဒီယာဝီကီ:Common.js

ဝစ်ရှင်နရီ မှ

မှတ်ချက်။ လွှင့်တင်လိုက်ပြီးသည့်နောက် ပြောင်းလဲမှုများ မြင်ရနိုင်ရန် သင့်အနေဖြင့် ဘရောက်ဇာ၏ cache အား ဖြတ်ကျော်နိုင်ရန် လိုအပ်ပါသည်။

  • Firefox / Safari: Reload ကို နှိပ်နေစဉ်အတွင်း Shift ကို ဖိထားပါ၊ သို့မဟုတ် Ctrl-F5 သို့ Ctrl-R (Mac တွင် ⌘-R) ကို နှိပ်ပါ။
  • Google Chrome: Ctrl-Shift-R (Mac တွင် ⌘-Shift-R) ကို နှိပ်ပါ။
  • Internet Explorer / Edge: Refresh ကို နှိပ်နေစဉ်အတွင်း Ctrl ကို ဖိထားပါ၊ သို့မဟုတ် Ctrl-F5 ကို နှိပ်ပါ။
  • Opera: Menu → Settings (Mac တွင် Opera → Preferences) သို့ သွားပြီး Privacy & security → Clear browsing data → Cached images and files ကို ပြုလုပ်ပါ။
/* Any JavaScript here will be loaded for all users on every page load. */

// JavaScript font detect code begins
/**
 * JavaScript code to detect available availability of a 
 * particular font in a browser using JavaScript and CSS. 
 * 
 * Author : Lalit Patel
 * Website: http://www.lalit.org/lab/jsoncookies
 * License: Creative Commons Attribution-ShareAlike 2.5
 *          http://creativecommons.org/licenses/by-sa/2.5/
 * Version: 0.1
 * Updated: Aug 11, 2007 10:09am
 * 
 */
 
/**
 * Actual function that does all the work. Returns an array with all the info.
 * My Assumption is that most of the browsers will have arial set as their default sans-serif font.
 */
var Detector = function(){
	var h = document.getElementsByTagName("BODY")[0];
	var d = document.createElement("DIV");
	var s = document.createElement("SPAN");
	d.appendChild(s);
	d.style.fontFamily = "Arial";		//font for the parent element DIV.
	s.style.fontFamily = "Arial";		//arial font used as a comparator.
	s.style.fontSize   = "72px";			//we test using 72px font size, we may use any size. I guess larger the better.
	s.innerHTML        = "ကကကကကကကကကကင";		//we use  က for maximum width. And we use a င so that the same matching fonts can get separated
	h.appendChild(d);
	var defaultWidth   = s.offsetWidth;		//now we have the defaultWidth
	var defaultHeight  = s.offsetHeight;	//and the defaultHeight, we compare other fonts with these.
	h.removeChild(d);
	/* test
	 * params:
	 * font - name of the font you wish to detect
	 * return: 
	 * f[0] - Input font name.
	 * f[1] - Computed width.
	 * f[2] - Computed height.
	 * f[3] - Detected? (true/false).
	 */
	function test(font) {
                h.appendChild(d);		
		var f = [];
		f[0] = s.style.fontFamily = font;	// Name of the font        
                s.style.innerHTML = "ကကကကကကကကကကင"
                s.style.fontSize = "72px";         
                h.appendChild(d);
		f[1] = s.offsetWidth;				// Width
		f[2] = s.offsetHeight;				// Height        
		h.removeChild(d);
		font = font.toLowerCase();
		if (font == "arial" || font == "sans-serif") {
			f[3] = true;	// to set arial and sans-serif true
		} else {
			f[3] = (f[1] != defaultWidth && f[2] != defaultHeight);	// Detected?
		}        
		return f;
	}
	this.test = test;
}
// Create new instance of Detector and pass each U51 font. 
// Update table with result[3]
function detectFont(){
    d = new Detector;
    result = d.test("Padauk");
	var p = document.getElementById("Masterpiece Uni Sans");
	if(p) p.innerHTML = result[3]
	result = d.test("Padauk");
	var p = document.getElementById("Padauk");
	if(p) p.innerHTML = result[3]
	result = d.test("Myanmar3");
	var p = document.getElementById("Myanmar3");
	if(p) p.innerHTML = result[3]
	result = d.test("Parabaik");
	var p = document.getElementById("Parabaik");
	if(p) p.innerHTML = result[3]
	result = d.test("MyMyanmar Unicode");
	var p = document.getElementById("MyMyanmar");
	if(p) p.innerHTML = result[3]
	result = d.test("Myanmar2");
	var p = document.getElementById("Myanmar2");
	if(p) p.innerHTML = result[3]
	result = d.test("Yunghkio");
	var p = document.getElementById("Yunghkio");
	if(p) p.innerHTML = result[3]
}                                               
 
$(detectFont);
// JavaScript font detect code ends

/* Including extra .js pages */ 
 
// switches for scripts
// var load_extratabs = true;
var load_edittools = true;

/* Conflicts with ULS - [[User:Nikerabbit]]
// extra drop down menu on editing for adding special characters
importScript( 'MediaWiki:Edittools.js' );
importScript( 'MediaWiki:keyboard.js' );
*/



// == "Did you mean" auto redirect in 3 seconds ==
/**
 * doRedirect will redirect if a did you mean box is found, and create a
 * "redirected from X" if a rdfrom is passed in the get parameters
**/

$.when(mw.loader.using("mediawiki.util"), $.ready).done(function(){
var rdFromValue = mw.util.getParamValue("rdfrom");
if (rdFromValue)
{
	rdFromValue = decodeURIComponent(rdFromValue);
	$('#siteSub').after(
		$('<div>').attr("id", 'contentSub')
			.append(document.createTextNode("(Auto-redirected from "))
			.append($('<a>', {
				href: mw.util.getUrl(rdFromValue, {redirect:"no"}),
				addClass: 'new'
			}).text(rdFromValue))
			.append(document.createTextNode(")")));
}
else 
{
	window.setTimeout(function () {	
		var target = $('#did-you-mean a').html();
		var	pagetitle = mw.config.get("wgTitle"); //$('h1').first().text().trim();
		var canRedirect = mw.util.getParamValue("redirect") != "no";
		
		if (target && target !== pagetitle && canRedirect &&
			(jQuery.cookie('WiktionaryDisableAutoRedirect') != 'true') &&
			mw.config.get("wgAction") == "view" &&
			mw.config.get('wgArticleId') === 0 &&
			mw.config.get('wgNamespaceNumber') === 0 &&
			!/Redirected from/.test(jQuery('#contentSub').html())
		) {
			window.location = mw.util.getUrl(target, { rdfrom: pagetitle });
		}
	}, 3000);
}
});