-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.html
359 lines (317 loc) · 13.4 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
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
<!DOCTYPE html>
<html lang="tr">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Fatrocu</title>
<script src="https://cdnjs.cloudflare.com/ajax/libs/xlsx/0.18.5/xlsx.full.min.js"></script>
<link rel="stylesheet" href="style.css">
<style>
/* Navbar CSS */
.navbar {
display: flex;
justify-content: space-between;
align-items: center;
background-color: #181818;
padding: 10px 20px;
}
.navbar a {
color: white;
text-decoration: none;
padding: 10px;
transition: background-color 0.3s;
}
.navbar a:hover {
background-color: #575757;
}
.navbar .logo {
font-size: 1.5rem;
font-weight: bold;
}
.navbar .nav-links {
display: flex;
gap: 20px;
}
/* Toggle Switch CSS */
.toggle-container {
display: flex;
justify-content: center;
align-items: center;
margin: 20px 0;
}
.toggle-container label {
margin: 0 10px;
font-weight: bold;
}
.toggle {
display: inline-block;
width: 60px;
height: 34px;
position: relative;
}
.toggle input {
display: none;
}
.slider {
position: absolute;
top: 0;
left: 0;
right: 0;
bottom: 0;
background-color: #ccc;
border-radius: 34px;
cursor: pointer;
transition: 0.4s;
}
.slider:before {
position: absolute;
content: "";
height: 26px;
width: 26px;
background-color: white;
border-radius: 50%;
bottom: 4px;
left: 4px;
transition: 0.4s;
}
input:checked + .slider {
background-color: #4CAF50;
}
input:checked + .slider:before {
transform: translateX(26px);
}
/* Theme Styles */
body.light-theme {
background-color: #f4f4f4;
color: #333;
}
body.dark-theme {
background-color: #333;
color: #f4f4f4;
}
/* Language Select */
.language-select {
font-size: 1rem;
padding: 5px;
background-color: #333;
color: white;
border: none;
border-radius: 5px;
cursor: pointer;
}
.language-select:focus {
outline: none;
}
.action-buttons {
display: flex;
gap: 10px;
align-items: center;
}
.action-buttons button {
padding: 5px 10px;
font-size: 1rem;
background-color: #4CAF50;
color: white;
border: none;
border-radius: 5px;
cursor: pointer;
}
.action-buttons button:hover {
background-color: #45a049;
}
#invoiceName {
width: 100%;
max-width: 1500px;
padding: 8px;
font-size: 16px;
box-sizing: border-box;
}
</style>
</head>
<body>
<!-- Navbar -->
<nav class="navbar">
<div class="logo">Fatrocu</div>
<div class="nav-links">
<a href="settings.html" id="settingsLink">Settings</a>
<div class="action-buttons">
<select class="language-select" id="languageSelect">
<option value="tr">Türkçe</option>
<option value="en">English</option>
</select>
<button id="saveButton">Save</button>
</div>
</div>
</nav>
<!-- Main Content -->
<h1 id="mainTitle">Fatrocu</h1>
<div>
<label for="invoiceName" id="invoiceLabel">Seller/Buyer Name:</label>
<input type="text" id="invoiceName" placeholder="Enter the name of the company/person (seller for income, buyer for expenses)">
<div>
<label>Type of Invoice:</label>
<input type="radio" name="invoiceType" value="expense" id="expense" checked>
<label for="expense">Expense</label>
<input type="radio" name="invoiceType" value="income" id="income">
<label for="income">Income</label>
</div>
</div>
<div id="dropArea">Drag invoices here or click to select</div>
<input type="file" id="fileInput" style="display: none;" multiple accept="image/*,.pdf">
<div id="fileList"></div>
<div id="progressBar"><div></div></div>
<button id="analyzeButton" disabled>Analyze</button>
<script src="script.js"></script>
<script src="https://cdn.jsdelivr.net/npm/i18next@21.6.4/i18next.min.js"></script>
<script>
// Sayfa yüklendiğinde tema ve dil ayarlarını yükle
document.addEventListener('DOMContentLoaded', () => {
// Tema ayarlarını yükle
const savedTheme = localStorage.getItem('theme') || 'light';
document.body.classList.add(savedTheme === 'dark' ? 'dark-theme' : 'light-theme');
// Dil ayarlarını yükle
const savedLanguage = localStorage.getItem('language') || 'en'; // Varsayılan olarak İngilizce
i18next.init({
lng: savedLanguage,
resources: {
en: {
translation: {
"mainTitle": "Fatrocu",
"invoiceLabel": "Seller/Buyer Name:",
"dropArea": "Drag invoices here or click to select",
"analyzeButton": "Analyze",
"settingsLink": "Settings",
"saveButton": "Save",
"invoiceTypeLabel": "Type of Invoice:",
"expense": "Expense",
"income": "Income"
}
},
tr: {
translation: {
"mainTitle": "Fatrocu",
"invoiceLabel": "Satıcı/Alıcı Adı:",
"dropArea": "Faturaları buraya sürükleyin veya tıklayarak seçin",
"analyzeButton": "Analiz Et",
"settingsLink": "Ayarlar",
"saveButton": "Kaydet",
"invoiceTypeLabel": "Fatura Türü:",
"expense": "Gider",
"income": "Gelir"
}
}
}
}, () => {
document.querySelector("h1").innerText = i18next.t('mainTitle');
document.querySelector("label[for='invoiceName']").innerText = i18next.t('invoiceLabel');
document.getElementById("dropArea").innerText = i18next.t('dropArea');
document.getElementById("analyzeButton").innerText = i18next.t('analyzeButton');
document.getElementById("settingsLink").innerText = i18next.t('settingsLink');
document.getElementById("saveButton").innerText = i18next.t('saveButton');
document.getElementById("invoiceTypeLabel").innerText = i18next.t('invoiceTypeLabel');
document.querySelectorAll("label[for='expense']").forEach(label => label.innerText = i18next.t('expense'));
document.querySelectorAll("label[for='income']").forEach(label => label.innerText = i18next.t('income'));
// Dil seçeneğini güncelle
languageSelect.value = savedLanguage; // Sayfa yüklendiğinde doğru dil seçilsin
});
});
// Dil değişikliği
const languageSelect = document.getElementById("languageSelect");
// Sayfa yüklendiğinde önceki sıralamayı ve dil seçim bilgisini al
window.addEventListener('load', () => {
const storedLanguage = localStorage.getItem('language');
const storedOrder = localStorage.getItem('order'); // Sıralama bilgisini al
if (storedLanguage) {
languageSelect.value = storedLanguage;
reorderLanguageOptions(storedLanguage, storedOrder); // Sıralamayı ve dili uygula
} else {
// Eğer önceki dil yoksa, varsayılan olarak Türkçe'yi seç
languageSelect.value = 'tr';
reorderLanguageOptions('tr', storedOrder);
}
// Dil değiştirildiğinde sıralamayı kaydet
languageSelect.addEventListener("change", (event) => {
const language = event.target.value;
const currentOrder = getCurrentOrder(language); // Güncel sıralama bilgisini al
localStorage.setItem('language', language);
localStorage.setItem('order', currentOrder); // Sıralamayı kaydet
reorderLanguageOptions(language, currentOrder); // Sıralamayı uygula
// i18next dil değişikliği
i18next.changeLanguage(language, () => {
document.querySelector("h1").innerText = i18next.t('mainTitle');
document.querySelector("label[for='invoiceName']").innerText = i18next.t('invoiceLabel');
document.getElementById("dropArea").innerText = i18next.t('dropArea');
document.getElementById("analyzeButton").innerText = i18next.t('analyzeButton');
document.getElementById("settingsLink").innerText = i18next.t('settingsLink');
document.getElementById("saveButton").innerText = i18next.t('saveButton');
document.getElementById("invoiceTypeLabel").innerText = i18next.t('invoiceTypeLabel');
document.querySelectorAll("label[for='expense']").forEach(label => label.innerText = i18next.t('expense'));
document.querySelectorAll("label[for='income']").forEach(label => label.innerText = i18next.t('income'));
});
});
});
// Dil sırasını güncelleyen fonksiyon
function reorderLanguageOptions(selectedLanguage, storedOrder) {
const options = languageSelect.options;
const optionEn = options[1]; // English
const optionTr = options[0]; // Türkçe
// Eğer sıralama bilgisi varsa, sıralamayı uygula
if (storedOrder) {
const order = storedOrder.split(','); // "," ile ayırarak sıralama bilgilerini al
if (order[0] === 'en') {
languageSelect.insertBefore(optionEn, optionTr);
} else {
languageSelect.insertBefore(optionTr, optionEn);
}
} else {
// Eğer sıralama yoksa, default sıralamayı uygula
if (selectedLanguage === 'en') {
languageSelect.insertBefore(optionEn, optionTr);
} else {
languageSelect.insertBefore(optionTr, optionEn);
}
}
}
// Güncel sıralama bilgisini al
function getCurrentOrder(selectedLanguage) {
if (selectedLanguage === 'en') {
return 'en,tr'; // İngilizce önce
} else {
return 'tr,en'; // Türkçe önce
}
}
// Tema değişikliği
document.getElementById("themeToggle").addEventListener('change', (e) => {
const newTheme = e.target.checked ? 'dark' : 'light';
localStorage.setItem('theme', newTheme);
document.body.classList.toggle('dark-theme', newTheme === 'dark');
});
// Dosya yükleme ve analiz etme işlemleri
document.getElementById('fileInput').addEventListener('change', handleFileSelect);
document.getElementById('analyzeButton').addEventListener('click', analyzeFiles);
function handleFileSelect(event) {
const files = event.target.files;
const fileList = document.getElementById('fileList');
fileList.innerHTML = '';
for (let i = 0; i < files.length; i++) {
const li = document.createElement('li');
li.innerText = files[i].name;
fileList.appendChild(li);
}
}
function analyzeFiles() {
// Dosyaları analiz et
const progressBar = document.getElementById('progressBar');
progressBar.style.display = 'block';
let progress = 0;
const interval = setInterval(() => {
progress += 10;
progressBar.querySelector('div').style.width = `${progress}%`;
if (progress === 100) {
clearInterval(interval);
}
}, 100);
}
</script>
</body>
</html>