MediaWiki:Common.js: Difference between revisions

no edit summary
No edit summary
No edit summary
Line 705: Line 705:


$(document).ready(function() {
$(document).ready(function() {
     alert('Script is running'); // This will confirm if the script is being executed.
     alert('Inline Script is running');


    // Get the page title
     var pageTitle = mw.config.get('wgTitle');
     var pageTitle = mw.config.get('wgTitle');


    // Create the download button
     var downloadButton = document.createElement('a');
     var downloadButton = $('<a>')
    downloadButton.href = '/find_epub.php?title=' + encodeURIComponent(pageTitle);
        .attr('href', '/find_epub.php?title=' + encodeURIComponent(pageTitle))
    downloadButton.innerText = 'Download EPUB';
        .text('Download EPUB')
    downloadButton.style.display = 'inline-block';
        .css({
    downloadButton.style.padding = '8px 16px';
            'display': 'inline-block',
    downloadButton.style.backgroundColor = '#4CAF50';
            'padding': '8px 16px',
    downloadButton.style.color = '#ffffff';
            'background-color': '#4CAF50',
    downloadButton.style.textAlign = 'center';
            'color': '#ffffff',
    downloadButton.style.borderRadius = '4px';
            'text-align': 'center',
    downloadButton.style.textDecoration = 'none';
            'border-radius': '4px',
    downloadButton.style.marginTop = '10px';
            'text-decoration': 'none',
    downloadButton.style.marginBottom = '10px';
            'margin-top': '10px',
            'margin-bottom': '10px'
        });


     // Add the button to the content area
     var contentArea = document.getElementById('mw-content-text');
    $('#mw-content-text').prepend(downloadButton); // Change to append if needed
    if (contentArea) {
        contentArea.insertBefore(downloadButton, contentArea.firstChild);
    } else {
        console.error('Content area not found.');
    }
});
});