-
Notifications
You must be signed in to change notification settings - Fork 1
/
index2.html
74 lines (69 loc) · 2.79 KB
/
index2.html
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
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Graph Klipper Stats</title>
<script language="JavaScript" type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jquery/3.6.3/jquery.min.js"></script>
<script language="JavaScript" type="text/javascript" src="./graphstats.js"></script>
<style>
#fileInput { margin-bottom: 10px; }
.button-container { display: flex; flex-direction: column; gap: 10px; }
#buttonProcess { width: auto; align-self: flex-start; }
</style>
</head>
<body>
<h1>Graph Klipper Stats</h1>
<div>
<p>This webpage uses the logic of Klipper's
<a href="https://github.com/Klipper3d/klipper/blob/master/scripts/graphstats.py" target="_blank">graphstats.py</a>
to analyze a <code>klippy.log</code> and display the results in graphs. This is a direct transformation of the Python
script and thus based on the original work of Kevin O'Connor.
</p>
<p>For the sources and license information see
<a href="https://github.com/Sineos/sineos.github.io" target="_blank">the GH repository</a>.
</p>
<p>Just browse for the <code>klippy.log</code> using the button below and press "Process Log".
</p>
<p>Note that processing large files can take some seconds and the browser may feel less responsive.
</p>
</div>
<div>
<input type="file" id="fileInput">
</div>
<div class="button-container">
<input name="buttonProcess" type="button" id="buttonProcess" value="Process Log">
</div>
<script>
document.getElementById('buttonProcess').addEventListener('click', () => {
const fileInput = document.getElementById('fileInput');
if (fileInput.files.length > 0) {
const file = fileInput.files[0];
const reader = new FileReader();
reader.onload = function(event) {
deleteDatabaseOrStore(DB_NAME, DB_STORE_NAME, (error) => {
if (error) {
console.error('Error during deletion:', error);
} else {
console.log('Deletion process completed successfully.');
}
});
const logData = event.target.result;
const parsedData = parseLog(logData);
openDb((db) => {
addParsedLogData(db, parsedData, () => {
window.location.href = 'graphs.html';
// window.open('graphs.html', '_blank');
});
});
};
reader.onerror = function(event) {
console.error('Error reading file:', event.target.error);
};
reader.readAsText(file);
} else {
alert('Please select a log file');
}
});
</script>
</body>
</html>