Jump to content

MediaWiki:Common.js: Difference between revisions

From Global Wiki
No edit summary
No edit summary
Line 61: Line 61:
             '<p style="margin: 5px 0; color: black; font-size: 110%;">See the sample profile below 👇</p>' +
             '<p style="margin: 5px 0; color: black; font-size: 110%;">See the sample profile below 👇</p>' +
             '<a href="https://api.whatsapp.com/send?phone=918464032709&text=Hi,%20I%20checked%20the%20sample%20profile%20and%20would%20like%20to%20publish%20my%20profile." target="_blank">' +
             '<a href="https://api.whatsapp.com/send?phone=918464032709&text=Hi,%20I%20checked%20the%20sample%20profile%20and%20would%20like%20to%20publish%20my%20profile." target="_blank">' +
                 '<button style="margin-top: 10px; padding: 12px 24px; font-size: 18px; background-color: #044b4f; color: white; border: 2px solid #30a0a2; border-radius: 5px; cursor: pointer;">Publish My Profile</button>' +
                 '<button class="publish-profile-button" style="margin-top: 10px; padding: 12px 24px; font-size: 18px; background-color: #044b4f; color: white; border: 2px solid #30a0a2; border-radius: 5px; cursor: pointer;">Publish My Profile</button>' +
             '</a>' +
             '</a>' +
         '</div>');
         '</div>');
Line 75: Line 75:
             '<p style="margin: 5px 0; color: black; font-size: 110%;">Profile will index on Google in 3 days.</p>' +
             '<p style="margin: 5px 0; color: black; font-size: 110%;">Profile will index on Google in 3 days.</p>' +
             '<a href="https://api.whatsapp.com/send?phone=918464032709&text=Hi,%20I%20checked%20the%20sample%20profile%20and%20would%20like%20to%20publish%20my%20profile." target="_blank">' +
             '<a href="https://api.whatsapp.com/send?phone=918464032709&text=Hi,%20I%20checked%20the%20sample%20profile%20and%20would%20like%20to%20publish%20my%20profile." target="_blank">' +
                 '<button style="margin-top: 10px; padding: 12px 24px; font-size: 18px; background-color: #044b4f; color: white; border: 2px solid #30a0a2; border-radius: 5px; cursor: pointer;">Publish My Profile</button>' +
                 '<button class="publish-profile-button" style="margin-top: 10px; padding: 12px 24px; font-size: 18px; background-color: #044b4f; color: white; border: 2px solid #30a0a2; border-radius: 5px; cursor: pointer;">Publish My Profile</button>' +
             '</a>' +
             '</a>' +
         '</div>');
         '</div>');
Line 97: Line 97:
         var stickyFooter = $(
         var stickyFooter = $(
             '<div id="custom-sticky-footer" style="position: fixed; bottom: 0; left: 0; width: 100%; background: #f1f8e9; color: white; text-align: center; padding: 20px 0; z-index: 99999; box-shadow: 0 -2px 5px rgba(0,0,0,0.15);">' +
             '<div id="custom-sticky-footer" style="position: fixed; bottom: 0; left: 0; width: 100%; background: #f1f8e9; color: white; text-align: center; padding: 20px 0; z-index: 99999; box-shadow: 0 -2px 5px rgba(0,0,0,0.15);">' +
                 '<button id="sticky-footer-button" style="padding: 30px 80px; font-size: 40px; background: #044b4f; color: white; border: 3px solid #30a0a2; border-radius: 8px; font-weight: bold; cursor: pointer; max-width: 90%; width: 700px;">Publish My Profile</button>' +
                 '<button class="publish-profile-button" id="sticky-footer-button" style="padding: 30px 80px; font-size: 40px; background: #044b4f; color: white; border: 3px solid #30a0a2; border-radius: 8px; font-weight: bold; cursor: pointer; max-width: 90%; width: 700px;">Publish My Profile</button>' +
             '</div>'
             '</div>'
         );
         );

Revision as of 16:54, 18 May 2025

/* Any JavaScript here will be loaded for all users on every page load. */


/* === Viewport Meta Tag Injection for Mobile Responsiveness - START === */
$(document).ready(function() {
    if ($('meta[name="viewport"]').length === 0) {
        $('head').append('<meta name="viewport" content="width=1024">');
        console.log('Viewport meta tag with fixed width added');
    } else {
        // If viewport tag exists, replace it with fixed width one
        $('meta[name="viewport"]').attr('content', 'width=1024');
        console.log('Viewport meta tag replaced with fixed width');
    }
});
/* === Viewport Meta Tag Injection for Mobile Responsiveness - END === */


/* === Draft article dialogue box on draft pages - START === */
$(document).ready(function() {
    if (mw.config.get('wgNamespaceNumber') === 120) {
        var warningHtml = '<div class="template-td" style="background-color: #ffcc00; color: black; padding: 10px; border-radius: 5px; font-weight: bold; text-align: center; margin-bottom:10px;">⚠ This is a draft article created for review. It is not yet published in the main space. Once approved, it will be moved to the main site and become publicly visible. ⚠</div>';
        
        // Insert after the subtitle, which is below the title and action tabs
        $('#mw-content-subtitle').after(warningHtml);
    }
});
/* === Draft article dialogue box on draft pages - END === */


/* === Custom Wikipedia Disclaimer at the Very End of Page - START === */
$(document).ready(function () {
    var footerDisclaimer = $('<div style="text-align:center; font-size:12px; padding:10px; background:#f9f9f9; border-top:1px solid #ccc;">This website is not affiliated with Wikipedia or the Wikimedia Foundation. Content is independently published.</div>');
    $('body').append(footerDisclaimer);
});
/* === Custom Wikipedia Disclaimer at the Very End of Page - END === */



