MediaWiki:Common.js: Unterschied zwischen den Versionen

Keine Bearbeitungszusammenfassung
Keine Bearbeitungszusammenfassung
Zeile 1: Zeile 1:
/* Unified Consent System JavaScript v250822r2
/* Unified Consent System JavaScript v250822r3
  * Single file for both EN and DE versions
  * Single file for both EN and DE versions
  * Automatically detects language based on domain
  * Automatically detects language based on domain
  */
  */
/* Common JavaScript - Keep only consent system if needed */


// Language detection helper
// Language detection helper
Zeile 32: Zeile 34:
};
};


// Get string in current language
function getString(key) {
function getString(key) {
     var lang = getCurrentLanguage();
     var lang = getCurrentLanguage();
Zeile 43: Zeile 44:
     if (!consentBox) return;
     if (!consentBox) return;
      
      
    // Check if already dismissed in this session
     var dismissed = sessionStorage.getItem('consent-acquisition-dismissed');
     var dismissed = sessionStorage.getItem('consent-acquisition-dismissed');
      
      
Zeile 49: Zeile 49:
         consentBox.style.display = 'none';
         consentBox.style.display = 'none';
     } else {
     } else {
        // SHOW the box if not dismissed
         consentBox.style.display = 'block';
         consentBox.style.display = 'block';
         consentBox.classList.add('show');
         consentBox.classList.add('show');
     }
     }
      
      
    // Add click handler to consent box
     consentBox.addEventListener('click', function() {
     consentBox.addEventListener('click', function() {
        // Set session storage
         sessionStorage.setItem('consent-acquisition-dismissed', 'true');
         sessionStorage.setItem('consent-acquisition-dismissed', 'true');
       
        // Navigate to correct language version
         var targetPage = getCurrentLanguage() === 'de' ?  
         var targetPage = getCurrentLanguage() === 'de' ?  
             '/wiki/Transformal_GmbH:Analyseeinstellungen' :  
             '/wiki/Transformal_GmbH:Analyseeinstellungen' :  
             '/wiki/Transformal_GmbH:Analyses_preferences';
             '/wiki/Transformal_GmbH:Analyses_preferences';
       
         window.location.href = targetPage;
         window.location.href = targetPage;
     });
     });
Zeile 69: Zeile 63:


// Convert template placeholders to actual checkboxes
// Convert template placeholders to actual checkboxes
console.log('Starting consent checkbox initialization');
$(function() {
$(function() {
   
     $('.consent-option').each(function() {
     $('.consent-option').each(function() {
         var $option = $(this);
         var $option = $(this);
       
        // Skip if already processed
         if ($option.find('.consent-checkbox').length > 0) return;
         if ($option.find('.consent-checkbox').length > 0) return;
          
          
Zeile 82: Zeile 71:
         var status = $option.find('.consent-status-data').text().trim();
         var status = $option.find('.consent-status-data').text().trim();
          
          
        // Find the checkbox-row div
         var $checkboxRow = $option.find('.checkbox-row');
         var $checkboxRow = $option.find('.checkbox-row');
         if (!$checkboxRow.length) return;
         if (!$checkboxRow.length) return;
          
          
        // Create checkbox and append directly
         var $container = $('<span class="checkbox-container"></span>');
         var $container = $('<span class="checkbox-container"></span>');
         var $checkbox = $('<input>', {
         var $checkbox = $('<input>', {
Zeile 107: Zeile 94:
         $container.append($checkbox).append($label);
         $container.append($checkbox).append($label);
         $checkboxRow.append($container);
         $checkboxRow.append($container);
       
        // Remove placeholder if exists
         $checkboxRow.find('.checkbox-placeholder').remove();
         $checkboxRow.find('.checkbox-placeholder').remove();
          
          
        // Load and bind
         var saved = localStorage.getItem(consentId) === 'true';
         var saved = localStorage.getItem(consentId) === 'true';
         $checkbox.prop('checked', saved);
         $checkbox.prop('checked', saved);
Zeile 159: Zeile 143:
         feedbackDiv.style.display = 'block';
         feedbackDiv.style.display = 'block';
          
          
        // Hide after 3 seconds
         setTimeout(function() {
         setTimeout(function() {
             feedbackDiv.style.display = 'none';
             feedbackDiv.style.display = 'none';