221
edits
No edit summary |
No edit summary |
||
Line 705: | Line 705: | ||
$(document).ready(function() { | $(document).ready(function() { | ||
// Get the page title | |||
var pageTitle = mw.config.get('wgTitle'); | |||
var pageTitle | // Encode the title and replace spaces with '%20' | ||
var encodedTitle = encodeURIComponent(pageTitle).replace(/%20/g, '%20'); // Correctly handle spaces | |||
var downloadButton = | // Create the download button | ||
var downloadButton = $('<a>') | |||
.attr('href', 'https://wiki.ekatrafoundation.org/images/epub/' + encodedTitle + '.epub') | |||
.attr('download', '') // Suggests to download the file rather than opening it | |||
.text('Download EPUB') | |||
.css({ | |||
'display': 'inline-block', | |||
'padding': '8px 16px', | |||
'background-color': '#4CAF50', | |||
'color': '#ffffff', | |||
'text-align': 'center', | |||
'border-radius': '4px', | |||
'text-decoration': 'none', | |||
'margin-top': '10px' | |||
}); | |||
// Add the button to the page content | |||
$('#bodyContent').append(downloadButton); | |||
}); | }); |