Skip to content

Commit 81536fc

Browse files
Add links and copy btn in function page
1 parent 1626dcc commit 81536fc

File tree

3 files changed

+27
-7
lines changed

3 files changed

+27
-7
lines changed

web/resources/assets/style.css

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,10 @@
1616
box-sizing: border-box;
1717
}
1818

19+
.small-fs {
20+
font-size: 0.8em;
21+
}
22+
1923
body {
2024
color: #d1d7e0;
2125
background-color: #212830;
@@ -252,4 +256,4 @@ header {
252256
padding-bottom: 0;
253257
margin: 0;
254258
color: #9F9FA2;
255-
}
259+
}

web/resources/function.html

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -7,12 +7,12 @@
77

88
<!-- Title & Description -->
99
<div class="function-type-title" style="color: {{type_colors[function.type_name]}};">{{ function.type_name|capitalize }} function</div>
10-
<h1 style="border-bottom: 3px solid {{type_colors[function.type_name]}}; padding-bottom: 0.1em;">{{ function.name }}</h1>
10+
<h1 style="border-bottom: 3px solid {{type_colors[function.type_name]}}; padding-bottom: 0.1em;">{{ function.name }} <a class="small-fs" href="#" onclick="copyText('{{ function.name }}', 'copy-{{ function.name }}')"><i class="fa-solid fa-copy"></i> <span id="copy-{{ function.name }}">Copy</span> </a></h1>
1111

1212
{{ function[function.type_name].description_html }}
1313

1414
<!-- Syntax -->
15-
<h2>Syntax</h2>
15+
<h2 id="syntax">Syntax <a href="#syntax"><i class="fa-solid fa-link"></i></a></h2>
1616
{% if function.syntaxes.single %}
1717
{% set syntax = function.syntaxes.single %}
1818
<div style="padding-left: 1em; margin-top: 1em; border: 1px solid {{ info_color }}; border-radius: 5px;">
@@ -91,11 +91,12 @@ <h4>Returns:</h4>
9191

9292
<!-- Preview Images -->
9393
{% if function.has_preview_image %}
94+
<h2 id="images">Preview images <a href="#images"><i class="fa-solid fa-link"></i></a></h2>
9495
{% for type_name in ['shared', 'client', 'server'] %}
9596
{% if function[type_name] %}
9697

9798
{% if function[type_name].preview_images %}
98-
<div style="padding-left: 1em; margin-top: 1em; border: 1px solid {{ info_color }}; border-radius: 5px;">
99+
<div style="padding-left: 1em; padding-bottom: 1em; margin-top: 1em; border: 1px solid {{ info_color }}; border-radius: 5px;">
99100
{% for image in function[type_name].preview_images %}
100101
{% if image.description_html %}
101102
<p>{{ image.description_html }}</p>
@@ -111,7 +112,7 @@ <h4>Returns:</h4>
111112

112113
<!-- Issues -->
113114
{% if function.has_issue %}
114-
<h2>Issues</h2>
115+
<h2 id="issues">Issues <a href="#issues"><i class="fa-solid fa-link"></i></a></h2>
115116
{% for type_name in ['shared', 'client', 'server'] %}
116117
{% if function[type_name] %}
117118

@@ -134,14 +135,14 @@ <h2>Issues</h2>
134135
{% endif %}
135136

136137
<!-- Examples -->
137-
<h2>Examples</h2>
138+
<h2 id="examples">Examples <a href="#examples"><i class="fa-solid fa-link"></i></a></h2>
138139
{% for type_name in ['shared', 'client', 'server'] %}
139140
{% if function[type_name] %}
140141

141142
{% if function[type_name].examples %}
142143
{% for example in function[type_name].examples %}
143144
<div style="padding-left: 1em; margin-top: 1em; border: 1px solid {{ type_colors[type_name] }}; border-radius: 5px;">
144-
<h3>Example {{ example.number }} <span style="color: {{ type_colors[type_name] }};">({{ type_name|capitalize }})</span></h3>
145+
<h3 id="example-{{ example.number }}">Example {{ example.number }} <span style="color: {{ type_colors[type_name] }};">({{ type_name|capitalize }})</span> <a href="#example-{{ example.number }}"><i class="fa-solid fa-link"></i></a></h3>
145146
{% if example.description_html %}
146147
{{ example.description_html }}
147148
{% endif %}

web/resources/layout.html

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -114,6 +114,21 @@
114114
sidebar.classList.toggle('open');
115115
});
116116
});
117+
118+
async function copyText(text, spanCopyText) {
119+
event.preventDefault()
120+
const type = "text/plain";
121+
const blob = new Blob([text], { type });
122+
const data = [new ClipboardItem({ [type]: blob })];
123+
await navigator.clipboard.write(data);
124+
if (spanCopyText) {
125+
spanCopyText = document.getElementById(spanCopyText);
126+
spanCopyText.innerText = "Copied!";
127+
setTimeout(() => {
128+
spanCopyText.innerText = "Copy";
129+
}, 2000);
130+
}
131+
}
117132
</script>
118133
</body>
119134
</html>

0 commit comments

Comments
 (0)