Changed around line 1
+ document.addEventListener('DOMContentLoaded', () => {
+ const attributes = ['brawn', 'finesse', 'resolve', 'wits', 'panache'];
+
+ // Initialize rating containers
+ attributes.forEach(attribute => {
+ const container = document.querySelector(`[data-attribute="${attribute}"]`);
+ for (let i = 0; i < 5; i++) {
+ const dot = document.createElement('div');
+ dot.className = 'rating-dot';
+ dot.setAttribute('data-index', i);
+ container.appendChild(dot);
+ }
+ });
+
+ // Handle rating clicks
+ document.querySelectorAll('.rating').forEach(rating => {
+ rating.addEventListener('click', (e) => {
+ if (e.target.classList.contains('rating-dot')) {
+ const dots = rating.querySelectorAll('.rating-dot');
+ const clickedIndex = parseInt(e.target.getAttribute('data-index'));
+
+ dots.forEach((dot, index) => {
+ dot.classList.toggle('filled', index <= clickedIndex);
+ });
+ }
+ });
+ });
+
+ // Save character
+ document.getElementById('saveButton').addEventListener('click', () => {
+ const character = {
+ name: document.getElementById('characterName').value,
+ player: document.getElementById('playerName').value,
+ attributes: {}
+ };
+
+ attributes.forEach(attribute => {
+ const filledDots = document.querySelectorAll(`[data-attribute="${attribute}"] .filled`).length;
+ character.attributes[attribute] = filledDots;
+ });
+
+ localStorage.setItem('character', JSON.stringify(character));
+ alert('Character saved!');
+ });
+
+ // Reset sheet
+ document.getElementById('resetButton').addEventListener('click', () => {
+ if (confirm('Are you sure you want to reset the character sheet?')) {
+ document.getElementById('characterName').value = '';
+ document.getElementById('playerName').value = '';
+ document.querySelectorAll('.rating-dot').forEach(dot => {
+ dot.classList.remove('filled');
+ });
+ localStorage.removeItem('character');
+ }
+ });
+
+ // Load saved character if exists
+ const savedCharacter = localStorage.getItem('character');
+ if (savedCharacter) {
+ const character = JSON.parse(savedCharacter);
+ document.getElementById('characterName').value = character.name;
+ document.getElementById('playerName').value = character.player;
+
+ attributes.forEach(attribute => {
+ const dots = document.querySelectorAll(`[data-attribute="${attribute}"] .rating-dot`);
+ dots.forEach((dot, index) => {
+ dot.classList.toggle('filled', index < character.attributes[attribute]);
+ });
+ });
+ }
+ });