User:Indic-TechCom/Script/BookReader.js
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.
/*
This is userscirpt is to embed BookReader in wiki
@Author [[User:Jayprakash12345]]
@OwnBy [[meta:Indic-TechCom]]
*/
$(document).ready( function() {
function BookReader(){
var src_url = "https://tools.wmflabs.org/bookreader/" + mw.config.get( 'wgContentLanguage' ) + "/" +mw.config.get( 'wgPageName' );
var embed = $("<embed />").attr("src", src_url ).attr("height", "600" ).attr("width", "800" );
var back_link = $("<a />").attr("onclick", "location.reload();" ).text("Back to Normal View");
$("#mw-content-text").empty().append( embed, "<br>", back_link );
}
// Check whether you are in file or index namespace or not
currentpage_namespace = mw.config.get('wgCanonicalNamespace');
if (currentpage_namespace != "File" && currentpage_namespace != "Index" ) {
return;
}
// Check Skin
if ( mw.config.get( 'skin' ) !== "vector" ) {
return;
}
// Add a portlet link.
var link = mw.util.addPortletLink(
'p-views',
'#',
"View in BookReader"
);
// Trigger for portlet link
$(link).click( function( e ) {
e.preventDefault();
BookReader();
});
});