[www-doc] [Git][VideoLAN.org/websites][master] Add the downloads counter on a live page for testing purpose

Ludovic Fauvet gitlab at videolan.org
Sun Feb 14 13:44:57 CET 2016


Ludovic Fauvet pushed to branch master at VideoLAN organization / websites


Commits:
41cae33f by Ludovic Fauvet at 2016-02-14T13:43:29Z
Add the downloads counter on a live page for testing purpose

- - - - -


1 changed file:

- www.videolan.org/include/os-specific.php


Changes:

=====================================
www.videolan.org/include/os-specific.php
=====================================
--- a/www.videolan.org/include/os-specific.php
+++ b/www.videolan.org/include/os-specific.php
@@ -230,6 +230,24 @@ function downloadButton2($dropdownItems = null, $targetOS = null, $displayMainOS
     $defaultOS = is_null($targetOS) || $targetOS == 'All' ? "windows" : $targetOS;
     $defaultDetail = getOS($defaultOS);
     ?>
+    <script>
+        var ws;
+
+        function openWSCounterSocket() {
+            if (ws === undefined || ws.readyState === undefined || ws.readyState > 1) {
+                ws = new WebSocket("wss://get.videolan.org/wscounter");
+                ws.onmessage = function(event) {
+                    $('#wscounter').text(event.data + " <?php echo _("downloads so far"); ?>");
+                };
+            }
+        }
+
+        $(function() {
+            openWSCounterSocket();
+            setInterval(openWSCounterSocket, 5000);
+        });
+    </script>
+
     <div class="inner center-xs">
         <div class="btn-group">
             <a id='downloadButton2' class="btn btn-default btn-lg btn-dl" href='<?php echo $defaultDetail["location"]; ?>'>
@@ -262,6 +280,7 @@ function downloadButton2($dropdownItems = null, $targetOS = null, $displayMainOS
         <div id="downloadDetails">
             Version <span id='downloadVersion'>
             <?php echo $defaultDetail["latestVersion"] ?></span> • <span id='downloadOS'><?php echo $defaultDetail["name"]; ?></span> • <span id='downloadSize'><?php echo $defaultDetail["size"] ?></span>
+            <br/><span id="wscounter"></span>
         </div>
         <?php if ($displayMainOSicons) { ?>
         <div class="platform-icons main-os-icons">



View it on GitLab: https://code.videolan.org/VideoLAN.org/websites/commit/41cae33f7f964ea3a115ed6f8e770c514feb0789
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mailman.videolan.org/pipermail/www-doc/attachments/20160214/f7b9799d/attachment.html>


More information about the www-doc mailing list