cjerzak commited on
Commit
7245094
·
verified ·
1 Parent(s): 55384eb

Update app.R

Browse files
Files changed (1) hide show
  1. app.R +99 -0
app.R CHANGED
@@ -118,6 +118,7 @@ getMetricLabel <- function(metric_value) {
118
  # UI Definition
119
  ui <- fluidPage(
120
  titlePanel("Multiscale Representations Explorer"),
 
121
  tags$p(
122
  style = "text-align: left; margin-top: -10px;",
123
  tags$a(
@@ -129,6 +130,104 @@ ui <- fluidPage(
129
  icon("external-link", style = "font-size: 12px;")
130
  )
131
  ),
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
132
  sidebarLayout(
133
  sidebarPanel(
134
  selectInput("application", "Application",
 
118
  # UI Definition
119
  ui <- fluidPage(
120
  titlePanel("Multiscale Representations Explorer"),
121
+
122
  tags$p(
123
  style = "text-align: left; margin-top: -10px;",
124
  tags$a(
 
130
  icon("external-link", style = "font-size: 12px;")
131
  )
132
  ),
133
+
134
+ # ---- Here is the minimal "Share" button HTML + JS inlined in Shiny ----
135
+ # We wrap it in tags$div(...) and tags$script(HTML(...)) so it is recognized
136
+ # by Shiny. You can adjust the styling or placement as needed.
137
+ tags$div(
138
+ style = "text-align: left; margin: 1em 0 1em 0em;",
139
+ HTML('
140
+ <button id="share-button"
141
+ style="
142
+ display: inline-flex;
143
+ align-items: center;
144
+ justify-content: center;
145
+ gap: 8px;
146
+ padding: 5px 10px;
147
+ font-size: 16px;
148
+ font-weight: normal;
149
+ color: #000;
150
+ background-color: #fff;
151
+ border: 1px solid #ddd;
152
+ border-radius: 6px;
153
+ cursor: pointer;
154
+ box-shadow: 0 1.5px 0 #000;
155
+ ">
156
+ <svg width="18" height="18" viewBox="0 0 24 24" fill="none" stroke="currentColor"
157
+ stroke-width="2" stroke-linecap="round" stroke-linejoin="round">
158
+ <circle cx="18" cy="5" r="3"></circle>
159
+ <circle cx="6" cy="12" r="3"></circle>
160
+ <circle cx="18" cy="19" r="3"></circle>
161
+ <line x1="8.59" y1="13.51" x2="15.42" y2="17.49"></line>
162
+ <line x1="15.41" y1="6.51" x2="8.59" y2="10.49"></line>
163
+ </svg>
164
+ <strong>Share</strong>
165
+ </button>
166
+ '),
167
+ # Insert the JS as well
168
+ tags$script(
169
+ HTML("
170
+ (function() {
171
+ const shareBtn = document.getElementById('share-button');
172
+ // Reusable helper function to show a small “Copied!” message
173
+ function showCopyNotification() {
174
+ const notification = document.createElement('div');
175
+ notification.innerText = 'Copied to clipboard';
176
+ notification.style.position = 'fixed';
177
+ notification.style.bottom = '20px';
178
+ notification.style.right = '20px';
179
+ notification.style.backgroundColor = 'rgba(0, 0, 0, 0.8)';
180
+ notification.style.color = '#fff';
181
+ notification.style.padding = '8px 12px';
182
+ notification.style.borderRadius = '4px';
183
+ notification.style.zIndex = '9999';
184
+ document.body.appendChild(notification);
185
+ setTimeout(() => { notification.remove(); }, 2000);
186
+ }
187
+ shareBtn.addEventListener('click', function() {
188
+ const currentURL = window.location.href;
189
+ const pageTitle = document.title || 'Check this out!';
190
+ // If browser supports Web Share API
191
+ if (navigator.share) {
192
+ navigator.share({
193
+ title: pageTitle,
194
+ text: 'Thought you’d like this!',
195
+ url: currentURL
196
+ })
197
+ .catch((error) => {
198
+ console.log('Sharing failed', error);
199
+ });
200
+ } else {
201
+ // Fallback: Copy URL
202
+ if (navigator.clipboard && navigator.clipboard.writeText) {
203
+ navigator.clipboard.writeText(currentURL).then(() => {
204
+ showCopyNotification();
205
+ }, (err) => {
206
+ console.error('Could not copy text: ', err);
207
+ });
208
+ } else {
209
+ // Double fallback for older browsers
210
+ const textArea = document.createElement('textarea');
211
+ textArea.value = currentURL;
212
+ document.body.appendChild(textArea);
213
+ textArea.select();
214
+ try {
215
+ document.execCommand('copy');
216
+ showCopyNotification();
217
+ } catch (err) {
218
+ alert('Please copy this link:\\n' + currentURL);
219
+ }
220
+ document.body.removeChild(textArea);
221
+ }
222
+ }
223
+ });
224
+ })();
225
+ ")
226
+ )
227
+ )
228
+ # ---- End: Minimal Share button snippet ----
229
+
230
+
231
  sidebarLayout(
232
  sidebarPanel(
233
  selectInput("application", "Application",