MediaWiki:Common.js: Difference between revisions

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


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

Revision as of 13:47, 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 copyToClip(str) {
  function listener(e) {
    e.clipboardData.setData("text/html", str);
    e.clipboardData.setData("text/plain", str);
    e.preventDefault();
  }
  document.addEventListener("copy", listener);
  document.execCommand("copy");
  document.removeEventListener("copy", listener);
};