MediaWiki:Common.js: Difference between revisions
Knowlepedia (talk | contribs) Created page with "→Any JavaScript here will be loaded for all users on every page load.: mw.loader.using('mediawiki.util').then(function () { function initAutoScroll() { const container = document.getElementById('scrollable-articles'); if (!container) return; if (container.dataset.autoScrollInitialized) return; container.dataset.autoScrollInitialized = 'true'; if (!container.dataset.duplicated) { const originalChildren = Array.from(container.children);..."  |
Knowlepedia (talk | contribs) No edit summary  |
||
(13 intermediate revisions by the same user not shown) | |||
Line 73: | Line 73: | ||
}); | }); | ||
$(document).ready(function () { | |||
$(document).ready(function() { | Â // Auto-tag NeedsReview | ||
  if (mw.config.get("wgAction") === "edit" || mw.config.get("wgAction") === "submit") { |   if (mw.config.get("wgAction") === "edit" || mw.config.get("wgAction") === "submit") { | ||
   var userGroups = mw.config.get( |    var userGroups = mw.config.get("wgUserGroups") || []; | ||
   if (userGroups.includes( |    if (userGroups.includes("user") && !userGroups.includes("approver") && !userGroups.includes("sysop")) { | ||
    var $wpTextbox1 = $( |     var $wpTextbox1 = $("#wpTextbox1"); | ||
    if ($wpTextbox1.length |  | ||
     |     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 () { | |||
 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'); | |||
  } |   } | ||
}); | }); |