Val Town is a social website to write and deploy JavaScript.
Build APIs and schedule functions from your browser.
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
export const njuskaloCreateHtmlResponse = (
res: express.Response,
formHtml: string,
dataHtml: string,
) =>
res.send(`
<!DOCTYPE html>
<html>
<head>
<title>Njuškalo sniffer</title>
</head>
<body>
<h1>Njuškalo sniffer</h1>
<h3>Set up search strings you would like to be notified about:</h3>
${formHtml}
<p>INFO: Njuškalo is a Croatian very popular e-bay-like online auction website.</p>
${dataHtml}
<script>
const removeMe = (id) => {
const oldElements = Array.from(document.getElementsByClassName("inputs"));
if(oldElements.length<=1) return;
document.getElementById(id).outerHTML = "";
}
const addNew = () => {
const oldElements = Array.from(document.getElementsByClassName("inputs"));
const newId = "b" +
(Number(oldElements[oldElements.length -1].
id.
replace("b", "")) + 1);
document.getElementById("inputs-container").innerHTML += \`
<span id="\$\{newId\}">
<br>
<input type="text" value="" name="keywords[]">
<input type="button" value="-" onclick="removeMe('\$\{newId\}')">
</span>
\`;
}
</script>
</body>
</html>
`);
October 23, 2023