add dark mode support

This commit is contained in:
Eduardo Silva
2026-03-17 12:04:11 -03:00
parent 46b383a0b6
commit e91bc48168
12 changed files with 315 additions and 52 deletions

View File

@@ -148,7 +148,7 @@
</div>
<center>
<img id="graphImg" src="/rrd/graph/?peer={{ current_peer.uuid }}{% if request.GET.period %}&period={{ request.GET.period }}{% endif %}"
<img id="graphImg" src="/rrd/graph/?peer={{ current_peer.uuid }}{% if request.GET.period %}&period={{ request.GET.period }}{% endif %}{% if request.COOKIES.darkMode == 'dark' %}&dark=1{% endif %}"
class="img-fluid" alt="{% trans 'No traffic history, please wait a few minutes' %}"
onerror="this.onerror=null; this.style.display='none'; this.insertAdjacentHTML('afterend', this.alt);">
</center>
@@ -324,7 +324,8 @@
button.addEventListener('click', function (e) {
e.preventDefault();
var period = this.getAttribute('data-period');
var newSrc = '/rrd/graph/?peer={{ current_peer.uuid }}&period=' + period;
var darkParam = $('body').hasClass('dark-mode') ? '&dark=1' : '';
var newSrc = '/rrd/graph/?peer={{ current_peer.uuid }}&period=' + period + darkParam;
var imgElement = document.getElementById('graphImg');
if (imgElement) {
imgElement.setAttribute('src', newSrc);