-
Notifications
You must be signed in to change notification settings - Fork 0
/
import.html
80 lines (80 loc) · 2.69 KB
/
import.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
<!DOCTYPE html>
<html>
<head>
<title>Import Dictionary</title>
<style>
body {
font-family: Arial, sans-serif;
margin: 20px;
}
label {
display: block;
margin-bottom: 10px;
}
input, select, button {
display: block;
margin-bottom: 20px;
width: 100%;
padding: 10px;
font-size: 16px;
}
.instructions {
font-size: 14px;
margin-bottom: 20px;
padding: 10px;
background-color: #f9f9f9;
border: 1px solid #ddd;
}
</style>
</head>
<body>
<h1>Import Dictionary</h1>
<div class="instructions">
<h2>Instructions</h2>
<p>Your custom dictionary file should be a text file with the following format:</p>
<pre>
word1 - translation1
word2 - translation2
...
</pre>
<p>Each line should contain a word and its translation, separated by a hyphen. Make sure there are no empty lines.</p>
</div>
<label for="dictionaryName">Dictionary Name:</label>
<input type="text" id="dictionaryName" placeholder="Enter dictionary name" required>
<label for="language">Language:</label>
<select id="language">
<option value="en">English</option>
<option value="de">German</option>
<option value="fr">French</option>
</select>
<label for="fromLanguage">From Language:</label>
<select id="fromLanguage">
<option value="en">English</option>
<option value="de">German</option>
<option value="fr">French</option>
<option value="ru">Russian</option>
</select>
<label for="file">Select Dictionary File:</label>
<input type="file" id="file" accept=".txt">
<button id="importButton">Import</button>
<script>
const { ipcRenderer } = require('electron');
document.getElementById('importButton').addEventListener('click', async () => {
const dictionaryName = document.getElementById('dictionaryName').value;
const language = document.getElementById('language').value;
const fromLanguage = document.getElementById('fromLanguage').value;
const file = document.getElementById('file').files[0];
if (dictionaryName && language && fromLanguage && file) {
const result = await ipcRenderer.invoke('import-dictionary', file.path, dictionaryName, language, fromLanguage);
if (result.success) {
alert(`Dictionary ${result.dictionaryName} imported successfully.`);
} else {
alert(`Failed to import dictionary: ${result.error}`);
}
} else {
alert('Please fill in all fields and select a file.');
}
});
</script>
</body>
</html>