-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.html
111 lines (107 loc) · 2.72 KB
/
index.html
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
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
<!DOCTYPE html>
<html>
<head>
<title>HTML to JSX</title>
<style>
body {
font-family: Arial, sans-serif;
margin: 0;
/* padding: 10px; */
background-color: #f1f1f1;
}
h1 {
margin-bottom: 20px;
text-align: center;
color: #333;
}
.container {
max-width: 800px;
margin: 0 auto;
background-color: #fff;
padding: 20px;
box-shadow: 0 0 5px rgba(0, 0, 0, 0.1);
border-radius: 5px;
}
label {
display: block;
font-weight: bold;
margin-bottom: 10px;
}
textarea {
width: 96%;
height: 200px;
padding: 10px;
border: 1px solid #ccc;
resize: vertical;
}
button {
margin-top: 10px;
padding: 8px 16px;
background-color: #4287f5;
color: white;
border: none;
border-radius: 4px;
cursor: pointer;
}
#response {
margin-top: 20px;
}
.copy-button {
display: inline-block;
margin-left: 10px;
padding: 8px 16px;
background-color: #333;
color: white;
border: none;
border-radius: 4px;
cursor: pointer;
}
</style>
</head>
<body>
<div class="container">
<h1>HTML to JSX</h1>
<label for="htmlInput">HTML Input:</label>
<textarea
id="htmlInput"
placeholder="Enter HTML here"
oninput="callAPI()"
></textarea>
<button onclick="sendHTML()">Submit</button>
<button class="copy-button" onclick="copyResponse()">Copy Output</button>
<br /><br />
<label for="response">Response:</label>
<textarea id="response" readonly></textarea>
</div>
<script>
function callAPI() {
clearTimeout(window.timer)
window.timer = setTimeout(sendHTML, 500)
}
function sendHTML() {
const htmlData = document.getElementById('htmlInput').value
const apiUrl = '/' // Replace with your API endpoint URL
fetch(apiUrl, {
method: 'POST',
headers: {
'Content-Type': 'text/plain',
},
body: htmlData,
})
.then(response => response.text())
.then(data => {
document.getElementById('response').value = data
})
.catch(error => {
console.error('Error:', error)
document.getElementById('response').value = 'An error occurred.'
})
}
function copyResponse() {
const responseTextArea = document.getElementById('response')
responseTextArea.select()
document.execCommand('copy')
}
</script>
</body>
</html>