Skip to content

Commit d8252bb

Browse files
committed
Create index.html
1 parent e799564 commit d8252bb

File tree

1 file changed

+208
-0
lines changed

1 file changed

+208
-0
lines changed

indenter/index.html

Lines changed: 208 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,208 @@
1+
<!DOCTYPE html>
2+
<html lang="en">
3+
<head>
4+
<meta charset="UTF-8" />
5+
<title>FSTAB Indenter with Width Control</title>
6+
<style>
7+
body {
8+
font-family: monospace;
9+
background: #f4f4f4;
10+
padding: 20px;
11+
}
12+
textarea {
13+
width: 100%;
14+
padding: 10px;
15+
margin: 10px 0;
16+
font-family: monospace;
17+
font-size: 14px;
18+
}
19+
textarea[readonly] {
20+
background: #222;
21+
color: #0f0;
22+
height: 200px;
23+
white-space: pre;
24+
overflow-x: auto;
25+
cursor: pointer;
26+
}
27+
textarea#fstabInput {
28+
background: #fff;
29+
color: #000;
30+
height: 200px;
31+
}
32+
button {
33+
padding: 10px 20px;
34+
font-weight: bold;
35+
cursor: pointer;
36+
margin-bottom: 10px;
37+
}
38+
label {
39+
margin-right: 15px;
40+
display: inline-block;
41+
min-width: 120px;
42+
}
43+
.field-control {
44+
margin-bottom: 10px;
45+
}
46+
.field-control input[type=number] {
47+
width: 50px;
48+
}
49+
50+
/* Footer styling */
51+
.site-footer {
52+
margin-top: 60px;
53+
padding: 20px;
54+
text-align: center;
55+
background-color: #f0f4fa;
56+
border-top: 1px solid #ddd;
57+
font-size: 0.9rem;
58+
color: #555;
59+
border-radius: 0 0 12px 12px;
60+
}
61+
62+
.site-footer a {
63+
color: #1e73ff;
64+
text-decoration: none;
65+
font-weight: 500;
66+
}
67+
68+
.site-footer a:hover {
69+
text-decoration: underline;
70+
}
71+
</style>
72+
</head>
73+
<body>
74+
75+
<h2>FSTAB Indenter with Toggle & Width Control</h2>
76+
77+
<div class="field-control">
78+
<label><input type="checkbox" checked id="col0"> device</label>
79+
Width: <input type="number" id="width0" value="40" min="1">
80+
</div>
81+
<div class="field-control">
82+
<label><input type="checkbox" checked id="col1"> mountPoint</label>
83+
Width: <input type="number" id="width1" value="40" min="1">
84+
</div>
85+
<div class="field-control">
86+
<label><input type="checkbox" checked id="col2"> fsType</label>
87+
Width: <input type="number" id="width2" value="10" min="1">
88+
</div>
89+
<div class="field-control">
90+
<label><input type="checkbox" checked id="col3"> options</label>
91+
Width: <input type="number" id="width3" value="30" min="1">
92+
</div>
93+
<div class="field-control">
94+
<label><input type="checkbox" checked id="col4"> dump</label>
95+
Width: <input type="number" id="width4" value="3" min="1">
96+
</div>
97+
<div class="field-control">
98+
<label><input type="checkbox" checked id="col5"> pass</label>
99+
Width: <input type="number" id="width5" value="3" min="1">
100+
</div>
101+
102+
<textarea id="fstabInput" placeholder="Paste your /etc/fstab content here..."></textarea>
103+
<br>
104+
<button onclick="indentFstab()">Format</button>
105+
106+
<textarea id="fstabOutput" readonly onclick="this.select()" placeholder="Formatted output will appear here..."></textarea>
107+
108+
<footer class="site-footer">
109+
<p>
110+
fstab Creator | &copy; <span id="year"></span> |
111+
<a href="https://github.com/safesploitOrg/fstab-creator" target="_blank" rel="noopener noreferrer">GitHub Repository</a>
112+
</p>
113+
</footer>
114+
115+
<script>
116+
function getUserSettings() {
117+
const indentColumns = [];
118+
const columnWidths = [];
119+
120+
// Header labels (for comparison)
121+
const headers = [
122+
'<file system>',
123+
'<mount point>',
124+
'<type>',
125+
'<options>',
126+
'<dump>',
127+
'<pass>'
128+
];
129+
130+
for (let i = 0; i < 6; i++) {
131+
indentColumns[i] = document.getElementById(`col${i}`).checked;
132+
const userWidth = parseInt(document.getElementById(`width${i}`).value, 10);
133+
columnWidths[i] = Math.max(userWidth, headers[i].length);
134+
}
135+
136+
return { indentColumns, columnWidths };
137+
}
138+
139+
140+
function formatLine(fields, indentColumns, columnWidths) {
141+
return fields.map((field, i) => {
142+
const width = columnWidths[i] || field.length;
143+
return indentColumns[i] ? field.padEnd(width + 2) : field + ' ';
144+
}).join('').trimEnd();
145+
}
146+
147+
function parseFstabLines(rawText) {
148+
const lines = rawText.split('\n');
149+
const parsed = [];
150+
151+
for (const line of lines) {
152+
if (/^\s*#/.test(line) || /^\s*$/.test(line)) {
153+
parsed.push({ isComment: true, text: line });
154+
} else {
155+
const fields = line.trim().split(/\s+/);
156+
parsed.push({ isComment: false, fields });
157+
}
158+
}
159+
160+
return parsed;
161+
}
162+
163+
function generateHeader(indentColumns, columnWidths) {
164+
const headers = [
165+
'<file system>',
166+
'<mount point>',
167+
'<type>',
168+
'<options>',
169+
'<dump>',
170+
'<pass>'
171+
];
172+
173+
const formatted = headers.map((field, i) => {
174+
const width = columnWidths[i] || field.length;
175+
return indentColumns[i] ? field.padEnd(width + 2) : field + ' ';
176+
}).join('').trimEnd();
177+
178+
return '# ' + formatted;
179+
}
180+
181+
function indentFstab() {
182+
const { indentColumns, columnWidths } = getUserSettings();
183+
const rawInput = document.getElementById('fstabInput').value;
184+
const parsedLines = parseFstabLines(rawInput);
185+
186+
let result = generateHeader(indentColumns, columnWidths) + '\n';
187+
188+
for (const line of parsedLines) {
189+
if (line.isComment) {
190+
result += line.text + '\n';
191+
} else {
192+
result += formatLine(line.fields, indentColumns, columnWidths) + '\n';
193+
}
194+
}
195+
196+
document.getElementById('fstabOutput').value = result.trim();
197+
}
198+
199+
// Set the current year in the footer
200+
function setFooterYear() {
201+
const year = new Date().getFullYear();
202+
document.getElementById('year').textContent = year;
203+
}
204+
setFooterYear();
205+
</script>
206+
207+
</body>
208+
</html>

0 commit comments

Comments
 (0)