AudioHTML/login.html

159 lines
5.9 KiB
HTML
Raw Normal View History

2023-10-29 16:52:53 +08:00
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title></title>
<link href="css/bootstrap.min.css" rel="stylesheet">
<link href="css/app.css" rel="stylesheet">
2023-11-08 00:29:39 +08:00
<script src="js/config.js"></script>
<script src="js/jquery-3.7.1.js"></script>
2023-10-29 16:52:53 +08:00
</head>
<body class="d-flex h-100 text-center text-bg-dark">
<div class="d-flex w-100 h-100 mx-auto flex-column">
<header class="mb-auto">
<!-- <div>
<h3 class="float-md-start mb-0">Cover</h3>
<nav class="nav nav-masthead justify-content-center float-md-end">
<a class="nav-link fw-bold py-1 px-0 active" aria-current="page" href="#">Home</a>
<a class="nav-link fw-bold py-1 px-0" href="#">Features</a>
<a class="nav-link fw-bold py-1 px-0" href="#">Contact</a>
</nav>
</div> -->
</header>
<main class="px-3 d-flex justify-content-center">
<div class="border border-black login">
<div class="dotblock py-3 login-title">GEAZAN</div>
<div class="login-form pt-5 mx-auto">
<div class="mb-4 input-group input-group-lg">
2023-11-08 19:15:11 +08:00
<input class="form-control" id="name" placeholder="Username" />
2023-10-29 16:52:53 +08:00
</div>
<div class="mb-5 input-group input-group-lg">
2023-11-08 19:15:11 +08:00
<input type="password" class="form-control" id="password" placeholder="Password" />
2023-10-29 16:52:53 +08:00
</div>
<div class="mt-5 pb-5 d-grid">
2023-11-08 19:15:11 +08:00
<button type="button" id="submit" class="btn btn-lg btn-dark border border-black">LOGIN</button>
2023-10-29 16:52:53 +08:00
</div>
<div class="mt-5 mb-3" style="color: #888888;">
2023-12-05 18:31:22 +08:00
<div>GUI <span id="guiv">V1.0.0</span>
2023-10-29 16:52:53 +08:00
</div>
2023-11-30 11:04:26 +08:00
<div>FIRMWARE <span id="firmwarev">V1.0.0</span></div>
2023-10-29 16:52:53 +08:00
</div>
</div>
</div>
<!-- <h1>Cover your page.</h1>
<p class="lead">Cover is a one-page template for building simple and beautiful home pages. Download, edit
the text, and add your own fullscreen background photo to make it your own.</p>
<p class="lead">
<a href="#" class="btn btn-lg btn-light fw-bold border-white bg-white">Learn more</a>
</p> -->
</main>
<footer class="mt-auto text-white-50">
<div class="dotblock d-flex justify-content-between px-5 py-4">
<div class="">Geazan</div>
<div>www.geazan.com</div>
</div>
</footer>
</div>
2023-11-08 00:29:39 +08:00
<script>
document.addEventListener("DOMContentLoaded", function () {
//初始化配置
2023-12-05 18:31:22 +08:00
2023-11-24 18:13:20 +08:00
loadData()
2023-12-05 18:31:22 +08:00
2023-11-08 00:29:39 +08:00
})
$(document).ready(function () {
2023-12-05 18:31:22 +08:00
console.log('ready', $("#name").val())
window.focus()
$("#name").focus()
var alertState = sessionStorage.getItem('alert')
if (alertState == 'alert') {
sessionStorage.removeItem('alert');
console.log('重新跳转')
window.location.href = 'login.html?t=' + new Date().getTime()
}
2023-11-08 00:29:39 +08:00
$("#submit").on("click", function () {
2023-11-08 19:15:11 +08:00
let name = $("#name").val()
let password = $("#password").val()
2023-11-10 11:53:14 +08:00
if (name.length == 0) {
2023-12-05 18:31:22 +08:00
sessionStorage.setItem('alert', 'alert');
2023-11-10 11:53:14 +08:00
alert('Please enter your username')
return
}
if (password.length == 0) {
2023-12-05 18:31:22 +08:00
sessionStorage.setItem('alert', 'alert');
2023-11-10 11:53:14 +08:00
alert('Please enter the account login password')
return
}
2023-12-05 18:31:22 +08:00
let url = '/cgi-bin/test.cgi';
2023-11-15 18:43:40 +08:00
let postData = {
action: 'login_set',
name: name,
password: password
}
2023-11-10 11:53:14 +08:00
$.ajax({
type: 'POST',
url: url,
2023-11-15 18:43:40 +08:00
data: postData,
2023-11-10 11:53:14 +08:00
dataType: "json",
2023-11-23 10:23:31 +08:00
//contentType: "application/json; charset=utf-8",
2023-11-10 11:53:14 +08:00
success: function (res) {
2023-11-15 18:43:40 +08:00
if (res.success) {
2023-12-05 18:31:22 +08:00
// alert('Login successful')
2023-12-05 20:16:42 +08:00
sessionStorage.setItem('state', 'logined');
2023-12-05 18:32:09 +08:00
window.location.href = "home.html"
2023-11-15 18:43:40 +08:00
}
else {
alert(res.message)
2023-12-05 18:31:22 +08:00
sessionStorage.setItem('alert', 'alert');
return
2023-11-15 18:43:40 +08:00
}
2023-11-10 11:53:14 +08:00
},
2023-11-15 18:43:40 +08:00
error: function (res) {
2023-12-05 18:31:22 +08:00
alert('error')
// sessionStorage.setItem('state', 'logined');
// window.location.href = "home.html"
2023-11-10 11:53:14 +08:00
}
})
2023-11-08 00:29:39 +08:00
})
})
2023-11-24 18:13:20 +08:00
function loadData() {
let url = "http://192.168.0.116/cgi-bin/test.cgi?action=system_get"
$.ajax({
type: "GET",
url: url,
success: function (res) {
data = res.content
bindData()
},
error: function () {
data = {
gui: "v1.0.2",
firmware: "v1.0.0",
sn: "SN-2343-123-NNDD",
hostname: "Test.Hostname"
}
bindData()
}
})
}
function bindData() {
$("#guiv").text(`${data.gui}`)
$("#firmwarev").text(`${data.firmware}`)
$("#sn").text(`${data.sn}`)
$("#hostName").text(`${data.hostname}`)
}
2023-11-08 00:29:39 +08:00
</script>
2023-12-05 18:31:22 +08:00
<script src="js/main.js"></script>
2023-10-29 16:52:53 +08:00
</body>
</html>