jQuery(document).ready(function($) { let userVotes = {}; function updateView() { if (djVotingSystem.isAdmin) { $('#pending-artists-heading').show(); $('#pending-artist-table').show(); $('.actions-column').show(); $('.edit-button, .delete-button').show(); } else { $('#pending-artists-heading').hide(); $('#pending-artist-table').hide(); $('.actions-column').hide(); $('.edit-button, .delete-button').hide(); } } function loadArtists() { $.ajax({ url: djVotingSystem.ajax_url, method: 'POST', data: { action: 'get_artists' }, success: function(response) { if (response.success) { const artists = response.data; $('#dj-vote-table-body').empty(); $('#pending-artist-table-body').empty(); artists.forEach(artist => { if (artist.status === 'pending' && djVotingSystem.isAdmin) { $('#pending-artist-table-body').append(createPendingArtistRow(artist)); } else if (artist.status === 'published') { $('#dj-vote-table-body').append(createArtistRow(artist)); } }); loadUserVotes(); } } }); } function loadUserVotes() { // Charger les votes de l'utilisateur depuis le stockage local userVotes = JSON.parse(localStorage.getItem('userVotes')) || {}; // Appliquer l'indicateur visuel pour les votes existants Object.keys(userVotes).forEach(artistId => { const voteType = userVotes[artistId]; $(`.vote-button[data-artist-id="${artistId}"][data-vote-type="${voteType}"]`).addClass('selected-vote'); }); } function createArtistRow(artist) { return ` ${artist.name} ${artist.name} ${artist.music_style} ${artist.artist_type} ${artist.votes} ${djVotingSystem.isAdmin ? ` ` : ''} `; } function createPendingArtistRow(artist) { return ` ${artist.name} ${artist.name} ${artist.music_style} ${artist.artist_type} ${artist.url} `; } $('#new-artist-form').on('submit', function(e) { e.preventDefault(); const artistName = $('#artist-name').val().trim(); const musicStyle = $('#music-style').val().trim(); const artistType = $('#artist-type').val().trim(); const artistUrl = $('#artist-url').val().trim(); const artistPhoto = $('#artist-photo')[0].files[0]; const reader = new FileReader(); reader.onload = function(e) { const photoUrl = e.target.result; $.ajax({ url: djVotingSystem.ajax_url, method: 'POST', data: { action: 'register_artist', name: artistName, music_style: musicStyle, artist_type: artistType, url: artistUrl, photo: photoUrl }, success: function(response) { if (response.success) { $('#newArtistModal').modal('hide'); $('#new-artist-form')[0].reset(); alert('L\'artiste a été ajouté et est en attente de validation par un administrateur.'); loadArtists(); } else { alert(response.data || 'Erreur lors de l\'ajout de l\'artiste.'); } } }); }; reader.readAsDataURL(artistPhoto); }); $(document).on('click', '.approve-button', function() { const artistId = $(this).data('artist-id'); $.ajax({ url: djVotingSystem.ajax_url, method: 'POST', data: { action: 'approve_artist', id: artistId }, success: function(response) { if (response.success) { loadArtists(); } else { alert('Erreur lors de l\'approbation de l\'artiste.'); } } }); }); $(document).on('click', '.reject-button', function() { const artistId = $(this).data('artist-id'); $.ajax({ url: djVotingSystem.ajax_url, method: 'POST', data: { action: 'reject_artist', id: artistId }, success: function(response) { if (response.success) { loadArtists(); } else { alert('Erreur lors du rejet de l\'artiste.'); } } }); }); $(document).on('click', '.edit-button', function() { const artistId = $(this).data('artist-id'); const artistRow = $(this).closest('tr'); const artistName = artistRow.find('td:nth-child(2) a').text(); const musicStyle = artistRow.find('td:nth-child(3)').text(); const artistType = artistRow.find('td:nth-child(4)').text(); const artistUrl = artistRow.find('td:nth-child(2) a').attr('href'); const artistPhoto = artistRow.find('td:nth-child(1) img').attr('src'); $('#edit-artist-id').val(artistId); $('#edit-artist-name').val(artistName); $('#edit-music-style').val(musicStyle); $('#edit-artist-type').val(artistType); $('#edit-artist-url').val(artistUrl); $('#edit-artist-photo').val(''); $('#editArtistModal').modal('show'); }); $('#edit-artist-form').on('submit', function(e) { e.preventDefault(); const artistId = $('#edit-artist-id').val().trim(); const artistName = $('#edit-artist-name').val().trim(); const musicStyle = $('#edit-music-style').val().trim(); const artistType = $('#edit-artist-type').val().trim(); const artistUrl = $('#edit-artist-url').val().trim(); const artistPhoto = $('#edit-artist-photo')[0].files[0]; const formData = new FormData(); formData.append('action', 'update_artist'); formData.append('id', artistId); formData.append('name', artistName); formData.append('music_style', musicStyle); formData.append('artist_type', artistType); formData.append('url', artistUrl); if (artistPhoto) { const reader = new FileReader(); reader.onload = function(e) { formData.append('photo', e.target.result); submitUpdateForm(formData); }; reader.readAsDataURL(artistPhoto); } else { submitUpdateForm(formData); } }); function submitUpdateForm(formData) { $.ajax({ url: djVotingSystem.ajax_url, method: 'POST', data: formData, contentType: false, processData: false, success: function(response) { if (response.success) { $('#editArtistModal').modal('hide'); loadArtists(); } else { alert('Erreur lors de la modification de l\'artiste.'); } } }); } $(document).on('click', '.delete-button', function() { const artistId = $(this).data('artist-id'); const artistName = $(this).closest('tr').find('td:nth-child(2) a').text(); $('#delete-artist-id').val(artistId); $('#delete-artist-name').text(artistName); $('#confirmDeleteModal').modal('show'); }); $('#confirm-delete-button').on('click', function() { const artistId = $('#delete-artist-id').val(); $.ajax({ url: djVotingSystem.ajax_url, method: 'POST', data: { action: 'delete_artist', id: artistId }, success: function(response) { if (response.success) { $('#confirmDeleteModal').modal('hide'); loadArtists(); } else { alert('Erreur lors de la suppression de l\'artiste.'); } } }); }); $(document).on('click', '.vote-button', function() { const artistId = $(this).data('artist-id'); const voteType = $(this).data('vote-type'); $.ajax({ url: djVotingSystem.ajax_url, method: 'POST', data: { action: 'add_vote', artist_id: artistId, vote_type: voteType }, success: function(response) { if (response.success) { $('#votes-' + artistId).text(response.data.new_votes); $('.vote-button[data-artist-id="' + artistId + '"]').removeClass('selected-vote'); $(`.vote-button[data-artist-id="${artistId}"][data-vote-type="${voteType}"]`).addClass('selected-vote'); // Mettre à jour le vote de l'utilisateur dans le stockage local userVotes[artistId] = voteType; localStorage.setItem('userVotes', JSON.stringify(userVotes)); } else { alert(response.data || 'Erreur lors du vote.'); } } }); }); loadArtists(); updateView(); }); BEGIN:VCALENDAR VERSION:2.0 METHOD:PUBLISH CALSCALE:GREGORIAN PRODID:-//WordPress - MECv7.11.0//EN X-ORIGINAL-URL:https://www.technomag.fr/ X-WR-CALNAME:Techno Mag X-WR-CALDESC:Le magazine underground de référence pour la techno REFRESH-INTERVAL;VALUE=DURATION:PT1H X-PUBLISHED-TTL:PT1H X-MS-OLK-FORCEINSPECTOROPEN:TRUE BEGIN:VEVENT CLASS:PUBLIC UID:MEC-3a4496776767aaa99f9804d0905fe584@technomag.fr DTSTART:20240508T220000Z DTEND:20240512T220000Z DTSTAMP:20231120T150300Z CREATED:20231120 LAST-MODIFIED:20231120 PRIORITY:5 SEQUENCE:1 TRANSP:OPAQUE SUMMARY:Son Libre Festival 2024 DESCRIPTION: Amateurs de la magie du dancefloor, le Son Libre 2024 célèbre ses 10 ans d’existence. Il y a une décennie, l’équipe voulait créer un festival qui réunirait les gens autour de la musique, quelles que soient leurs préférences ou leurs différences. Un festival où chacun se sentirait libre de lâcher prise.\nDix ans plus tard, le public du Son Libre est là, fou, beau, libre, ouvert. Une grande famille se réunit chaque année pour partager des moments uniques et indélébiles, car chaque édition du Son Libre a ses histoires à vivre.\nQue chacun prépare ses plus beaux costumes de soirée, rejoigne cette belle et truculente famille, car ça va swinguer dur ! Ensemble, célébrons dignement ces dix années et rendez-vous les 9, 10, 11 et 12 mai 2024.\n✅ 3 stages ▹ ✅ 72h non stop music ▹ ✅ Entrée/sortie libre ▹ ✅ Camping include ▹ ✅ Quality beer ▹ ✅ Quality food ▹ ✅ Chill out ▹ ✅ Sound system Lambda Labs\n URL:https://www.technomag.fr/events/son-libre-festival-2024/ CATEGORIES:Festival LOCATION:Collias ATTACH;FMTTYPE=image/png:https://www.technomag.fr/wp-content/uploads/2023/11/ScreenShot-Tool-20231120170010.png END:VEVENT END:VCALENDAR