User:Andriy.v/global.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)
- Edge: Hold Ctrl while clicking Refresh, or press Ctrl-F5.
// get unencoded page URL
if (window.CopyURI === undefined) {
window.CopyURI = {
install: function() {
var cu = this;
var link = mw.util.addPortletLink('p-tb', '#', 'Undecoded URL');
$( link ).click( function ( e ) {
e.preventDefault();
cu.showDialog();
});
},
showDialog: function () {
var cu = this;
if( $( '#cu-dialog' ).length === 0 ) {
$( "#mw-content-text" ).append('<div id="cu-dialog"><p style=\"font-size:180%\">'+ decodeURIComponent(window.location.href) + '</p></div>');
}
mw.loader.using( 'jquery.ui', function() {
$( '#cu-dialog' ).dialog({
width: 300,
buttons: {
'Copy' : function() {
cu.SelectText("cu-dialog");
document.execCommand("copy");
},
}
});
});
},
SelectText: function (element) {
var text = document.getElementById(element);
var selection = window.getSelection();
var range = document.createRange();
range.selectNodeContents(text);
selection.removeAllRanges();
selection.addRange(range);
}
};
}
//CopyURI.install();