feat: upgrade to SQLite session & data store with zero-data-loss migration, dark theme, and Turkish i18n
This commit is contained in:
parent
1af973d001
commit
56274f479b
27 changed files with 4222 additions and 1360 deletions
|
|
@ -18,6 +18,13 @@ document.addEventListener('DOMContentLoaded', () => {
|
|||
let currentSearch = '';
|
||||
let currentSubject = '';
|
||||
|
||||
function t(key, params) {
|
||||
if (typeof window.BeKulturT === 'function') {
|
||||
return window.BeKulturT(key, params);
|
||||
}
|
||||
return key;
|
||||
}
|
||||
|
||||
// Checkbox toggle
|
||||
if (assignmentList) {
|
||||
assignmentList.addEventListener('click', async (e) => {
|
||||
|
|
@ -26,7 +33,7 @@ document.addEventListener('DOMContentLoaded', () => {
|
|||
// Exclude / Restore button
|
||||
if (target.classList.contains('btn-exclude') || target.classList.contains('btn-disinclude')) {
|
||||
if (window.BeKulturPWA && window.BeKulturPWA.isOffline()) {
|
||||
alert('Çevrimdışı moddasınız. Ödev gizleme/geri alma işlemi için internet bağlantısı gereklidir.');
|
||||
alert(t('dashboard.offlineExcludeAlert'));
|
||||
return;
|
||||
}
|
||||
const assignmentId = target.dataset.id;
|
||||
|
|
@ -47,8 +54,8 @@ document.addEventListener('DOMContentLoaded', () => {
|
|||
if (data.success && data.stats) {
|
||||
card.dataset.excluded = newExcluded ? 'true' : 'false';
|
||||
card.classList.toggle('is-excluded', newExcluded);
|
||||
target.textContent = newExcluded ? 'Restore' : 'Exclude';
|
||||
target.title = newExcluded ? 'Restore this homework to your active list' : 'Exclude this homework (e.g. from another class)';
|
||||
target.textContent = newExcluded ? t('dashboard.btnRestore') : t('dashboard.btnExclude');
|
||||
target.title = newExcluded ? t('dashboard.btnRestoreTitle') : t('dashboard.btnExcludeTitle');
|
||||
|
||||
const checkbox = card.querySelector('.assignment-toggle');
|
||||
if (checkbox) checkbox.disabled = newExcluded;
|
||||
|
|
@ -59,7 +66,7 @@ document.addEventListener('DOMContentLoaded', () => {
|
|||
if (badgesContainer) {
|
||||
const b = document.createElement('span');
|
||||
b.className = 'badge badge-excluded';
|
||||
b.textContent = 'Excluded';
|
||||
b.textContent = t('dashboard.badgeExcluded');
|
||||
badgesContainer.insertBefore(b, target);
|
||||
}
|
||||
} else if (!newExcluded && badgeExcluded) {
|
||||
|
|
@ -84,7 +91,7 @@ document.addEventListener('DOMContentLoaded', () => {
|
|||
|
||||
if (window.BeKulturPWA && window.BeKulturPWA.isOffline()) {
|
||||
target.checked = !target.checked;
|
||||
alert('Çevrimdışı moddasınız. Ödev durumu internet bağlantısı olmadan değiştirilemez.');
|
||||
alert(t('dashboard.offlineToggleAlert'));
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
@ -131,21 +138,21 @@ document.addEventListener('DOMContentLoaded', () => {
|
|||
if (existingStatusBadge) {
|
||||
if (status === 'completed') {
|
||||
existingStatusBadge.className = 'badge badge-completed';
|
||||
existingStatusBadge.textContent = 'Done';
|
||||
existingStatusBadge.textContent = t('dashboard.badgeCompleted');
|
||||
} else {
|
||||
const orig = card.dataset.status;
|
||||
if (orig === 'next-week') {
|
||||
existingStatusBadge.className = 'badge badge-next-week';
|
||||
existingStatusBadge.textContent = 'Next Week';
|
||||
existingStatusBadge.textContent = t('dashboard.badgeNextWeek');
|
||||
} else if (orig === 'due-soon') {
|
||||
existingStatusBadge.className = 'badge badge-due-soon';
|
||||
existingStatusBadge.textContent = 'Due Soon';
|
||||
existingStatusBadge.textContent = t('dashboard.badgeDueSoon');
|
||||
} else if (orig === 'overdue') {
|
||||
existingStatusBadge.className = 'badge badge-overdue';
|
||||
existingStatusBadge.textContent = 'Overdue';
|
||||
existingStatusBadge.textContent = t('dashboard.badgeOverdue');
|
||||
} else {
|
||||
existingStatusBadge.className = 'badge badge-active';
|
||||
existingStatusBadge.textContent = 'Active';
|
||||
existingStatusBadge.textContent = t('dashboard.badgeActive');
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -162,7 +169,7 @@ document.addEventListener('DOMContentLoaded', () => {
|
|||
const statTotal = document.getElementById('statTotalCount');
|
||||
|
||||
if (statCompRate) statCompRate.textContent = `${stats.completionRate}%`;
|
||||
if (statCompFrac) statCompFrac.textContent = `${stats.completed} / ${stats.total} done`;
|
||||
if (statCompFrac) statCompFrac.textContent = `${stats.completed} / ${stats.total} ${t('dashboard.statDoneUnit')}`;
|
||||
if (progressBar) progressBar.style.width = `${stats.completionRate}%`;
|
||||
if (statActive) statActive.textContent = stats.active;
|
||||
if (statNextWeek) statNextWeek.textContent = stats.checkedNextWeek;
|
||||
|
|
@ -310,7 +317,7 @@ document.addEventListener('DOMContentLoaded', () => {
|
|||
});
|
||||
|
||||
if (filteredCountText) {
|
||||
filteredCountText.textContent = `Showing ${visibleCount} assignments`;
|
||||
filteredCountText.textContent = t('dashboard.showingCount', { count: visibleCount });
|
||||
}
|
||||
|
||||
if (noResults) {
|
||||
|
|
@ -322,12 +329,12 @@ document.addEventListener('DOMContentLoaded', () => {
|
|||
if (btnSyncRecent) {
|
||||
btnSyncRecent.addEventListener('click', async () => {
|
||||
if (window.BeKulturPWA && window.BeKulturPWA.isOffline()) {
|
||||
showAlert('Çevrimdışı moddasınız. Senkronizasyon için internet bağlantısı gereklidir.', 'danger');
|
||||
showAlert(t('dashboard.offlineSyncAlert'), 'danger');
|
||||
return;
|
||||
}
|
||||
btnSyncRecent.disabled = true;
|
||||
btnSyncRecent.textContent = 'Syncing...';
|
||||
showAlert('Fetching recent assignments...', 'info');
|
||||
btnSyncRecent.textContent = t('dashboard.syncing');
|
||||
showAlert(t('dashboard.fetchingRecent'), 'info');
|
||||
|
||||
try {
|
||||
const res = await fetch('/api/sync', { method: 'POST' });
|
||||
|
|
@ -335,14 +342,14 @@ document.addEventListener('DOMContentLoaded', () => {
|
|||
if (data.success) {
|
||||
window.location.reload();
|
||||
} else {
|
||||
showAlert(`Sync failed: ${data.error}`, 'danger');
|
||||
showAlert(`${t('dashboard.syncFailed')} ${data.error}`, 'danger');
|
||||
btnSyncRecent.disabled = false;
|
||||
btnSyncRecent.textContent = 'Sync Recent';
|
||||
btnSyncRecent.textContent = t('dashboard.syncRecent');
|
||||
}
|
||||
} catch (err) {
|
||||
showAlert('Network error while syncing.', 'danger');
|
||||
showAlert(t('dashboard.networkError'), 'danger');
|
||||
btnSyncRecent.disabled = false;
|
||||
btnSyncRecent.textContent = 'Sync Recent';
|
||||
btnSyncRecent.textContent = t('dashboard.syncRecent');
|
||||
}
|
||||
});
|
||||
}
|
||||
|
|
@ -350,12 +357,12 @@ document.addEventListener('DOMContentLoaded', () => {
|
|||
if (btnSyncAll) {
|
||||
btnSyncAll.addEventListener('click', async () => {
|
||||
if (window.BeKulturPWA && window.BeKulturPWA.isOffline()) {
|
||||
showAlert('Çevrimdışı moddasınız. Senkronizasyon için internet bağlantısı gereklidir.', 'danger');
|
||||
showAlert(t('dashboard.offlineSyncAlert'), 'danger');
|
||||
return;
|
||||
}
|
||||
btnSyncAll.disabled = true;
|
||||
btnSyncAll.textContent = 'Syncing all...';
|
||||
showAlert('Syncing full history from portal...', 'info');
|
||||
btnSyncAll.textContent = t('dashboard.syncingAll');
|
||||
showAlert(t('dashboard.fetchingAll'), 'info');
|
||||
|
||||
try {
|
||||
const res = await fetch('/api/sync-all', { method: 'POST' });
|
||||
|
|
@ -363,14 +370,14 @@ document.addEventListener('DOMContentLoaded', () => {
|
|||
if (data.success) {
|
||||
window.location.reload();
|
||||
} else {
|
||||
showAlert(`Sync all failed: ${data.error}`, 'danger');
|
||||
showAlert(`${t('dashboard.syncFailed')} ${data.error}`, 'danger');
|
||||
btnSyncAll.disabled = false;
|
||||
btnSyncAll.textContent = 'Sync Full History';
|
||||
btnSyncAll.textContent = t('dashboard.syncAll');
|
||||
}
|
||||
} catch (err) {
|
||||
showAlert('Network error while syncing full history.', 'danger');
|
||||
showAlert(t('dashboard.networkError'), 'danger');
|
||||
btnSyncAll.disabled = false;
|
||||
btnSyncAll.textContent = 'Sync Full History';
|
||||
btnSyncAll.textContent = t('dashboard.syncAll');
|
||||
}
|
||||
});
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue