Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Implemented Minimal DarkMode. #445

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
145 changes: 144 additions & 1 deletion example-singleServer-chart.html
Original file line number Diff line number Diff line change
Expand Up @@ -35,11 +35,82 @@
display: block;
margin: 0 auto;
}

.theme-switch-wrapper {
margin: 20px;
}

.theme-switch {
display: inline-block;
height: 40px;
position: relative;
width: 65px;
}

.theme-switch input {
display: none;
}

.slider {
background: #000;
bottom: 0;
left: 0;
position: absolute;
right: 0;
top: 0;
font-size: 13px;
transition: 0.4s;
}

.slider p:after {
color: #fff;
float: right;
margin: 0 5px 0 0;
content: "OFF";
transition: 0.4s;
}

input:checked + .slider p:after {
float: left;
color: #000;
content: "ON";
margin: 0 0 0 5px;
}

.slider:before {
background: #fff;
top: 8px;
content: "";
height: 26px;
left: 4px;
position: absolute;
transition: 0.4s;
width: 26px;
}

input:checked + .slider {
background-color: #fff;
}

input:checked + .slider:before {
transform: translateX(28px);
background: #000;
}

.slider.round {
border-radius: 34px;
}

.slider.round:before {
border-radius: 50%;
}
</style>
<script src="https://cdnjs.cloudflare.com/ajax/libs/Chart.js/2.5.0/Chart.bundle.min.js"></script> <!--THIS LIBRARY SUCKS!-->
<script src="speedtest.js"></script>
<script type="text/javascript">
var s = null
var s = null;
var xAxesColor='#000';
var yAxesColor='#000';
function runTest() {
var chart1ctx = document.getElementById('chart1Area').getContext('2d')
var chart2ctx = document.getElementById('chart2Area').getContext('2d')
Expand Down Expand Up @@ -150,13 +221,23 @@
},
ticks: {
beginAtZero: true
},
gridLines: {
display: true ,
color:xAxesColor,
lineWidth:0.1
}
}],
yAxes: [{
display: true,
scaleLabel: 'Speed',
ticks: {
beginAtZero: true
},
gridLines: {
display:true,
color:yAxesColor,
lineWidth:0.1
}
}]
}
Expand All @@ -180,13 +261,23 @@
},
ticks: {
beginAtZero: true
},
gridLines: {
display: true ,
color:xAxesColor,
lineWidth:0.1
}
}],
yAxes: [{
display: true,
scaleLabel: 'Latency',
ticks: {
beginAtZero: true
},
gridLines: {
display:true,
color:yAxesColor,
lineWidth:0.1
}
}]
}
Expand Down Expand Up @@ -251,6 +342,58 @@ <h2>Latency</h2>
<a href="javascript:abortTest()" id="abortBtn">Abort</a>
</div>
<a href="javascript:runTest()" id="startBtn">Run speedtest</a>
<div id='darkMode'>
<h3>DARKMODE</h3>
<div class="theme-switch-wrapper">
<label class="theme-switch" for="checkbox">
<input type="checkbox" id="checkbox" />
<div class="slider round">
<p></p>
</div>
</div>
<br/><br/> Charts by <a href="http://www.chartjs.org/">Chart.js</a><br/><br/><a href="https://github.com/librespeed/speedtest">Source code</a>
<script>
//DARMODE
const toggleSwitch = document.querySelector(
'.theme-switch input[type="checkbox"]'
);

function switchTheme(e) {
if (e.target.checked) {
toggleDarkMode();
} else {
toggleDarkMode();
}
}
toggleSwitch.addEventListener("change", switchTheme, true);

var countToggleDark = 0;

