You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
136 lines
5.0 KiB
136 lines
5.0 KiB
<!DOCTYPE html>
|
|
<html lang="en-US">
|
|
<head>
|
|
<meta http-equiv="Content-type" content="text/html;charset=UTF-8"/>
|
|
<meta name="viewport" content="width=device-width, initial-scale=1.0"/>
|
|
<link rel="icon" type="image/ico" href="images/favicon.ico"/>
|
|
<title>Manga Reader</title>
|
|
<link rel="stylesheet" type="text/css" href="/css/home.css" id="pagesheet"/>
|
|
<link rel="stylesheet" href="https://fonts.googleapis.com/css2?family=Material+Symbols+Outlined:opsz,wght,FILL,GRAD@20..48,100..700,0..1,-50..200" />
|
|
<script type="module" src="/js/home.js"></script>
|
|
<script src="https://unpkg.com/htmx.org@1.9.10"></script>
|
|
|
|
</head>
|
|
|
|
<body>
|
|
<div class="progress" style="height: 3px; background-color: white;">
|
|
<div class="indeterminate" style="background-color: red;"></div>
|
|
</div>
|
|
<div id="configWrapper">
|
|
<form class="configForm" id="configForm" action="/config" method="post" >
|
|
<section class="usernameSection">
|
|
<!-- <div class="marker"></div> -->
|
|
<label for="username" class="username">Username:</label>
|
|
<input type="text" name="username" id="username" class="formInput" required>
|
|
</section>
|
|
<section class="passwordSection">
|
|
<!-- <div class="marker"></div> -->
|
|
<label for="password" class="password">Password:</label>
|
|
<input type="password" name="password" id="password"class="formInput" required>
|
|
<label for="password2" class="password">Confirm password:</label>
|
|
<input type="password" name="password2"id="password2" class="formInput" required>
|
|
</section>
|
|
<section class="folderPathSection">
|
|
<!-- <div class="marker"></div> -->
|
|
<label for="saveFolder" class="saveFolder">Save folder Path: </label>
|
|
<input type="text" name="saveFolder" id="saveFolder" class="formInput" list="dirs" placeholder="Can be left blank if default is fine">
|
|
<datalist id="dirs">
|
|
<% data.forEach(dir=>{ %>
|
|
<option value="<%= dir %>">
|
|
<%}) %>
|
|
</datalist>
|
|
</section>
|
|
<section class="buttonSection">
|
|
<button id="configSubmitBt" type="submit">Configure</button>
|
|
</section>
|
|
</form>
|
|
</div>
|
|
</body>
|
|
<script>
|
|
const regex = /^[a-zA-Z]+$/;
|
|
const Errors = {
|
|
Mismatch:'Passwords don\'t match.',
|
|
Short:'Password is too short. (min 10 characters)',
|
|
Arguments:'Password must have special characters.',
|
|
}
|
|
function handler(event)
|
|
{
|
|
let passwordInput = document.getElementById('password');
|
|
let password2Input = document.getElementById('password2');
|
|
let password = passwordInput.value;
|
|
let password2 = password2Input.value;
|
|
let userInput = document.getElementById('username');
|
|
let user = userInput.value;
|
|
resetValidity([passwordInput, password2Input, userInput])
|
|
if(user.length < 4) return userInput.setCustomValidity(Errors.Short);
|
|
if(password.length < 10) return passwordInput.setCustomValidity(Errors.Short);
|
|
if(password!=password2) return password2Input.setCustomValidity(Errors.Mismatch);
|
|
if(regex.test(password)) return passwordInput.setCustomValidity(Errors.Arguments);
|
|
}
|
|
function resetValidity(Elements)
|
|
{
|
|
for(var element of Elements)
|
|
{
|
|
element.setCustomValidity('');
|
|
}
|
|
}
|
|
document.getElementById('username').addEventListener('keyup', handler);
|
|
document.getElementById('password').addEventListener('keyup', handler);
|
|
document.getElementById('password2').addEventListener('keyup', handler);
|
|
document.getElementById('saveFolder').addEventListener('keyup', handler);
|
|
input.onfocus = function () {
|
|
browsers.style.display = 'block';
|
|
input.style.borderRadius = "5px 5px 0 0";
|
|
};
|
|
for (let option of browsers.options) {
|
|
option.onclick = function () {
|
|
input.value = option.value;
|
|
browsers.style.display = 'none';
|
|
input.style.borderRadius = "5px";
|
|
}
|
|
};
|
|
|
|
input.oninput = function() {
|
|
currentFocus = -1;
|
|
var text = input.value.toUpperCase();
|
|
for (let option of browsers.options) {
|
|
if(option.value.toUpperCase().indexOf(text) > -1){
|
|
option.style.display = "block";
|
|
}else{
|
|
option.style.display = "none";
|
|
}
|
|
};
|
|
}
|
|
var currentFocus = -1;
|
|
input.onkeydown = function(e) {
|
|
if(e.keyCode == 40){
|
|
currentFocus++
|
|
addActive(browsers.options);
|
|
}
|
|
else if(e.keyCode == 38){
|
|
currentFocus--
|
|
addActive(browsers.options);
|
|
}
|
|
else if(e.keyCode == 13){
|
|
e.preventDefault();
|
|
if (currentFocus > -1) {
|
|
/*and simulate a click on the "active" item:*/
|
|
if (browsers.options) browsers.options[currentFocus].click();
|
|
}
|
|
}
|
|
}
|
|
|
|
function addActive(x) {
|
|
if (!x) return false;
|
|
removeActive(x);
|
|
if (currentFocus >= x.length) currentFocus = 0;
|
|
if (currentFocus < 0) currentFocus = (x.length - 1);
|
|
x[currentFocus].classList.add("active");
|
|
}
|
|
function removeActive(x) {
|
|
for (var i = 0; i < x.length; i++) {
|
|
x[i].classList.remove("active");
|
|
}
|
|
}
|
|
</script>
|
|
</html> |