/* === Verified blue tick beside page title - START === */
$(document).ready(function () {
    if (mw.config.get("wgNamespaceNumber") === 0) { // Main/article pages only
        var title = $('#firstHeading');
        var badgeUrl = 'https://globalwiki.org/images/2/22/Verified.png';

        $('<img>', {
            src: badgeUrl,
            alt: 'Verified',
            style: 'margin-left: 10px; height: 20px; vertical-align: middle;'
        }).appendTo(title);
    }
});
/* === Verified blue tick beside page title - END === */

// === START: Custom Header and Footer for "Prasad" Page ===
$(document).ready(function () {
    if (mw.config.get('wgPageName') === 'Prasad') {

        // === START: Custom Header Section ===
        var customHeader = $('<div class="custom-header" style="background: #f1f8e9; padding: 15px; text-align: center; margin-bottom: 15px; border-radius: 10px;">' +
            '<h2 style="margin: 5px 0 11px 0; color: #044b4f; font-weight: bold;">Publish Your Biography & Visible on Google - Just ₹2000/-</h2>' +
            '<p style="margin: 5px 0; color: black; font-size: 110%;">See the sample profile below 👇</p>' +
            '<a href="https://api.whatsapp.com/send?phone=918464032709&text=Hi,%20I%20checked%20the%20sample%20profile%20and%20would%20like%20to%20publish%20my%20profile." target="_blank">' +
                '<button class="publish-profile-button" style="margin-top: 10px; padding: 12px 24px; font-size: 18px; background-color: #044b4f; color: white; border: 2px solid #30a0a2; border-radius: 5px; cursor: pointer;">Publish My Profile</button>' +
            '</a>' +
        '</div>');

        // Move the header to the top before the page title and menu box
        $('#mw-content-text').parent().before(customHeader);
        // === END: Custom Header Section ===


        // === START: Custom Footer Section ===
        var customFooter = $('<div class="custom-footer" style="background: #f1f8e9; padding: 15px; text-align: center; margin-top: 30px; border-radius: 10px;">' +
            '<h3 style="margin: 5px 0; color: #044b4f;">No Advance Needed - Pay after your profile is live.</h3>' +
            '<p style="margin: 5px 0; color: black; font-size: 110%;">Profile will index on Google in 3 days.</p>' +
            '<a href="https://api.whatsapp.com/send?phone=918464032709&text=Hi,%20I%20checked%20the%20sample%20profile%20and%20would%20like%20to%20publish%20my%20profile." target="_blank">' +
                '<button class="publish-profile-button" style="margin-top: 10px; padding: 12px 24px; font-size: 18px; background-color: #044b4f; color: white; border: 2px solid #30a0a2; border-radius: 5px; cursor: pointer;">Publish My Profile</button>' +
            '</a>' +
        '</div>');

        // Insert footer after page content
        $('#mw-content-text').after(customFooter);
        // === END: Custom Footer Section ===
    }
});
// === END: Custom Header and Footer for "Prasad" Page ===


/* === Sticky Footer with WhatsApp CTA button on Prasad page - START === */
$(document).ready(function () {
    var pageName = mw.config.get('wgPageName');
    console.log('Common.js loaded on page:', pageName);

    if (pageName === 'Prasad') {
        console.log('On Prasad page - adding sticky footer');

        var stickyFooter = $(
            '<div id="custom-sticky-footer" style="position: fixed; bottom: 0; left: 0; width: 100%; background: #f1f8e9; color: white; text-align: center; padding: 20px 0; z-index: 99999; box-shadow: 0 -2px 5px rgba(0,0,0,0.15);">' +
                '<button class="publish-profile-button" id="sticky-footer-button" style="padding: 30px 80px; font-size: 40px; background: #044b4f; color: white; border: 3px solid #30a0a2; border-radius: 8px; font-weight: bold; cursor: pointer; max-width: 90%; width: 700px;">Publish My Profile</button>' +
            '</div>'
        );

        $('body').append(stickyFooter);
        $('body').css('padding-bottom', '100px');

        $('#sticky-footer-button').click(function () {
            window.open('https://api.whatsapp.com/send?phone=918464032709&text=Hi,%20I%20checked%20the%20sample%20profile%20and%20would%20like%20to%20publish%20my%20profile.', '_blank');
        });

        var lastScrollTop = 0;
        var footer = $('#custom-sticky-footer');

        $(window).on('scroll', function () {
            var st = $(this).scrollTop();
            if (st < lastScrollTop) {
                footer.show();
            } else {
                footer.show();
            }
            lastScrollTop = st;
        });
    }
});
/* === Sticky Footer with WhatsApp CTA button on Prasad page - END === */


// Google Tag Manager script injection (head) - START //
(function(w,d,s,l,i){
  w[l]=w[l]||[];
  w[l].push({'gtm.start': new Date().getTime(), event:'gtm.js'});
  var f=d.getElementsByTagName(s)[0],
      j=d.createElement(s),
      dl=l!='dataLayer'?'&l='+l:'';
  j.async=true;
  j.src='https://www.googletagmanager.com/gtm.js?id='+i+dl;
  f.parentNode.insertBefore(j,f);
})(window,document,'script','dataLayer','GTM-P6Z2D7SR');

// Google Tag Manager <noscript> injection (body)
$(document).ready(function() {
  var iframe = document.createElement('iframe');
  iframe.src = "https://www.googletagmanager.com/ns.html?id=GTM-P6Z2D7SR";
  iframe.height = 0;
  iframe.width = 0;
  iframe.style.display = "none";
  iframe.style.visibility = "hidden";
  document.body.insertBefore(iframe, document.body.firstChild);
});
// Google Tag Manager script injection (head) - END//