-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathlk_applications.js
More file actions
368 lines (357 loc) · 11.8 KB
/
lk_applications.js
File metadata and controls
368 lines (357 loc) · 11.8 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
(function (d, $, S) {
"use strict";
const controller = "contenders.d";
const saveDraft = d.getElementById("saveDraft");
const send = d.getElementById("send");
function switchStage() {
const stages = d.querySelectorAll(".account-stages__link");
const lastStages = d.querySelector(".account-stages");
lastStages.lastChild.classList.add("active");
d.forms[stages.length - 1].classList.remove("hide");
stages.forEach((element) => {
element.addEventListener("click", function (e) {
e.preventDefault();
stages.forEach((element) => {
element.classList.remove("active");
d.forms[element.dataset.stages].classList.add("hide");
});
element.classList.add("active");
d.forms[element.dataset.stages].classList.remove("hide");
});
});
}
switchStage();
function setInputRestrictions() {
const input = document.querySelectorAll(".setInputRestrictions");
for (let item of input) {
item.value = item.value.replace(/[^0-9\.\,]/g, "");
}
}
// удаление строки
function removeLine() {
const remove = document.querySelectorAll(".button_remove_line");
remove.forEach(element => {
element.addEventListener("click", function (event) {
event.preventDefault();
element.closest(".createTr").remove();
totalAmount();
});
});
}
// Подсчет суммы
function totalAmount() {
const total = document.querySelectorAll(".total");
let input;
let output;
for (let elem of total) {
let dataName = elem.dataset.total;
switch (dataName) {
case "outlay":
input = document.querySelectorAll(".totalOutlay");
output = document.querySelector(".totalSumm_outlay");
int();
break;
case "financing_other":
input = document.querySelectorAll(".totalFinancing_other");
output = document.getElementById("financing_other_summ");
int();
break;
case "column_three":
output = document.getElementById("column_three");
input = document.querySelectorAll('[data-total="column_three"]');
int();
break;
case "column_four":
output = document.getElementById("column_four");
input = document.querySelectorAll('[data-total="column_four"]');
int();
break;
case "column_six":
output = document.getElementById("column_six");
input = document.querySelectorAll('[data-total="column_six"]');
int();
break;
case "third_column":
output = document.getElementById("third_column");
input = document.querySelectorAll('[data-total="third_column"]');
console.log(input);
int();
break;
case "fourth_column":
output = document.getElementById("fourth_column");
input = document.querySelectorAll('[data-total="fourth_column"]');
int();
break;
case "fifth_column":
output = document.getElementById("fifth_column");
input = document.querySelectorAll('[data-total="fifth_column"]');
int();
break;
case "sixth_column":
output = document.getElementById("sixth_column");
input = document.querySelectorAll('[data-total="sixth_column"]');
int();
break;
}
}
// int();
function int() {
input = Array.from(input);
let result = input.map(function (ele) {
let age = Number(ele.innerHTML) || Number(ele.value);
return age;
});
let reduce = result.reduce(function (a, b) {
return a + b;
}, 0);
output.value = reduce.toFixed(2);
output.innerHTML = reduce.toFixed(2);
}
}
// Добавление строки
function create() {
let line = document.querySelector(".line");
let empty = "";
let tr = document.createElement("tr");
tr.setAttribute("class", "createTr");
tr.setAttribute("id", "newTr");
let button__close = '<button class="button_remove_line"> </button>';
for (let i = 0; i < 4; i++) {
let td = `<td contenteditable class="financing_input">`;
let input = ``;
switch (i) {
case 0:
input = `<input class="input metaTable_input" name ='name'></input>`;
break;
case 1:
input = `<input class="input setInputRestrictions metaTable_input" name ='quality'></input>`;
break;
case 2:
input = `<input class="input setInputRestrictions metaTable_input" name ='price'></input>`;
break;
case 3:
td = `<td class="financing_input">`;
input = `<input readonly='readonly' class="totalOutlay total input setInputRestrictions metaTable_input" name ='amount' data-total="outlay"></input>`;
break;
}
empty += td + input + `</td>`;
}
tr.innerHTML += empty + button__close;
line.before(tr);
return tr;
}
// таблица (1)
outlayy();
function outlayy() {
try {
let button = document.getElementById("button");
button.addEventListener("click", function (e) {
e.preventDefault();
let tr = create();
tr.oninput = function sum() {
setInputRestrictions();
let one = tr.childNodes[1].childNodes[0].value;
let two = tr.childNodes[2].childNodes[0].value;
let summa = tr.childNodes[3].childNodes[0];
let sums = one * two;
summa.value = sums.toFixed(2);
totalAmount(document.getElementById("tableOutlay"));
};
removeLine();
});
} catch(e) { }
}
// таблица (2)
financing();
function financing() {
try {
const finance = document.getElementById("table_finance"),
co_financing = document.getElementById("co-financing"),
co_percent = document.getElementById("co-percent"),
all__financing = document.getElementById("all__financing"),
all__percent = document.getElementById("all__percent");
let all__finance = document.querySelectorAll(".input__finance");
let projectAmount_percent = document.querySelectorAll(
".projectAmount_percent"
);
let input__finance = document.querySelectorAll(".input__finance");
all__finance = Array.from(all__finance);
all__finance.map(function (ele) {
ele.oninput = function action() {
setInputRestrictions();
co_financing.innerHTML = input__finance[0].value;
let result = all__finance.map(function (x) {
let age = Number(x.value);
return age;
});
let reduce = result.reduce(function (a, b) {
return a + b;
});
all__percent.innerHTML = reduce !== 0 ? "100" : "";
all__financing.innerHTML =
reduce.toFixed(2) !== "0.00" ? reduce.toFixed(2) : "";
percents();
function percents() {
let percent;
for (let i = 0; i < input__finance.length; i++) {
projectAmount_percent[i].value = (
(input__finance[i].value * 100) /
reduce
).toFixed(2);
percent = projectAmount_percent[0].value = (
(input__finance[0].value * 100) /
reduce
).toFixed(2);
if (percent === "NaN") {
percent = "";
}
if (projectAmount_percent[i].value === "NaN") {
projectAmount_percent[i].value = "";
}
}
co_percent.innerHTML = percent;
}
};
});
} catch(e) { }
}
// --таблица 3 --
financing_other()
function financing_other() {
try {
let button = document.getElementById("buttons");
let line = document.getElementById("linee");
button.onclick = function click(e) {
e.preventDefault();
function create__three() {
let empty = "";
let tr = document.createElement("tr");
tr.setAttribute("class", "createTr");
let button__close = '<button class="button_remove_line"> </button>';
for (let i = 0; i < 2; i++) {
let td = `<td contenteditable class='financing_input'>`;
let input = ``;
if (i == 0) {
input = `<input type ='text'name ='name' class="metaTable_input_financing_other"></input>`;
}
if (i == 1) {
input = `<input name ='amount' class="allS setInputRestrictions metaTable_input_financing_other totalFinancing_other total" data-total="financing_other"></input>`;
}
empty += td + input + `</td>`;
}
tr.innerHTML += empty + button__close;
line.before(tr);
return tr;
}
let tr = create__three();
tr.oninput = function sum() {
setInputRestrictions();
totalAmount();
};
removeLine();
};
} catch(e) { }
}
// --таблица 4 --
financing_report();
function financing_report() {
try {
let button = document.getElementById("third_button");
let line = document.getElementById("third_line");
button.onclick = function click() {
function create() {
let empty = "";
let tr = document.createElement("tr");
tr.setAttribute("class", "createTr");
let button__close = '<button class="button_remove_line"> </button>';
creation();
function creation() {
for (let i = 0; i < 9; i++) {
let td = `<td >`;
let input = `<input></input>`;
if (i == 0 || i == 1 || i == 2 || i == 6 || i == 8) {
input =
"<input type='text' name ='input' class='metaTable_input'></input>";
}
switch (i) {
case 0:
input = ``;
break;
case 3:
input = `<input class = 'allS setInputRestrictions metaTable_input total' data-total='third_column' name ='input'></>`;
break;
case 4:
input = `<input class = 'allS setInputRestrictions metaTable_input total' data-total='fourth_column' name ='input'></input>`;
break;
case 5:
input = `<input class = 'allS setInputRestrictions metaTable_input total' data-total='fifth_column' name ='input'></input>`;
break;
case 7:
input = `<input class = 'allS setInputRestrictions metaTable_input total' data-total='sixth_column' name ='input'></input>`;
break;
}
empty += td + input + `</td>`;
}
}
tr.innerHTML += empty + button__close;
line.before(tr);
return tr;
}
let tr = create();
tr.oninput = function sum() {
totalAmount();
};
removeLine();
};
} catch(e) { }
}
// --таблица 5 --
jobs_report()
function jobs_report() {
try {
let button = document.getElementById("fourth_button");
let line = document.getElementById("fourth_line");
let number = 1
button.addEventListener("click", function (e) {
e.preventDefault();
function create() {
let empty = "";
let tr = document.createElement("tr");
tr.setAttribute("class", "createTr");
let button__close = '<button class="button_remove_line"> </button>';
creation();
function creation() {
for (let i = 0; i < 8; i++) {
let td = `<td> `;
let input = `<input type ='text' name ='input' class="metaTable_input"> </input>`;
switch (i) {
case 0:
input = `${number}`;
break;
case 3:
input = `<input class = 'allS setInputRestrictions total metaTable_input' data-total='column_three'name ='input'></input>`;
break;
case 4:
input = `<input class = 'allS setInputRestrictions total metaTable_input' data-total='column_four' name ='input'></input>`;
break;
case 6:
input = `<input class = 'allS setInputRestrictions total metaTable_input' data-total='column_six' name ='input'></input>`;
break;
}
empty += td + input + `</td>`;
}
}
tr.innerHTML += empty + button__close;
line.before(tr);
return tr;
}
let tr = create();
tr.oninput = function sum() {
totalAmount()
};
removeLine();
number ++
});
} catch(e) { }
}
})(document, jQuery, Sensei);