MediaWiki:Common.js: Difference between revisions

No edit summary
No edit summary
Line 5: Line 5:
}
}


function copyToClip(str) {
function copyToClipboard(element) {
   function listener(e) {
   var $temp = $("<input>");
    e.clipboardData.setData("text/html", str);
  $("body").append($temp);
    e.clipboardData.setData("text/plain", str);
   $temp.val($(element).text()).select();
    e.preventDefault();
   }
  document.addEventListener("copy", listener);
   document.execCommand("copy");
   document.execCommand("copy");
   document.removeEventListener("copy", listener);
   $temp.remove();
};
}

Revision as of 15:11, 20 April 2023

/* Any JavaScript here will be loaded for all users on every page load. */

if ( mw.config.get( 'wgCanonicalSpecialPageName' ) === 'Watchlist' ) {
    document.body.classList.add( 'mw-rcfilters-ui-initialized' );
}

function copyToClipboard(element) {
  var $temp = $("<input>");
  $("body").append($temp);
  $temp.val($(element).text()).select();
  document.execCommand("copy");
  $temp.remove();
}
No categories assignedEdit