gbdk-2020 | GameBoy Development Kit |
| download: https://git.y1.nz/archives/gbdk.tar.gz | |
| README | Files | Log | Refs | LICENSE |
docs/config/doxygen-awesome-theme/doxygen-awesome-fragment-copy-button.js
1 // SPDX-License-Identifier: MIT
2 /**
3
4 Doxygen Awesome
5 https://github.com/jothepro/doxygen-awesome-css
6
7 Copyright (c) 2022 - 2025 jothepro
8
9 */
10
11 class DoxygenAwesomeFragmentCopyButton extends HTMLElement {
12 constructor() {
13 super();
14 this.onclick=this.copyContent
15 }
16 static title = "Copy to clipboard"
17 static copyIcon = `<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" width="24" height="24"><path d="M0 0h24v24H0V0z" fill="none"/><path d="M23.04,10.322c0,-2.582 -2.096,-4.678 -4.678,-4.678l-6.918,-0c-2.582,-0 -4.678,2.096 -4.678,4.678c0,-0 0,8.04 0,8.04c0,2.582 2.096,4.678 4.678,4.678c0,-0 6.918,-0 6.918,-0c2.582,-0 4.678,-2.096 4.678,-4.678c0,-0 0,-8.04 0,-8.04Zm-2.438,-0l-0,8.04c-0,1.236 -1.004,2.24 -2.24,2.24l-6.918,-0c-1.236,-0 -2.239,-1.004 -2.239,-2.24l-0,-8.04c-0,-1.236 1.003,-2.24 2.239,-2.24c0,0 6.918,0 6.918,0c1.236,0 2.24,1.004 2.24,2.24Z"/><path d="M5.327,16.748c-0,0.358 -0.291,0.648 -0.649,0.648c0,0 0,0 0,0c-2.582,0 -4.678,-2.096 -4.678,-4.678c0,0 0,-8.04 0,-8.04c0,-2.582 2.096,-4.678 4.678,-4.678l6.918,0c2.168,0 3.994,1.478 4.523,3.481c0.038,0.149 0.005,0.306 -0.09,0.428c-0.094,0.121 -0.239,0.191 -0.392,0.191c-0.451,0.005 -1.057,0.005 -1.457,0.005c-0.238,0 -0.455,-0.14 -0.553,-0.357c-0.348,-0.773 -1.128,-1.31 -2.031,-1.31c-0,0 -6.918,0 -6.918,0c-1.236,0 -2.24,1.004 -2.24,2.24l0,8.04c0,1.236 1.004,2.24 2.24,2.24l0,-0c0.358,-0 0.649,0.29 0.649,0.648c-0,0.353 -0,0.789 -0,1.142Z" style="fill-opacity:0.6;"/></svg>`
18 static successIcon = `<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" width="24" height="24"><path d="M8.084,16.111c-0.09,0.09 -0.212,0.141 -0.34,0.141c-0.127,-0 -0.249,-0.051 -0.339,-0.141c-0.746,-0.746 -2.538,-2.538 -3.525,-3.525c-0.375,-0.375 -0.983,-0.375 -1.357,0c-0.178,0.178 -0.369,0.369 -0.547,0.547c-0.375,0.375 -0.375,0.982 -0,1.357c1.135,1.135 3.422,3.422 4.75,4.751c0.27,0.27 0.637,0.421 1.018,0.421c0.382,0 0.749,-0.151 1.019,-0.421c2.731,-2.732 10.166,-10.167 12.454,-12.455c0.375,-0.375 0.375,-0.982 -0,-1.357c-0.178,-0.178 -0.369,-0.369 -0.547,-0.547c-0.375,-0.375 -0.982,-0.375 -1.357,0c-2.273,2.273 -9.567,9.567 -11.229,11.229Z"/></svg>`
19 static successDuration = 980
20 static init() {
21 $(function() {
22 $(document).ready(function() {
23 if(navigator.clipboard) {
24 const fragments = document.getElementsByClassName("fragment")
25 for(const fragment of fragments) {
26 const fragmentWrapper = document.createElement("div")
27 fragmentWrapper.className = "doxygen-awesome-fragment-wrapper"
28 const fragmentCopyButton = document.createElement("doxygen-awesome-fragment-copy-button")
29 fragmentCopyButton.innerHTML = DoxygenAwesomeFragmentCopyButton.copyIcon
30 fragmentCopyButton.title = DoxygenAwesomeFragmentCopyButton.title
31
32 fragment.parentNode.replaceChild(fragmentWrapper, fragment)
33 fragmentWrapper.appendChild(fragment)
34 fragmentWrapper.appendChild(fragmentCopyButton)
35
36 }
37 }
38 })
39 })
40 }
41
42
43 copyContent() {
44 const content = this.previousSibling.cloneNode(true)
45 // filter out line number from file listings
46 content.querySelectorAll(".lineno, .ttc").forEach((node) => {
47 node.remove()
48 })
49 let textContent = content.textContent
50 // remove trailing newlines that appear in file listings
51 let numberOfTrailingNewlines = 0
52 while(textContent.charAt(textContent.length - (numberOfTrailingNewlines + 1)) == '\n') {
53 numberOfTrailingNewlines++;
54 }
55 textContent = textContent.substring(0, textContent.length - numberOfTrailingNewlines)
56 navigator.clipboard.writeText(textContent);
57 this.classList.add("success")
58 this.innerHTML = DoxygenAwesomeFragmentCopyButton.successIcon
59 window.setTimeout(() => {
60 this.classList.remove("success")
61 this.innerHTML = DoxygenAwesomeFragmentCopyButton.copyIcon
62 }, DoxygenAwesomeFragmentCopyButton.successDuration);
63 }
64 }
65
66 customElements.define("doxygen-awesome-fragment-copy-button", DoxygenAwesomeFragmentCopyButton)
This webpage is intended to be an accessible preview of this repository. To get a fuller picture, clone it and use the git CLI.