Skip to content

Commit

Permalink
remove light style
Browse files Browse the repository at this point in the history
  • Loading branch information
zdz committed May 10, 2022
1 parent 1cbd6f3 commit cc2e3ab
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 96 deletions.
67 changes: 0 additions & 67 deletions web/css/light.css

This file was deleted.

Binary file removed web/img/light.png
Binary file not shown.
16 changes: 2 additions & 14 deletions web/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@
<meta name="robots" content="noindex">
<link rel="stylesheet" href="css/bootstrap.min.css">
<link rel="stylesheet" href="css/bootstrap-theme.min.css">
<link rel="stylesheet" href="css/light.css" title="light">
<link rel="stylesheet" href="css/dark.css" title="dark">
<style>
body {
Expand Down Expand Up @@ -39,18 +38,7 @@
</button>
<a href="#" class="navbar-brand">ServerStatus</a>
</div>
<div class="navbar-collapse collapse">
<ul class="nav navbar-nav">
<li class="dropdown">
<a data-toggle="dropdown" class="dropdown-toggle" href="#">风格<b class="caret"></b></a>
<ul class="dropdown-menu">
<li><a href="#" onclick="setActiveStyleSheet('dark', true)">黑夜</a></li>
<li><a href="#" onclick="setActiveStyleSheet('light', true)">白天</a></li>
</ul>
</li>
</ul>
</div>
<!--/.nav-collapse -->

</div>
</div>
</div>
Expand Down Expand Up @@ -107,4 +95,4 @@
<script src="js/serverstatus.js"></script>
</body>

</html>
</html>
32 changes: 17 additions & 15 deletions web/js/serverstatus.js
Original file line number Diff line number Diff line change
Expand Up @@ -364,19 +364,21 @@ function readCookie(name) {
}

window.onload = function(e) {
var cookie = readCookie("style");
if (cookie && cookie != 'null' ) {
setActiveStyleSheet(cookie);
} else {
function handleChange (mediaQueryListEvent) {
if (mediaQueryListEvent.matches) {
setActiveStyleSheet('dark');
} else {
setActiveStyleSheet('light');
}
}
const mediaQueryListDark = window.matchMedia('(prefers-color-scheme: dark)');
setActiveStyleSheet(mediaQueryListDark.matches ? 'dark' : 'light');
mediaQueryListDark.addEventListener("change",handleChange);
}
setActiveStyleSheet("dark");

// var cookie = readCookie("style");
// if (cookie && cookie != 'null' ) {
// setActiveStyleSheet(cookie);
// } else {
// function handleChange (mediaQueryListEvent) {
// if (mediaQueryListEvent.matches) {
// setActiveStyleSheet('dark');
// } else {
// setActiveStyleSheet('light');
// }
// }
// const mediaQueryListDark = window.matchMedia('(prefers-color-scheme: dark)');
// setActiveStyleSheet(mediaQueryListDark.matches ? 'dark' : 'light');
// mediaQueryListDark.addEventListener("change",handleChange);
// }
}

0 comments on commit cc2e3ab

Please sign in to comment.