function toggleDarkMode() {
if (countToggleDark == 0) {
document.querySelector("html").style.background = "#000";
document.querySelector("body").style.background = "#000";
document.querySelector("html").style.color = "#fdfdfd";
document.querySelector("body").style.color = "#fdfdfd";
document.querySelector("#startBtn").style.border =
"0.15em solid #fff";
document.querySelector("#startBtn").style.color = "#fff";
xAxesColor="#fff";
yAxesColor="#fff";
countToggleDark++;
} else {
document.querySelector("html ").style.background = "#fdfdfd";
document.querySelector("body").style.background = "#fdfdfd";
document.querySelector("html").style.color = "#202020";
document.querySelector("body").style.color = "#202020";
document.querySelector("#startBtn").style.border =
"0.15em solid #000";
document.querySelector("#startBtn").style.color = "#6060AA";
xAxesColor="#000";
yAxesColor="#000";
countToggleDark = 0;
}
}
</script>
</body>
</html>
125 changes: 122 additions & 3 deletions example-singleServer-customSettings.html
Original file line number Diff line number Diff line change
Expand Up @@ -78,9 +78,9 @@
box-shadow: 0 0 2em rgba(0,0,0,0.1), inset 0 0 1em rgba(0,0,0,0.1);
}
#startStopBtn.running{
background-color:#FF3030;
border-color:#FF6060;
color:#FFFFFF;
background-color:#FF3030!important;
border-color:#FF6060!important;
color:#FFFFFF!important;
}
#startStopBtn:before{
content:"Start";
Expand Down Expand Up @@ -147,6 +147,74 @@
}
}

.theme-switch-wrapper {
margin: 20px;
}

.theme-switch {
display: inline-block;
height: 40px;
position: relative;
width: 65px;
}

.theme-switch input {
display: none;
}

.slider {
background: #000;
bottom: 0;
left: 0;
position: absolute;
right: 0;
top: 0;
font-size: 13px;
transition: 0.4s;
}

.slider p:after {
color: #fff;
float: right;
margin: 0 5px 0 0;
content: "OFF";
transition: 0.4s;
}

input:checked + .slider p:after {
float: left;
color: #000;
content: "ON";
margin: 0 0 0 5px;
}

.slider:before {
background: #fff;
top: 8px;
content: "";
height: 26px;
left: 4px;
position: absolute;
transition: 0.4s;
width: 26px;
}

input:checked + .slider {
background-color: #fff;
}

input:checked + .slider:before {
transform: translateX(28px);
background: #000;
}

.slider.round {
border-radius: 34px;
}

.slider.round:before {
border-radius: 50%;
}
</style>
</head>
<body>
Expand All @@ -166,9 +234,60 @@ <h1>LibreSpeed Example</h1>
</div>
</div>
</div>
<div id='darkMode'>
<h3>DARKMODE</h3>
<div class="theme-switch-wrapper">
<label class="theme-switch" for="checkbox">
<input type="checkbox" id="checkbox" />
<div class="slider round">
<p></p>
</div>
</div>
<a href="https://github.com/librespeed/speedtest">Source code</a>
<script type="text/javascript">
initUI();

//DARMODE
const toggleSwitch = document.querySelector(
'.theme-switch input[type="checkbox"]'
);

function switchTheme(e) {
if (e.target.checked) {
toggleDarkMode();
} else {
toggleDarkMode();
}
}
toggleSwitch.addEventListener("change", switchTheme, true);

var countToggleDark = 0;

function toggleDarkMode() {
if (countToggleDark == 0) {
document.querySelector("html").style.background = "#000";
document.querySelector("body").style.background = "#000";
document.querySelector("html").style.color = "#fdfdfd";
document.querySelector("body").style.color = "#fdfdfd";
document.querySelector("#startStopBtn").style.border =
"0.15em solid #996cb4";
document.querySelector("#startStopBtn").style.color = "#996cb4";
document.querySelector("h1").style.color = "#d3cfcf";
document.querySelector("#dlText").style.color = "#996cb4";
countToggleDark++;
} else {
document.querySelector("html ").style.background = "#fdfdfd";
document.querySelector("body").style.background = "#fdfdfd";
document.querySelector("html").style.color = "#202020";
document.querySelector("body").style.color = "#202020";
document.querySelector("#startStopBtn").style.border =
"0.15em solid #6060FF";
document.querySelector("#startStopBtn").style.color = "#6060AA";
document.querySelector("h1").style.color = "#404040";
document.querySelector("#dlText").style.color = "#000";
countToggleDark = 0;
}
}
</script>
</body>
</html>