-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathreplacer-engineAllocationConfiguration.html
More file actions
112 lines (93 loc) · 4.14 KB
/
Copy pathreplacer-engineAllocationConfiguration.html
File metadata and controls
112 lines (93 loc) · 4.14 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
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.0/dist/css/bootstrap.min.css">
<script src="https://cdn.jsdelivr.net/npm/bootstrap@5.3.0/dist/js/bootstrap.bundle.min.js"></script>
<title>Replacer Engine</title>
</head>
<body>
<div class="container mt-5">
<h2>Replacer Engine<sup>1.0.0</sup></h2>
<pre>
Permite pegar um arquivo .xml e remove os mecanismos de atribuição para facilitar a exportação para o servidor
</pre>
<div class="mb-3">
<label for="fileInput" class="form-label">
Arquivo xml do processo:
<span class="badge badge-contracted"><span class="rounded-circle bg-danger"></span></span>
<span class="badge badge-expanded rounded-pill bg-danger">obrigatório</span>
</label>
<input type="file" class="form-control" id="fileInput">
</div>
<button type="button" class="btn btn-primary" onclick="processFile()">Processar</button>
</div>
<script>
function processFile() {
// Obtém o elemento de input de arquivo
var fileInput = document.getElementById('fileInput');
// Verifica se um arquivo foi selecionado
if (fileInput.files.length > 0) {
var file = fileInput.files[0];
var reader = new FileReader();
// Função callback para quando a leitura do arquivo estiver concluída
reader.onload = function (e) {
// Obtém o conteúdo do arquivo
var content = e.target.result;
// Faça as substituições necessárias. Neste exemplo, substituímos 'linha1' por 'novaLinha1'
content = content.replace(/<engineAllocationConfiguration>.*?<\/engineAllocationConfiguration>/gs, '<engineAllocationConfiguration></engineAllocationConfiguration>');
content = content.replace(/<engineAllocationId>.*?<\/engineAllocationId>/gs, '<engineAllocationId></engineAllocationId>');
// Cria um Blob com o conteúdo modificado
var modifiedBlob = new Blob([content], { type: 'text/plain' });
// Cria um link de download
var downloadLink = document.createElement('a');
downloadLink.href = URL.createObjectURL(modifiedBlob);
downloadLink.download = 'arquivo_modificado.txt';
// Adiciona o link ao corpo da página e simula o clique para iniciar o download
document.body.appendChild(downloadLink);
downloadLink.click();
// Remove o link depois que o download for iniciado
document.body.removeChild(downloadLink);
};
// Lê o conteúdo do arquivo como texto
reader.readAsText(file);
} else {
alert('Por favor, selecione um arquivo.');
}
}
</script>
<style>
sup {
font-size: 0.3em;
top: -1.5em;
left: 1em;
}
.badge-container {
position: relative;
display: inline-block;
cursor: pointer;
}
.badge-expanded {
visibility: hidden;
opacity: 0;
transition: opacity 1.5s ease;
}
.rounded-circle {
display: inline-block;
width: 10px;
height: 10px;
}
.form-label:hover .badge-expanded {
visibility: visible;
opacity: 1;
}
.form-label:hover .badge-contracted {
display: none;
}
</style>
<!-- Google tag (gtag.js) -->
<script async src="https://www.googletagmanager.com/gtag/js?id=G-KRF0YWKD8Z"></script><script> window.dataLayer = window.dataLayer || []; function gtag(){dataLayer.push(arguments);} gtag('js', new Date()); gtag('config', 'G-KRF0YWKD8Z');
</script>
</body>
</html>