Skip to content

Commit 6de7925

Browse files
committed
✨ added import and export for watched content & progress
1 parent e1eeced commit 6de7925

File tree

3 files changed

+97
-0
lines changed

3 files changed

+97
-0
lines changed

css/styles.css

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -344,6 +344,7 @@ body {
344344
line-height: 1.3;
345345
display: -webkit-box;
346346
-webkit-line-clamp: 2;
347+
line-clamp: 2;
347348
-webkit-box-orient: vertical;
348349
overflow: hidden;
349350
}
@@ -419,6 +420,53 @@ body {
419420
background-color: var(--bg-hover);
420421
}
421422

423+
.export-import-group {
424+
display: flex;
425+
gap: 1rem;
426+
flex-wrap: wrap;
427+
justify-content: center;
428+
align-items: center;
429+
margin: 2rem 0;
430+
}
431+
432+
.export-import-group .btn {
433+
min-width: 180px;
434+
justify-content: center;
435+
font-size: 1rem;
436+
padding: 0.85rem 1.5rem;
437+
border-radius: var(--border-radius-large);
438+
box-shadow: 0 2px 8px rgba(var(--accent-rgb), 0.10);
439+
transition: box-shadow 0.2s, background 0.2s, color 0.2s;
440+
}
441+
442+
.export-import-group .btn-primary {
443+
background: var(--gradient-primary);
444+
color: #fff;
445+
border: 1px solid var(--accent);
446+
}
447+
448+
.export-import-group .btn-primary:hover {
449+
background: var(--gradient-hover);
450+
color: #fff;
451+
box-shadow: 0 4px 16px rgba(var(--accent-rgb), 0.18);
452+
}
453+
454+
.export-import-group .btn-secondary {
455+
background: var(--bg-card);
456+
color: var(--accent);
457+
border: 1px solid var(--border);
458+
}
459+
460+
.export-import-group .btn-secondary:hover {
461+
background: var(--border);
462+
color: #fff;
463+
border-color: var(--accent);
464+
}
465+
466+
.export-import-group input[type="file"] {
467+
display: none;
468+
}
469+
422470
.rating-filter {
423471
display: flex;
424472
align-items: center;

index.html

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,16 @@ <h3>Films populaires</h3>
5151
<h3>Séries populaires</h3>
5252
<div class="content-grid" id="popularSeries"></div>
5353
</div>
54+
55+
<div class="export-import-group">
56+
<button class="btn btn-primary" id="exportWatchedBtn">
57+
<i class="fas fa-download"></i> Exporter ma progression
58+
</button>
59+
<label class="btn btn-secondary" style="cursor:pointer;">
60+
<i class="fas fa-upload"></i> Importer ma progression
61+
<input type="file" id="importWatchedInput" accept=".json" style="display:none;">
62+
</label>
63+
</div>
5464
</div>
5565
</section>
5666

js/scripts.js

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,45 @@ document.addEventListener('DOMContentLoaded', async () => {
5555
showSection('home');
5656
populateFilters();
5757
displayPopularContent();
58+
59+
const exportBtn = document.getElementById('exportWatchedBtn');
60+
const importInput = document.getElementById('importWatchedInput');
61+
if (exportBtn) {
62+
exportBtn.addEventListener('click', () => {
63+
const data = localStorage.getItem('watchedContent') || '{"films":{},"series":{}}';
64+
const blob = new Blob([data], {type: 'application/json'});
65+
const url = URL.createObjectURL(blob);
66+
const a = document.createElement('a');
67+
a.href = url;
68+
a.download = 'streamit_progression.json';
69+
document.body.appendChild(a);
70+
a.click();
71+
document.body.removeChild(a);
72+
URL.revokeObjectURL(url);
73+
});
74+
}
75+
if (importInput) {
76+
importInput.addEventListener('change', (e) => {
77+
const file = e.target.files[0];
78+
if (!file) return;
79+
const reader = new FileReader();
80+
reader.onload = function(evt) {
81+
try {
82+
const imported = JSON.parse(evt.target.result);
83+
if (imported.films && imported.series) {
84+
localStorage.setItem('watchedContent', JSON.stringify(imported));
85+
alert('Progression importée avec succès !');
86+
location.reload();
87+
} else {
88+
alert('Fichier invalide.');
89+
}
90+
} catch {
91+
alert('Erreur lors de l\'import.');
92+
}
93+
};
94+
reader.readAsText(file);
95+
});
96+
}
5897
});
5998

6099
async function loadData() {

0 commit comments

Comments
 (0)