Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
P
PPC
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package Registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Vojtěch Novotný
PPC
Commits
3b4415f8
Commit
3b4415f8
authored
3 weeks ago
by
Vojtěch Novotný
Browse files
Options
Downloads
Patches
Plain Diff
nightmode
parent
41de9235
No related branches found
Branches containing commit
No related tags found
1 merge request
!4
stabilni verze semestralni prace, 3 cviceni, domaci ukol 1
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
semestralni_prace/main.html
+37
-8
37 additions, 8 deletions
semestralni_prace/main.html
with
37 additions
and
8 deletions
semestralni_prace/main.html
+
37
−
8
View file @
3b4415f8
...
...
@@ -13,6 +13,15 @@
margin
:
0
;
padding
:
20px
;
text-align
:
center
;
transition
:
background-color
0.5s
,
color
0.5s
;
/* Smooth transition */
}
/* Night Mode Styles */
body
.night-mode
{
background-color
:
#000000
;
color
:
#a0a0a0
;
/* Muted text color */
}
h1
{
...
...
@@ -57,6 +66,23 @@
return
day
+
'
/
'
+
month
+
'
/
'
+
year
+
'
'
+
hours
+
'
:
'
+
minutes
;
}
// Function to check if night mode should be enabled
function
isNightMode
()
{
var
now
=
new
Date
();
var
hours
=
now
.
getHours
();
return
hours
>=
22
||
hours
<
6
;
// Night mode between 22:00 and 6:00
}
// Function to toggle night mode
function
toggleNightMode
()
{
var
body
=
document
.
body
;
if
(
isNightMode
())
{
body
.
classList
.
add
(
'
night-mode
'
);
}
else
{
body
.
classList
.
remove
(
'
night-mode
'
);
}
}
// Function to fetch and display data
function
fetchData
()
{
var
statusElement
=
document
.
getElementById
(
'
status
'
);
...
...
@@ -120,12 +146,6 @@
'
<span style="font-size: 10px; color: grey;">
'
+
'
Last updated:
'
+
formatDate
(
data
[
room
].
timestamp
)
+
'
</span>
'
+
'
</div>
'
;
}
//html += '
<
div
class
=
"
data
"
style
=
"
display: inline-block; width: 45%; vertical-align: top; margin: 10px;
"
>
'
+
//
'
<
strong
>
'
+ room +
'
<
/strong><br>'
+
// '
<
strong
><
span
style
=
"
font-size: 50px;
"
>
'
+ data[room].temperature +
'
°
C
<
/span></
strong
><
br
>
'
+
//
'
<
strong
><
span
style
=
"
font-size: 50px;
"
>
'
+ data[room].humidity +
'
%<
/span><strong><br>'
+
// '
<
span
style
=
"
font-size: 10px; color: grey;
"
>
'
+
'
Last
updated
:
'
+ formatDate(data[room].timestamp) +
'
<
/span>'
+
// '
<
/div>';
*
}
}
...
...
@@ -169,11 +189,20 @@
// Start the data refresh when page loads
if
(
document
.
addEventListener
)
{
document
.
addEventListener
(
'
DOMContentLoaded
'
,
startDataRefresh
);
document
.
addEventListener
(
'
DOMContentLoaded
'
,
function
()
{
toggleNightMode
();
// Apply night mode on page load
startDataRefresh
();
});
}
else
{
// For older browsers
window
.
onload
=
startDataRefresh
;
window
.
onload
=
function
()
{
toggleNightMode
();
// Apply night mode on page load
startDataRefresh
();
};
}
// Check for night mode every minute
setInterval
(
toggleNightMode
,
60000
);
</script>
</body>
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment