2019-09-18 19:54:28 +00:00
|
|
|
<!DOCTYPE html>
|
|
|
|
<html lang="en">
|
|
|
|
|
|
|
|
<head>
|
|
|
|
<meta charset="UTF-8">
|
|
|
|
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
|
|
|
<meta http-equiv="X-UA-Compatible" content="ie=edge">
|
|
|
|
<title>{{title}}</title>
|
|
|
|
<link rel="stylesheet" href="https://unpkg.com/@hibas123/theme/out/base.css">
|
2019-09-19 14:24:35 +00:00
|
|
|
<link rel="stylesheet" href="https://unpkg.com/@hibas123/theme/out/light.css">
|
2019-09-18 19:54:28 +00:00
|
|
|
|
|
|
|
<style>
|
|
|
|
#message {
|
|
|
|
visibility: hidden;
|
|
|
|
background-color: lightgreen;
|
|
|
|
border: 1px solid lime;
|
|
|
|
border-radius: .5rem;
|
|
|
|
padding: 1rem;
|
|
|
|
font-size: 1.5rem;
|
|
|
|
margin-bottom: 1rem;
|
|
|
|
}
|
|
|
|
</style>
|
|
|
|
</head>
|
|
|
|
|
|
|
|
<body>
|
|
|
|
<div class="container">
|
|
|
|
<div class="margin" style="margin-top: 4rem;">
|
|
|
|
<h1>{{title}}</h1>
|
|
|
|
<div id="message"> </div>
|
|
|
|
<form id="f1" action="JavaScript:void(null)">
|
|
|
|
{{#each fields}}
|
2019-10-11 17:35:36 +00:00
|
|
|
<div class="input-group">
|
|
|
|
<label>{{label}}</label>
|
|
|
|
{{#ifCond type "===" "text"}}
|
2020-03-24 17:33:47 +00:00
|
|
|
<input type="text" placeholder="{{label}}" name="{{name}}" value="{{value}}" {{disabled}} />
|
2019-10-11 17:35:36 +00:00
|
|
|
{{/ifCond}}
|
2019-09-18 19:54:28 +00:00
|
|
|
|
2019-10-11 17:35:36 +00:00
|
|
|
{{#ifCond type "===" "number"}}
|
2020-03-24 17:33:47 +00:00
|
|
|
<input type="number" placeholder="{{label}}" name="{{name}}" value="{{value}}" {{disabled}} />
|
2019-10-11 17:35:36 +00:00
|
|
|
{{/ifCond}}
|
2019-09-18 19:54:28 +00:00
|
|
|
|
2019-10-11 17:35:36 +00:00
|
|
|
{{#ifCond type "===" "boolean"}}
|
2020-03-24 17:33:47 +00:00
|
|
|
<input type="checkbox" name="{{name}}" checked="{{value}}" {{disabled}} />
|
2019-10-11 17:35:36 +00:00
|
|
|
{{/ifCond}}
|
2019-09-18 19:54:28 +00:00
|
|
|
|
2019-10-11 17:35:36 +00:00
|
|
|
{{#ifCond type "===" "textarea"}}
|
2020-03-24 17:33:47 +00:00
|
|
|
<textarea class="inp" name="{{name}}" rows="20" {{disabled}}>{{value}}</textarea>
|
2019-10-11 17:35:36 +00:00
|
|
|
{{/ifCond}}
|
|
|
|
</div>
|
2019-09-18 19:54:28 +00:00
|
|
|
{{/each}}
|
|
|
|
|
|
|
|
<button class="btn btn-primary" onclick="submitData()">Submit</button>
|
|
|
|
</form>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
|
|
|
|
<script>
|
2019-10-11 17:35:36 +00:00
|
|
|
let u = new URL("{{url}}", window.location.origin);
|
|
|
|
let key = new URL(window.location.href).searchParams.get("key");
|
|
|
|
if (key)
|
|
|
|
u.searchParams.set("key", key);
|
2019-09-18 19:54:28 +00:00
|
|
|
|
|
|
|
const message = document.getElementById("message");
|
|
|
|
const form = document.getElementById("f1");
|
|
|
|
function submitData() {
|
|
|
|
let res = {};
|
|
|
|
Array.from(new FormData(form).entries()).forEach(([name, value]) => res[name] = value);
|
2019-10-11 17:35:36 +00:00
|
|
|
fetch(u.href, {
|
2019-09-18 19:54:28 +00:00
|
|
|
method: "POST",
|
|
|
|
headers: {
|
|
|
|
"content-type": "application/json"
|
|
|
|
},
|
|
|
|
body: JSON.stringify(res)
|
|
|
|
}).then(res => {
|
|
|
|
return res.text();
|
|
|
|
}).then(res => {
|
|
|
|
message.innerText = res;
|
|
|
|
message.style.visibility = "unset";
|
|
|
|
})
|
|
|
|
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
</script>
|
|
|
|
</body>
|
|
|
|
|
2020-03-24 17:33:47 +00:00
|
|
|
</html>
|