summaryrefslogtreecommitdiffstats
path: root/test.html
blob: 4fd4b7cecf424c14b8582280c9fd30683e21a0a9 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
<html>
<body>
	<br>
	<br>
	<br>
	<br>
	<br>
	<br>
	<div id="sexy_time"></div>

	<script>
		function sendData() {
			let data = {};
			let inputs = document.getElementById('sexy_time').getElementsByTagName('input');
			for (let i = 0; i < inputs.length; i++) {
				data[inputs[i].name] = inputs[i].value;
			}
			window.pywry.result(JSON.stringify(data));
		}
		if (window.json_data) {
			let json_data = window.json_data;
			if (typeof json_data === 'string') {
				json_data = JSON.parse(json_data);
			}
			console.log(json_data);
			let sexy_time = document.getElementById('sexy_time').innerHTML;
			json_data.params.forEach((parm) => {
				sexy_time += `<label for="${parm}">${parm}</label>`;
				sexy_time += `<input type"text" name="${parm}"></input>`;
			});

			sexy_time += `<button onclick="sendData()">Submit</button>`;
			document.getElementById('sexy_time').innerHTML = sexy_time;
		}
	</script>
</body>
</html>