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