A simple pastebin you can run on any server with Apache and PHP.
Nevar pievienot vairāk kā 25 tēmas Tēmai ir jāsākas ar burtu vai ciparu, tā var saturēt domu zīmes ('-') un var būt līdz 35 simboliem gara.

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. /*******************************/
  2. /* EVENT LISTENER MANIPULATION */
  3. /*******************************/
  4. /* Adds an event listener to a button (or other clickable element), attaching
  5. it to both "click" and "keyup" events (for use with keyboard navigation).
  6. Optionally also attaches the listener to the 'mousedown' event, making the
  7. element activate on mouse down instead of mouse up. */
  8. Element.prototype.addActivateEvent = function(func, includeMouseDown) {
  9. let ael = this.activateEventListener = (event) => { if (event.button === 0 || event.key === ' ') func(event) };
  10. if (includeMouseDown) this.addEventListener("mousedown", ael);
  11. this.addEventListener("click", ael);
  12. this.addEventListener("keyup", ael);
  13. }
  14. /* Removes event listener from a clickable element, automatically detaching it
  15. from all relevant event types. */
  16. Element.prototype.removeActivateEvent = function() {
  17. let ael = this.activateEventListener;
  18. this.removeEventListener("mousedown", ael);
  19. this.removeEventListener("click", ael);
  20. this.removeEventListener("keyup", ael);
  21. }
  22. /***********/
  23. /* HELPERS */
  24. /***********/
  25. function selectElementContents(element) {
  26. var range = document.createRange();
  27. range.selectNodeContents(element);
  28. var selection = window.getSelection();
  29. selection.removeAllRanges();
  30. selection.addRange(range);
  31. }
  32. function copyTextToClipboard(string) {
  33. let scratchpad = document.querySelector("#scratchpad");
  34. scratchpad.value = string;
  35. scratchpad.select();
  36. document.execCommand("copy");
  37. }
  38. function setMessage(string) {
  39. document.querySelector("#controls .message").innerText = string;
  40. }