Thank You thankyouwiki https://thankyou.wikipedia.org/wiki/Main_Page MediaWiki 1.47.0-wmf.7 first-letter Media Special Talk User User talk Thank You Thank You talk File File talk MediaWiki MediaWiki talk Template Template talk Help Help talk Category Category talk TimedText TimedText talk Module Module talk MediaWiki:Common.js 8 32 1472 1470 2026-06-22T12:25:58Z EHughes (WMF) 9 Adding parameter to be able to show matching gifts CTA 1472 javascript text/javascript /* Any JavaScript here will be loaded for all users on every page load. */ // Framebuster for https://phabricator.wikimedia.org/T176669 if ( self !== top ) { top.location.href = window.location; } // Redirect anons to en if page doesn't exist if ( mw.config.get('wgUserName') === null && mw.config.get('wgArticleId') === 0 ) { var basePageName = mw.config.get('wgPageName').split('/')[0]; var redirectUrl = 'https://thankyou.wikipedia.org/wiki/'; if ( basePageName === 'Recurring_donor_page' ) { redirectUrl += 'Recurring_donor_page/en'; } else if ( basePageName === 'WP25' ) { redirectUrl += 'WP25/en'; } else { redirectUrl += 'Thank_You/en'; } redirectUrl += window.location.search; // params window.location.replace( redirectUrl ); } mw.loader.using( [ 'mediawiki.cookie' ], function() { /** * Extend a url with a subset of query parameters * * @param {string} url Base url to extend * @param {object} allParams Object with all available query parameters (usually for the current location) * @param {array} paramsToInclude List of parameters to include in the extended url * @return {string} Extended url */ function extendWithSomeParams( url, allParams, paramsToInclude ) { var urlObject = new URL( url ); // Fallback for survey links allParams.wmf_medium = allParams.wmf_medium || allParams.utm_medium; allParams.wmf_campaign = allParams.wmf_campaign || allParams.utm_campaign; allParams.wmf_source = allParams.wmf_source || allParams.utm_source; paramsToInclude.forEach( function(key) { if ( allParams[key] ) { urlObject.searchParams.set( key, allParams[key] ); } }); return urlObject.toString(); } /* -- Start of main TY page code -- */ var params = {}; for ( const [key, value] of new URLSearchParams( location.search ) ) { params[key] = value; } var country = params.country, pageLanguage = mw.config.get('wgPageName').split('/')[1]; if ( params.recurring === '1' ) { document.getElementById('ty-recurringOrganic').style.display = 'block'; } if ( params.recurring === '1' && params.frequency_unit === 'year' ) { document.getElementById('ty-recurringOrganic').style.display = 'none'; document.getElementById('ty-recurringOrganicAnnual').style.display = 'block'; } if ( params.recurringConversion === '1' ) { document.getElementById('ty-recurringConversion').style.display = 'block'; } if ( params.recurringConversion === '1' && params.frequency_unit === 'year' ) { document.getElementById('ty-recurringConversion').style.display = 'none'; document.getElementById('ty-recurringConversionAnnual').style.display = 'block'; } // Recurring Upgrade if ( params.recurUpgrade === '1' ) { var recurUpgradeAmt = params.recurAmount; var recurUpgradeDate = params.recurDate; $('.recurUpgrade-yes').show(); if ( recurUpgradeAmt && recurUpgradeDate ) { $('.recurUpgradeAmt').text(recurUpgradeAmt); if ( params.country === 'US' ) { $('.recurUpgradeAmt').prepend("$"); } var upgradeDate = new Date(recurUpgradeDate); var formatOptions = { timeZone: 'UTC', weekday: 'long', year: 'numeric', month: 'long', day: 'numeric' }; $('.recurUpgradeDate').text( upgradeDate.toLocaleDateString('en-US', formatOptions) ); $('.recurUpgrade-receipt').show(); } else { $('.recurUpgrade-receipt').hide(); } } else if ( params.recurUpgrade === '0' ) { $('.recurUpgrade-no').show(); } else { $('.ty-vision, .ty-text').show(); } // Extend survey links $('.ty-survey-link, a[href^="https://www.surveymonkey.com"]').attr('href', function( i, val ) { return extendWithSomeParams( val, params, [ 'country', 'payment_method', 'recurring', 'recurringConversion', 'amount', 'currency', 'order_id', 'wmf_medium', 'wmf_campaign', 'wmf_source' ] ); }); // Return to Wikipedia link var returnToUrl = mw.cookie.get( 'fundraising_returnTo', '' ); if ( returnToUrl ) { $( '.ty-return a' ).attr( 'href', returnToUrl ); $( '.ty-return' ).show(); mw.cookie.set( 'fundraising_returnTo', null, { prefix: '', domain: '.wikipedia.org' } ); } // TODO: refactor this to be by feature instead of country? if ( params.featureEndowment ) { // To force endowment feature $( '.primary-ctas .endowment, \ .other-ctas, \ .other-ctas .store, \ .other-ctas .survey, \ .other-ctas .edit-6c' ).show(); } else if ( params.featureMatching ) { // To force matching gifts feature $( '.primary-ctas .matching, \ .other-ctas, \ .other-ctas .store, \ .other-ctas .will-US, \ .other-ctas .survey, \ .other-ctas .edit-6c' ).show(); } else if ( country === 'US' ) { $( '.primary-ctas .endowment, \ .other-ctas, \ .other-ctas .store, \ .other-ctas .survey, \ .other-ctas .edit-6c' ).show(); } else if ( country === 'CA' || country === 'GB' ) { $( '.primary-ctas .survey, \ .other-ctas, \ .other-ctas .store, \ .other-ctas .will-notUS, \ .other-ctas .edit-6c' ).show(); } else if ( country === 'IE' || country === 'AU' || country === 'NZ' ) { $( '.primary-ctas .survey, \ .other-ctas, \ .other-ctas .store, \ .other-ctas .edit-6c' ).show(); } else if ( country === 'IT' || country === 'PT' || country === 'BR' || country === 'JP' || country === 'FR' ) { $( '.primary-ctas .survey, \ .other-ctas, \ .other-ctas .store' ).show(); } else if ( country === 'ES' || country === 'CL' || country === 'CO' || country === 'MX' || country === 'PE' || country === 'UY' ) { $( '.primary-ctas .survey, \ .other-ctas, \ .other-ctas .store' ).show(); } else if ( country === 'BE' || country === 'CZ' || country === 'NO' || country === 'AT' || country === 'DK' || country === 'PL' || country === 'HU' ) { $( '.primary-ctas .survey, \ .other-ctas' ).show(); } else { $( '.primary-ctas .survey' ).show(); } if ( country === 'SE' ) { $('.chapter-SE').show(); } if ( country === 'CZ' ) { $('.chapter-CZ').show(); } if ( country === 'IT' ) { $('.chapter-IT').show(); } if ( country === 'AU' ) { $('.chapter-AU').show(); } if ( country === 'FR' ) { $('.chapter-FR').show(); } if ( country === 'GB' ) { $('.chapter-GB').show(); } if ( country === 'CA' ) { $('.chapter-CA').show(); } if ( country === 'NO' ) { $('.chapter-NO').show(); } if ( country === 'BE' ) { $('.chapter-BE').show(); } if ( country === 'NL' ) { $('.chapter-NL').show(); } if ( country === 'NZ' ) { $('.chapter-NZ').show(); } if ( country === 'AT' ) { $('.chapter-AT').show(); } if ( country === 'CO' ) { $('.chapter-CO').show(); } if ( country === 'MX' ) { $('.chapter-MX').show(); } if ( country === 'BR' ) { $('.chapter-BR').show(); } if ( country === 'UY' ) { $('.chapter-UY').show(); } if ( country === 'PL' ) { $('.chapter-PL').show(); } if ( country === 'HU' ) { $('.chapter-HU').show(); } /* Wikiminute blocks */ if ( country === 'CL' || country === 'CO' || country === 'MX' || country === 'PE' || country === 'UY' ) { $('.wikiminute-LATAM').show(); } if ( country === 'ES' ) { $('.wikiminute-ES').show(); } if ( country === 'FR' ) { $('.wikiminute-FR').show(); } if ( country === 'AT' ) { $('.wikiminute-DE').show(); } if ( country === 'IT' ) { $('.wikiminute-IT').show(); } if ( country === 'BR' ) { $('.wikiminute-ptBR').show(); } if ( country === 'NL' ) { $('.wikiminute-NL').show(); } if ( country === 'DK' ) { $('.wikiminute-DK').show(); } if ( country === 'SE' ) { $('.wikiminute-SV').show(); } if ( country === 'NO' ) { $('.wikiminute-NB').show(); } if ( country === 'JP' ) { $('.wikiminute-JA').show(); } /* Tax deductibility disclaimer */ if ( country === 'US' ) { $('.tax-disclaimer-US').show(); } else if ( country === 'NL' ) { $('.tax-disclaimer-NL').show(); } else if ( country === 'FR' ) { $('.tax-disclaimer-FR').show(); } else { $('.tax-disclaimer-default').show(); } /* -- "Try editing" feature -- */ var editingUrls = { 'IN': { 'en': 'https://en.wikipedia.org/w/index.php?title=Special:CreateAccount&geEnabled=1&campaign=typage-in-en-2022' }, 'ZA': { 'en': 'https://en.wikipedia.org/w/index.php?title=Special:CreateAccount&geEnabled=1&campaign=typage-za-en-2022' }, // Latin America 'BR': { 'en': 'https://en.wikipedia.org/w/index.php?title=Special:CreateAccount&geEnabled=1&campaign=typage-latam-en-2022', 'pt-br': 'https://pt.wikipedia.org/w/index.php?title=Special:CreateAccount&geEnabled=1&campaign=typage-latam-pt-2022&uselang=pt-br' }, 'AR': { 'en': 'https://en.wikipedia.org/w/index.php?title=Special:CreateAccount&geEnabled=1&campaign=typage-latam-en-2022', 'es-419': 'https://es.wikipedia.org/w/index.php?title=Special:CreateAccount&geEnabled=1&campaign=typage-latam-es-2022' }, 'CL': { 'en': 'https://en.wikipedia.org/w/index.php?title=Special:CreateAccount&geEnabled=1&campaign=typage-latam-en-2022', 'es-419': 'https://es.wikipedia.org/w/index.php?title=Special:CreateAccount&geEnabled=1&campaign=typage-latam-es-2022' }, 'CO': { 'en': 'https://en.wikipedia.org/w/index.php?title=Special:CreateAccount&geEnabled=1&campaign=typage-latam-en-2022', 'es-419': 'https://es.wikipedia.org/w/index.php?title=Special:CreateAccount&geEnabled=1&campaign=typage-latam-es-2022' }, 'MX': { 'en': 'https://en.wikipedia.org/w/index.php?title=Special:CreateAccount&geEnabled=1&campaign=typage-latam-en-2022', 'es-419': 'https://es.wikipedia.org/w/index.php?title=Special:CreateAccount&geEnabled=1&campaign=typage-latam-es-2022' }, 'PE': { 'en': 'https://en.wikipedia.org/w/index.php?title=Special:CreateAccount&geEnabled=1&campaign=typage-latam-en-2022', 'es-419': 'https://es.wikipedia.org/w/index.php?title=Special:CreateAccount&geEnabled=1&campaign=typage-latam-es-2022' }, 'UY': { 'en': 'https://en.wikipedia.org/w/index.php?title=Special:CreateAccount&geEnabled=1&campaign=typage-latam-en-2022', 'es-419': 'https://es.wikipedia.org/w/index.php?title=Special:CreateAccount&geEnabled=1&campaign=typage-latam-es-2022' }, // Northern and Western Europe 'SE': { 'sv': 'https://sv.wikipedia.org/w/index.php?title=Special:CreateAccount&campaign=typage-nwe-sv-2023', 'en': 'https://en.wikipedia.org/w/index.php?title=Special:CreateAccount&campaign=typage-nwe-sv-2023' }, 'IT': { 'it': 'https://it.wikipedia.org/w/index.php?title=Special:CreateAccount&campaign=typage-nwe-it-2023', 'en': 'https://en.wikipedia.org/w/index.php?title=Special:CreateAccount&campaign=typage-nwe-it-2023' }, 'FR': { 'fr': 'https://fr.wikipedia.org/w/index.php?title=Special:CreateAccount&campaign=typage-nwe-fr-2023', 'en': 'https://en.wikipedia.org/w/index.php?title=Special:CreateAccount&campaign=typage-nwe-fr-2023' }, 'NL': { 'nl': 'https://nl.wikipedia.org/w/index.php?title=Special:CreateAccount&campaign=typage-nwe-nl-2023', 'en': 'https://en.wikipedia.org/w/index.php?title=Special:CreateAccount&campaign=typage-nwe-nl-2023' }, // Central Europe 'PL': { 'pl': 'https://pl.wikipedia.org/w/index.php?title=Special:CreateAccount&campaign=typage-ce-pl-2026', 'en': 'https://en.wikipedia.org/w/index.php?title=Special:CreateAccount&campaign=typage-ce-pl-2026' }, // East, Southeast Asia, and Pacific 'JP': { 'ja': 'https://ja.wikipedia.org/w/index.php?title=Special:CreateAccount&campaign=typage-eseap-ja-2023', 'en': 'https://en.wikipedia.org/w/index.php?title=Special:CreateAccount&campaign=typage-eseap-ja-2023' }, }; // Separate list so we can have others in prep for proofing var editingCTACountries = [ 'IN', 'ZA', 'BR', 'AR', 'CL', 'CO', 'MX', 'PE', 'UY', 'SE', 'IT', 'FR', 'NL', 'JP', 'PL' ]; if ( editingCTACountries.indexOf(country) !== -1 || params.testEditingCTA ) { if ( editingUrls[country] ) { if ( editingUrls[country][pageLanguage] ) { $( '.try-editing a' ).attr( 'href', editingUrls[country][pageLanguage] ); $( '.primary-ctas .survey' ).hide(); $( '.primary-ctas .try-editing, .other-ctas, .other-ctas .survey' ).show(); } } } // Only show survey 25% of time on English page //if ( pageLanguage === 'en' ) { // if ( Math.random() > 0.25 ) { // $('.survey').hide(); // } //} if ( pageLanguage === 'en' ) { var surveyNumber = Math.random(); if ( surveyNumber > 0.5 ) { $('.survey').hide(); } else if ( surveyNumber > 0.25 && surveyNumber <= 0.5 ) { $('.survey-1').hide(); } else if ( surveyNumber > 0 && surveyNumber <= 0.25 ) { $('.survey-2').hide(); } } // Don't show editing CTAs on apps: https://phabricator.wikimedia.org/T353023 if ( params.utm_medium === 'WikipediaApp' || params.wmf_medium === 'WikipediaApp' ) { $('.other-ctas .edit-6c, .primary-ctas .try-editing').hide(); } // Finally, if there are no secondary CTAs shown then hide the section header if ( $('.other-ctas .focus-block:visible').length === 0 ) { $('.other-ctas h2').hide(); } // One Click Survey page show/hide CTAs if ($('.ty-page').hasClass('one-click-survey')) { if ( params.variant === 'donate' ) { // To show donate CTA $( '.other-ctas .donate, \ .other-ctas .store, \ .other-ctas .will-notUS' ).show(); } else { // Show edit CTA $( '.other-ctas .edit-6c, \ .other-ctas .store, \ .other-ctas .will-notUS' ).show(); } } // MGFE event invite show/hide if ( ( params.wmf_campaign === 'MGYEA1R25' || params.wmf_campaign === 'MGYEA2R25' ) && params.wmf_medium === 'MGFE' ) { $('.wp25-block').show(); } if ( ( params.wmf_campaign === 'ENDYEA1R25' || params.wmf_campaign === 'ENDYEA2R25' ) && params.wmf_medium === 'endowment' ) { $('.wp25-block').show(); } // WP25 specific if ( country === 'US' ) { $('.wp25 .tax-disclaimer').hide(); } // Show social media share & social media footer only in English if ( pageLanguage === 'en' ) { $( '.social-share' ).show(); $( '.social-footer' ).show(); } /* -- Legacy giving form --- */ var lg = { post: function( $form ) { // Create iframe for the form and use it as the form's target var frameName = 'lgFrame'; if ( $("iframe[name=" + frameName + "]").length === 0 ) { var $iframe = $('<iframe style="display: none;" name="' + frameName + '"></iframe>'); $form.attr('target', $iframe.attr('name')); $form.after($iframe); } $form[0].submit(); }, getCurrentDate: function() { /* Get current date in correct format for Silverpop */ var today = new Date(); var dd = today.getDate(); var mm = today.getMonth()+1; // January is 0! var yyyy = today.getFullYear(); if( dd < 10 ) { dd = '0' + dd; } if( mm < 10 ) { mm = '0' + mm; } return mm+'/'+dd+'/'+yyyy; }, init: function() { var legacyForm = document.getElementById( 'lg-form' ), legacyDialog = document.getElementById( 'frb-dialog-legacy' ); if ( !legacyForm ) { return false; } // pre-fill country, only shown in US for now legacyForm.country.value = 'United States'; legacyForm.lg_submitDate.value = lg.getCurrentDate(); $('.frb-dialog-link').on( 'click', function(e) { legacyDialog.showModal(); legacyForm.firstname.focus(); }); $('#frb-dialog-legacy .frb-dialog-close').on( 'click', function(e) { legacyDialog.close(); }); // form submit $('#lg-form .lg-submit').on( 'click', function() { var pdfUrl = "https://upload.wikimedia.org/wikipedia/donate/9/97/Wikipedia_Planned_Giving_Guide.pdf"; if ( legacyForm.checkValidity() ) { lg.post( $('#lg-form') ); legacyDialog.close(); mw.notify( 'Thank you! Our team will be in touch.' ); window.open(pdfUrl, '_blank'); } else { legacyForm.reportValidity(); } return false; }); } }; lg.init(); /* -- donor badge dialog --- */ var donorBadge = { init: function() { var donorBadgeDialog = document.getElementById( 'frb-dialog-donor-badge' ); $('.getDonorBadge').on( 'click', function(e) { donorBadge.setCookie(); donorBadgeDialog.showModal(); }); $('#frb-dialog-donor-badge .frb-dialog-close').on( 'click', function(e) { donorBadgeDialog.close(); e.target.blur(); }); }, setCookie: function() { const DONOR_BADGE_COOKIE_NAME = 'fundraising_donor_badge'; const DONOR_BADGE_COOKIE_OPTIONS = { domain: 'wikipedia.org', path: '/', expires: 90 * 24 * 60 * 60 // 90 days }; mw.loader.using( 'mediawiki.cookie' ).then( function () { $.cookie( DONOR_BADGE_COOKIE_NAME, '1', DONOR_BADGE_COOKIE_OPTIONS ); }); } }; donorBadge.init(); // hack to set page language based on template const tyPage = document.querySelector( '.ty-page' ); if ( tyPage ) { document.documentElement.lang = tyPage.lang || 'en'; } }); if ( navigator.share ) { $('#ty-web-share').click(function(e) { var url = 'https://donate.wikimedia.org/?wmf_medium=SocialMedia&wmf_campaign=ThankYouPage&wmf_source=WebShare'; if ( $(this).data('share-language') ) { url += '&uselang=' + $(this).data('share-language'); } navigator.share({ text: $(this).data('share-text'), url: url }); e.preventDefault(); }); $('#ty-web-share').show(); } /* Show all elements for testing and checking translations */ function tyDebug() { $('.ty-page *:not(dialog)').show(); } 0h966fcnxs843dqqkzscizsi5ctxdft