Spaces:
Running
Running
Update app.R
Browse files
app.R
CHANGED
@@ -117,90 +117,89 @@ ui <- fluidPage(
|
|
117 |
tags$div(
|
118 |
style = "text-align: left; margin: 0.5em 0 0.5em 0em;",
|
119 |
HTML('
|
120 |
-
|
121 |
-
|
122 |
-
|
123 |
-
|
124 |
-
|
125 |
-
|
126 |
-
|
127 |
-
|
128 |
-
|
129 |
-
|
130 |
-
|
131 |
-
|
132 |
-
|
133 |
-
|
134 |
-
|
135 |
-
|
136 |
-
|
137 |
-
|
138 |
-
|
139 |
-
|
140 |
-
|
141 |
-
|
142 |
-
|
143 |
-
|
144 |
-
|
145 |
-
|
146 |
'),
|
147 |
tags$script(
|
148 |
HTML("
|
149 |
-
(function() {
|
150 |
-
|
151 |
-
|
152 |
-
|
153 |
-
|
154 |
-
|
155 |
-
|
156 |
-
|
157 |
-
|
158 |
-
|
159 |
-
|
160 |
-
|
161 |
-
|
162 |
-
|
163 |
-
|
164 |
-
|
165 |
-
|
166 |
-
|
167 |
-
|
168 |
-
|
169 |
-
|
170 |
-
|
171 |
-
|
172 |
-
|
173 |
-
|
174 |
-
|
175 |
-
|
176 |
-
|
177 |
-
|
178 |
-
|
179 |
-
|
180 |
-
|
181 |
-
|
182 |
-
|
183 |
-
|
184 |
-
|
185 |
-
|
186 |
-
|
187 |
-
|
188 |
-
|
189 |
-
|
190 |
-
|
191 |
-
|
192 |
-
|
193 |
-
|
194 |
-
|
195 |
-
|
196 |
-
|
197 |
-
|
198 |
-
|
199 |
-
|
200 |
-
|
201 |
-
|
202 |
-
|
203 |
-
})();
|
204 |
")
|
205 |
)
|
206 |
),
|
@@ -377,3 +376,4 @@ server <- function(input, output, session) {
|
|
377 |
# Run the app
|
378 |
shinyApp(ui, server)
|
379 |
|
|
|
|
117 |
tags$div(
|
118 |
style = "text-align: left; margin: 0.5em 0 0.5em 0em;",
|
119 |
HTML('
|
120 |
+
<button id="share-button"
|
121 |
+
style="
|
122 |
+
display: inline-flex;
|
123 |
+
align-items: center;
|
124 |
+
justify-content: center;
|
125 |
+
gap: 8px;
|
126 |
+
padding: 5px 10px;
|
127 |
+
font-size: 16px;
|
128 |
+
font-weight: normal;
|
129 |
+
color: #000;
|
130 |
+
background-color: #fff;
|
131 |
+
border: 1px solid #ddd;
|
132 |
+
border-radius: 6px;
|
133 |
+
cursor: pointer;
|
134 |
+
box-shadow: 0 1.5px 0 #000;
|
135 |
+
">
|
136 |
+
<svg width="18" height="18" viewBox="0 0 24 24" fill="none" stroke="currentColor"
|
137 |
+
stroke-width="2" stroke-linecap="round" stroke-linejoin="round">
|
138 |
+
<circle cx="18" cy="5" r="3"></circle>
|
139 |
+
<circle cx="6" cy="12" r="3"></circle>
|
140 |
+
<circle cx="18" cy="19" r="3"></circle>
|
141 |
+
<line x1="8.59" y1="13.51" x2="15.42" y2="17.49"></line>
|
142 |
+
<line x1="15.41" y1="6.51" x2="8.59" y2="10.49"></line>
|
143 |
+
</svg>
|
144 |
+
<strong>Share</strong>
|
145 |
+
</button>
|
146 |
'),
|
147 |
tags$script(
|
148 |
HTML("
|
149 |
+
(function () {
|
150 |
+
const shareBtn = document.getElementById('share-button');
|
151 |
+
|
152 |
+
function showCopyNotification(targetBtn) {
|
153 |
+
const notification = document.createElement('div');
|
154 |
+
notification.innerText = 'Copied to clipboard';
|
155 |
+
notification.style.position = 'absolute';
|
156 |
+
notification.style.pointerEvents = 'none';
|
157 |
+
notification.style.backgroundColor = 'rgba(0, 0, 0, 0.8)';
|
158 |
+
notification.style.color = '#fff';
|
159 |
+
notification.style.padding = '6px 10px';
|
160 |
+
notification.style.borderRadius = '4px';
|
161 |
+
notification.style.fontSize = '14px';
|
162 |
+
notification.style.whiteSpace = 'nowrap';
|
163 |
+
notification.style.zIndex = '10000';
|
164 |
+
|
165 |
+
const rect = targetBtn.getBoundingClientRect();
|
166 |
+
const top = rect.top + window.scrollY - 40; // 40 px above the button
|
167 |
+
const left = rect.left + window.scrollX + rect.width / 2;
|
168 |
+
|
169 |
+
notification.style.top = top + 'px';
|
170 |
+
notification.style.left = left + 'px';
|
171 |
+
notification.style.transform = 'translateX(-50%)';
|
172 |
+
|
173 |
+
document.body.appendChild(notification);
|
174 |
+
setTimeout(() => notification.remove(), 2000);
|
175 |
+
}
|
176 |
+
|
177 |
+
shareBtn.addEventListener('click', function () {
|
178 |
+
const currentURL = window.location.href;
|
179 |
+
const pageTitle = document.title || 'Check this out!';
|
180 |
+
|
181 |
+
if (navigator.share) {
|
182 |
+
navigator.share({ title: pageTitle, url: currentURL })
|
183 |
+
.catch(error => console.log('Sharing failed', error));
|
184 |
+
} else if (navigator.clipboard && navigator.clipboard.writeText) {
|
185 |
+
navigator.clipboard.writeText(currentURL)
|
186 |
+
.then(() => showCopyNotification(shareBtn))
|
187 |
+
.catch(err => console.error('Could not copy text: ', err));
|
188 |
+
} else {
|
189 |
+
const textArea = document.createElement('textarea');
|
190 |
+
textArea.value = currentURL;
|
191 |
+
document.body.appendChild(textArea);
|
192 |
+
textArea.select();
|
193 |
+
try {
|
194 |
+
document.execCommand('copy');
|
195 |
+
showCopyNotification(shareBtn);
|
196 |
+
} catch (err) {
|
197 |
+
alert('Please copy this link:\n' + currentURL);
|
198 |
+
}
|
199 |
+
document.body.removeChild(textArea);
|
200 |
+
}
|
201 |
+
});
|
202 |
+
})();
|
|
|
203 |
")
|
204 |
)
|
205 |
),
|
|
|
376 |
# Run the app
|
377 |
shinyApp(ui, server)
|
378 |
|
379 |
+
|