|
@@ -2,7 +2,15 @@
|
|
|
{% load static %}
|
|
{% load static %}
|
|
|
{% load helpers %}
|
|
{% load helpers %}
|
|
|
<!DOCTYPE html>
|
|
<!DOCTYPE html>
|
|
|
-<html lang="en">
|
|
|
|
|
|
|
+<html
|
|
|
|
|
+ lang="en"
|
|
|
|
|
+ data-netbox-path="{{ request.path }}"
|
|
|
|
|
+ {% if preferences|get_key:'ui.colormode' == 'dark'%}
|
|
|
|
|
+ data-netbox-color-mode="dark"
|
|
|
|
|
+ {% else %}
|
|
|
|
|
+ data-netbox-color-mode="light"
|
|
|
|
|
+ {% endif %}
|
|
|
|
|
+ >
|
|
|
<head>
|
|
<head>
|
|
|
<meta charset="UTF-8" />
|
|
<meta charset="UTF-8" />
|
|
|
<meta
|
|
<meta
|
|
@@ -13,6 +21,37 @@
|
|
|
{# Page title #}
|
|
{# Page title #}
|
|
|
<title>{% block title %}Home{% endblock %} | NetBox</title>
|
|
<title>{% block title %}Home{% endblock %} | NetBox</title>
|
|
|
|
|
|
|
|
|
|
+ <script>
|
|
|
|
|
+ /**
|
|
|
|
|
+ * Determine the best initial color mode to use prior to rendering.
|
|
|
|
|
+ */
|
|
|
|
|
+ (function() {
|
|
|
|
|
+ // Browser prefers dark color scheme.
|
|
|
|
|
+ var preferDark = window.matchMedia('(prefers-color-scheme: dark)').matches;
|
|
|
|
|
+ // Browser prefers light color scheme.
|
|
|
|
|
+ var preferLight = window.matchMedia('(prefers-color-scheme: light)').matches;
|
|
|
|
|
+ // Client NetBox color-mode override.
|
|
|
|
|
+ var clientMode = localStorage.getItem('netbox-color-mode');
|
|
|
|
|
+ // NetBox server-rendered value.
|
|
|
|
|
+ var serverMode = document.documentElement.getAttribute('data-netbox-color-mode');
|
|
|
|
|
+
|
|
|
|
|
+ if ((clientMode !== null) && (clientMode !== serverMode)) {
|
|
|
|
|
+ // If the client mode is set, use its value over the server's value.
|
|
|
|
|
+ return document.documentElement.setAttribute('data-netbox-color-mode', clientMode);
|
|
|
|
|
+ }
|
|
|
|
|
+ if (preferDark && serverMode === 'light') {
|
|
|
|
|
+ // If the client value matches the server value, the browser preferrs dark-mode, but
|
|
|
|
|
+ // the server value doesn't match the browser preference, use dark mode.
|
|
|
|
|
+ return document.documentElement.setAttribute('data-netbox-color-mode', 'dark');
|
|
|
|
|
+ }
|
|
|
|
|
+ if (preferLight && serverMode === 'dark') {
|
|
|
|
|
+ // If the client value matches the server value, the browser preferrs dark-mode, but
|
|
|
|
|
+ // the server value doesn't match the browser preference, use light mode.
|
|
|
|
|
+ return document.documentElement.setAttribute('data-netbox-color-mode', 'light');
|
|
|
|
|
+ }
|
|
|
|
|
+ })();
|
|
|
|
|
+ </script>
|
|
|
|
|
+
|
|
|
{# Static resources #}
|
|
{# Static resources #}
|
|
|
<link
|
|
<link
|
|
|
rel="stylesheet"
|
|
rel="stylesheet"
|
|
@@ -42,12 +81,7 @@
|
|
|
{% block head %}{% endblock %}
|
|
{% block head %}{% endblock %}
|
|
|
</head>
|
|
</head>
|
|
|
|
|
|
|
|
- <body
|
|
|
|
|
- {% if preferences|get_key:'ui.colormode' == 'dark'%} data-netbox-color-mode="dark"
|
|
|
|
|
- {% else %} data-netbox-color-mode="light"
|
|
|
|
|
- {% endif %}
|
|
|
|
|
- data-netbox-path="{{ request.path }}"
|
|
|
|
|
- >
|
|
|
|
|
|
|
+ <body>
|
|
|
|
|
|
|
|
{# Page layout #}
|
|
{# Page layout #}
|
|
|
{% block layout %}{% endblock %}
|
|
{% block layout %}{% endblock %}
|