-
-
Notifications
You must be signed in to change notification settings - Fork 1
/
fmt.ordinal.min.js
1 lines (1 loc) · 2.1 KB
/
fmt.ordinal.min.js
1
/* vim: set expandtab tabstop=4 shiftwidth=4: */(function(w,undefined){let digits=["","\ub9cc","\uc5b5","\uc870","\uacbd","\ud574","\uc790","\uc591","\uad6c","\uac04","\uc815","\uc7ac","\uadf9","\ud56d\ud558\uc0ac","\uc544\uc2b9\uae30","\ub098\uc720\ud0c0","\ubd88\uac00\uc0ac\uc758","\ubb34\ub7c9\ub300\uc218","\uac81","\uc5c5"],num=["","\uc77c","\uc774","\uc0bc","\uc0ac","\uc624","\uc721","\uce60","\ud314","\uad6c"],cardinal=["","\uc2ed","\ubc31","\ucc9c"],ordinal=[["","\ud558\ub098","\ub458","\uc14b","\ub137","\ub2e4\uc12f","\uc5ec\uc12f","\uc77c\uacf1","\uc5ec\ub35f","\uc544\ud649"],["","\ud55c","\ub450","\uc138","\ub124","\ub2e4\uc12f","\uc5ec\uc12f","\uc77c\uacf1","\uc5ec\ub35f","\uc544\ud649"]],largeordinal=["","\uc5f4","\uc2a4\ubb3c","\uc11c\ub978","\ub9c8\ud754","\uc270","\uc608\uc21c","\uc77c\ud754","\uc5ec\ub4e0","\uc544\ud754"],fmt={toCardinal:function(n,pronunFirstOne){n+="";if(n.length>80)return"\ubb34\ud55c";const r=[];let pronunDigits=true;for(let i=0;i<n.length-1;i++){const d=n.length-i-1;if(n[i]>"1"||i>0&&d%4==0||pronunFirstOne&&i==0){const tnum=num[n[i]*1];if(tnum){r.push(tnum);pronunDigits=true}}if(pronunDigits&&d%4==0){r.push(digits[d/4]);pronunDigits=false}if(n[i]!="0"){r.push(cardinal[d%4])}}r.push(num[n[n.length-1]*1]);return r.join("")},$cardinal:function(){var t=$(this).text();this.title=t;$(this).text(fmt.toCardinal(t,$(this).data("pronun-first-one")))},toOrdinal:function(n,type,unit){n+="";if(n.length>80)return"\ubb34\ud55c";if(!type)type=1;if(!unit)unit="";if(n=="1"&&type==2&&unit=="")return"\ucc98\uc74c";var s,r=[];if(unit!=""){var u=unit.charCodeAt(0)-44032,cho=Math.floor(u/588),jong=u%588%28;s=(cho==1||cho==4||cho==8||cho==10||cho==13)&&jong==0?0:1}else{s=0;type=1}if(n.length>2){r.push(fmt.toCardinal(n.substring(0,n.length-2)+"00"))}n="0"+n;n=n.substring(n.length-2);r.push(largeordinal[n[0]*1]);r.push(type==2&&n[1]=="1"?"\uccab":ordinal[s][n[1]*1]);r.push(unit);return r.join("")},$ordinal:function(){var t=$(this).text();this.title=t;$(this).text(fmt.toOrdinal(t,$(this).data("type"),$(this).data("unit")))}};if(w.define)define(function(){return fmt});else w.FmtOrdinal=fmt})(window);