|
| 1 | +<!DOCTYPE html> |
| 2 | +<html lang="en"> |
| 3 | +<head> |
| 4 | + <meta charset="UTF-8"> |
| 5 | + <meta name="viewport" content="width=device-width, initial-scale=1.0"> |
| 6 | + <title>SQL to JSON/Table Converter</title> |
| 7 | + <link href=" https://cdn.jsdelivr.net/npm/[email protected]/dist/css/bootstrap.min.css" rel=" stylesheet" > |
| 8 | + <style> |
| 9 | + body { |
| 10 | + padding: 20px; |
| 11 | + max-width: 1200px; |
| 12 | + margin: 0 auto; |
| 13 | + } |
| 14 | + .output-section { |
| 15 | + margin-top: 20px; |
| 16 | + padding: 15px; |
| 17 | + border: 1px solid #ddd; |
| 18 | + border-radius: 5px; |
| 19 | + } |
| 20 | + pre { |
| 21 | + background-color: #f8f9fa; |
| 22 | + padding: 10px; |
| 23 | + border-radius: 5px; |
| 24 | + max-height: 300px; |
| 25 | + overflow-y: auto; |
| 26 | + } |
| 27 | + h2 { |
| 28 | + margin-top: 30px; |
| 29 | + margin-bottom: 15px; |
| 30 | + } |
| 31 | + table { |
| 32 | + margin-top: 15px; |
| 33 | + } |
| 34 | + </style> |
| 35 | +</head> |
| 36 | +<body> |
| 37 | + <div class="container"> |
| 38 | + <h1 class="mb-4">SQL to JSON/Table Converter</h1> |
| 39 | + |
| 40 | + <!-- Section 1: Input & Actions --> |
| 41 | + <section class="mb-4"> |
| 42 | + <h2 class="h4 mb-3">Input & Actions</h2> |
| 43 | + <div class="mb-3"> |
| 44 | + <label for="sqlInput" class="form-label">Paste your SQL here (you can include CREATE TABLE and multiple INSERT statements):</label> |
| 45 | + <textarea class="form-control" id="sqlInput" rows="8" placeholder="CREATE TABLE ...; INSERT INTO table_name (col1, col2, ...) VALUES (...), (...);"></textarea> |
| 46 | + </div> |
| 47 | + <div class="d-flex align-items-center gap-2 mb-2"> |
| 48 | + <button id="convertBtn" class="btn btn-primary">Convert</button> |
| 49 | + <div class="ms-auto d-flex align-items-center gap-2"> |
| 50 | + <label for="outputMode" class="form-label m-0">Output:</label> |
| 51 | + <select id="outputMode" class="form-select form-select-sm" style="width: 180px;"> |
| 52 | + <option value="grouped" selected>Grouped by Table</option> |
| 53 | + <option value="flat">Flat Array</option> |
| 54 | + </select> |
| 55 | + <button id="downloadJsonBtn" class="btn btn-outline-secondary btn-sm" type="button">Download JSON</button> |
| 56 | + <button id="downloadCsvBtn" class="btn btn-outline-secondary btn-sm" type="button">Download CSV</button> |
| 57 | + </div> |
| 58 | + </div> |
| 59 | + <div id="messages" class="mb-0"></div> |
| 60 | + </section> |
| 61 | + |
| 62 | + <hr/> |
| 63 | + |
| 64 | + <!-- Section 2: Output - JSON Actions --> |
| 65 | + <section class="mb-4"> |
| 66 | + <h2 class="h4 mb-3">Output: JSON Actions</h2> |
| 67 | + <div class="d-flex align-items-center justify-content-between mb-2"> |
| 68 | + <div class="d-flex align-items-center gap-2"> |
| 69 | + <div class="form-check form-switch"> |
| 70 | + <input class="form-check-input" type="checkbox" id="expandJsonToggle"> |
| 71 | + <label class="form-check-label" for="expandJsonToggle">Expand JSON values</label> |
| 72 | + </div> |
| 73 | + </div> |
| 74 | + <div class="d-flex align-items-center gap-2"> |
| 75 | + <button id="viewJsonBtn" class="btn btn-sm btn-outline-secondary" type="button">View JSON</button> |
| 76 | + <button id="copyJsonBtn" class="btn btn-sm btn-outline-primary" type="button">Copy JSON</button> |
| 77 | + </div> |
| 78 | + </div> |
| 79 | + <div id="output" class="d-none"> |
| 80 | + <div class="output-section d-none"> |
| 81 | + <pre id="jsonOutput"></pre> |
| 82 | + </div> |
| 83 | + </div> |
| 84 | + </section> |
| 85 | + |
| 86 | + <hr/> |
| 87 | + |
| 88 | + <!-- Section 3: Output - HTML Table --> |
| 89 | + <section class="mb-4"> |
| 90 | + <div class="d-flex align-items-center justify-content-between mb-2"> |
| 91 | + <h2 class="h4 m-0">Output: HTML Table</h2> |
| 92 | + <div class="d-flex align-items-center gap-2"> |
| 93 | + <button id="compareBtn" class="btn btn-sm btn-outline-secondary" type="button">Compare Selected</button> |
| 94 | + <button id="generateUpdateBtn" class="btn btn-sm btn-outline-primary" type="button">Generate UPDATEs</button> |
| 95 | + </div> |
| 96 | + </div> |
| 97 | + <div class="output-section"> |
| 98 | + <div id="tableOutput"></div> |
| 99 | + </div> |
| 100 | + </section> |
| 101 | + |
| 102 | + <!-- Action Modal (Diff / SQL Output) --> |
| 103 | + <div class="modal fade" id="actionModal" tabindex="-1" aria-labelledby="actionModalLabel" aria-hidden="true"> |
| 104 | + <div class="modal-dialog modal-lg modal-dialog-scrollable"> |
| 105 | + <div class="modal-content"> |
| 106 | + <div class="modal-header"> |
| 107 | + <h5 class="modal-title" id="actionModalLabel">Action Result</h5> |
| 108 | + <button type="button" class="btn-close" data-bs-dismiss="modal" aria-label="Close"></button> |
| 109 | + </div> |
| 110 | + <div class="modal-body"> |
| 111 | + <pre id="actionModalBody" class="mb-0"></pre> |
| 112 | + </div> |
| 113 | + <div class="modal-footer"> |
| 114 | + <button id="actionCopyBtn" type="button" class="btn btn-outline-primary">Copy</button> |
| 115 | + <button type="button" class="btn btn-secondary" data-bs-dismiss="modal">Close</button> |
| 116 | + </div> |
| 117 | + </div> |
| 118 | + </div> |
| 119 | + </div> |
| 120 | + |
| 121 | + <!-- JSON Modal --> |
| 122 | + <div class="modal fade" id="jsonModal" tabindex="-1" aria-labelledby="jsonModalLabel" aria-hidden="true"> |
| 123 | + <div class="modal-dialog modal-lg modal-dialog-scrollable"> |
| 124 | + <div class="modal-content"> |
| 125 | + <div class="modal-header"> |
| 126 | + <h5 class="modal-title" id="jsonModalLabel">JSON Value</h5> |
| 127 | + <button type="button" class="btn-close" data-bs-dismiss="modal" aria-label="Close"></button> |
| 128 | + </div> |
| 129 | + <div class="modal-body"> |
| 130 | + <pre id="jsonModalBody" class="mb-0"></pre> |
| 131 | + </div> |
| 132 | + <div class="modal-footer"> |
| 133 | + <button type="button" class="btn btn-secondary" data-bs-dismiss="modal">Close</button> |
| 134 | + </div> |
| 135 | + </div> |
| 136 | + </div> |
| 137 | + </div> |
| 138 | + |
| 139 | + <script src="script.js"></script> |
| 140 | + <script src=" https://cdn.jsdelivr.net/npm/[email protected]/dist/js/bootstrap.bundle.min.js" ></script> |
| 141 | +</body> |
| 142 | +</html> |
0 commit comments