-
Notifications
You must be signed in to change notification settings - Fork 0
/
ui.R
93 lines (82 loc) · 2.62 KB
/
ui.R
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
# Tab modules
source('./constant.R')
source('./tabs/session.R')
source('./tabs/stat.R')
source('./tabs/plots.R')
source('./tabs/sound.R')
source('./tabs/profile.R')
source('./tabs/formSpreeDash.R')
# packages
library(shiny)
library(shinytitle)
library(svglite)
library(shinycssloaders)
library(plotly)
# Define UI for application that draws a histogram
timer_js <- "
let startTime = new Date().getTime();
function updateTimer() {
let now = new Date().getTime();
let elapsed = now - startTime;
let seconds = Math.floor((elapsed / 1000) % 60);
let minutes = Math.floor((elapsed / (1000 * 60)) % 60);
let hours = Math.floor((elapsed / (1000 * 60 * 60)) % 24);
document.getElementById('timer').innerHTML =
(hours < 10 ? '0' + hours : hours) + ':' +
(minutes < 10 ? '0' + minutes : minutes) + ':' +
(seconds < 10 ? '0' + seconds : seconds);
// Check every second
setTimeout(updateTimer, 1000);
}
document.addEventListener('DOMContentLoaded', (event) => {
updateTimer();
});
"
shinyUI(
navbarPage(
title = div(
textOutput("app_title"),
div(id = "timer", "00:00:00")
),
use_shiny_title(),
header = tags$head(
tags$style(type = "text/css", "
#timer {
position: absolute;
top: 15px;
right: 15px;
font-size: 16px;
font-weight: bold;
color: #FFFFFF;
background-color: rgba(0, 0, 0, 0.7);
padding: 5px;
border-radius: 5px;
z-index: 9999;
}
"),
tags$script(HTML(timer_js)),
tags$script(HTML("
// JavaScript function to update document title based on active tab
function updateTitleBasedOnTab(tabName) {
document.title = tabName + ' | EasyEyes Analysis';
}
// Set initial title to 'EasyEyes Analysis' with the default tab
document.addEventListener('DOMContentLoaded', function() {
updateTitleBasedOnTab('Session'); // Default tab name
});
// Update title whenever a tab is clicked
$(document).on('shown.bs.tab', 'a[data-toggle=\"tab\"]', function (e) {
var tabName = $(e.target).text(); // Get the active tab name
updateTitleBasedOnTab(tabName);
});
"))
),
# tabs
tabPanel("Session", value = "Session", sessionTab),
tabPanel("Stats", value = "Stats", statTab),
tabPanel("Plots", value = "Plots", plotsTab),
tabPanel("Sound", value = "Sound", soundTab),
tabPanel("Profile", value = "Profile", profileTab),
tabPanel("FormSpree", value = "FormSpree", formSpreeTab)
)
)