Browse Source

Merge commit 'dd40a3a4937d88fdc2337adb190fb9d091e849a4' into newdesign

sstidl 1 year ago
parent
commit
13f6c4972c
2 changed files with 234 additions and 6 deletions
  1. 6 6
      doc_docker.md
  2. 228 0
      examples/example-singleServer-modern.html

+ 6 - 6
doc_docker.md

@@ -11,10 +11,10 @@ An Alpine Linux based docker version of LibreSpeed is also available here: [GitH
 If you just want to try it, the fastest way is:
 
 ```shell
-docker run -p 80:80 -d --name speedtest --rm ghcr.io/librespeed/speedtest
+docker run -p 80:8080 -d --name speedtest --rm ghcr.io/librespeed/speedtest
 ```
 
-Then go with your browser to port 80 of your server and try it out. If port 80 is already in use, adjust the first number in 80:80 above.
+Then go with your browser to port 80 of your server and try it out. If port 80 is already in use, adjust the first number in 80:8080 above.
 Default is to run in standalone mode.
 
 ## Docker Compose
@@ -41,9 +41,9 @@ services:
       #DISABLE_IPINFO: "false"
       #IPINFO_APIKEY: "your api key"
       #DISTANCE: "km"
-      #WEBPORT: 80
+      #WEBPORT: 8080
     ports:
-      - "80:80" # webport mapping (host:container)
+      - "80:8080" # webport mapping (host:container)
 ```
 
 Please adjust the environment variables according to the intended operating mode.
@@ -73,7 +73,7 @@ Here's a list of additional environment variables available in this mode:
 * __`DISABLE_IPINFO`__: If set to `true`, ISP info and distance will not be fetched from either [ipinfo.io](https://ipinfo.io) or the offline database. Default: value: `false`
 * __`IPINFO_APIKEY`__: API key for [ipinfo.io](https://ipinfo.io). Optional, but required if you want to use the full [ipinfo.io](https://ipinfo.io) APIs (required for distance measurement)
 * __`DISTANCE`__: When `DISABLE_IPINFO` is set to false, this specifies how the distance from the server is measured. Can be either `km` for kilometers, `mi` for miles, or an empty string to disable distance measurement. Requires an [ipinfo.io](https://ipinfo.io) API key. Default value: `km`
-* __`WEBPORT`__: Allows choosing a custom port for the included web server. Default value: `80`. Note that you will have to expose it through docker with the -p argument. This is not the port where the service is exposed outside docker!
+* __`WEBPORT`__: Allows choosing a custom port for the included web server. Default value: `8080`. Note that you will have to expose it through docker with the -p argument. This is not the port where the service is exposed outside docker!
 
 If telemetry is enabled, a stats page will be available at `http://your.server/results/stats.php`, but a password must be specified.
 
@@ -110,7 +110,7 @@ Here's a list of additional environment variables available in this mode:
 This command starts LibreSpeed in backend mode, with the default settings, on port 80:
 
 ```shell
-docker run -e MODE=backend -p 80:80 -it ghcr.io/librespeed/speedtest
+docker run -e MODE=backend -p 80:8080 -it ghcr.io/librespeed/speedtest
 ```
 
 ### Frontend mode

+ 228 - 0
examples/example-singleServer-modern.html

@@ -0,0 +1,228 @@
+<!DOCTYPE html>
+<html>
+<head>
+<meta charset="UTF-8" />
+<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no, user-scalable=no" />
+<title>LibreSpeed</title>
+<link rel="shortcut icon" href="favicon.ico">
+<link rel="preconnect" href="https://fonts.googleapis.com">
+<link href="https://fonts.googleapis.com/css2?family=Roboto:wght@400;700&family=Open+Sans:wght@400;700&family=Noto+Color+Emoji&display=swap" rel="stylesheet">
+<script type="text/javascript" src="speedtest.js"></script>
+<script type="text/javascript">
+
+//INITIALIZE SPEEDTEST
+var s=new Speedtest(); //create speedtest object
+s.setParameter("telemetry_level","basic"); //enable telemetry
+
+s.onupdate=function(data){ //callback to update data in UI
+    I("ip").textContent=data.clientIp;
+    I("dlText").textContent=(data.testState==1&&data.dlStatus==0)?"...":data.dlStatus;
+    I("ulText").textContent=(data.testState==3&&data.ulStatus==0)?"...":data.ulStatus;
+    I("pingText").textContent=data.pingStatus;
+    I("jitText").textContent=data.jitterStatus;
+}
+s.onend=function(aborted){ //callback for test ended/aborted
+    I("startStopBtn").className=""; //show start button again
+    if(aborted){ //if the test was aborted, clear the UI and prepare for new test
+        initUI();
+    } else {
+        // Check if download speed is greater than 50 Mbit/s
+        var dlSpeed = parseFloat(I("dlText").textContent);
+        if (dlSpeed > 50) {
+            I("speedMessage").textContent = "📽️👍";
+        } else {
+            I("speedMessage").textContent = "🙄";
+        }
+    }
+}
+
+function startStop(){ //start/stop button pressed
+    if(s.getState()==3){
+        //speedtest is running, abort
+        s.abort();
+    }else{
+        //test is not running, begin
+        s.start();
+        I("startStopBtn").className="running";
+    }
+}
+
+//function to (re)initialize UI
+function initUI(){
+    I("dlText").textContent="";
+    I("ulText").textContent="";
+    I("pingText").textContent="";
+    I("jitText").textContent="";
+    I("ip").textContent="";
+}
+
+function I(id){return document.getElementById(id);}
+
+// Automatically start the test when the page loads
+window.onload = function() {
+    startStop();
+}
+</script>
+
+<style type="text/css">
+    html,body{
+        border:none; padding:0; margin:0;
+        background:#f4f4f9;
+        color:#333;
+        font-family:"Roboto",sans-serif;
+    }
+    body{
+        text-align:center;
+    }
+    h1{
+        color:#333;
+        margin-top:1em;
+    }
+    #startStopBtn{
+        display:inline-block;
+        margin:1em auto;
+        color:#fff;
+        background-color:#007bff;
+        border:none;
+        border-radius:0.3em;
+        transition:all 0.3s;
+        box-sizing:border-box;
+        width:10em; height:3em;
+        line-height:3em;
+        cursor:pointer;
+        box-shadow: 0 0 0 rgba(0,0,0,0.1), inset 0 0 0 rgba(0,0,0,0.1);
+        font-size:1em;
+    }
+    #startStopBtn:hover{
+        background-color:#0056b3;
+    }
+    #startStopBtn.running{
+        background-color:#dc3545;
+    }
+    #startStopBtn:before{
+        content:"Start";
+    }
+    #startStopBtn.running:before{
+        content:"Abort";
+    }
+    #test{
+        margin-top:2em;
+        margin-bottom:4em;
+    }
+    div.testArea{
+        display:inline-block;
+        width:14em;
+        height:9em;
+        position:relative;
+        box-sizing:border-box;
+        margin:1em;
+        background:#fff;
+        border-radius:0.5em;
+        box-shadow:0 0 10px rgba(0,0,0,0.1);
+        padding:1em;
+    }
+    div.testName{
+        position:absolute;
+        top:0.5em; left:0;
+        width:100%;
+        font-size:1.2em;
+        z-index:9;
+        color:#555;
+    }
+    div.meterText{
+        position:absolute;
+        bottom:1.5em; left:0;
+        width:100%;
+        font-size:2.5em;
+        z-index:9;
+        color:#007bff;
+    }
+    div.testConclusion{
+        position:absolute;
+        bottom:2em; left:0;
+        width:100%;
+        font-size:5em;
+        z-index:9;
+        color:#333;
+	text-shadow:0 0 10px #888;
+    }
+    #dlText{
+        color:#007bff;
+    }
+    #ulText{
+        color:#28a745;
+    }
+    #pingText,#jitText{
+        color:#dc3545;
+    }
+    div.meterText:empty:before{
+        color:#ccc !important;
+        content:"0.00";
+    }
+    div.unit{
+        position:absolute;
+        bottom:2em; left:0;
+        width:100%;
+        z-index:9;
+        color:#777;
+    }
+    div.testGroup{
+        display:inline-block;
+    }
+    @media all and (max-width:65em){
+        body{
+            font-size:1.5vw;
+        }
+    }
+    @media all and (max-width:40em){
+        body{
+            font-size:0.8em;
+        }
+        div.testGroup{
+            display:block;
+            margin: 0 auto;
+        }
+    }
+
+</style>
+</head>
+<body>
+<h1>LibreSpeed</h1>
+<div id="startStopBtn" onclick="startStop()"></div>
+<div id="test">
+    <div class="testGroup">
+        <div class="testArea">
+            <div class="testName">Download</div>
+            <div id="dlText" class="meterText"></div>
+            <div class="unit">Mbit/s</div>
+        </div>
+        <div class="testArea">
+            <div class="testName">Upload</div>
+            <div id="ulText" class="meterText"></div>
+            <div class="unit">Mbit/s</div>
+        </div>
+    </div>
+    <div class="testGroup">
+        <div class="testArea">
+            <div class="testName">Ping</div>
+            <div id="pingText" class="meterText"></div>
+            <div class="unit">ms</div>
+        </div>
+        <div class="testArea">
+            <div class="testName">Jitter</div>
+            <div id="jitText" class="meterText"></div>
+            <div class="unit">ms</div>
+        </div>
+    </div>
+    <div id="speedMessage" class="testConclusion">
+    </div>
+    <div id="ipArea">
+        IP Address: <span id="ip"></span>
+    </div>
+</div>
+<a href="https://github.com/librespeed/speedtest">Source code</a>
+<script type="text/javascript">
+    initUI();
+</script>
+</body>
+</html>