MediaWiki:Common.js: Difference between revisions

From Startupidia
Redirect anonymous users to login page when they try to edit
Tag: Reverted
Checking bugs
 
(6 intermediate revisions by the same user not shown)
Line 1: Line 1:
/* Any JavaScript here will be loaded for all users on every page load. */
/* Any JavaScript here will be loaded for all users on every page load. */


$(function () {
$(document).ready(function() {
  const structuredData = {
    // Create a <script> tag for schema markup
    "@context": "https://schema.org",
    var schemaScript = document.createElement('script');
    "@type": "WebSite",
    schemaScript.type = 'application/ld+json';
    "name": "Startupedia",
    schemaScript.text = JSON.stringify({
    "url": "https://startupwiki.ai",
        "@context": "http://schema.org",
    "potentialAction": {
        "@type": "WebSite",
      "@type": "SearchAction",
        "name": "Startupidia",
      "target": "https://startupwiki.ai/index.php?search={search_term_string}",
        "url": "https://startupidia.org",
      "query-input": "required name=search_term_string"
        "description": "Startupidia is an innovative, dedicated encyclopedia designed to serve as a comprehensive resource for the startup ecosystem.",
    }
        "publisher": {
  };
            "@type": "Organization",
 
            "name": "Startupidia",
  const script = document.createElement('script');
            "url": "https://startupidia.org",
  script.type = 'application/ld+json';
            "logo": {
  script.text = JSON.stringify(structuredData);
                "@type": "ImageObject",
  document.head.appendChild(script);
                "url": "https://startupidia.org/resources/assets/Startupeidia_Logo.png",
                "caption": "Startupidia Logo"
            }
        },
        "potentialAction": {
            "@type": "SearchAction",
            "target": "https://startupidia.org/index.php?title=Special:Search&search={search_term_string}",
            "query-input": "required name=search_term_string"
        }
    });
    document.head.appendChild(schemaScript);
});
});


$(function () {
$(function () {
   $('a.external').attr('target', '_blank');
   $('a.external').attr('target', '_blank');
});
// Redirect anonymous users to login page when they try to edit
$(function () {
    var isAnon = mw.config.get('wgUserName') === null;
    var action = mw.config.get('wgAction');
    if (isAnon && (action === 'edit' || action === 'submit')) {
        var returnTo = mw.config.get('wgPageName');
        window.location.href = mw.util.getUrl('Special:UserLogin') + '?returnto=' + encodeURIComponent(returnTo);
    }
});
});

Latest revision as of 17:08, 21 July 2025

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

$(document).ready(function() {
    // Create a <script> tag for schema markup
    var schemaScript = document.createElement('script');
    schemaScript.type = 'application/ld+json';
    schemaScript.text = JSON.stringify({
        "@context": "http://schema.org",
        "@type": "WebSite",
        "name": "Startupidia",
        "url": "https://startupidia.org",
        "description": "Startupidia is an innovative, dedicated encyclopedia designed to serve as a comprehensive resource for the startup ecosystem.",
        "publisher": {
            "@type": "Organization",
            "name": "Startupidia",
            "url": "https://startupidia.org",
            "logo": {
                "@type": "ImageObject",
                "url": "https://startupidia.org/resources/assets/Startupeidia_Logo.png",
                "caption": "Startupidia Logo"
            }
        },
        "potentialAction": {
            "@type": "SearchAction",
            "target": "https://startupidia.org/index.php?title=Special:Search&search={search_term_string}",
            "query-input": "required name=search_term_string"
        }
    });
    document.head.appendChild(schemaScript);
});

$(function () {
  $('a.external').attr('target', '_blank');
});