Commit fb7cbade authored by Sergey Antonovich's avatar Sergey Antonovich 🇯🇵

number-to-string.conf

parent d643fa2d
<?xml version="1.0" encoding="utf-8"?>
<configuration version="1" date="2018-03-28 14:26:52" synergyVersion="3.15">
<objects version="1" date="2018-03-28 14:26:52" synergyVersion="3.15">
<customComponent code="number_to_string" name="Числа прописью" use_in_forms="true">
<javascript>function numberToText(c) {
function k(b, c) {
var d = c[0], e = c[1], f = c[2];
return b % 10 == 1 &amp;&amp; b % 100 != 11 ? d : b % 10 &gt;= 2 &amp;&amp; b % 10 &lt;= 4 &amp;&amp; (b % 100 &lt; 10 || b % 100 &gt;= 20) ? e : f
}
for (var d = {
0: {
1: "\u043e\u0434\u0438\u043d",
2: "\u0434\u0432\u0430",
3: "\u0442\u0440\u0438",
4: "\u0447\u0435\u0442\u044b\u0440\u0435",
5: "\u043f\u044f\u0442\u044c",
6: "\u0448\u0435\u0441\u0442\u044c",
7: "\u0441\u0435\u043c\u044c",
8: "\u0432\u043e\u0441\u0435\u043c\u044c",
9: "\u0434\u0435\u0432\u044f\u0442\u044c",
10: "\u0434\u0435\u0441\u044f\u0442\u044c",
11: "\u043e\u0434\u0438\u043d\u043d\u0430\u0434\u0446\u0430\u0442\u044c",
12: "\u0434\u0432\u0435\u043d\u0430\u0434\u0446\u0430\u0442\u044c",
13: "\u0442\u0440\u0438\u043d\u0430\u0434\u0446\u0430\u0442\u044c",
14: "\u0447\u0435\u0442\u044b\u0440\u043d\u0430\u0434\u0446\u0430\u0442\u044c",
15: "\u043f\u044f\u0442\u043d\u0430\u0446\u0430\u0442\u044c",
16: "\u0448\u0435\u0441\u0442\u043d\u0430\u0434\u0446\u0430\u0442\u044c",
17: "\u0441\u0435\u043c\u043d\u0430\u0434\u0446\u0430\u0442\u044c",
18: "\u0432\u043e\u0441\u0435\u043c\u043d\u0430\u0434\u0446\u0430\u0442\u044c",
19: "\u0434\u0435\u0432\u044f\u0442\u043d\u0430\u0434\u0446\u0430\u0442\u044c",
20: "\u0434\u0432\u0430\u0434\u0446\u0430\u0442\u044c",
30: "\u0442\u0440\u0438\u0434\u0446\u0430\u0442\u044c",
40: "\u0441\u043e\u0440\u043e\u043a",
50: "\u043f\u044f\u0442\u044c\u0434\u0435\u0441\u044f\u0442",
60: "\u0448\u0435\u0441\u0442\u044c\u0434\u0435\u0441\u044f\u0442",
70: "\u0441\u0435\u043c\u044c\u0434\u0435\u0441\u044f\u0442",
80: "\u0432\u043e\u0441\u0435\u043c\u044c\u0434\u0435\u0441\u044f\u0442",
90: "\u0434\u0435\u0432\u044f\u043d\u043e\u0441\u0442\u043e",
100: "\u0441\u0442\u043e",
200: "\u0434\u0432\u0435\u0441\u0442\u0438",
300: "\u0442\u0440\u0438\u0441\u0442\u0430",
400: "\u0447\u0435\u0442\u044b\u0440\u0435\u0441\u0442\u0430",
500: "\u043f\u044f\u0442\u044c\u0441\u043e\u0442",
600: "\u0448\u0435\u0441\u0442\u044c\u0441\u043e\u0442",
700: "\u0441\u0435\u043c\u044c\u0441\u043e\u0442",
800: "\u0432\u043e\u0441\u0435\u043c\u044c\u0441\u043e\u0442",
900: "\u0434\u0435\u0432\u044f\u0442\u044c\u0441\u043e\u0442"
}, 1: {1: "\u043e\u0434\u043d\u0430", 2: "\u0434\u0432\u0435"}
}, i = {
0: ["", "", ""],
1: ["\u0442\u044b\u0441\u044f\u0447\u0430", "\u0442\u044b\u0441\u044f\u0447\u0438", "\u0442\u044b\u0441\u044f\u0447"],
2: ["\u043c\u0438\u043b\u043b\u0438\u043e\u043d", "\u043c\u0438\u043b\u043b\u0438\u043e\u043d\u0430", "\u043c\u0438\u043b\u043b\u0438\u043e\u043d\u043e\u0432"],
3: ["\u043c\u0438\u043b\u043b\u0438\u0430\u0440\u0434", "\u043c\u0438\u043b\u043b\u0438\u0430\u0440\u0434\u0430", "\u043c\u0438\u043b\u043b\u0438\u0430\u0440\u0434\u043e\u0432"],
4: ["\u0442\u0440\u0438\u043b\u043b\u0438\u043e\u043d", "\u0442\u0440\u0438\u043b\u043b\u0438\u043e\u043d\u0430", "\u0442\u0440\u0438\u043b\u043b\u0438\u043e\u043d\u043e\u0432"],
5: ["\u043a\u0432\u0430\u0434\u0440\u0438\u043b\u043b\u0438\u043e\u043d", "\u043a\u0432\u0430\u0434\u0440\u0438\u043b\u043b\u0438\u043e\u043d\u0430", "\u043a\u0432\u0430\u0434\u0440\u0438\u043b\u043b\u0438\u043e\u043d\u043e\u0432"],
6: ["\u043a\u0432\u0438\u043d\u0442\u0438\u043b\u043b\u0438\u043e\u043d", "\u043a\u0432\u0438\u043d\u0442\u0438\u043b\u043b\u0438\u043e\u043d\u0430", "\u043a\u0432\u0438\u043d\u0442\u0438\u043b\u043b\u0438\u043e\u043d\u043e\u0432"]
}, h = "", j = (("" + c).match(/(\d{1,3})(?=((\d{3})*([^\d]|$)))/g) || []).reverse(), e = 0; e &lt; j.length; e++) {
for (var f = d[e], c = j[e], b = "", g = 0; g &lt; c.length; g++) if (a = c.substr(g), f &amp;&amp; f[a] || d[0][a]) {
b = b + " " + (f &amp;&amp; f[a] || d[0][a]);
break;
} else a = +c.substr(g, 1) * Math.pow(10, a.length - 1), +a in d[0] &amp;&amp; (b = b + " " + d[0][a]);
b &amp;&amp; (b = b + " " + k(+c, i[e] || i[0]));
h = b + h
}
return h || "\u043d\u043e\u043b\u044c"
}
model.getAsfData = function (blockNumber) {
if(model.getValue()){
var valueObject = JSON.stringify(model.getValue());
return AS.FORMS.ASFDataUtils.getBaseAsfData(model.asfProperty, blockNumber, valueObject, valueObject);
}else{
return AS.FORMS.ASFDataUtils.getBaseAsfData(model.asfProperty, blockNumber);
}
};
model.setAsfData = function(asfData){
if(!asfData || !asfData.value) return;
model.setValue(JSON.parse(asfData.value));
};
view.updateValueFromModel = function(){
if(('code' in model) !== false &amp;&amp; typeof(model.code) === 'object'){
for(var cmpG in model.code){
var cmpS = model.code[cmpG];
if(cmpG.indexOf('#table') !== -1){
if(Array.isArray(cmpS.to) &amp;&amp; Array.isArray(cmpS.from)){
model.playerModel.getModelWithId(""+cmpS.from[0],""+cmpS.from[1],cmpS.from[2]).procedureToString = cmpS;
model.playerModel.getModelWithId(""+cmpS.from[0],""+cmpS.from[1],cmpS.from[2]).on('valueChange',function(e,m){
model.playerModel.getModelWithId(""+m.procedureToString.to[0],""+m.procedureToString.to[1],m.procedureToString.to[2]).setValue(""+numberToText(""+(!m.getValue()?'ноль':m.getValue())));
});
var v = model.playerModel.getModelWithId(""+cmpS.from[0],""+cmpS.from[1],cmpS.from[2]).getValue();
model.playerModel.getModelWithId(""+cmpS.to[0],""+cmpS.to[1],cmpS.to[2]).setValue(""+(!v?'ноль':v));
}else if(Array.isArray(cmpS.to)){
model.playerModel.getModelWithId(""+cmpS.from).procedureToString = cmpS;
model.playerModel.getModelWithId(""+cmpS.from).on('valueChange',function(e,m){
model.playerModel.getModelWithId(""+m.procedureToString.to[0],""+m.procedureToString.to[1],m.procedureToString.to[2]).setValue(""+numberToText(""+(!m.getValue()?'ноль':m.getValue())));
});
var v = model.playerModel.getModelWithId(""+cmpS.from).getValue();
model.playerModel.getModelWithId(""+cmpS.to[0],""+cmpS.to[1],cmpS.to[2]).setValue(""+(!v?'ноль':v));
}else if(Array.isArray(cmpS.from)){
model.playerModel.getModelWithId(""+cmpS.from[0],""+cmpS.from[1],cmpS.from[2]).procedureToString = cmpS;
model.playerModel.getModelWithId(""+cmpS.from[0],""+cmpS.from[1],cmpS.from[2]).on('valueChange',function(e,m){
model.playerModel.getModelWithId(""+m.procedureToString.to).setValue(""+numberToText(""+(!m.getValue()?'ноль':m.getValue())));
});
var v = model.playerModel.getModelWithId(""+cmpS.from[0],""+cmpS.from[1],cmpS.from[2]).getValue();
model.playerModel.getModelWithId(""+cmpS.to).setValue(""+(!v?'ноль':v));
}
}else{
model.playerModel.getModelWithId(""+cmpG).procedureToString = [cmpS,cmpG];
model.playerModel.getModelWithId(""+cmpG).on('valueChange',function(e,m){
var v = model.playerModel.getModelWithId(""+m.procedureToString[1]).getValue();
model.playerModel.getModelWithId(""+m.procedureToString[0]).setValue(""+numberToText((!v?'ноль':v)));
});
var v = model.playerModel.getModelWithId(""+cmpG).getValue();
model.playerModel.getModelWithId(""+cmpS).setValue(""+numberToText((!v?'ноль':v)));
}
}
}
};
view.updateValueFromModel();</javascript>
<html></html>
</customComponent>
</objects>
<dependencies/>
</configuration>
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment