-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathoutput.html
More file actions
77 lines (69 loc) · 3.08 KB
/
output.html
File metadata and controls
77 lines (69 loc) · 3.08 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
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>IEEE-754 Decimal-32 Floating-Point Converter - Output</title>
<link rel="stylesheet" href="layout/styles.css">
</head>
<body>
<header>
<h1>IEEE-754 Decimal-32 floating-point <span>converter</span></h1>
</header>
<div class="container-output">
<div class="container-title-output">
Conversion Results:
</div>
<div class="output-boxes">
<div class="output-box">
<h2>Decimal</h2>
<p id="decimal-output">[Decimal output will be displayed here]</p>
</div>
<div class="output-box">
<h2>Binary (32-bit)</h2>
<p id="binary-output">[Binary output will be displayed here]</p>
</div>
<div class="output-box">
<h2>Hexadecimal (32-bit)</h2>
<p id="hex-output">[Hexadecimal output will be displayed here]</p>
</div>
</div>
<div class="button-container">
<button class="action-button"><a href="decimal.html">Go back</a></button>
<button class="action-button" onclick="exportToText()">Export as .txt</button>
</div>
</div>
<footer>
<p>By GROUP 14: Calugtong, Salic, Valladolid</p>
</footer>
<script>
function exportToText() {
const decimal = document.getElementById('decimal-output').innerText;
const binary = document.getElementById('binary-output').innerText;
const hex = document.getElementById('hex-output').innerText;
// Build the text content for the file
const text = `Decimal: ${decimal}\nBinary: ${binary}\nHexadecimal: ${hex}`;
// Create a Blob object with the text content
const blob = new Blob([text], { type: 'text/plain' });
const url = URL.createObjectURL(blob);
// Create an anchor element to download the file
const a = document.createElement('a');
a.href = url;
a.download = 'conversion-results.txt';
// Append the anchor to the body and trigger a click to start the download
document.body.appendChild(a);
a.click();
// Remove the anchor element from the document
document.body.removeChild(a);
// Revoke the object URL to free up resources
URL.revokeObjectURL(url);
}
document.addEventListener('DOMContentLoaded', () => {
// Retrieve data from localStorage and display it
document.getElementById('decimal-output').innerText = localStorage.getItem('decimal') || 'No data';
document.getElementById('binary-output').innerText = localStorage.getItem('binary') || 'No data';
document.getElementById('hex-output').innerText = localStorage.getItem('hexadecimal') || 'No data';
});
</script>
</body>
</html>