Skip to content

Commit 44ffcfa

Browse files
authored
Update embed.js
1 parent c76bfcd commit 44ffcfa

File tree

1 file changed

+3
-61
lines changed

1 file changed

+3
-61
lines changed

embed.js

Lines changed: 3 additions & 61 deletions
Original file line numberDiff line numberDiff line change
@@ -259,55 +259,8 @@
259259
}
260260

261261

262-
function saveGameToHistory(game) {
263-
let history = JSON.parse(localStorage.getItem('gameHistory')) || [];
264-
history = history.filter(item => item.alt !== game.alt);
265-
history.unshift(game); // Add to the beginning
266-
// 10 games limit
267-
history = history.slice(0, 10);
268-
localStorage.setItem('gameHistory', JSON.stringify(history));
269-
displayGameHistory();
270-
}
271-
272-
273-
function displayGameHistory() {
274-
const historyContainer = document.getElementById('gameHistoryContainer');
275-
const noHistoryMessage = document.getElementById('noHistoryMessage');
276-
277-
278-
if (!historyContainer || !noHistoryMessage) {
279-
console.warn("History container or no history message element not found, skipping history display.");
280-
return;
281-
}
282-
283-
const history = JSON.parse(localStorage.getItem('gameHistory')) || [];
284-
285-
if (history.length === 0) {
286-
noHistoryMessage.classList.remove('hidden');
287-
historyContainer.innerHTML = ''; // delete the mf history
288-
} else {
289-
noHistoryMessage.classList.add('hidden');
290-
historyContainer.innerHTML = history.map(game => `
291-
<div
292-
onclick="opengame('${game.apiUrl}', '${game.alt}', '${game.title}')"
293-
class="flex items-center justify-between p-3 mb-2 rounded-lg cursor-pointer hover:bg-gray-100 transition-colors duration-200 outline outline-1 outline-offset-1 outline-gray-200"
294-
>
295-
<span class="font-medium">${game.title}</span>
296-
<i data-lucide="play" class="w-5 h-5 text-blue-500"></i>
297-
</div>
298-
`).join('');
299-
}
300-
301-
lucide.createIcons(); //naw
302-
}
303262

304263

305-
function clearGameHistory() {
306-
localStorage.removeItem('gameHistory');
307-
displayGameHistory();
308-
showMessage('Game history cleared!');
309-
}
310-
311264
// themes
312265

313266
function setTheme(themeName) {
@@ -352,7 +305,7 @@
352305
//sidebar logic
353306

354307
function showSection(sectionId) {
355-
const sections = ['gameContainer', 'gameHistorySection', 'settingsSection'];
308+
const sections = ['gameContainer', 'settingsSection'];
356309
const searchSortSection = document.getElementById('searchSortSection');
357310
const paginationControls = document.getElementById('paginationControls');
358311

@@ -391,8 +344,6 @@
391344
});
392345
if (sectionId === 'gameContainer') {
393346
document.getElementById('navHomeBtn').classList.add('active');
394-
} else if (sectionId === 'gameHistorySection') {
395-
document.getElementById('navHistoryBtn').classList.add('active');
396347
} else if (sectionId === 'settingsSection') {
397348
document.getElementById('navSettingsBtn').classList.add('active');
398349
}
@@ -415,7 +366,6 @@
415366
// Sidebar
416367

417368
document.getElementById('navHomeBtn').addEventListener('click', () => showSection('gameContainer'));
418-
document.getElementById('navHistoryBtn').addEventListener('click', () => { showSection('gameHistorySection'); displayGameHistory(); });
419369
document.getElementById('navSettingsBtn').addEventListener('click', () => showSection('settingsSection'));
420370

421371

@@ -461,9 +411,6 @@
461411
opengame(gameToOpen.apiUrl, gameToOpen.alt, gameToOpen.title);
462412
} else {
463413
showMessage('Game not found.');
464-
if (window.location.protocol !== 'blob:') {
465-
history.replaceState({}, document.title, window.location.pathname);
466-
}
467414
}
468415
}
469416

@@ -490,12 +437,9 @@
490437

491438

492439
if (window.location.protocol !== 'blob:') {
493-
const newUrl = `${window.location.pathname}?id=${alt}`;
494-
history.pushState({ gameAlt: alt }, title, newUrl);
495-
}
440+
const newUrl = `${window.location.pathname}?id=${alt}`; }
496441

497442

498-
saveGameToHistory({ apiUrl, alt, title });
499443
};
500444

501445

@@ -508,9 +452,7 @@
508452
gamePageContainer.classList.remove("flex");
509453
document.body.style.overflow = '';
510454

511-
if (window.location.protocol !== 'blob:') {
512-
history.replaceState({}, document.title, window.location.pathname);
513-
}
455+
514456
};
515457

516458

0 commit comments

Comments
 (0)