Spaces:
Running
Running
Update app.R
Browse files
app.R
CHANGED
|
@@ -274,7 +274,7 @@ ui <- dashboardPage(
|
|
| 274 |
# ========== Header =================
|
| 275 |
dashboardHeader(
|
| 276 |
title = span(
|
| 277 |
-
style = "font-weight: 600; font-size:
|
| 278 |
a(
|
| 279 |
href = "https://fastrerandomize.github.io/",
|
| 280 |
"fastrerandomize.github.io",
|
|
@@ -459,7 +459,104 @@ ui <- dashboardPage(
|
|
| 459 |
)
|
| 460 |
)
|
| 461 |
|
| 462 |
-
) # end tabItems
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 463 |
) # end dashboardBody
|
| 464 |
) # end dashboardPage
|
| 465 |
|
|
|
|
| 274 |
# ========== Header =================
|
| 275 |
dashboardHeader(
|
| 276 |
title = span(
|
| 277 |
+
style = "font-weight: 600; font-size: 14px;",
|
| 278 |
a(
|
| 279 |
href = "https://fastrerandomize.github.io/",
|
| 280 |
"fastrerandomize.github.io",
|
|
|
|
| 459 |
)
|
| 460 |
)
|
| 461 |
|
| 462 |
+
), # end tabItems
|
| 463 |
+
|
| 464 |
+
# ---- Here is the minimal "Share" button HTML + JS inlined in Shiny ----
|
| 465 |
+
# We wrap it in tags$div(...) and tags$script(HTML(...)) so it is recognized
|
| 466 |
+
# by Shiny. You can adjust the styling or placement as needed.
|
| 467 |
+
tags$div(
|
| 468 |
+
style = "text-align: left; margin: 1em 0 1em 0em;",
|
| 469 |
+
HTML('
|
| 470 |
+
<button id="share-button"
|
| 471 |
+
style="
|
| 472 |
+
display: inline-flex;
|
| 473 |
+
align-items: center;
|
| 474 |
+
justify-content: center;
|
| 475 |
+
gap: 8px;
|
| 476 |
+
padding: 5px 10px;
|
| 477 |
+
font-size: 16px;
|
| 478 |
+
font-weight: normal;
|
| 479 |
+
color: #000;
|
| 480 |
+
background-color: #fff;
|
| 481 |
+
border: 1px solid #ddd;
|
| 482 |
+
border-radius: 6px;
|
| 483 |
+
cursor: pointer;
|
| 484 |
+
box-shadow: 0 1.5px 0 #000;
|
| 485 |
+
">
|
| 486 |
+
<svg width="18" height="18" viewBox="0 0 24 24" fill="none" stroke="currentColor"
|
| 487 |
+
stroke-width="2" stroke-linecap="round" stroke-linejoin="round">
|
| 488 |
+
<circle cx="18" cy="5" r="3"></circle>
|
| 489 |
+
<circle cx="6" cy="12" r="3"></circle>
|
| 490 |
+
<circle cx="18" cy="19" r="3"></circle>
|
| 491 |
+
<line x1="8.59" y1="13.51" x2="15.42" y2="17.49"></line>
|
| 492 |
+
<line x1="15.41" y1="6.51" x2="8.59" y2="10.49"></line>
|
| 493 |
+
</svg>
|
| 494 |
+
<strong>Share</strong>
|
| 495 |
+
</button>
|
| 496 |
+
'),
|
| 497 |
+
# Insert the JS as well
|
| 498 |
+
tags$script(
|
| 499 |
+
HTML("
|
| 500 |
+
(function() {
|
| 501 |
+
const shareBtn = document.getElementById('share-button');
|
| 502 |
+
// Reusable helper function to show a small “Copied!” message
|
| 503 |
+
function showCopyNotification() {
|
| 504 |
+
const notification = document.createElement('div');
|
| 505 |
+
notification.innerText = 'Copied to clipboard';
|
| 506 |
+
notification.style.position = 'fixed';
|
| 507 |
+
notification.style.bottom = '20px';
|
| 508 |
+
notification.style.right = '20px';
|
| 509 |
+
notification.style.backgroundColor = 'rgba(0, 0, 0, 0.8)';
|
| 510 |
+
notification.style.color = '#fff';
|
| 511 |
+
notification.style.padding = '8px 12px';
|
| 512 |
+
notification.style.borderRadius = '4px';
|
| 513 |
+
notification.style.zIndex = '9999';
|
| 514 |
+
document.body.appendChild(notification);
|
| 515 |
+
setTimeout(() => { notification.remove(); }, 2000);
|
| 516 |
+
}
|
| 517 |
+
shareBtn.addEventListener('click', function() {
|
| 518 |
+
const currentURL = window.location.href;
|
| 519 |
+
const pageTitle = document.title || 'Check this out!';
|
| 520 |
+
// If browser supports Web Share API
|
| 521 |
+
if (navigator.share) {
|
| 522 |
+
navigator.share({
|
| 523 |
+
title: pageTitle,
|
| 524 |
+
text: 'Thought you’d like this!',
|
| 525 |
+
url: currentURL
|
| 526 |
+
})
|
| 527 |
+
.catch((error) => {
|
| 528 |
+
console.log('Sharing failed', error);
|
| 529 |
+
});
|
| 530 |
+
} else {
|
| 531 |
+
// Fallback: Copy URL
|
| 532 |
+
if (navigator.clipboard && navigator.clipboard.writeText) {
|
| 533 |
+
navigator.clipboard.writeText(currentURL).then(() => {
|
| 534 |
+
showCopyNotification();
|
| 535 |
+
}, (err) => {
|
| 536 |
+
console.error('Could not copy text: ', err);
|
| 537 |
+
});
|
| 538 |
+
} else {
|
| 539 |
+
// Double fallback for older browsers
|
| 540 |
+
const textArea = document.createElement('textarea');
|
| 541 |
+
textArea.value = currentURL;
|
| 542 |
+
document.body.appendChild(textArea);
|
| 543 |
+
textArea.select();
|
| 544 |
+
try {
|
| 545 |
+
document.execCommand('copy');
|
| 546 |
+
showCopyNotification();
|
| 547 |
+
} catch (err) {
|
| 548 |
+
alert('Please copy this link:\\n' + currentURL);
|
| 549 |
+
}
|
| 550 |
+
document.body.removeChild(textArea);
|
| 551 |
+
}
|
| 552 |
+
}
|
| 553 |
+
});
|
| 554 |
+
})();
|
| 555 |
+
")
|
| 556 |
+
)
|
| 557 |
+
),
|
| 558 |
+
# ---- End: Minimal Share button snippet ----
|
| 559 |
+
|
| 560 |
) # end dashboardBody
|
| 561 |
) # end dashboardPage
|
| 562 |
|