cleanup repo + add articles
This commit is contained in:
93
archive/etyd/etyd.js
Normal file
93
archive/etyd/etyd.js
Normal file
@@ -0,0 +1,93 @@
|
||||
window.onload = function() {
|
||||
if (navigator.userAgent.includes("Firefox")) {
|
||||
document.getElementById('resultfeed').value += `\nClipboard buttons only work on Firefox >127.`
|
||||
}
|
||||
|
||||
// Event listeners can only be added after the page is loaded
|
||||
document.getElementById("actiondropdown").addEventListener("change", function() {
|
||||
if (document.getElementById("actiondropdown").value === "POST") {
|
||||
document.getElementById("randomizationtoggle").disabled = false
|
||||
document.getElementById("valuefield").disabled = false
|
||||
} else if (document.getElementById("actiondropdown").value === "DELETE") {
|
||||
document.getElementById("randomizationtoggle").disabled = true
|
||||
document.getElementById("randomizationtoggle").checked = false
|
||||
randomUrlTick()
|
||||
document.getElementById("valuefield").disabled = true
|
||||
} else {
|
||||
console.error("UI Code Error: Action dropdown event listener function reached impossible state")
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
function makeRandomHex(amount) {
|
||||
const characters = "1234567890abcdef"
|
||||
let counter = 0
|
||||
let result = ""
|
||||
while (counter < amount) {
|
||||
result += characters.charAt(Math.floor(Math.random() * characters.length))
|
||||
counter += 1
|
||||
}
|
||||
return result
|
||||
}
|
||||
|
||||
|
||||
|
||||
function randomUrlTick() {
|
||||
if (document.getElementById("randomizationtoggle").checked == true) {
|
||||
document.getElementById("targetfield").disabled = true
|
||||
document.getElementById("targetfield").value = makeRandomHex(6)
|
||||
} else {
|
||||
document.getElementById("targetfield").disabled = false
|
||||
document.getElementById("targetfield").value = null
|
||||
}
|
||||
}
|
||||
|
||||
// function buttonCopyResult() {
|
||||
// navigator.clipboard.writeText(`${document.location.href}${document.getElementById("urlfield").value}`)
|
||||
// }
|
||||
|
||||
function buttonFillFromClipboard() {
|
||||
navigator.clipboard.readText().then(res => {
|
||||
document.getElementById("valuefield").value = res;
|
||||
})
|
||||
}
|
||||
|
||||
// Changes the buttons text to OK for 500ms for action feedback
|
||||
// "internal" in this context just means not called from the page
|
||||
function internalButtonConfirmation(element) {
|
||||
let normalValue = document.getElementById(element).innerHTML
|
||||
document.getElementById(element).innerHTML = "Ok"
|
||||
setTimeout(function() {
|
||||
document.getElementById(element).innerHTML = normalValue
|
||||
}, 500)
|
||||
}
|
||||
|
||||
function buttonCopyUrl() {
|
||||
navigator.clipboard.writeText(`this doesn't work rn lol`)
|
||||
internalButtonConfirmation("buttonCopyUrl")
|
||||
}
|
||||
|
||||
function buttonClearLog() {
|
||||
document.getElementById("resultfeed").value = ""
|
||||
internalButtonConfirmation("buttonClearLog")
|
||||
}
|
||||
|
||||
function submitData() {
|
||||
fetch(`http://nrdesktop:8081/etyd${document.getElementById("targetfield").value}`, {
|
||||
method: document.getElementById("actiondropdown").value,
|
||||
mode: "cors",
|
||||
headers: {
|
||||
"Authorization": document.getElementById("authfield").value
|
||||
},
|
||||
body: JSON.stringify({
|
||||
"target": document.getElementById("targetfield").value,
|
||||
"value": document.getElementById("valuefield").value,
|
||||
"action": document.getElementById("actiondropdown").value,
|
||||
"random": document.getElementById("randomizationtoggle").checked
|
||||
})
|
||||
}).then(response => {
|
||||
document.getElementById("resultfeed").value += `\n${response.status} ${response.body}`
|
||||
}).catch(error => {
|
||||
document.getElementById("resultfeed").value += `\nError: ${error}`
|
||||
})
|
||||
}
|
||||
45
archive/etyd/index.css
Normal file
45
archive/etyd/index.css
Normal file
@@ -0,0 +1,45 @@
|
||||
body {
|
||||
font-family: Arial, Helvetica, sans-serif;
|
||||
}
|
||||
|
||||
.flexbox {
|
||||
display: flex;
|
||||
flex-wrap: wrap;
|
||||
}
|
||||
|
||||
.marginright1em {
|
||||
margin-right: 1em;
|
||||
}
|
||||
|
||||
.marginbottom1em {
|
||||
margin-bottom: 1em;
|
||||
}
|
||||
|
||||
.resultfeed {
|
||||
height: 100%;
|
||||
}
|
||||
|
||||
@media (max-width: 700px) {
|
||||
.resultfeed {
|
||||
min-height: 20vh;
|
||||
}
|
||||
}
|
||||
|
||||
@media (prefers-color-scheme: dark) { /* Dark mode support */
|
||||
body {
|
||||
background-color: black;
|
||||
color: white;
|
||||
}
|
||||
|
||||
input, select, textarea, button {
|
||||
background: none;
|
||||
color: white;
|
||||
border: 1px solid white;
|
||||
padding: 1px 2px;
|
||||
}
|
||||
|
||||
input:disabled, button:disabled {
|
||||
opacity: 0.8;
|
||||
cursor: not-allowed;
|
||||
}
|
||||
}
|
||||
53
archive/etyd/index.html
Normal file
53
archive/etyd/index.html
Normal file
@@ -0,0 +1,53 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
<script src="_static/etyd.js"></script>
|
||||
<link rel="stylesheet" href="_static/index.css">
|
||||
<title>etyd.cc</title>
|
||||
</head>
|
||||
<body>
|
||||
<h1>etyd.cc URL Shortener</h1>
|
||||
|
||||
<div class="flexbox"> <!--FLEXBOX: [Input Panel] [Log]-->
|
||||
|
||||
<div class="marginright1em">
|
||||
|
||||
<button class="marginbottom1em" id="loginbutton">Logout enstrayed</button>
|
||||
|
||||
<div class="marginbottom1em">
|
||||
<label for="action">I want to </label>
|
||||
<select name="action" id="actiondropdown">
|
||||
<option value="POST">Add</option>
|
||||
<option value="DELETE">Delete</option>
|
||||
</select>
|
||||
</div>
|
||||
|
||||
<div class="marginbottom1em">
|
||||
<label for="url">etyd.cc/</label>
|
||||
<input type="text" id="targetfield"><input type="checkbox" id="randomizationtoggle" onclick="randomUrlTick()"> <label>Random</label>
|
||||
</div>
|
||||
|
||||
<div class="marginbottom1em">
|
||||
<label for="value">to go to: </label>
|
||||
<input type="text" id="valuefield" placeholder="https://example.com">
|
||||
<button onclick="buttonFillFromClipboard()" id="clipboard1">Clipboard</button>
|
||||
</div>
|
||||
|
||||
<div class="marginbottom1em">
|
||||
<button onclick="buttonSubmit()" id="buttonSubmit">Submit</button>
|
||||
<button onclick="buttonCopyUrl()" id="buttonCopyUrl">Copy Shortened URL</button>
|
||||
<button onclick="buttonClearLog()" id="buttonClearLog">Clear Log</button>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div>
|
||||
<textarea id="resultfeed" cols="50" class="resultfeed" readonly></textarea>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
|
||||
|
||||
</body>
|
||||
</html>
|
||||
21
archive/old.js
Normal file
21
archive/old.js
Normal file
@@ -0,0 +1,21 @@
|
||||
// This file contains old code not used anymore
|
||||
|
||||
app.post("/api/sync", (rreq,rres) => {
|
||||
checkToken(rreq.query.auth,"fpupdate").then(checkResponse => {
|
||||
if (checkResponse === true) {
|
||||
if (rreq.headers["x-github-event"] == "ping") {
|
||||
rres.sendStatus(200)
|
||||
} else if (rreq.headers["x-github-event"] == "push") {
|
||||
execSync("git pull")
|
||||
logRequest(rres,rreq,200,"Ran git pull, exiting to restart...")
|
||||
rres.sendStatus(200)
|
||||
process.exit(0)
|
||||
} else {
|
||||
logRequest(rres,rreq,400)
|
||||
rres.sendStatus(400)
|
||||
}
|
||||
} else {
|
||||
rres.sendStatus(401)
|
||||
}
|
||||
})
|
||||
})
|
||||
Reference in New Issue
Block a user