MediaWiki:Common.js: Difference between revisions
From Sanatan Hindu Dharma
No edit summary |
No edit summary Tag: Reverted |
||
| Line 2: | Line 2: | ||
$(document).ready(function() { | $(document).ready(function() { | ||
if (mw.config.get('wgNamespaceNumber') >= 0) { // Only show on normal pages | if (mw.config.get('wgNamespaceNumber') >= 0) { // Only show on normal pages | ||
var pageName = mw.config.get(' | 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>') | $('<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() { | .click(function() { | ||
window.location.href = | window.location.href = mw.util.getUrl('Form:UploadVideo'); | ||
}).appendTo('body'); | }).appendTo('body'); | ||
} | } | ||
}); | }); | ||
Revision as of 17:54, 7 February 2025
/* 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');
}
});
