Jump to content

MediaWiki:Common.js: Difference between revisions

From A Modern Way To Be Known
No edit summary
Tags: Manual revert Reverted
No edit summary
Tag: Reverted
Line 1: Line 1:
/* Any JavaScript here will be loaded for all users on every page load. */
mw.loader.using('mediawiki.util').then(function () {
mw.loader.using('mediawiki.util').then(function () {
  function initAutoScroll() {
    const container = document.getElementById('scrollable-articles');
    if (!container) return;


    if (container.dataset.autoScrollInitialized) return;
  if (
     container.dataset.autoScrollInitialized = 'true';
    mw.config.get('wgNamespaceNumber') === 0 &&
     mw.config.get('wgTitle') === 'Gaurav_Singh_Chouhan'
  ) {


     if (!container.dataset.duplicated) {
     var personSchema = {
       const originalChildren = Array.from(container.children);
      "@context": "https://schema.org",
       originalChildren.forEach(child => {
      "@type": "Person",
         const clone = child.cloneNode(true);
      "name": "Gaurav Singh Chouhan",
         container.appendChild(clone);
      "image": "https://bharatwikipedia.org/wiki/Special:FilePath/Gaurav_Singh_Chouhan.jpg",
       });
       "url": "https://bharatwikipedia.org/wiki/Gaurav_Singh_Chouhan",
       container.dataset.originalWidth = container.scrollWidth / 2;
       "sameAs": [
       container.dataset.duplicated = 'true';
        "https://www.instagram.com/mrgauravchouhan",
     }
         "https://www.linkedin.com/in/mrgauravchouhan",
         "https://x.com/mrgauravchouhan"
      ],
      "birthDate": "1999-07-21",
       "jobTitle": "Writer, Law Student, Motivational Speaker",
       "nationality": "Indian",
       "description": "Gaurav Singh Chouhan is an Indian writer, motivational speaker, and law student."
     };


     let scrollSpeed = window.innerWidth < 500 ? 0.3 : 0.5;
     var script = document.createElement('script');
    let requestId;
     script.type = 'application/ld+json';
 
     script.text = JSON.stringify(personSchema);
    function autoScroll() {
     document.head.appendChild(script);
      container.scrollLeft += scrollSpeed;
      const originalWidth = parseFloat(container.dataset.originalWidth);
 
      if (container.scrollLeft >= originalWidth) {
        container.scrollLeft -= originalWidth;
      }
 
      requestId = requestAnimationFrame(autoScroll);
      container._autoScrollRequestId = requestId;
    }
 
    if (container._autoScrollRequestId) {
      cancelAnimationFrame(container._autoScrollRequestId);
    }
 
     function pauseScroll() {
      if (container._autoScrollRequestId) {
        cancelAnimationFrame(container._autoScrollRequestId);
        container._autoScrollRequestId = null;
      }
    }
 
    function resumeScroll() {
      if (!container._autoScrollRequestId) {
        autoScroll();
      }
    }
 
    container.removeEventListener('mouseenter', pauseScroll);
     container.removeEventListener('mouseleave', resumeScroll);
 
     container.addEventListener('mouseenter', pauseScroll);
    container.addEventListener('mouseleave', resumeScroll);
 
    autoScroll();
   }
   }


  if (document.readyState === 'complete' || document.readyState === 'interactive') {
    initAutoScroll();
  } else {
    document.addEventListener('DOMContentLoaded', initAutoScroll);
  }
  mw.hook('wikipage.content').add(initAutoScroll);
});
});
// Hide 'View source' tab using JS fallback
$(document).ready(function () {
  $('#ca-viewsource').hide();
});
$(document).ready(function () {
  // Auto-tag NeedsReview
  if (mw.config.get("wgAction") === "edit" || mw.config.get("wgAction") === "submit") {
    var userGroups = mw.config.get("wgUserGroups") || [];
    if (userGroups.includes("user") && !userGroups.includes("approver") && !userGroups.includes("sysop")) {
      var $wpTextbox1 = $("#wpTextbox1");
      if ($wpTextbox1.length) {
        var currentText = $wpTextbox1.val();
        // Add NeedsReview if not present
        if (!currentText.includes("{{NeedsReview}}")) {
          currentText = "{{NeedsReview}}\n" + currentText;
        }
        // Add Notability if it's a new page and not already added
        var isNewPage = mw.config.get("wgIsArticle") === false;
        if (isNewPage && !currentText.includes("{{Notability")) {
          currentText = "{{Notability|reason=Please add reliable sources.|by=" + mw.config.get("wgUserName") + "|date=" + new Date().toLocaleString('default', { month: 'long', year: 'numeric' }) + "}}\n" + currentText;
        }
        // Set updated text
        $wpTextbox1.val(currentText);
      }
    }
  }
  // Meta description injection (SEO)
  var desc = $('meta[name="knowlepedia-desc"]').attr("content");
  if (desc) {
    $('head').append('<meta name="description" content="' + desc + '">');
  }
});
mw.loader.using('mediawiki.util').then(function () {
mw.loader.using('mediawiki.util').then(function () {
  var schema = {
    "@context": "https://schema.org",
    "@type": "Person",
    "name": "Gaurav Singh Chouhan",
    "image": "https://commons.wikimedia.org/wiki/Special:FilePath/Gaurav_Singh_Chouhan.jpg",
    "url": "https://knowlepedia.org/wiki/Gaurav_Singh_Chouhan",
    "sameAs": [
      "https://www.imdb.com/name/nm14658047/",
      "https://www.instagram.com/mrgauravchouhan",
      "https://www.linkedin.com/in/mrgauravchouhan",
      "https://x.com/mrgauravchouhan",
      "https://www.timesofmalwa.in/2025/06/gaurav-singh-chouhan.html"
    ],
    "birthDate": "1999-07-21",
    "jobTitle": "Writer, Law Student, Motivational Speaker",
    "alumniOf": "Chaudhary Charan Singh University",
    "nationality": "Indian",
    "description": "Gaurav Singh Chouhan is an Indian writer, motivational speaker, and BA LLB student, known for his public talks and biography 'From Pen to Purpose.'"
  };


  var script = document.createElement('script');
  script.type = 'application/ld+json';
  script.text = JSON.stringify(schema);
  document.head.appendChild(script);
});
$(document).ready(function () {
  if (mw.config.get('wgNamespaceNumber') === 2 && mw.config.get('wgTitle').endsWith('/Dashboard')) {
    mw.util.addPortletLink('p-personal', mw.config.get('wgServer') + '/wiki/User:' + mw.config.get('wgUserName') + '/Dashboard', '🛠 Dashboard');
  }
});
// Show lock icon for protected pages
$(function () {
  if (mw.config.get("wgIsProtected")) {
    $("<span>")
      .addClass("mw-protected-icon")
      .css({
        float: "right",
        marginLeft: "10px",
        fontSize: "16px"
      })
      .html("🔒")
      .prependTo(".mw-first-heading");
  }
});
// === Google Analytics 4 (GA4) - gtag ===
(function () {
  var s = document.createElement('script');
  s.async = true;
  s.src = 'https://www.googletagmanager.com/gtag/js?id=G-BQD14XDBB1';
  document.head.appendChild(s);
  window.dataLayer = window.dataLayer || [];
  function gtag(){dataLayer.push(arguments);}
  window.gtag = window.gtag || gtag;
  gtag('js', new Date());
  gtag('config', 'G-BQD14XDBB1');
})();
mw.loader.using('mediawiki.util').then(function () {
   if (
   if (
     mw.config.get('wgNamespaceNumber') === 0 &&
     mw.config.get('wgNamespaceNumber') === 0 &&
     mw.config.get('wgTitle') === 'Trilok_Media'
     mw.config.get('wgTitle') === 'ConnexAbility_Private_Limited'
   ) {
   ) {
     var orgSchema = {
     var orgSchema = {
       "@context": "https://schema.org",
       "@context": "https://schema.org",
       "@type": "Organization",
       "@type": "Organization",
       "name": "Trilok Media",
       "name": "ConnexAbility Private Limited",
       "alternateName": "Trilok Media Agency",
       "alternateName": "ConnexAbility",
       "description": "Trilok Media is an Indian digital marketing and public relations agency providing SEO, online reputation management, media coverage, and brand visibility solutions.",
       "url": "https://bharatwikipedia.org/wiki/ConnexAbility_Private_Limited",
       "foundingDate": "2022",
       "logo": "https://bharatwikipedia.org/wiki/Special:FilePath/Connex.png",
      "founders": [
      "foundingDate": "2025-09-08",
        { "@type": "Person", "name": "Trilok Singh", "jobTitle": "Founder" },
       "description": "ConnexAbility Private Limited is an Indian branding and digital services company.",
        { "@type": "Person", "name": "Kumkum Singh Chauhan", "jobTitle": "Co-Founder" }
      ],
       "url": "https://trilokmedia.in",
      "logo": "https://trilokmedia.in/logo.png",
       "address": {
       "address": {
         "@type": "PostalAddress",
         "@type": "PostalAddress",
         "addressCountry": "IN"
         "addressCountry": "IN"
       },
       },
      "areaServed": "India",
       "sameAs": [
       "sameAs": [
         "https://www.facebook.com/trilokmedia.in/",
         "https://connexability.in"
        "https://www.instagram.com/trilokmedia.in/",
        "https://www.linkedin.com/company/trilok-media/",
        "https://x.com/trilokmedia_in"
       ]
       ]
     };
     };
Line 211: Line 60:
     document.head.appendChild(script);
     document.head.appendChild(script);
   }
   }
});
mw.loader.using('mediawiki.util').then(function () {
  if (
    mw.config.get('wgNamespaceNumber') === 0 &&
    mw.config.get('wgTitle') === 'Movie_Title_Here'
  ) {
    var movieSchema = {
      "@context": "https://schema.org",
      "@type": "Movie",
      "name": "Movie Name",
      "url": "https://bharatwikipedia.org/wiki/Movie_Title_Here",
      "description": "Movie description here",
      "datePublished": "2024",
      "image": "POSTER_URL"
    };
    var script = document.createElement('script');
    script.type = 'application/ld+json';
    script.text = JSON.stringify(movieSchema);
    document.head.appendChild(script);
  }
});
});

