MediaWiki:Common.js

From Sanatan Hindu Dharma
Revision as of 17:54, 7 February 2025 by Admin (talk | contribs)

Note: After publishing, you may have to bypass your browser's cache to see the changes.

  • Firefox / Safari: Hold Shift while clicking Reload, or press either Ctrl-F5 or Ctrl-R (⌘-R on a Mac)
  • Google Chrome: Press Ctrl-Shift-R (⌘-Shift-R on a Mac)
  • Internet Explorer / Edge: Hold Ctrl while clicking Refresh, or press Ctrl-F5
  • Opera: Press Ctrl-F5.
/* Any JavaScript here will be loaded for all users on every page load. */
$(document).ready(function() {
    if (mw.config.get('wgNamespaceNumber') >= 0) { // Only show on normal pages
        var pageName = mw.config.get('wgTitle'); // Get the current page name

        // Create a hidden input field to store page name
        var inputField = $('<input>')
            .attr('type', 'hidden')
            .attr('id', 'currentPageName')
            .attr('value', pageName);

        $('body').append(inputField); // Add hidden field to the body

        // Create Upload Button
        $('<div style="position:fixed; bottom:20px; right:20px; background:#007bff; color:white; padding:10px; border-radius:5px; cursor:pointer; font-weight:bold;">Upload a Video</div>')
        .click(function() {
            window.location.href = mw.util.getUrl('Form:UploadVideo');
        }).appendTo('body');
    }
});