netgate-switch/index.html
2024-07-21 20:10:19 +08:00

110 lines
2.7 KiB
HTML

<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html;charset=utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no">
<meta name="format-detection" content="telephone=no" />
<title>NetgateSwitch</title>
<style>
html,
body {
height: 100%;
}
body {
display: flex;
align-items: center;
background-color: #f5f5f5;
}
.title {
margin: 1rem 0 0 0;
font-size: 1.8rem;
}
main {
width: 100%;
max-width: 30rem;
margin: auto;
text-align: center;
background-color: #ffffff;
border-radius: 1rem;
box-shadow: 0.5rem 0.5rem 1rem rgba(0, 0, 0, 0.2);
}
.btn {
width: 3rem;
height: 2rem;
margin-bottom: 1rem;
border: none;
border-radius: 0.5rem;
background-color: #dfdfdf;
}
.btn:hover {
background-color: #b9b9b9;
}
.btn:active {
background-color: #b9b9b9;
color: #ffffff;
box-shadow: 0 3px #666;
transform: translateY(2px);
}
</style>
</head>
<body>
<main>
<h1 class="title">NetgateSwitch</h1>
<form>
<div class="text-area">
</div>
<button class="btn" id="getlist">获取</button>
<button class="btn" id="switchaddr">更改</button>
</form>
</main>
</body>
<script>
document.getElementById('getlist').addEventListener('click', async (event) => {
try {
let res = await fetch('./core/get/', {
method: 'POST',
headers: {
'Content-Type': 'application/json'
}, body: {}
});
if (!res.ok) {
alert(await res.text());
}
} catch (err) {
console.log(err);
}
});
document.getElementById('switchaddr').addEventListener('click', async (event) => {
try {
let res = await fetch('./core/switch/', {
method: 'POST',
headers: {
'Content-Type': 'application/json'
}, body: JSON.stringify({
id: 'a',
group: 'main',
})
});
if (!res.ok) {
alert(await res.text());
}
} catch (err) {
console.log(err);
}
});
</script>
</html>