Revision as of 19:40, 17 December 2025

mw.loader.using('mediawiki.util').then(function () {

  if (
    mw.config.get('wgNamespaceNumber') === 0 &&
    mw.config.get('wgTitle') === 'Gaurav_Singh_Chouhan'
  ) {

    var personSchema = {
      "@context": "https://schema.org",
      "@type": "Person",
      "name": "Gaurav Singh Chouhan",
      "image": "https://bharatwikipedia.org/wiki/Special:FilePath/Gaurav_Singh_Chouhan.jpg",
      "url": "https://bharatwikipedia.org/wiki/Gaurav_Singh_Chouhan",
      "sameAs": [
        "https://www.instagram.com/mrgauravchouhan",
        "https://www.linkedin.com/in/mrgauravchouhan",
        "https://x.com/mrgauravchouhan"
      ],
      "birthDate": "1999-07-21",
      "jobTitle": "Writer, Law Student, Motivational Speaker",
      "nationality": "Indian",
      "description": "Gaurav Singh Chouhan is an Indian writer, motivational speaker, and law student."
    };

    var script = document.createElement('script');
    script.type = 'application/ld+json';
    script.text = JSON.stringify(personSchema);
    document.head.appendChild(script);
  }

});
mw.loader.using('mediawiki.util').then(function () {

  if (
    mw.config.get('wgNamespaceNumber') === 0 &&
    mw.config.get('wgTitle') === 'ConnexAbility_Private_Limited'
  ) {

    var orgSchema = {
      "@context": "https://schema.org",
      "@type": "Organization",
      "name": "ConnexAbility Private Limited",
      "alternateName": "ConnexAbility",
      "url": "https://bharatwikipedia.org/wiki/ConnexAbility_Private_Limited",
      "logo": "https://bharatwikipedia.org/wiki/Special:FilePath/Connex.png",
      "foundingDate": "2025-09-08",
      "description": "ConnexAbility Private Limited is an Indian branding and digital services company.",
      "address": {
        "@type": "PostalAddress",
        "addressCountry": "IN"
      },
      "sameAs": [
        "https://connexability.in"
      ]
    };

    var script = document.createElement('script');
    script.type = 'application/ld+json';
    script.text = JSON.stringify(orgSchema);
    document.head.appendChild(script);
  }

});
mw.loader.using('mediawiki.util').then(function () {

  if (
    mw.config.get('wgNamespaceNumber') === 0 &&
    mw.config.get('wgTitle') === 'Movie_Title_Here'
  ) {

    var movieSchema = {
      "@context": "https://schema.org",
      "@type": "Movie",
      "name": "Movie Name",
      "url": "https://bharatwikipedia.org/wiki/Movie_Title_Here",
      "description": "Movie description here",
      "datePublished": "2024",
      "image": "POSTER_URL"
    };

    var script = document.createElement('script');
    script.type = 'application/ld+json';
    script.text = JSON.stringify(movieSchema);
    document.head.appendChild(script);
  }

});