yeah
All checks were successful
Deploy App / build (push) Successful in 10s
Deploy App / deploy (push) Successful in 11s

This commit is contained in:
valere
2026-02-02 21:00:28 +01:00
parent e257e076c4
commit b9a3d0184f
98 changed files with 5068 additions and 3713 deletions

View File

@@ -1,21 +0,0 @@
import type { CardSuit, CardRank } from '~/types/cards'
export function getCardFromDate(date: Date): { suit: CardSuit; rank: CardRank } {
const month = date.getMonth() + 1
const day = date.getDate()
const hour = date.getHours()
const suit: CardSuit =
month >= 12 || month <= 2
? '♠'
: month >= 3 && month <= 5
? '♥'
: month >= 6 && month <= 8
? '♦'
: '♣'
const ranks: CardRank[] = ['A', '2', '3', '4', '5', '6', '7', '8', '9', '10', 'J', 'Q', 'K']
const rank = ranks[(day + hour) % ranks.length]
return { suit, rank }
}

52
utils/tabManager.ts Normal file
View File

@@ -0,0 +1,52 @@
// Gestionnaire d'onglets pour les cartes NFC
export function openOrFocusCard(slug: string) {
const url = `${window.location.origin}/card/${slug}`
// Vérifier si un onglet est déjà ouvert
const isTabOpen = localStorage.getItem('nfc-active-tab') === 'true'
if (isTabOpen) {
// Si un onglet est déjà ouvert, on envoie un message pour le rafraîchir
const channel = new BroadcastChannel('nfc-channel')
channel.postMessage({
type: 'nfc-focus',
slug: slug,
timestamp: Date.now()
})
// On se concentre sur l'onglet existant
window.focus()
// On ferme le canal après un court délai
setTimeout(() => channel.close(), 1000)
// On empêche l'ouverture d'un nouvel onglet
return false
}
// Aucun onglet ouvert, on en ouvre un nouveau
window.open(url, '_blank')
return true
}
// Fonction pour formater l'URL à utiliser dans la carte NFC
export function getNfcCardUrl(slug: string): string {
return `javascript:(function(){
const url = '${window.location.origin}/card/${slug}';
const isTabOpen = localStorage.getItem('nfc-active-tab') === 'true';
if (isTabOpen) {
const channel = new BroadcastChannel('nfc-channel');
channel.postMessage({
type: 'nfc-focus',
slug: '${slug}',
timestamp: Date.now()
});
setTimeout(() => channel.close(), 1000);
window.focus();
window.location.href = url;
} else {
window.open(url, '_blank');
}
})();`
}