-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.js
43 lines (38 loc) · 1.48 KB
/
main.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
$(document).ready(function () {
viewInit();
});
function viewInit() {
include('/ui/menu.html', 'menu-top-ui');
include('/view/configuracoes.html', 'configuracoesview');
include('/view/simulador.html', 'simuladorview');
}
//gera numeros aleatorios
function getRandomInt() {
return Math.floor(Math.random() * (999999)) + 100;
}
function include(file, elementIdToSetContent) {
fetch(file+'?'+getRandomInt())
.then((result) => {
return result.text();
})
.then((content) => {
document.getElementById(elementIdToSetContent).innerHTML = content;
});
}
function screenshot(elm) {
$(elm).html('<i class="fas fa-sync fa-spin"></i> Capturando...');
html2canvas(document.getElementById("mainprintscreen")).then(canvas => {
var img = canvas.toDataURL("image/png");
var dlLink = document.createElement('a');
dlLink.download = "screenshot.png";
dlLink.href = img;
dlLink.dataset.downloadurl = ["image/png", dlLink.download, dlLink.href].join(':');
document.body.appendChild(dlLink);
dlLink.click();
document.body.removeChild(dlLink);
$(elm).addClass('btn-success').removeClass('btn-primary').removeClass('pulse-button').html('<i class="fas fa-check"></i> Sucesso!');
setTimeout(function (){
$(elm).removeClass('btn-success').addClass('btn-primary').addClass('pulse-button').html('<i class="fas fa-camera"></i> Capturar');
}, 2000);
});
}