-
Notifications
You must be signed in to change notification settings - Fork 2
/
source.js
58 lines (54 loc) · 1.82 KB
/
source.js
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
var separator = ';';
var total = parseInt($('#grid-paging .cmpInline').text().trim().replace('\/ ', ''));
var lines = [
[
"Provedení",
"Účet",
"Popis",
"Typ",
"Částka",
"Poplatek"
].join(separator)
];
function rows_to_lines() {
$('.mhtTable.mhtTableLinks tr').each(function(k, row) {
var tds = $(row).find('td');
lines.push([
$(tds[1]).text().trim(),
$.map($(tds[2]).find('strong'), function(val) {return $(val).text().trim();}).join(" - "),
$(tds[2]).find('.uiEllipsis').text().trim(),
$(tds[3]).text().trim(),
$(tds[4]).text().trim().replace("CZK", "").replace(",", "."),
$(tds[5]).text().trim().replace("CZK", "").replace(",", ".")
].join(separator));
});
}
function check_next(to_check, finished) {
if (!$('body.mhtLoaderBodySync').length) {
var curr = parseInt($('#grid-paging input[type=text]').val());
rows_to_lines();
if (curr != total) {
var next = $('.cmpLinkNext a');
if(next) {
next.click();
}
check_next(curr + 1, finished);
} else {
finished();
}
return;
}
setTimeout(function() {
check_next(to_check, finished);
}, 1000);
}
$('#grid-paging input[type=text]').val(1).blur();
setTimeout(function() {
check_next(1, function() {
$('<div class="cmpDialogInner"><div class="cmpDialogCont"><div class="cmpDialogPad clearfix"><p><a href="" download="export.csv" class="csv"><span class="m2-icon-file"><span class="ui-button-icon"></span></span>Stáhnout soubor</a></p><div class="mhtDialogCloseCallback"></div></div>').dialog(
{
'title': 'Export','modal': true,
});
$('.csv').off('click').attr('href', 'data:application/csv;charset=utf-8,' + encodeURIComponent(lines.join("\n")));
});
}, 1000);