-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.html
More file actions
172 lines (161 loc) · 8.45 KB
/
index.html
File metadata and controls
172 lines (161 loc) · 8.45 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
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>SQL to JSON/Table Converter</title>
<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.0/dist/css/bootstrap.min.css" rel="stylesheet">
<style>
body {
padding: 20px;
max-width: 1200px;
margin: 0 auto;
}
.output-section {
margin-top: 20px;
padding: 15px;
border: 1px solid var(--bs-border-color);
border-radius: 5px;
background-color: var(--bs-body-bg);
}
pre {
background-color: var(--bs-tertiary-bg);
padding: 10px;
border-radius: 5px;
max-height: 300px;
overflow-y: auto;
color: var(--bs-body-color);
}
h2 {
margin-top: 30px;
margin-bottom: 15px;
}
table {
margin-top: 15px;
}
</style>
</head>
<body>
<div class="container">
<div class="d-flex align-items-center justify-content-between mb-4">
<h1 id="title" class="m-0">SQL to JSON/Table Converter</h1>
<div class="d-flex align-items-center gap-2">
<label id="langLabel" for="langSelect" class="form-label m-0">Language</label>
<select id="langSelect" class="form-select form-select-sm" style="width: 140px;">
<option value="en" selected>English</option>
<option value="zh">中文</option>
</select>
<label id="themeLabel" for="themeSelect" class="form-label m-0">Theme</label>
<select id="themeSelect" class="form-select form-select-sm" style="width: 140px;">
<option value="system" selected>System</option>
<option value="light">Light</option>
<option value="dark">Dark</option>
</select>
<a href="https://github.com/snakewa/html5-sql-insert-tools" class="btn btn-outline-secondary btn-sm ms-2" target="_blank" rel="noopener" aria-label="GitHub Repository" title="GitHub Repository">
<svg xmlns="http://www.w3.org/2000/svg" width="18" height="18" viewBox="0 0 24 24" fill="currentColor" role="img" aria-hidden="true">
<path d="M12 .5a12 12 0 0 0-3.79 23.4c.6.11.82-.26.82-.58v-2.03c-3.34.73-4.04-1.61-4.04-1.61-.55-1.39-1.34-1.76-1.34-1.76-1.09-.74.08-.73.08-.73 1.2.08 1.83 1.24 1.83 1.24 1.07 1.83 2.8 1.3 3.48.99.11-.78.42-1.3.76-1.6-2.66-.3-5.46-1.33-5.46-5.93 0-1.31.47-2.38 1.24-3.22-.12-.3-.54-1.52.12-3.17 0 0 1.01-.32 3.3 1.23a11.5 11.5 0 0 1 6 0c2.28-1.55 3.29-1.23 3.29-1.23.66 1.65.24 2.87.12 3.17.77.84 1.23 1.91 1.23 3.22 0 4.61-2.8 5.62-5.47 5.92.43.37.81 1.1.81 2.22v3.29c0 .32.22.7.83.58A12 12 0 0 0 12 .5z"/>
</svg>
</a>
</div>
</div>
<!-- Section 1: Input & Actions -->
<section class="mb-4">
<div class="mb-3">
<label id="sqlLabel" for="sqlInput" class="form-label">Paste your SQL here (you can include CREATE TABLE and multiple INSERT statements):</label>
<textarea class="form-control" id="sqlInput" rows="8" placeholder="CREATE TABLE ...; INSERT INTO table_name (col1, col2, ...) VALUES (...), (...);"></textarea>
</div>
<div class="d-flex align-items-center gap-2 mb-2">
<button id="convertBtn" class="btn btn-primary">Convert</button>
<div class="ms-auto d-flex align-items-center gap-2">
<label id="outputModeLabel" for="outputMode" class="form-label m-0">Output:</label>
<select id="outputMode" class="form-select form-select-sm" style="width: 180px;">
<option value="grouped" selected>Grouped by Table</option>
<option value="flat">Flat Array</option>
</select>
<button id="downloadJsonBtn" class="btn btn-outline-secondary btn-sm" type="button">Download JSON</button>
<button id="downloadCsvBtn" class="btn btn-outline-secondary btn-sm" type="button">Download CSV</button>
</div>
</div>
<div class="d-flex align-items-center gap-2 mb-0">
<div class="form-check">
<input class="form-check-input" type="checkbox" id="saveInputToggle">
<label id="saveInputLabel" class="form-check-label" for="saveInputToggle">Save input in browser</label>
</div>
</div>
<div id="messages" class="mb-0"></div>
</section>
<!-- Section 2: Output - JSON Actions -->
<section id="jsonActionsSection" class="mb-4 d-none">
<hr/>
<h2 id="jsonSectionTitle" class="h4 mb-3">Output: JSON Actions</h2>
<div class="d-flex align-items-center justify-content-between mb-2">
<div class="d-flex align-items-center gap-2">
<div class="form-check form-switch">
<input class="form-check-input" type="checkbox" id="expandJsonToggle">
<label id="expandJsonLabel" class="form-check-label" for="expandJsonToggle">Expand JSON values</label>
</div>
</div>
<div class="d-flex align-items-center gap-2">
<button id="viewJsonBtn" class="btn btn-sm btn-outline-secondary" type="button">View JSON</button>
<button id="copyJsonBtn" class="btn btn-sm btn-outline-primary" type="button">Copy JSON</button>
</div>
</div>
<div id="output" class="d-none">
<div class="output-section d-none">
<pre id="jsonOutput"></pre>
</div>
</div>
<hr/>
</section>
<!-- Section 3: Output - HTML Table -->
<section id="tableSection" class="mb-4 d-none">
<div class="d-flex align-items-center justify-content-between mb-2">
<h2 id="tableSectionTitle" class="h4 m-0">Output: HTML Table</h2>
<div class="d-flex align-items-center gap-2">
<button id="compareBtn" class="btn btn-sm btn-outline-secondary" type="button">Compare Selected</button>
<button id="generateUpdateBtn" class="btn btn-sm btn-outline-primary" type="button">Generate UPDATEs</button>
</div>
</div>
<div class="output-section">
<div id="tableOutput"></div>
</div>
</section>
<!-- Action Modal (Diff / SQL Output) -->
<div class="modal fade" id="actionModal" tabindex="-1" aria-labelledby="actionModalLabel" aria-hidden="true">
<div class="modal-dialog modal-lg modal-dialog-scrollable">
<div class="modal-content">
<div class="modal-header">
<h5 class="modal-title" id="actionModalLabel">Action Result</h5>
<button type="button" class="btn-close" data-bs-dismiss="modal" aria-label="Close"></button>
</div>
<div class="modal-body">
<pre id="actionModalBody" class="mb-0"></pre>
</div>
<div class="modal-footer">
<button id="actionCopyBtn" type="button" class="btn btn-outline-primary">Copy</button>
<button type="button" class="btn btn-secondary" data-bs-dismiss="modal">Close</button>
</div>
</div>
</div>
</div>
<!-- JSON Modal -->
<div class="modal fade" id="jsonModal" tabindex="-1" aria-labelledby="jsonModalLabel" aria-hidden="true">
<div class="modal-dialog modal-lg modal-dialog-scrollable">
<div class="modal-content">
<div class="modal-header">
<h5 class="modal-title" id="jsonModalLabel">JSON Value</h5>
<button type="button" class="btn-close" data-bs-dismiss="modal" aria-label="Close"></button>
</div>
<div class="modal-body">
<pre id="jsonModalBody" class="mb-0"></pre>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-secondary" data-bs-dismiss="modal">Close</button>
</div>
</div>
</div>
</div>
<script src="script.js"></script>
<script src="https://cdn.jsdelivr.net/npm/bootstrap@5.3.0/dist/js/bootstrap.bundle.min.js"></script>
</body>
</html>