-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathconfig-migration-tool.html
More file actions
262 lines (233 loc) · 10.3 KB
/
config-migration-tool.html
File metadata and controls
262 lines (233 loc) · 10.3 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
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8" />
<title>Config Migration Tool</title>
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<!-- Materialize CSS -->
<link href="https://cdnjs.cloudflare.com/ajax/libs/materialize/1.0.0/css/materialize.min.css" rel="stylesheet">
<!-- Material Icons -->
<link href="https://fonts.googleapis.com/icon?family=Material+Icons" rel="stylesheet">
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/highlight.js/11.11.1/styles/dark.min.css">
<script src="https://cdnjs.cloudflare.com/ajax/libs/highlight.js/11.11.1/highlight.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/highlight.js/11.11.1/languages/kotlin.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/highlight.js/11.11.1/languages/swift.min.js"></script>
<!-- CodeMirror for JSON input highlighting -->
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/codemirror/5.65.2/codemirror.min.css">
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/codemirror/5.65.2/theme/material-darker.min.css">
<script src="https://cdnjs.cloudflare.com/ajax/libs/codemirror/5.65.2/codemirror.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/codemirror/5.65.2/mode/javascript/javascript.min.js"></script>
<script defer src="script/config-migration-android.js"></script>
<script defer src="script/config-migration-ios.js"></script>
<link rel="stylesheet" href="style/config-migration-tool.css" />
<script>
let inputEditor;
let currentTab = 'kotlin';
document.addEventListener("DOMContentLoaded", function () {
// Initialize Materialize components
M.AutoInit();
// Initialize CodeMirror for JSON input
inputEditor = CodeMirror.fromTextArea(document.getElementById('input'), {
mode: { name: "javascript", json: true },
theme: "material-darker",
lineNumbers: true,
lineWrapping: true,
indentUnit: 2,
smartIndent: true,
matchBrackets: true,
autoCloseBrackets: true,
foldGutter: true,
gutters: ["CodeMirror-linenumbers", "CodeMirror-foldgutter"],
placeholder: "Paste your config.json here...",
viewportMargin: Infinity
});
// Load example configuration
fetch('script/example-config.json')
.then(response => response.text())
.then(jsonText => {
inputEditor.setValue(jsonText);
})
.catch(error => {
console.error('Error loading example config:', error);
inputEditor.setValue('{\n "backbase": {\n "serverURL": "https://your-server-url.com",\n "version": "6.1.5"\n }\n}');
});
// Tab switching functionality
const kotlinTab = document.getElementById("kotlinTab");
const swiftTab = document.getElementById("swiftTab");
const kotlinOutput = document.getElementById("kotlinOutput");
const swiftOutput = document.getElementById("swiftOutput");
kotlinTab.onclick = () => {
currentTab = 'kotlin';
kotlinTab.classList.add('active');
swiftTab.classList.remove('active');
kotlinOutput.style.display = 'block';
swiftOutput.style.display = 'none';
};
swiftTab.onclick = () => {
currentTab = 'swift';
swiftTab.classList.add('active');
kotlinTab.classList.remove('active');
swiftOutput.style.display = 'block';
kotlinOutput.style.display = 'none';
};
const migrateButton = document.getElementById("migrateButton");
migrateButton.onclick = () => {
const input = inputEditor.getValue();
if (!input.trim()) {
M.toast({ html: 'Please enter some configuration to convert', classes: 'orange' });
return;
}
try {
const kotlin = convertToKotlinConfig(input);
const swift = convertToSwiftConfig(input);
// Update Kotlin output
const kotlinCodeElement = kotlinOutput.querySelector('code');
kotlinCodeElement.textContent = kotlin;
kotlinCodeElement.removeAttribute('data-highlighted');
kotlinCodeElement.className = 'language-kotlin';
hljs.highlightElement(kotlinCodeElement);
// Update Swift output
const swiftCodeElement = swiftOutput.querySelector('code');
swiftCodeElement.textContent = swift;
swiftCodeElement.removeAttribute('data-highlighted');
swiftCodeElement.className = 'language-swift';
hljs.highlightElement(swiftCodeElement);
M.toast({ html: 'Configuration converted successfully!', classes: 'green' });
} catch (error) {
M.toast({ html: 'Error converting configuration: ' + error.message, classes: 'red' });
}
}
// Copy to clipboard functionality
const copyButton = document.getElementById("copyButton");
copyButton.onclick = () => {
const activeOutput = currentTab === 'kotlin' ? kotlinOutput : swiftOutput;
const codeElement = activeOutput.querySelector('code');
const codeText = codeElement ? codeElement.textContent : activeOutput.textContent;
if (!codeText.trim()) {
M.toast({ html: 'Nothing to copy', classes: 'orange' });
return;
}
navigator.clipboard.writeText(codeText).then(() => {
M.toast({ html: 'Copied to clipboard!', classes: 'green' });
}).catch(() => {
M.toast({ html: 'Failed to copy to clipboard', classes: 'red' });
});
}
});
</script>
</head>
<body>
<div class="container main-container">
<div class="row">
<div class="col s12">
<div class="card">
<div class="card-content">
<div class="card-title center-align">
<i class="material-icons feature-icon large teal-text">settings</i>
<h4>Config.json to BBConfiguration Converter</h4>
<p class="grey-text">Transform your JSON configuration files into Kotlin or Swift BBConfiguration format</p>
</div>
<div class="row">
<div class="col s12">
<div class="section-title">
<i class="material-icons feature-icon">code</i>
Input JSON Configuration
</div>
<div class="input-field">
<textarea id="input" style="display: none;" placeholder="Loading example configuration..."></textarea>
</div>
</div>
</div>
<div class="center-align">
<button id="migrateButton" class="btn-large waves-effect waves-light teal">
<i class="material-icons left">transform</i>
Convert Configuration
</button>
</div>
<div class="output-section" id="outputSection" style="display: none;">
<div class="section-title">
<i class="material-icons feature-icon">code</i>
Generated BBConfiguration
<button id="copyButton" class="btn-small waves-effect waves-light blue right">
<i class="material-icons left">content_copy</i>
Copy
</button>
</div>
<!-- Tabs -->
<div class="row">
<div class="col s12">
<div class="custom-tabs">
<button class="tab-button active" id="kotlinTab">
<i class="material-icons left">android</i>Kotlin
</button>
<button class="tab-button" id="swiftTab">
<i class="material-icons left">phone_iphone</i>Swift
</button>
</div>
</div>
</div>
<!-- Tab Content -->
<div id="kotlinOutput" class="tab-content">
<pre><code class="language-kotlin"></code></pre>
</div>
<div id="swiftOutput" class="tab-content" style="display: none;">
<pre><code class="language-swift"></code></pre>
</div>
</div>
</div>
</div>
</div>
</div>
<!-- Features Section -->
<div class="row">
<div class="col s12 m4">
<div class="card">
<div class="card-content center-align">
<i class="material-icons large teal-text">speed</i>
<h5>Fast Conversion</h5>
<p>Instantly convert your JSON configuration files to Kotlin or Swift BBConfiguration format</p>
</div>
</div>
</div>
<div class="col s12 m4">
<div class="card">
<div class="card-content center-align">
<i class="material-icons large teal-text">code</i>
<h5>Multi-Platform</h5>
<p>Generate clean, readable code for both Android (Kotlin) and iOS (Swift) projects</p>
</div>
</div>
</div>
<div class="col s12 m4">
<div class="card">
<div class="card-content center-align">
<i class="material-icons large teal-text">content_copy</i>
<h5>Easy Copy</h5>
<p>One-click copy to clipboard functionality for seamless workflow integration</p>
</div>
</div>
</div>
</div>
</div>
<!-- Materialize JavaScript -->
<script src="https://cdnjs.cloudflare.com/ajax/libs/materialize/1.0.0/js/materialize.min.js"></script>
<script>
// Show output section when conversion is done
document.addEventListener("DOMContentLoaded", function () {
const originalMigrateFunction = document.getElementById("migrateButton").onclick;
document.getElementById("migrateButton").onclick = function () {
const result = originalMigrateFunction();
const outputSection = document.getElementById("outputSection");
const kotlinOutput = document.getElementById("kotlinOutput");
const kotlinCodeElement = kotlinOutput.querySelector('code');
const hasContent = kotlinCodeElement ? kotlinCodeElement.textContent.trim() : false;
if (hasContent) {
outputSection.style.display = 'block';
outputSection.scrollIntoView({ behavior: 'smooth' });
}
return result;
};
});
</script>
</body>
</html>