Browse Source

More SpeedTest Work

Added config for speed test
causefx 9 years ago
parent
commit
8719a7d76f
10 changed files with 158 additions and 8 deletions
  1. 1 0
      config/configDefaults.php
  2. 137 1
      homepage.php
  3. 2 1
      lang/de.ini
  4. 2 1
      lang/en.ini
  5. 2 1
      lang/es.ini
  6. 2 1
      lang/fr.ini
  7. 2 1
      lang/it.ini
  8. 2 1
      lang/nl.ini
  9. 2 1
      lang/pl.ini
  10. 6 0
      settings.php

+ 1 - 0
config/configDefaults.php

@@ -71,4 +71,5 @@ return array(
 	"homepageCustomHTML1Auth" => false,
 	"git_branch" => "master",
 	"git_check" => true,
+    "speedTest" => false,
 );

+ 137 - 1
homepage.php

@@ -102,7 +102,7 @@ $endDate = date('Y-m-d',strtotime("+".CALENDARENDDAY." days"));
         <link rel="stylesheet" href="bower_components/fullcalendar/dist/fullcalendar.css">
 
         <link rel="stylesheet" href="css/style.css">
-        <link rel="stylesheet" href="<?=$baseURL;?>bower_components/mdi/css/materialdesignicons.min.css?v=<?php echo INSTALLEDVERSION; ?>">
+        <link rel="stylesheet" href="bower_components/mdi/css/materialdesignicons.min.css?v=<?php echo INSTALLEDVERSION; ?>">
 
         <!--Scripts-->
         <script src="bower_components/jquery/dist/jquery.min.js"></script>
@@ -234,6 +234,142 @@ endif; ?>
 					<?php echo HOMEPAGECUSTOMHTML1; ?>
 				</div>
                 <?php } ?>
