-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.html
321 lines (274 loc) · 13.2 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
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
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
<!DOCTYPE html>
<html>
<head>
<title>Textio</title>
<meta name="version" content="1.25">
<!--<base href="/textio/">-->
<script>
if (window.location.protocol === "file:") {
// Local file system, set base to current directory
const baseElement = document.createElement('base');
baseElement.href = './';
document.head.appendChild(baseElement);
} else {
// Deployed, set base to /textio/
const baseElement = document.createElement('base');
baseElement.href = '/textio/';
document.head.appendChild(baseElement);
}
</script>
<script src="libs/js-yaml/4.1.0/js-yaml.min.js"></script>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<meta name="mobile-web-app-capable" content="yes">
<meta name="theme-color" content="#000000">
<link rel="manifest" href="manifest.json">
<link rel="icon" type="image/png" href="assets/favicons/textio.png">
<link rel="stylesheet" href="style.css">
<script>
if ('serviceWorker' in navigator) {
navigator.serviceWorker
.register('service-worker.js') // Correct the hyphen here
.then(function() {
console.log("Service Worker Registered");
})
.catch(function(error) {
console.error("Service Worker Registration Failed:", error); // Add error handling
});
}
window.addEventListener('DOMContentLoaded', async () => {
const urlParams = new URLSearchParams(window.location.search);
// Fetch the main textarea element
const textareaMain = document.getElementById('textareaMain');
if (!textareaMain) {
console.error('textareaMain element not found.');
return;
}
// Handle shared content (title, text, and URL)
const sharedTitle = urlParams.get('title');
const sharedText = urlParams.get('text');
const sharedUrl = urlParams.get('url');
let finalText = ''; // Accumulate shared content
if (sharedTitle) {
finalText += `${sharedTitle}\n`;
console.log('sharedTitle:', sharedTitle);
}
if (sharedText) {
finalText += `${sharedText}\n`;
console.log('sharedText:', sharedText);
}
if (sharedUrl) {
finalText += `${sharedUrl}\n`;
console.log('sharedUrl:', sharedUrl);
}
// Set shared content in textareaMain if present
if (finalText) {
textareaMain.value = finalText;
}
// Handle file opening (via fileHandler parameter)
if (urlParams.has('fileHandler')) {
try {
// Fetch the file content sent via the file handler
const response = await fetch(window.location.href);
const fileContent = await response.text();
// Append or overwrite the content in the main textarea
textareaMain.value = fileContent;
} catch (error) {
console.error('Failed to read file content:', error);
}
}
});
</script>
</head>
<body>
<main>
<!-- Home Screen -->
<div class="screen" id="home-screen">
<section>
<nav>
<input id="fileInputHidden" type='file' style="visibility:hidden;display:none;" onchange="fileManager.readFile(event)" />
<button id="historyBack" disabled>Step back</button>
<button id="resetEditor">New</button>
<select id="navButtonsOpen" onChange="if(this.value){eval(this.value)}; this.selectedIndex = '0'; this.blur();" style="max-width:85px">
<option value="">-Open-</option>
<option value="fileManager.clickHiddenInput()">Open file</option>
<optgroup id="optgroupLcRecords" label="Open document (LS):"></optgroup>
<!--<option value="LoadFile('slovicka-en.txt')" value="">Open file from server</option>-->
</select>
<select id="saveOptions" onChange="if(this.value){eval(this.value)}; this.selectedIndex = '0'; this.blur();" class="mobile-dropdown" style="max-width: 55px;">
<option value="" disabled selected>Save</option>
<option value="docManager.overwriteOpened()">Save (overwrite)</option>
<option value="docManager.saveAsNew()">Save as new</option>
<option value="docManager.downloadFile()">Download</option>
</select>
<button id="btnSettings" onclick="uiManager.navigateToScreen('settings-screen')">Settings</button>
<br>
<span>Document: <em id="currentDocName"></em></span>
<span>Current step:<em id="currentStep">0</em></span>
</nav>
</section>
<section id="editor-textarea-main">
<textarea id="textareaMain"></textarea>
</section>
<section id="editor-buttons">
<select id="navButtonsTools" onChange="if(this.value){utils.callFunc(transformManager[this.value])}; this.selectedIndex = '0'; this.blur();" style="max-width:115px">
<option value="">-Transform-</option>
<option value="yamlToVocabulary">Vocabulary yaml to separated item</option>
<option value="parseAllXmlTagsFromDoc">Parse All Tags From Xml</option>
<option value="linesToList">Rows to List</option>
<option value="listToArray">List to Array</option>
<option value="listToLines">List to Rows</option>
<option value="sortList">Sort list</option>
<option value="removeSpaces">Remove spaces</option>
<option value="removeEmptyLines">Remove empty rows</option>
<option value="removeLineBreaks">Remove line breaks</option>
<option value="removeDiacritics">Remove diacritics</option>
<option value="encodeBase64">Encode Base64</option>
<option value="decodeBase64">Decode Base64</option>
<option value="convertToSlug">Convert to Slug</option>
<option value="parseMarkdownLinks">Parse markdown links</option>
<option value="increaseLineBreaks">TTS: increase line breaks</option>
<option value="editForTts">TTS: dot end, lowerCase, capitilize</option>
<option value="excelToJsonMap">2 excel columns to JSON map</option>
<option value="encodeUri">Encode URL</option>
<option value="decodeUri">Decode URL</option>
</select>
<select id="insertOptions" onChange="if(this.value){utils[this.value]()}; this.selectedIndex = '0'; this.blur();" class="mobile-dropdown" style="max-width: 60px;">
<option value="" disabled selected>Insert</option>
<option value="insertDate">Date</option>
<option value="insertSeparator">Separator</option>
<option value="insertFieldSeparator">Field Separator</option>
<option value="insertRandomId">Random id</option>
</select>
<button onclick="uiManager.openModal('replaceFeature')">Replace text</button>
<br>
<button id="processDocData" class='orange' onclick="flashcardsManager.processDoc()">Doc to flash cards</button>
<br>
<button id="btnToggleTtsSection" onclick="uiManager.toggleVisibility('#tts-controls', this.id)">Show speech</button>
</section>
<section id="tts-controls" class="expandable-section" style="display: none;">
<nav>
Voice:
<select id="tts-voices"></select></br>
Rate:
<select id="tts-rate">
<option value="0.3">very slow</option>
<option value="0.6">slow</option>
<option value="1" selected>normal</option>
<option value="1.5">fast</option>
<option value="1.8">very fast</option>
</select>
Pitch:
<select id="tts-pitch">
<option value="0">low</option>
<option value="1" selected>normal</option>
<option value="2">high</option>
</select></br>
Flash cards auto-speak:
<input type="checkbox" id="checkbox-auto-speak">
<br>
<br>
<button id="tts-play" onclick="ttsManager.speak(elements.editor.main.value)">Speak</button>
<button id="tts-reset" onclick="ttsManager.stop()">Stop</button>
<br>
</naV>
</section>
<section id="customCode" class="hidden">
<textarea id="textareaEval"></textarea>
<button onclick="evalManager.executeScript()">Execute custom script</button>
</section>
<section id="logs" class="hidden">
<textarea id="textarea-logs"></textarea>
</section>
</div>
<!-- Flashcards Screen -->
<div class="screen hidden" id="flashcards-screen">
<div class="back-btn" onclick="flashcardsManager.cleanup(); uiManager.navigateToScreen('home-screen'); ttsManager.stop();">Back</div>
<div class="flashcards-counter">
<span id="currentCardIndex">0</span> / <span id="totalCards">0</span>
</div>
<div class="flashcards-content">
<div class="card-front"></div>
<div class="card-back"></div>
</div>
<div class="flashcards-controls">
<button onclick="flashcardsManager.navigate('previous')">Previous</button>
<button onclick="flashcardsManager.navigate('next')">Next</button>
<br>
<button onclick="flashcardsManager.turnCard()">Turn</button>
<br>
<button onclick="ttsManager.speak(flashcardsManager.currentCard[0])">Read aloud</button>
<br>
</div>
</div>
<!-- Settings Screen -->
<div class="screen hidden" id="settings-screen">
<div class="screen-container">
<div class="back-btn" onclick="uiManager.navigateToScreen('home-screen')">Back</div>
<h2 class="screen-title">Settings</h2>
<div class="row"><input type="checkbox" id="showCustomCode"> <label for="showCustomCode">Show custom code</label></div>
<div class="row"><input type="checkbox" id="showLogs"> <label for="showLogs">Show logs</label></div>
<div class="row"><button class="btn-outline" id="removeDoc">Remove document</button></div>
<div class="row"><button class="btn-outline" onclick="docManager.exportData()">Export data</button></div>
<div class="row"><button class="btn-outline" onclick="docManager.importData()">Import data</button></div>
<div class="row"><button class="btn-outline" onclick="docManager.removeAllDocs()">Remove app data</button></div>
</div>
</div>
<!-- Items Processing Screen -->
<div class="screen hidden" id="items-processing-screen">
<div class="screen-container">
<div class="back-btn" onclick="navigateToScreen('home-screen')"></div>
<h2 class="screen-title">Items data processing</h2>
<div class="row"><input type="checkbox" id="showCustomCode"> <label for="showCustomCode">Show custom code</label></div>
<div class="row"><input type="checkbox" id="showLogs"> <label for="showLogs">Show logs</label></div>
<div class="row"><button class="btn-outline" id="removeDoc">Remove document</button></div>
<div class="row"><button class="btn-outline" onclick="exportData()">Export data</button></div>
<div class="row"><button class="btn-outline" onclick="importData()">Import data</button></div>
<div class="row"><button class="btn-outline" onclick="RemoveAppData()">Remove app data</button></div>
</div>
</div>
<!-- Modals -->
<div id="universalModal" class="modal hidden">
<div class="modal-overlay" onclick="uiManager.closeModal()"></div>
<div class="modal-content">
<button class="modal-close" onclick="uiManager.closeModal()">×</button>
<div class="modal-body">
<!-- Replace Feature Modal Content -->
<div id="replaceFeature" class="hidden">
<h3>Replace Text</h3>
<div class="input-container">
<input type="text" id="oldText" placeholder="Text to be replaced" />
<span></span>
<button class="clear-input">×</button>
</div>
<div class="input-container">
<input type="text" id="newText" placeholder="Replacing text" />
<button class="clear-input">×</button>
</div>
<button onclick="transformManager.replaceText()">Replace</button>
</div>
<!-- Tag Selection Modal Content -->
<div id="tagSelectionModal" class="hidden">
<h3>Select XML Tag</h3>
<div class="card-list" id="parsedTagCards"></div>
</div>
<!-- Field Mapping Modal Content -->
<div id="fieldMappingModal" class="hidden">
<h3>Map Fields for Flashcards</h3>
<div class="field-mapping-container"></div>
</div>
<!-- Other modal features here -->
</div>
</div>
</div>
<!-- Dialogs -->
<dialog id="testDialog">
<div class="dialog-content">
<button class="modal-close">×</button>
<p>This is a dialog.</p>
</div>
</dialog>
</main>
<script src="app.js"></script>
</body>
</html>