MediaWiki:Common.js: Unterschied zwischen den Versionen
Erscheinungsbild
Keine Bearbeitungszusammenfassung |
Keine Bearbeitungszusammenfassung |
||
| Zeile 162: | Zeile 162: | ||
} | } | ||
/* Template 'ConditionalContent' - | /* Template 'ConditionalContent' - v250925r8 */ | ||
/* Two templates for alternative running text (ConditionalContent) and alternative sections (ConditionalSection) */ | |||
mw.loader.using('mediawiki.user').then(function() { | mw.loader.using('mediawiki.user').then(function() { | ||
if (mw.user.isAnon()) { | if (mw.user.isAnon()) { | ||
// Inline content | |||
$('.logged-out-only').each(function() { | $('.logged-out-only').each(function() { | ||
if ($(this).is(':empty') || !$(this).text().replace(/\s/g, '')) { | if ($(this).is(':empty') || !$(this).text().replace(/\s/g, '')) { | ||
$(this).css('display', 'none'); | $(this).css('display', 'none'); | ||
} else { | } else { | ||
$(this).css('display', 'inline'); | |||
$(this).css('display', | |||
} | } | ||
}); | }); | ||
$('.logged-in-only').css('display', 'none'); | $('.logged-in-only').css('display', 'none'); | ||
// Block content | |||
$('.logged-out-section').each(function() { | |||
if ($(this).is(':empty') || !$(this).text().replace(/\s/g, '')) { | |||
$(this).css('display', 'none'); | |||
} else { | |||
$(this).css('display', 'block'); | |||
} | |||
}); | |||
$('.logged-in-section').css('display', 'none'); | |||
} else { | } else { | ||
// Inline content | |||
$('.logged-in-only').each(function() { | $('.logged-in-only').each(function() { | ||
if ($(this).is(':empty') || !$(this).text().replace(/\s/g, '')) { | if ($(this).is(':empty') || !$(this).text().replace(/\s/g, '')) { | ||
$(this).css('display', 'none'); | $(this).css('display', 'none'); | ||
} else { | } else { | ||
$(this).css('display', 'inline'); | |||
$(this).css('display', | |||
} | } | ||
}); | }); | ||
$('.logged-out-only').css('display', 'none'); | $('.logged-out-only').css('display', 'none'); | ||
// Block content | |||
$('.logged-in-section').each(function() { | |||
if ($(this).is(':empty') || !$(this).text().replace(/\s/g, '')) { | |||
$(this).css('display', 'none'); | |||
} else { | |||
$(this).css('display', 'block'); | |||
} | |||
}); | |||
$('.logged-out-section').css('display', 'none'); | |||
} | } | ||
}); | }); | ||
Version vom 25. September 2025, 15:27 Uhr
/* Unified Consent System JavaScript v250911r1
* Single file for both EN and DE versions
* Automatically detects language based on domain
*/
/* Common JavaScript - Keep only consent system if needed */
// Language detection helper
function getCurrentLanguage() {
var hostname = window.location.hostname;
return (hostname === 'de.transformal.com' ||
hostname === 'de.olaflangmack.info' ||
hostname === 'de.mediawiki.transformal.com') ? 'de' : 'en';
}
// Localized strings
var strings = {
en: {
journalingEnabled: 'Journaling enabled',
journalingDisabled: 'Journaling disabled',
proofOfWorkEnabled: 'Proof-of-work enabled',
proofOfWorkDisabled: 'Proof-of-work disabled',
preferencesSaved: 'Your preferences are being saved',
checkboxLabel: 'Enabled'
},
de: {
journalingEnabled: 'Aufzeichnungen zugelassen',
journalingDisabled: 'Aufzeichnungen nicht zugelassen',
proofOfWorkEnabled: 'Proof-of-work zugelassen',
proofOfWorkDisabled: 'Proof-of-work nicht zugelassen',
preferencesSaved: 'Ihre Einstellungen werden gespeichert',
checkboxLabel: 'Erlaubt'
}
};
function getString(key) {
var lang = getCurrentLanguage();
return strings[lang][key] || strings.en[key];
}
// Handle consent acquisition box - 90-day reminder for everyone
$(document).ready(function() {
var consentBox = document.getElementById('consent-acquisition-box');
if (!consentBox) return;
// Check if dismissed within last 90 days
var dismissedUntil = localStorage.getItem('consent-acquisition-dismissed-until');
var now = Date.now();
if (dismissedUntil && parseInt(dismissedUntil) > now) {
// Still within 90-day dismissal period
consentBox.style.display = 'none';
} else {
// Show box - dismissal expired or never dismissed
consentBox.style.display = 'block';
consentBox.classList.add('show');
}
consentBox.addEventListener('click', function() {
sessionStorage.setItem('consent-acquisition-dismissed', 'true');
// ADD THIS LINE:
localStorage.setItem('consent-acquisition-dismissed-until', Date.now() + (90 * 24 * 60 * 60 * 1000));
var targetPage = getCurrentLanguage() === 'de' ?
'/wiki/Transformal_GmbH:Einstellungen' :
'/wiki/Transformal_GmbH:Settings';
window.location.href = targetPage;
});
});
// Convert template placeholders to actual checkboxes
$(function() {
$('.consent-option').each(function() {
var $option = $(this);
if ($option.find('.consent-checkbox').length > 0) return;
var consentId = $option.find('.consent-data').text().trim();
var status = $option.find('.consent-status-data').text().trim();
var $checkboxRow = $option.find('.checkbox-row');
if (!$checkboxRow.length) return;
var $container = $('<span class="checkbox-container"></span>');
var $checkbox = $('<input>', {
type: 'checkbox',
id: consentId,
class: 'consent-checkbox'
});
if (status === 'disabled') {
$checkbox.prop('disabled', true);
}
var label = $option.find('.checkbox-placeholder').attr('data-label') || getString('checkboxLabel');
var $label = $('<label>', {
'for': consentId,
text: ' ' + label,
style: 'cursor: pointer;'
});
$container.append($checkbox).append($label);
$checkboxRow.append($container);
$checkboxRow.find('.checkbox-placeholder').remove();
var saved = localStorage.getItem(consentId) === 'true';
$checkbox.prop('checked', saved);
$checkbox.on('change', function() {
localStorage.setItem(consentId, this.checked);
if (typeof handleConsentChange === 'function') {
handleConsentChange(consentId, this.checked);
}
if (typeof showConsentFeedback === 'function') {
showConsentFeedback(consentId, this.checked);
}
});
});
});
// Handle consent changes for different features
function handleConsentChange(feature, enabled) {
if (feature === 'matomo-consent') {
if (enabled) {
if (window._paq) {
// Enable enhanced tracking
_paq.push(['setCookieConsentGiven']);
_paq.push(['setConsentGiven']);
// Track this page view again with full details
_paq.push(['trackPageView']);
_paq.push(['enableHeartBeatTimer']);
_paq.push(['trackVisibleContentImpressions']);
}
} else {
if (window._paq) {
// Revert to anonymous tracking only
_paq.push(['forgetCookieConsentGiven']);
_paq.push(['forgetConsentGiven']);
// Note: Already tracked pages remain in this session
}
}
}
}
// Show feedback when consent changes
function showConsentFeedback(feature, enabled) {
var feedbackDiv = document.getElementById('consent-feedback');
if (!feedbackDiv) return;
var message = '';
if (feature === 'matomo-consent') {
message = enabled ? getString('journalingEnabled') : getString('journalingDisabled');
} else if (feature === 'altcha-consent') {
message = enabled ? getString('proofOfWorkEnabled') : getString('proofOfWorkDisabled');
}
if (message) {
feedbackDiv.innerHTML = message + ' – ' + getString('preferencesSaved');
feedbackDiv.style.display = 'block';
setTimeout(function() {
feedbackDiv.style.display = 'none';
}, 3000);
}
}
/* Template 'ConditionalContent' - v250925r8 */
/* Two templates for alternative running text (ConditionalContent) and alternative sections (ConditionalSection) */
mw.loader.using('mediawiki.user').then(function() {
if (mw.user.isAnon()) {
// Inline content
$('.logged-out-only').each(function() {
if ($(this).is(':empty') || !$(this).text().replace(/\s/g, '')) {
$(this).css('display', 'none');
} else {
$(this).css('display', 'inline');
}
});
$('.logged-in-only').css('display', 'none');
// Block content
$('.logged-out-section').each(function() {
if ($(this).is(':empty') || !$(this).text().replace(/\s/g, '')) {
$(this).css('display', 'none');
} else {
$(this).css('display', 'block');
}
});
$('.logged-in-section').css('display', 'none');
} else {
// Inline content
$('.logged-in-only').each(function() {
if ($(this).is(':empty') || !$(this).text().replace(/\s/g, '')) {
$(this).css('display', 'none');
} else {
$(this).css('display', 'inline');
}
});
$('.logged-out-only').css('display', 'none');
// Block content
$('.logged-in-section').each(function() {
if ($(this).is(':empty') || !$(this).text().replace(/\s/g, '')) {
$(this).css('display', 'none');
} else {
$(this).css('display', 'block');
}
});
$('.logged-out-section').css('display', 'none');
}
});