-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.html
More file actions
153 lines (131 loc) · 3.52 KB
/
index.html
File metadata and controls
153 lines (131 loc) · 3.52 KB
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
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Code Conversion</title>
<style>
/* CSS styles for the page layout and appearance */
body {
background-color: rgb(43, 42, 42);
color: white;
font-family: monospace;
margin: 0;
padding: 0;
}
.container {
display: flex;
flex-direction: column;
height: 100vh;
overflow: hidden;
}
.header {
display: flex;
justify-content: flex-end;
padding: 8px;
}
.header select,
.header button {
font-size: 16px;
padding: 10px 20px;
margin-left: 2%;
background-color: darkgray;
color: white;
border: none;
border-radius: 4px;
cursor: pointer;
}
.input-section {
flex-grow: 1;
display: flex;
padding: 8px;
}
.input-section textarea {
flex-grow: 1;
background-color: transparent;
border: none;
color: white;
outline: none;
resize: none;
}
.output-section {
flex-grow: 1;
padding: 8px;
overflow-y: auto;
border-top: 1px solid white;
}
.output-section pre {
margin: 0;
white-space: pre-wrap;
}
.output-section pre.error {
color: red;
}
</style>
</head>
<body>
<div class="container">
<div class="header">
<select id="language">
<option value="java">Java</option>
<option value="javascript">JavaScript</option>
<option value="python">Python</option>
</select>
<button onclick="convertCode()">Convert</button>
<button onclick="debugCode()">Debug</button>
<button onclick="qualityCheck()">Quality Check</button>
</div>
<div class="input-section">
<textarea id="code" rows="10" placeholder="Enter your code here..."></textarea>
</div>
<div class="output-section">
<pre id="output"></pre>
</div>
</div>
<script>
const baseURL = 'https://blue-cooperative-tortoise.cyclic.app/';
async function convertCode() {
const code = document.getElementById('code').value;
const language = document.getElementById('language').value;
const response = await fetch(`${baseURL}/convert`, {
method: 'POST',
headers: {
'Content-Type': 'application/json'
},
body: JSON.stringify({ code, targetLanguage: language })
});
const data = await response.json();
// Check if the response has converted code
if (data.convertedCode) {
document.getElementById('output').innerText = data.convertedCode;
} else {
document.getElementById('output').innerText = 'Failed to convert the code.';
}
}
async function debugCode() {
const code = document.getElementById('code').value;
const response = await fetch(`${baseURL}/debug`, {
method: 'POST',
headers: {
'Content-Type': 'application/json'
},
body: JSON.stringify({ code })
});
const data = await response.json();
document.getElementById('output').innerText = data.shayari;
}
async function qualityCheck() {
const code = document.getElementById('code').value;
const response = await fetch(`${baseURL}/check`, {
method: 'POST',
headers: {
'Content-Type': 'application/json'
},
body: JSON.stringify({ code })
});
const data = await response.json();
document.getElementById('output').innerText = data.shayari;
}
</script>
</body>
</html>