Last active
April 1, 2023 15:22
-
-
Save sudodoki/6700883 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
| // from http://vvsite.com.ua/?attachment_id=783 | |
| //<!-- | |
| var cifir_ru= new Array("од","дв","три","четыр","пят","шест","сем","восем","девят"); | |
| var sotN_ru=new Array("сто","двести","триста","четыреста","пятьсот","шестьсот","семьмот","восемьсот","девятьсот"); | |
| var milion_ru=new Array("триллион","миллиард","миллион","тысяч"); | |
| var anDan_ru =new Array("","","","сорок","","","","","девяносто"); | |
| function SPRU(XS){ | |
| (XS>0? this.XS=sumPROPRU(Math.floor(XS),Math.round((XS-Math.floor(XS))*100)) : this.XS="Пусто!" ); | |
| return this; | |
| } | |
| function sumPROPRU(xx,xx1){ | |
| var scet=4; | |
| var cifR=''; | |
| var cfR=''; | |
| var oboR=new Array(0); | |
| //========================== | |
| if (xx>999999999999999) { cfR="Густо!"; return cfR; } | |
| while(xx/1000>0){ | |
| yy=Math.floor(xx/1000); | |
| delen=Math.round((xx/1000-yy)*1000); | |
| //------------------------------- | |
| sot=Math.floor(delen/100)*100; | |
| des=(Math.floor(delen-sot)>9?Math.floor((delen-sot)/10)*10:0); | |
| ed=Math.floor(delen-sot)-Math.floor((delen-sot)/10)*10; | |
| //------------------------------- | |
| forDes=(des/10==2?'а':'') | |
| forEd=(ed==1?'ин': (ed==2?'е':'') ); | |
| ffD=(ed>4?'ь': (ed==1 || scet<3? (scet<3 && ed<2?'ин': (scet==3?'на': (scet<4? (ed==2?'а':( ed==4?'е':'')) :'на') ) ) : (ed==2 || ed==4?'е':'') ) ); | |
| forTys=(des/10==1? (scet<3?'ов':'') : (scet<3? (ed==1?'': (ed>1 && ed<5?'а':'ов') ) : (ed==1?'а': (ed>1 && ed<5?'и':'') )) ); | |
| //=============================== | |
| oprSot=(sotN_ru[sot/100-1]!=null?sotN_ru[sot/100-1]:''); | |
| oprDes=' '+(cifir_ru[des/10-1]!=null? (des/10==1?'': (des/10==4 || des/10==9?anDan_ru[des/10-1]:(des/10==2 || des/10==3?cifir_ru[des/10-1]+forDes+'дцать':cifir_ru[des/10-1]+'ьдесят') ) ) :''); | |
| oprEd=' '+(cifir_ru[ed-1]!=null? cifir_ru[ed-1]+(des/10==1?forEd+'надцать' : ffD ) : (des==10?'десять':'') ); | |
| oprTys=' '+(milion_ru[scet]!=null && delen>0 ?milion_ru[scet]+forTys:''); | |
| //------------------------------- | |
| cifR=(oprSot.length>1?oprSot:'')+ | |
| (oprDes.length>1?oprDes:'')+ | |
| (oprEd.length>1?oprEd:'')+ | |
| (oprTys.length>1?oprTys:''); | |
| oboR[oboR.length]=cifR; | |
| xx=Math.floor(xx/1000); | |
| scet-=1; | |
| if ( Math.floor(xx)<1 ) { break; } | |
| } | |
| oboR.reverse(); | |
| for (i=0; i<oboR.length; i++){ | |
| cfR+=oboR[i]+' '; | |
| } | |
| (cfR.length<3?cfR='ноль ':cfR); | |
| cfR+='грн. '+xx1+' коп.'; | |
| return cfR.replace(' ',' ').replace(/^\s\s*/, '').replace(/\s\s*$/, ''); | |
| } | |
| //--> |
This file contains hidden or 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
| // from http://vvsite.com.ua/?attachment_id=783 | |
| //<!-- | |
| var cifir= new Array("од","дв","три","чотир","п'ят","шіст","сім","вісім","дев'ят"); | |
| var sotN=new Array("сто","двісті","триста","чотириста","п'ятсот","шістсот","сімсот","вісімсот","дев'ятсот"); | |
| var milion=new Array("трильйон","мільярд","мільйон","тисяч"); | |
| var anDan =new Array("","","","сорок","","","","","дев'яносто"); | |
| function SPUA(XS){ | |
| (XS>0? this.XS=sumPROPUA(Math.floor(XS),Math.round((XS-Math.floor(XS))*100)) : this.XS="Пусте!" ); | |
| return this; | |
| } | |
| function sumPROPUA(xx,xx1){ | |
| var scet=4; | |
| var cifR=''; | |
| var cfR=''; | |
| var oboR=new Array(0); | |
| //========================== | |
| if (xx>999999999999999) { cfR="Забагато!"; return cfR; } | |
| while(xx/1000>0){ | |
| yy=Math.floor(xx/1000); | |
| delen=Math.round((xx/1000-yy)*1000); | |
| //------------------------------- | |
| sot=Math.floor(delen/100)*100; | |
| des=(Math.floor(delen-sot)>9?Math.floor((delen-sot)/10)*10:0); | |
| ed=Math.floor(delen-sot)-Math.floor((delen-sot)/10)*10; | |
| //------------------------------- | |
| forDes=(des/10==2?'а':'') | |
| forEd=(ed==1?'и': (ed==2?'а':'') ); | |
| ffD=( (ed>4 && ed!=7 && ed!=8 )?'ь': (ed==1 || scet<3? (scet<3 && ed<2?'ин': (scet==3?'на': (scet<4? (ed==2?'а':( ed==4?'и':'')) :'на') ) ) : (ed==2?'і': (ed==4?'и': '' ) ) ) ); | |
| forTys=(des/10==1? (scet<3?'ов':'') : (scet<3? (ed==1?'': (ed>1 && ed<5?'а':'ов') ) : (ed==1?'а': (ed>1 && ed<5?'и':'') )) ); | |
| //=============================== | |
| oprSot=(sotN[sot/100-1]!=null?sotN[sot/100-1]:''); | |
| oprDes=' '+(cifir[des/10-1]!=null? (des/10==1?'': (des/10==4 || des/10==9?anDan[des/10-1]:(des/10==2 || des/10==3?cifir[des/10-1]+forDes+'дцять':cifir[des/10-1]+'ьдесят') ) ) :''); | |
| oprEd=' '+(cifir[ed-1]!=null? cifir[ed-1]+(des/10==1?forEd+'надцять' : ffD ) : (des==10?'десять':'') ); | |
| oprTys=' '+(milion[scet]!=null && delen>0 ?milion[scet]+forTys:''); | |
| //------------------------------- | |
| cifR=(oprSot.length>1?oprSot:'')+ | |
| (oprDes.length>1?oprDes:'')+ | |
| (oprEd.length>1?oprEd:'')+ | |
| (oprTys.length>1?oprTys:''); | |
| oboR[oboR.length]=cifR; | |
| xx=Math.floor(xx/1000); | |
| scet-=1; | |
| if ( Math.floor(xx)<1 ) { break; } | |
| } | |
| oboR.reverse(); | |
| for (i=0; i<oboR.length; i++){ | |
| cfR+=oboR[i]+' '; | |
| } | |
| (cfR.length<3?cfR='нуль ':cfR); | |
| cfR+='грн. '+xx1+' коп.'; | |
| return cfR.replace(' ',' ').replace(/^\s\s*/, '').replace(/\s\s*$/, ''); | |
| } | |
| //--> |
This file contains hidden or 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
| http://javascript.ru/forum/misc/40642-summa-propisyu.html#post272371 | |
| еще вариант | |
| https://docs.google.com/document/d/1aFc3yZHkXbgkruRpBKIvVXifC_yuzXqOxURHlVEWF1U/edit?hl=ru#heading=h.38e89506ae61 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment