mirror of
https://gitlab.com/MrFry/mrfrys-node-server
synced 2025-04-01 20:24:18 +02:00
194 lines
5.5 KiB
Text
194 lines
5.5 KiB
Text
<html>
|
|
<body bgcolor="#222426">
|
|
<head>
|
|
<title>Frylabs</title>
|
|
<meta charset="UTF-8">
|
|
<meta name="viewport" content="width=device-width, initial-scale=0.6" />
|
|
<style>
|
|
|
|
.center {
|
|
width: 340px;
|
|
height: 340px;
|
|
position: absolute;
|
|
left: 0;
|
|
right: 0;
|
|
top: 0;
|
|
bottom: 0;
|
|
margin: auto;
|
|
max-width: 100%;
|
|
max-height: 100%;
|
|
overflow: auto;
|
|
|
|
text-align: center;
|
|
}
|
|
.text {
|
|
font-size: 18px;
|
|
color: white;
|
|
margin: 20px;
|
|
}
|
|
.title {
|
|
font-size: 50px;
|
|
font-weight: bold;
|
|
color: white;
|
|
}
|
|
.inputContainer {
|
|
width: 100%;
|
|
}
|
|
.showpwContainer {
|
|
color: white;
|
|
width: 40px;
|
|
cursor: pointer;
|
|
}
|
|
input[type=text], input[type=password], textarea {
|
|
font-size: 20px;
|
|
color: #ffffff;
|
|
background-color: #181a1b;
|
|
width: 100%;
|
|
padding: 12px 20px;
|
|
margin: 8px 0;
|
|
box-sizing: border-box;
|
|
border: 2px solid #333333;
|
|
text-align: center;
|
|
}
|
|
input[type=text], input[type=password]:focus {
|
|
border: 2px solid #000;
|
|
}
|
|
button {
|
|
background-color: #9999ff;
|
|
border: none;
|
|
color: white;
|
|
padding: 16px 32px;
|
|
text-decoration: none;
|
|
margin: 4px 2px;
|
|
cursor: pointer;
|
|
}
|
|
.ircLinkContainer {
|
|
display: flex;
|
|
justify-content: flex-end
|
|
}
|
|
.ircLink {
|
|
color: #9999ff;
|
|
font-size: 12px;
|
|
text-decoration: underline;
|
|
cursor: pointer;
|
|
}
|
|
#feedback {
|
|
display: none;
|
|
}
|
|
#feedbackTextArea {
|
|
text-align: left;
|
|
font-size: 16px;
|
|
height: 160px;
|
|
resize: none;
|
|
}
|
|
</style>
|
|
</head>
|
|
<div class='center'>
|
|
<div class='title'>
|
|
Frylabs
|
|
</div>
|
|
<div id='text' class='text'>
|
|
</div>
|
|
<div id='feedback'>
|
|
<textarea placeholder='Feedback' id='feedbackTextArea'></textarea>
|
|
<div class='ircLinkContainer' >
|
|
<a class='ircLink' href='https://qmining.frylabs.net/irc?loginClick'>IRC</a>
|
|
</div>
|
|
<button id='sendFeedbackButton' onclick="SendFeedback(this)">Submit</button>
|
|
</div>
|
|
<div id='form'>
|
|
<div class='inputContainer'>
|
|
<input type='password' id='pw' name='pw' autocomplete="off"/>
|
|
</div>
|
|
<div class='ircLinkContainer' >
|
|
<a class='ircLink' onclick='ShowFeedback()'>Contact</a>
|
|
</div>
|
|
<button id='sendButton' onclick="Login(this)">Submit</button>
|
|
</div>
|
|
</div>
|
|
</body>
|
|
<script>
|
|
function HandleFeedbackResp (resp) {
|
|
document.getElementById('sendButton').innerText = 'Submit'
|
|
const textNode = document.getElementById('text')
|
|
const feedback = document.getElementById('feedback').style.display = "none";
|
|
if (resp.success) {
|
|
textNode.innerText = 'Visszajelzés elküldve'
|
|
} else {
|
|
textNode.innerText = 'Szerver oldali hiba :c'
|
|
}
|
|
}
|
|
async function SendFeedback (button) {
|
|
const feedback = document.getElementById('feedbackTextArea').value
|
|
button.innerText = '...'
|
|
const rawResponse = await fetch('http://api.frylabs.net/postfeedback', {
|
|
method: 'POST',
|
|
credentials: 'include',
|
|
headers: {
|
|
'Accept': 'application/json',
|
|
'Content-Type': 'application/json'
|
|
},
|
|
body: JSON.stringify({
|
|
description: feedback,
|
|
fromLogin: true
|
|
})
|
|
})
|
|
if (!rawResponse.ok) {
|
|
document.getElementById('text').innerText = 'Internal server error'
|
|
button.innerText = 'Submit'
|
|
}
|
|
try {
|
|
rawResponse.json()
|
|
.then((resp) => {
|
|
HandleFeedbackResp(resp)
|
|
})
|
|
} catch (e) {
|
|
document.getElementById('text').innerText = 'Invalid data recieved from server'
|
|
button.innerText = 'Submit'
|
|
console.log(e)
|
|
}
|
|
}
|
|
function ShowFeedback () {
|
|
const form = document.getElementById('form').style.display = "none";
|
|
const feedback = document.getElementById('feedback').style.display = "block";
|
|
}
|
|
function HandleResp (resp) {
|
|
document.getElementById('sendButton').innerText = 'Submit'
|
|
const textNode = document.getElementById('text')
|
|
if (resp.result === 'success') {
|
|
location.reload()
|
|
textNode.innerText = resp.msg
|
|
} else {
|
|
textNode.innerText = resp.msg
|
|
}
|
|
}
|
|
async function Login(button) {
|
|
button.innerText = '...'
|
|
const rawResponse = await fetch('http://api.frylabs.net/login', {
|
|
method: 'POST',
|
|
credentials: 'include',
|
|
headers: {
|
|
'Accept': 'application/json',
|
|
'Content-Type': 'application/json'
|
|
},
|
|
body: JSON.stringify({
|
|
pw: document.getElementById('pw').value
|
|
})
|
|
})
|
|
if (!rawResponse.ok) {
|
|
document.getElementById('text').innerText = 'Internal server error'
|
|
button.innerText = 'Submit'
|
|
}
|
|
try {
|
|
rawResponse.json()
|
|
.then((resp) => {
|
|
HandleResp(resp)
|
|
})
|
|
} catch (e) {
|
|
document.getElementById('text').innerText = 'Invalid data recieved from server'
|
|
button.innerText = 'Submit'
|
|
console.log(e)
|
|
}
|
|
}
|
|
</script>
|
|
</html>
|