|
|
| Zeile 739: |
Zeile 739: |
|
| |
|
| // ------------------------------------- | | // ------------------------------------- |
|
| |
| /* Whisky News – nur News/Karten, ohne Animation (v8) */
| |
| mw.loader.using(['mediawiki.util','jquery']).then(function () {
| |
| (function ($, mw) {
| |
| 'use strict';
| |
|
| |
| var CONFIG = {
| |
| enabled: true,
| |
| id: 'whisky_news_plain_v8', // bei Änderungen erhöhen
| |
| title: 'Whisky News: Messeabfüllungen – World of Whisky (Mannheim)',
| |
| introHTML: '<p>Das Brühler Whiskyhaus bringt zur World of Whisky in Mannheim zwei exklusive Messeabfüllungen, erhältlich nur vor Ort. Restkontingent (falls verfügbar): Bestellung per E-Mail an info@worldofwhiskyfair.de. Schau sie dir an und bewerte sie im Wiki!</p>',
| |
| cards: [
| |
| {
| |
| // ← ersetze src bei Bedarf durch eure Bild-URL
| |
| src: 'https://ados-wiki.de/images/2/2f/South_Islay_Single_Malt_13_year-old_%28Sherry_Octave_Cask_Finish%29.single.jpg',
| |
| alt: 'South Islay 13y – Sherry Octave Cask Finish',
| |
| link: 'https://ados-wiki.de/wiki/South_Islay_Single_Malt_13_year-old_(Sherry_Octave_Cask_Finish)',
| |
| cta: 'Zur South Islay Abfüllung'
| |
| },
| |
| {
| |
| src: 'https://ados-wiki.de/images/9/95/Tullibardine_13_year-old_%28Shiraz_Wine_Octave_Cask_Finish%29.single.jpg',
| |
| alt: 'Tullibardine 13y – Shiraz Wine Octave Cask Finish',
| |
| link: 'https://ados-wiki.de/wiki/Tullibardine_13_year-old',
| |
| cta: 'Zur Tullibardine Abfüllung'
| |
| }
| |
| ],
| |
| dailyLimit: 1,
| |
| escToClose: true,
| |
| clickBackdropToClose: true
| |
| };
| |
|
| |
| if (!CONFIG.enabled) return;
| |
|
| |
| // 1×/Tag
| |
| var isAnon = (mw.config.get('wgUserName') === null);
| |
| function LSget(k){ try { return localStorage.getItem(k); } catch(e){ return null; } }
| |
| function LSset(k,v){ try { localStorage.setItem(k,v); } catch(e){} }
| |
| var key = 'popup_' + CONFIG.id + (isAnon?':anon':':user');
| |
| var today = (d => d.getFullYear()+'-'+('0'+(d.getMonth()+1)).slice(-2)+'-'+('0'+d.getDate()).slice(-2))(new Date());
| |
| if (LSget(key) === today) return;
| |
| function markSeen(){ LSset(key, today); }
| |
|
| |
| $(function () {
| |
| // Overlay + Modal
| |
| var $overlay = $('<div>', {'class':'mwnews-overlay'});
| |
| var $modal = $('<div>', {'class':'mwnews-modal', 'role':'dialog', 'aria-modal':'true', 'aria-labelledby':'mwnews-title'});
| |
|
| |
| // Inhalt
| |
| var $title = $('<h2>', {id:'mwnews-title'}).text(CONFIG.title);
| |
| var $intro = $('<div>', {'class':'mwnews-intro'}).html(CONFIG.introHTML);
| |
|
| |
| // Karten
| |
| var $cards = $('<div>', {'class':'mwnews-cards'});
| |
| CONFIG.cards.forEach(function (c) {
| |
| var $a = $('<a>', {'class':'mwnews-card', href:c.link, target:'_blank', rel:'noopener'});
| |
| var $thumb = $('<div>', {'class':'mwnews-thumb'});
| |
| if (c.src) $thumb.append($('<img>', {src:c.src, alt:c.alt || '' , loading:'lazy'}));
| |
| $a.append(
| |
| $thumb,
| |
| $('<div>', {'class':'mwnews-meta'}).append(
| |
| $('<div>', {'class':'mwnews-title', text:c.alt || ''}),
| |
| $('<div>', {'class':'mwnews-cta', text:c.cta || 'Mehr ansehen'})
| |
| )
| |
| );
| |
| $cards.append($a);
| |
| });
| |
|
| |
| // Button
| |
| var $btnRow = $('<div>', {'class':'mwnews-btnrow'});
| |
| var $ok = $('<button>', {'class':'mwnews-close', type:'button'}).text('OK');
| |
| $btnRow.append($ok);
| |
|
| |
| // zusammenbauen
| |
| $modal.append($title, $intro, $cards, $btnRow);
| |
| $('body').append($overlay, $modal);
| |
|
| |
| function close(){
| |
| markSeen();
| |
| $overlay.remove(); $modal.remove();
| |
| $(document).off('keydown.mwnews');
| |
| }
| |
| if (CONFIG.clickBackdropToClose) $overlay.on('click', close);
| |
| $ok.on('click', close);
| |
| if (CONFIG.escToClose){
| |
| $(document).on('keydown.mwnews', function(e){
| |
| var k = e.key || e.keyCode;
| |
| if (k==='Escape' || k==='Esc' || k===27){ e.preventDefault(); close(); }
| |
| });
| |
| }
| |
| });
| |
| })(jQuery, mw);
| |
| });
| |
|
| |
|
| mw.loader.load('ext.cargo.nvd3'); | | mw.loader.load('ext.cargo.nvd3'); |