Skip to content

Commit eb787fc

Browse files
committed
backend express init
1 parent f67329d commit eb787fc

File tree

4 files changed

+127
-8
lines changed

4 files changed

+127
-8
lines changed

index.js

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,18 @@
1-
const { express } = require('express');
1+
const express = require('express');
22
const app = express();
33

4-
express.static('public');
4+
const PORT = 4000;
55

6+
app.use(express.static('public'));
7+
8+
// Use Cache-Control: no-store
9+
10+
app.get('/search', (req, res) => {
11+
const query = req.query;
12+
query.signatures = decodeURIComponent(query.signatures);
13+
query.signatures = JSON.parse(query.signatures);
14+
res.set('Cache-Control', 'no-store');
15+
res.send('Received');
16+
});
17+
18+
app.listen(PORT, () => console.log('Listening on port ' + PORT));

public/httpParser.js

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,4 +40,42 @@ function convertNonPrintableToHex(inputString) {
4040
}
4141

4242
return result;
43+
}
44+
45+
46+
// RESULTS
47+
48+
document.getElementById('search-btn').addEventListener("click", async (event) => {
49+
event.preventDefault();
50+
hideResults();
51+
52+
const query = new URLSearchParams({
53+
path: document.getElementById('pathInput').value,
54+
timeframe: document.querySelector('#timeframes-container input[name="timeframe"]:checked').value,
55+
signatures: encodeURIComponent(JSON.stringify(document.getElementById('sigs').value.split('\n')))
56+
}).toString();
57+
58+
await fetch(`/search?${query}`);
59+
});
60+
61+
function hideResults() {
62+
const resultsContainer = document.getElementById('results-container');
63+
resultsContainer.style.display = 'none';
64+
65+
let percent = 0;
66+
const loadingText = document.getElementById('loading-text');
67+
loadingText.style.display = 'flow';
68+
const loadingPercent = document.getElementById('loading-percent');
69+
70+
let interval = setInterval(async () => {
71+
if (percent >= 100) {
72+
await new Promise(r => setTimeout(r, 600));
73+
loadingText.style.display = 'none';
74+
resultsContainer.style.display = 'grid';
75+
clearInterval(interval);
76+
return;
77+
}
78+
percent += 1;
79+
loadingPercent.innerText = percent;
80+
}, 4);
4381
}

public/index.html

Lines changed: 49 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -10,19 +10,19 @@
1010
</head>
1111
<body>
1212
<div id="container">
13-
<h1>HTTP Cache Parser</h1>
13+
<h1>HTTP Cache File Signature Parser</h1>
1414
<h2>Configure</h2>
1515
<form action="/submit" >
1616
<label for="directoryPath">Enter directory path:</label><br>
17-
<input class="mb" type="text" name="directoryPath" placeholder="e.g. %LocalAppData%\Mozilla\Firefox\Profiles\toy7mtpb.default-release\cache2" required><br>
17+
<input class="mb" id="pathInput" type="text" name="directoryPath" placeholder="e.g. %LocalAppData%\Mozilla\Firefox\Profiles\toy7mtpb.default-release\cache2" required><br>
1818

1919
<label for="">Timeframe:</label><br>
2020
<div class="mb" id="timeframes-container">
21-
<input type="radio" id="timeframe-1hr" name="timeframe" value="timeframe-1hr" checked>
21+
<input type="radio" id="timeframe-1hr" name="timeframe" value="1hr" checked>
2222
<label for="timeframe-1hr">Last 1hr</label>
23-
<input type="radio" id="timeframe-3hr" name="timeframe" value="timeframe-3hr">
23+
<input type="radio" id="timeframe-3hr" name="timeframe" value="3hr">
2424
<label for="timeframe-3hr">Last 3hrs</label>
25-
<input type="radio" id="timeframe-today" name="timeframe" value="timeframe-today">
25+
<input type="radio" id="timeframe-today" name="timeframe" value="today">
2626
<label for="timeframe-today">Today</label>
2727
</div>
2828

@@ -38,12 +38,55 @@ <h2>Configure</h2>
3838
<textarea id="sigs" type="text" rows="4" required></textarea><br>
3939
<small class="mb">Delimited by newline</small><br>
4040

41-
<button type="submit">Search</button>
41+
<button id="search-btn" type="submit">Search</button>
4242
</form>
4343

4444
<hr></hr>
4545

4646
<h2>Results</h2>
47+
<i id="loading-text">Loading... <span id="loading-percent">0</span>%</i>
48+
<div id="results-container">
49+
<div class="item">
50+
<div class="item-preview">
51+
<img src="C:\Users\prest\OneDrive\Documents\LL\items.png" alt="no preview">
52+
</div>
53+
<div class="item-description">
54+
2.45MB - 2021-09-01 12:00:00 path
55+
</div>
56+
</div>
57+
<div class="item">
58+
<div class="item-preview">
59+
<img src="https://via.placeholder.com/150" alt="no preview">
60+
</div>
61+
<div class="item-description">
62+
2.45MB - 2021-09-01 12:00:00 path
63+
</div>
64+
</div>
65+
<div class="item">
66+
<div class="item-preview">
67+
<img src="https://via.placeholder.com/150" alt="no preview">
68+
</div>
69+
<div class="item-description">
70+
2.45MB - 2021-09-01 12:00:00 path
71+
</div>
72+
</div>
73+
<div class="item">
74+
<div class="item-preview">
75+
<img src="https://via.placeholder.com/150" alt="no preview">
76+
</div>
77+
<div class="item-description">
78+
2.45MB - 2021-09-01 12:00:00 path
79+
</div>
80+
</div>
81+
<div class="item">
82+
<div class="item-preview">
83+
<img src="https://via.placeholder.com/150" alt="no preview">
84+
</div>
85+
<div class="item-description">
86+
2.45MB - 2021-09-01 12:00:00 path
87+
</div>
88+
</div>
89+
</div>
4790
</div>
4891
</body>
4992
</html>

public/style.css

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -96,6 +96,31 @@ label[for="preset"] {
9696
margin-left: 5px;
9797
}
9898

99+
/* RESULTS CONTAINER */
100+
#loading-text {
101+
display: none;
102+
}
103+
104+
#results-container {
105+
display: none;
106+
/* display: grid; */
107+
grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
108+
gap: 1em;
109+
grid-template-rows: auto;
110+
}
111+
112+
.item-preview {
113+
min-width: 180px;
114+
height: 200px;
115+
border: 1px solid var(--border-color);
116+
border-radius: 4px;
117+
background-color: var(--bg-primary-color);
118+
display: flex;
119+
justify-content: center;
120+
align-items: center;
121+
}
122+
123+
99124

100125
.mukta-vaani-extralight {
101126
font-family: "Mukta Vaani", sans-serif;

0 commit comments

Comments
 (0)