အသုံးပြုသူ:ကိုရာဝီ/monobook.js: တည်းဖြတ်မှု မူကွဲများ
ပုံပန်းသွင်ပြင်
Content deleted Content added
No edit summary |
No edit summary |
||
စာကြောင်း ၄၆ - | စာကြောင်း ၄၆ - | ||
h.removeChild(d); |
h.removeChild(d); |
||
font = font.toLowerCase(); |
font = font.toLowerCase(); |
||
if (font == "arial" || font == "sans-serif") { |
//if (font == "arial" || font == "sans-serif") { |
||
f[3] = true; // to set arial and sans-serif true |
// f[3] = true; // to set arial and sans-serif true |
||
} else { |
//} else { |
||
f[3] = true; // Set default as true. |
|||
if((f[1] != defaultWidth || f[2] != defaultHeight){ |
|||
f[3] = false; // Detected? |
|||
} |
} |
||
return f; |
return f; |
၁၉:၂၂၊ ၄ စက်တင်ဘာ ၂၀၀၈ ရက်နေ့က မူ
/**
* 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 = "sans-serif"; //font for the parent element DIV.
s.style.fontFamily = "sans-serif"; //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 = "mmmmmmmmmml"; //we use m or w because these two characters take up the maximum width. And we use a L 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
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] = true; // Set default as true.
if((f[1] != defaultWidth || f[2] != defaultHeight){
f[3] = false; // Detected?
}
return f;
}
this.test = test;
}
function detectFont(){
d = new Detector;
result = d.test("Paduak");
var installed = document.createTextNode(result[3]);
document.getElementById('Paduak').appendChild(installed);
result = d.test("Myanmar3");
var installed = document.createTextNode(result[3]);
document.getElementById('Myanmar3').appendChild(installed);
result = d.test("Myanmar2");
var installed = document.createTextNode(result[3]);
document.getElementById('Myanmar2').appendChild(installed);
result = d.test("Parabaik");
var installed = document.createTextNode(result[3]);
document.getElementById('Parabaik').appendChild(installed);
result = d.test("MyMyanmar Unicode");
var installed = document.createTextNode(result[3]);
document.getElementById('MyMyanmar').appendChild(installed);
}
addOnloadHook(
detectFont
);