Last active
August 29, 2015 14:09
-
-
Save greenlikeorange/362c27e40f85c6de3db0 to your computer and use it in GitHub Desktop.
ကိန္ဒရီ ဖောင့်တွဲခွဲ စနစ်
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* Knayi-myscript Detection and font tagging script | |
* | |
* Nov 10, 2014 | |
* greenlikeorange<beginofalove@hotmail.com> | |
* | |
* original: | |
* https://github.com/greenlikeorange/knayi-myscript | |
* | |
*/ | |
(function(){ | |
/*Setting*/ | |
var interval = 2000; // milliseconds | |
var unicodeFont = "Padauk"; | |
var zawgyiFont = "Zawgyi-One"; | |
/*END setting*/ | |
var whitespace = "[\\x20\\t\\r\\n\\f]"; | |
var detectlib = { | |
myanmar: ['\u103e', '\u103f', '\u100a\u103a', '\u1014\u103a', '\u1004\u103a', '\u1031\u1038', '\u1031\u102c','\u103a\u1038', '\u1035', '[\u1050-\u1059]', '^([\u1000-\u1021]\u103c|[\u1000-\u1021]\u1031)'], | |
zawgyi : ['\u102c\u1039', '\u103a\u102c', whitespace+'(\u103b|\u1031|[\u107e-\u1084])[\u1000-\u1021]', '^(\u103b|\u1031|[\u107e-\u1084])[\u1000-\u1021]', '[\u1000-\u1021]\u1039[^\u1000-\u1021]', '\u1025\u1039','\u1039\u1038' ,'[\u102b-\u1030\u1031\u103a\u1038](\u103b|[\u107e-\u1084])[\u1000-\u1021]' ,'\u1036\|u102f','[\u1000-\u1021]\u1039\u1031' , '\u1064','\u1039'+whitespace, '\u102c\u1031','[\u102b-\u1030\u103a\u1038]\u1031[\u1000-\u1021]', '\u1031\u1031', '\u102f\u102d', '\u1039$'] | |
}; | |
function justText( elem ) { | |
if ( elem == null || !elem.nodeType ) return false; | |
if ( elem.nodeType === 3 ) return elem.value; | |
var text = "", | |
i = 0, | |
childNodes = elem.childNodes; | |
for ( ; i < childNodes.length; i++ ) { | |
if ( childNodes[ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* Compress version of https://gist.github.com/greenlikeorange/362c27e40f85c6de3db0 | |
*/ | |
var interval=1000; // milliseconds | |
var unicodeFont="Pyidaungsu"; | |
var zawgyiFont="Zawgyi-One"; | |
(function(){function n(e){if(e==null||!e.nodeType)return false;if(e.nodeType===3)return e.value;var t="",n=0,r=e.childNodes;for(;n<r.length;n++){if(r[n].nodeType===3&&r[n].nodeValue!=null)t+="*$"+r[n].nodeValue.trim()}return t.replace(/\*\$/,"","g")}function r(e,n){var r=[],i;e=e.trim().replace(/\u200B/g,"");if(!e.match(/[\u1000-\u1097]/g)){if(n)return"non";return[{type:"non"}]}for(i in t){var s=t[i],o=0,u,a,f=0;for(;o<s.length;o++){u=new RegExp(s[o],"g");if(a=e.match(s[o])){f+=a.length}r.push({type:i,times:f})}}r.sort(function(e,t){if(e.times<t.times)return 1;if(e.times>t.times)return-1;return 0});if(n)return r[0].type;return r}var e="[\\x20\\t\\r\\n\\f]";var t={myanmar:["ှ","ဿ","ည်","န်","င်","ေး","ော","်း","ဵ","[ၐ-ၙ]","^([က-အ]ြ|[က-အ]ေ)"],zawgyi:["ာ္","်ာ",e+"(ျ|ေ|[ၾ-ႄ])[က-အ]","^(ျ|ေ|[ၾ-ႄ])[က-အ]","[က-အ]္[^က-အ]","ဥ္","္း","[ါ-ူေ်း](ျ|[ၾ-ႄ])[က-အ]","ံု","[က-အ]္ေ","ၤ","္"+e,"ာေ","[ါ-ူ်း]ေ[က-အ]","ေေ","ုိ","္$"]};setInterval(function(){var e=document.body.getElementsByTagName("*"),t=0,i;for(;t<e.length;t++){if(!e[t].nodeName.match("SCRIPT|STYPE")&&!e[t].knyDetected&&e[t].nodeType===1){i=r(n(e[t]),true);e[t].knyDetected=i;switch(i){case"myanmar":e[t].style.fontFamily=unicodeFont;break;case"zawgyi":e[t].style.fontFamily=zawgyiFont;break}}}},interval)})() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
ဖောင့်ခွဲတွဲ script တစ်ခုရေးထားပါတယ်။ Addon မရှိတဲ့ Browser တွေ ဥပမာ Safari တိုမှာ JavaScript Scratchpad အနေနဲ့သုံးနိုင်ပါတယ်။ ယခင် လုပ်ခဲ့တဲ့ Kain Na Yi Addon ထပ် လုပ်ဆောင်ချက်တွေပိုမြန်ပါလိမ့်မယ်။ မိမိဖော်ပြလိုသည့် Font အမျိုးအစားကို /Setting/ အောက်မှာ ပြောင်းနိုင်ပါတယ်။ အဆင်ပြေကြပါစေ။