Difference between revisions of "MediaWiki:QRCode.js"
Jump to navigation
Jump to search
Jayprakash (talk | contribs) (Created page with "/* This is userscirpt to genreate qr Code on wiki. @Author User:Jayprakash12345 @OwnBy meta:Indic-TechCom Please note The word "QR Code" is registered t...") |
Jayprakash (talk | contribs) m |
||
| (2 intermediate revisions by the same user not shown) | |||
| Line 1: | Line 1: | ||
/* | /* | ||
| − | This is userscirpt to | + | This is userscirpt to Generate qr Code on wiki. |
@Author [[User:Jayprakash12345]] | @Author [[User:Jayprakash12345]] | ||
| Line 10: | Line 10: | ||
// Load module | // Load module | ||
| − | mw.loader.load( ' | + | mw.loader.load( '/index.php?title=User:Jayprakash/jquery-qrcode.min.js&action=raw&ctype=text/javascript' ); |
// Add a portlet link. | // Add a portlet link. | ||
| Line 16: | Line 16: | ||
'p-tb', | 'p-tb', | ||
'#', | '#', | ||
| − | ' | + | 'Generate QR code' |
); | ); | ||
| Line 24: | Line 24: | ||
pageName = mw.config.get( 'wgPageName' ) | pageName = mw.config.get( 'wgPageName' ) | ||
| − | url = | + | url = mw.config.get( 'wgServer' ) + '/wiki/' + mw.config.get( 'wgPageName' ); |
// Create dic with qrCode id | // Create dic with qrCode id | ||
Latest revision as of 12:25, 13 January 2020
/*
This is userscirpt to Generate qr Code on wiki.
@Author [[User:Jayprakash12345]]
@OwnBy [[meta:Indic-TechCom]]
Please note The word "QR Code" is registered trademark of DENSO WAVE INCORPORATED
*/
$(document).ready( function() {
// Load module
mw.loader.load( '/index.php?title=User:Jayprakash/jquery-qrcode.min.js&action=raw&ctype=text/javascript' );
// Add a portlet link.
var link = mw.util.addPortletLink(
'p-tb',
'#',
'Generate QR code'
);
// Trigger for portlet link
$(link).click( function( e ) {
e.preventDefault();
pageName = mw.config.get( 'wgPageName' )
url = mw.config.get( 'wgServer' ) + '/wiki/' + mw.config.get( 'wgPageName' );
// Create dic with qrCode id
qrCodeDiv = $( '<div/>' ).attr('id','qrCode');
// Create paragraph
para = $('<p/>').css('font-weight', 'bold').text('This is the QR Code for '+ url + ' URL.' )
$( qrCodeDiv ).append( para, '<br/>' );
$( '#bodyContent' ).children().hide();
$( '#bodyContent' ).append( qrCodeDiv );
var qrcode = $( '#qrCode' ).qrcode( {
render: 'canvas',
text: url,
size: '460'
} );
mw.loader.using( 'oojs-ui-core' ).done( function () {
var downloadBtn = new OO.ui.ButtonWidget( { label: 'Download PNG' } ),
cancelBtn = new OO.ui.ButtonWidget( { label: 'Back to Page', flags: ['destructive' ] } );
cancelBtn.on( 'click', function () {
location.reload();
} );
downloadBtn.on( 'click', function () {
var a = document.createElement('a');
a.href = $(document).find('canvas').get(0).toDataURL('image/png');
a.download = mw.config.get( 'wgPageName' ) + '-qrCode.png';
document.body.appendChild(a);
a.click();
document.body.removeChild(a);
} );
var notice = '<br/><br/><small>Notice: The word QR Code is registered trademark of DENSO WAVE INCORPORATED</small>';
$( '#qrCode' ).append( '<br/><br/>', downloadBtn.$element, cancelBtn.$element, notice );
} );
});
});