-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathhelp.html
More file actions
115 lines (101 loc) · 3.83 KB
/
help.html
File metadata and controls
115 lines (101 loc) · 3.83 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
113
114
115
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>SimRISC-V Help</title>
<button type="button" onclick="window.location.href='/'" >Back</button>
<style>
body {
background-color: black;
color: whitesmoke;
}
table {
border-collapse: collapse;
width: 80%;
}
th, td {
border: 1px solid whitesmoke;
padding: 2px;
text-align: left;
font-size: 12px;
}
th {
color: white;
font-size: 14px;
}
</style>
</head>
<body>
<h2>Available Instructions</h2>
<div id="table-container"></div>
<script>
document.addEventListener('DOMContentLoaded', function() {
const tableContainer = document.getElementById('table-container');
// Ruta al archivo CSV
const csvPath = 'help.csv';
// Función para cargar y procesar el CSV
function loadCSV() {
fetch(csvPath)
.then(response => response.text())
.then(data => {
const rows = parseCSV(data);
const headers = rows[0];
let html = '<table><thead><tr>';
headers.forEach(header => {
html += `<th>${header}</th>`;
});
html += '</tr></thead><tbody>';
for (let i = 1; i < rows.length; i++) {
const row = rows[i];
html += '<tr>';
row.forEach(cell => {
html += `<td>${cell}</td>`;
});
html += '</tr>';
}
html += '</tbody></table>';
tableContainer.innerHTML = html;
})
.catch(error => {
console.error('Error al cargar el archivo CSV:', error);
});
}
// Función para parsear el CSV teniendo en cuenta las comillas
function parseCSV(csv) {
// Divide el CSV en líneas
const lines = csv.trim().split('\n');
const result = [];
// Procesa cada línea
lines.forEach(line => {
let insideQuotes = false;
let field = '';
const fields = [];
// Itera sobre cada caracter de la línea
for (let i = 0; i < line.length; i++) {
const char = line[i];
if (char === '"') {
// Cambia el estado de "dentro de comillas"
insideQuotes = !insideQuotes;
} else if (char === ',' && !insideQuotes) {
// Si no está dentro de comillas y encuentra una coma, guarda el campo
fields.push(field.trim());
field = '';
} else {
// Agrega el caracter al campo actual
field += char;
}
}
// Añade el último campo
fields.push(field.trim());
// Agrega la fila procesada al resultado final
result.push(fields);
});
return result;
}
// Llamar a la función para cargar el CSV cuando se carga el contenido de la página
loadCSV();
});
</script>
</body>
</html>