+                <?php if(SPEEDTEST == "true"){ ?>
+                <style type="text/css">
+
+                    .flash {
+                        animation: flash 0.6s linear infinite;
+                    }
+
+                    @keyframes flash {
+                        0% { opacity: 0.6; }
+                        50% { opacity: 1; }
+                    }
+
+                </style>
+                <script type="text/javascript">
+                    var w = null
+                    function runTest() {
+                        document.getElementById('startBtn').style.display = 'none'
+                        document.getElementById('testArea').style.display = ''
+                        document.getElementById('abortBtn').style.display = ''
+                        w = new Worker('bower_components/speed/speedtest_worker.min.js')
+                        var interval = setInterval(function () { w.postMessage('status') }, 100)
+                        w.onmessage = function (event) {
+                            var data = event.data.split(';')
+                            var status = Number(data[0])
+                            var dl = document.getElementById('download')
+                            var ul = document.getElementById('upload')
+                            var ping = document.getElementById('ping')
+                            var jitter = document.getElementById('jitter')
+                            dl.className = status === 1 ? 'flash' : ''
+                            ping.className = status === 2 ? 'flash' : ''
+                            jitter.className = ul.className = status === 3 ? 'flash' : ''
+                            if (status >= 4) {
+                                clearInterval(interval)
+                                document.getElementById('abortBtn').style.display = 'none'
+                                document.getElementById('startBtn').style.display = ''
+                                w = null
+                            }
+                            if (status === 5) {
+                                document.getElementById('testArea').style.display = 'none'
+                            }
+                            dl.textContent = data[1] + " Mbit/s";
+                            $("#downloadpercent").attr("style", "width: " + data[1] + "%;");
+                            $("#uploadpercent").attr("style", "width: " + data[2] + "%;");
+                            $("#pingpercent").attr("style", "width: " + data[3] + "%;");
+                            $("#jitterpercent").attr("style", "width: " + data[5] + "%;");
+                            ul.textContent = data[2] + " Mbit/s";
+                            ping.textContent = data[3] + " ms";
+                            jitter.textContent = data[5] + " ms";
+                        }
+                        w.postMessage('start')
+                    }
+                    function abortTest() {
+                        if (w) w.postMessage('abort')
+                    }
+                </script>
+
+                <div class="row" id="testArea" style="display:none">
+
+                    <div class="test col-sm-3 col-lg-3">
+                        <div class="content-box ultra-widget green-bg" data-counter="">
+                            <div id="downloadpercent" class="progress-bar progress-bar-striped active w-used" style=""></div>
+                            <div class="w-content">
+                                <div class="w-icon right pull-right"><i class="mdi mdi-cloud-download"></i></div>
+                                <div class="w-descr left pull-left text-center">
+                                    <span class="testName text-uppercase w-name">Download</span>
+                                    <br>
+                                    <span class="w-amount counter" id="download" ></span>
+                                </div>
+                            </div>
+                        </div>
+                    </div>
+
+                    <div class="test col-sm-3 col-lg-3">
+                        <div class="content-box ultra-widget red-bg" data-counter="">
+                            <div id="uploadpercent" class="progress-bar progress-bar-striped active w-used" style=""></div>
+                            <div class="w-content">
+                                <div class="w-icon right pull-right"><i class="mdi mdi-cloud-upload"></i></div>
+                                <div class="w-descr left pull-left text-center">
+                                    <span class="testName text-uppercase w-name">Upload</span>
+                                    <br>
+                                    <span class="w-amount counter" id="upload" ></span>
+                                </div>
+                            </div>
+                        </div>
+                    </div>
+
+                    <div class="test col-sm-3 col-lg-3">
+                        <div class="content-box ultra-widget yellow-bg" data-counter="">
+                            <div id="pingpercent" class="progress-bar progress-bar-striped active w-used" style=""></div>
+                            <div class="w-content">
+                                <div class="w-icon right pull-right"><i class="mdi mdi-timer"></i></div>
+                                <div class="w-descr left pull-left text-center">
+                                    <span class="testName text-uppercase w-name">Latency</span>
+                                    <br>
+                                    <span class="w-amount counter" id="ping" ></span>
+                                </div>
+                            </div>
+                        </div>
+                    </div>
+
+                    <div class="test col-sm-3 col-lg-3">
+                        <div class="content-box ultra-widget blue-bg" data-counter="">
+                            <div id="jitterpercent" class="progress-bar progress-bar-striped active w-used" style=""></div>
+                            <div class="w-content">
+                                <div class="w-icon right pull-right"><i class="mdi mdi-pulse"></i></div>
+                                <div class="w-descr left pull-left text-center">
+                                    <span class="testName text-uppercase w-name">Jitter</span>
+                                    <br>
+                                    <span class="w-amount counter" id="jitter" ></span>
+                                </div>
+                            </div>
+                        </div>
+                    </div>
+
+                    <br/>
+
+                </div>
+
+                <div id="abortBtn" class="row" style="display: none" onclick="javascript:abortTest()">
+                    <div class="col-lg-12">
+                        <div class="content-box red-bg" style="cursor: pointer;">
+                            <h1 style="margin: 10px" class="text-uppercase text-center">Abort Speed Test</h1>
+                            <div class="clearfix"></div>
+                        </div>
+                    </div>
+                </div>
+
+                <div id="startBtn" class="row" onclick="javascript:runTest()">
+                    <div class="col-lg-12">
+                        <div class="content-box green-bg" style="cursor: pointer;">
+                            <h1 style="margin: 10px" class="text-uppercase text-center">Run Speed Test</h1>
+                            <div class="clearfix"></div>
+                        </div>
+                    </div>
+                </div>
+                <?php } ?>
                 <?php if((NZBGETURL != "" && qualifyUser(NZBGETHOMEAUTH)) || (SABNZBDURL != "" && qualifyUser(SABNZBDHOMEAUTH))) { ?>
                 <div id="downloadClientRow" class="row">
                     <sort>2</sort>

+ 2 - 1
lang/de.ini

@@ -250,4 +250,5 @@ REMOVE = "Remove"
 GIT_BRANCH = "Github branch to use when force installing (Leave this alone unless you are beta testing)"
 GIT_CHECK = "Check for new 'master' releases"
 GIT_FORCE = "Force Install Branch"
-GIT_FORCE_CONFIRM = "Are you sure you want to install this branch? Going from a newer version to an older verison is not recommended or supported."
+GIT_FORCE_CONFIRM = "Are you sure you want to install this branch? Going from a newer version to an older verison is not recommended or supported."
+SPEED_TEST = "Speed Test"

+ 2 - 1
lang/en.ini

@@ -250,4 +250,5 @@ REMOVE = "Remove"
 GIT_BRANCH = "Github branch to use when force installing (Leave this alone unless you are beta testing)"
 GIT_CHECK = "Check for new 'master' releases"
 GIT_FORCE = "Force Install Branch"
-GIT_FORCE_CONFIRM = "Are you sure you want to install this branch? Going from a newer version to an older verison is not recommended or supported."
+GIT_FORCE_CONFIRM = "Are you sure you want to install this branch? Going from a newer version to an older verison is not recommended or supported."
+SPEED_TEST = "Speed Test"

+ 2 - 1
lang/es.ini

@@ -250,4 +250,5 @@ REMOVE = "Remove"
 GIT_BRANCH = "Github branch to use when force installing (Leave this alone unless you are beta testing)"
 GIT_CHECK = "Check for new 'master' releases"
 GIT_FORCE = "Force Install Branch"
-GIT_FORCE_CONFIRM = "Are you sure you want to install this branch? Going from a newer version to an older verison is not recommended or supported."
+GIT_FORCE_CONFIRM = "Are you sure you want to install this branch? Going from a newer version to an older verison is not recommended or supported."
+SPEED_TEST = "Speed Test"

+ 2 - 1
lang/fr.ini

@@ -250,4 +250,5 @@ REMOVE = "Remove"
 GIT_BRANCH = "Github branch to use when force installing (Leave this alone unless you are beta testing)"
 GIT_CHECK = "Check for new 'master' releases"
 GIT_FORCE = "Force Install Branch"
-GIT_FORCE_CONFIRM = "Are you sure you want to install this branch? Going from a newer version to an older verison is not recommended or supported."
+GIT_FORCE_CONFIRM = "Are you sure you want to install this branch? Going from a newer version to an older verison is not recommended or supported."
+SPEED_TEST = "Speed Test"

+ 2 - 1
lang/it.ini

@@ -250,4 +250,5 @@ REMOVE = "Remove"
 GIT_BRANCH = "Github branch to use when force installing (Leave this alone unless you are beta testing)"
 GIT_CHECK = "Check for new 'master' releases"
 GIT_FORCE = "Force Install Branch"
-GIT_FORCE_CONFIRM = "Are you sure you want to install this branch? Going from a newer version to an older verison is not recommended or supported."
+GIT_FORCE_CONFIRM = "Are you sure you want to install this branch? Going from a newer version to an older verison is not recommended or supported."
+SPEED_TEST = "Speed Test"

+ 2 - 1
lang/nl.ini

@@ -250,4 +250,5 @@ REMOVE = "Remove"
 GIT_BRANCH = "Github branch to use when force installing (Leave this alone unless you are beta testing)"
 GIT_CHECK = "Check for new 'master' releases"
 GIT_FORCE = "Force Install Branch"
-GIT_FORCE_CONFIRM = "Are you sure you want to install this branch? Going from a newer version to an older verison is not recommended or supported."
+GIT_FORCE_CONFIRM = "Are you sure you want to install this branch? Going from a newer version to an older verison is not recommended or supported."
+SPEED_TEST = "Speed Test"

+ 2 - 1
lang/pl.ini

@@ -250,4 +250,5 @@ REMOVE = "Remove"
 GIT_BRANCH = "Github branch to use when force installing (Leave this alone unless you are beta testing)"
 GIT_CHECK = "Check for new 'master' releases"
 GIT_FORCE = "Force Install Branch"
-GIT_FORCE_CONFIRM = "Are you sure you want to install this branch? Going from a newer version to an older verison is not recommended or supported."
+GIT_FORCE_CONFIRM = "Are you sure you want to install this branch? Going from a newer version to an older verison is not recommended or supported."
+SPEED_TEST = "Speed Test"

+ 6 - 0
settings.php

@@ -619,6 +619,12 @@ echo buildSettings(
 						'value' => HOMEPAGEAUTHNEEDED,
 						'options' => $userTypes,
 					),
+                    array(
+                        'type' => 'checkbox',
+                        'labelTranslate' => 'SPEED_TEST',
+                        'name' => 'speedTest',
+                        'value' => SPEEDTEST,
+                    ),
 					/*
 					array(
 						'type' => 'custom',