-
Notifications
You must be signed in to change notification settings - Fork 3
/
siscad_tweak_utils.js
83 lines (82 loc) · 3.55 KB
/
siscad_tweak_utils.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
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
function downloadFile(filename, url) {
var a = document.createElement('a');
a.href = url;
a.download = filename;
document.body.appendChild(a);
a.click();
setTimeout(function () {
document.body.removeChild(a);
window.URL.revokeObjectURL(url);
}, 100);
}
function makeCSVFile(txt) {
var data = new Blob([txt], {
type: 'text/csv'
});
// returns a URL you can use as a href
return window.URL.createObjectURL(data);
}
function getValue(x) {
var posabre = x.indexOf('(');
var pospercent = x.indexOf('%');
var percent = x.substring(posabre + 1, pospercent);
return parseFloat(percent.replace(',', '.'));
}
function percent(value, total) {
return Math.round(value * 100 / total);
}
function getData(line, pos) {
return line.find('td').eq(pos).text().trim();
}
function isFailed(value) {
return value > 25;
}
function isWarning(value) {
return value > 19;
}
function appendLogo(){
$('.logoApplication').append('<div id=\'twk\' style=\'top:50;left:230;position:absolute;background-color:red;font-size:large;color:black\'><b>TWEAKED!</b></div>');
}
function highlightLinks(line) {
var fhighon = function () {
$(this).contents('td').css({
'border': '1px solid black',
'border-left': 'none',
'border-right': 'none',
'font-weight': 'Bold'
});
var a = line.find('a');
//make line bold on hover
a.each(function (index) {
$(this).css('font-weight', 'Bold');
});
};
var fhighoff = function () {
$(this).contents('td').css({
'border': 'none',
'border-left': 'none',
'border-right': 'none',
'font-weight': ''
});
var a = line.find('a');
//make line bold on hover
a.each(function (index) {
$(this).css('font-weight', '');
});
};
line.hover(fhighon, fhighoff);
}
function appendSummaryTable(warning, failed, total){
var active = total - failed - warning;
var activep = percent(active, total);
var warningp = percent(warning, total);
var failedp = percent(failed, total);
$('.caixaAzul').last().after('<table style="border-collapse:collapse;border-spacing:0;margin-left:auto;margin-right: auto;"><tr><td style="font-weight:bold;border-style:solid;border-width:1px;padding:5px;text-align:center;">Situação<br></td><td style="font-weight:bold;border-style:solid;border-width:1px;padding:5px;text-align:center;">Quantidade (%)<br></td></tr><tr><td style="border-style:solid;border-width:1px;padding:5px;background-color:#ff7d66;color:#ffffff;">Reprovados por falta</td><td style="border-style:solid;border-width:1px;padding:5px;background-color:#ff7d66;color:#ffffff;text-align:center;">' + failed + ' (' + failedp + '%)' + '</td></tr><tr><td style="border-style:solid;border-width:1px;padding:5px;background-color:khaki;">Atenção</td><td style="border-style:solid;border-width:1px;padding:5px;background-color:khaki;text-align:center;">' + warning + ' (' + warningp + '%)' + '</td></tr><tr><td style="border-style:solid;border-width:1px;padding:5px;background-color:#9aff99;">Ativos<br></td><td style="border-style:solid;border-width:1px;padding:5px;background-color:#9aff99;text-align:center;">' + active + ' (' + activep + '%) / ativos + atenção = '+ (active+warning) + '</td></tr><tr><td style="border-style:solid;border-width:1px;padding:5px;font-weight:bold;">Total</td><td style="border-style:solid;border-width:1px;padding:5px;text-align:center;font-weight:bold;">' + total + '</td></tr></table>');
}
function copyToClipboard(text) {
var $temp = $("<input>");
$("body").append($temp);
$temp.val(text).select();
document.execCommand("copy");
$temp.remove();
}