]> scm.dxcluster.org Git - dweather.git/commitdiff
display speeds in mph rather than m/s
authorDirk Koopman <djk@tobit.co.uk>
Wed, 9 Dec 2015 23:44:13 +0000 (23:44 +0000)
committerDirk Koopman <djk@tobit.co.uk>
Wed, 9 Dec 2015 23:44:13 +0000 (23:44 +0000)
templates/index.html.ep

index c8ef3b52ad6eafc00a3f5857d8bd49e24d42d5ef..443408d92e71fd8f0df349be51915cbb2afb27b1 100644 (file)
 
                var h = new Object();
 
+               var trans = {
+                       "Wind" : function (speed) { return (speed * 2.236936).toFixed(1); },
+                       "Wind_1m" : function (speed) { return (speed * 2.236936).toFixed(1); },
+                       "Wind_Max": function (speed) { return (speed * 2.236936).toFixed(1); }
+               };
+                       
+
                function do_debug(text) {
                        document.getElementById("do_debug").innerHTML = text;
                }
                function fill_html(key,value) {
                        var d = document.getElementById(key);
                        if (d !== null) {
-                               d.innerHTML = value;
+                               var f = trans[key];
+                               if (f && typeof(f) === "function") {
+                                       d.innerHTML = trans[key](value);
+                               } else {
+                                       d.innerHTML = value;
+                               }
                        }
                }
 
                                                <th>Humidity:</th><td> <span id="Humidity_Out"> </span> %</td>
                                                <th>Dew Point:</th><td> <span id="Dew_Point"> </span> °C</td>
                                        </tr>
-                                       <tr><th>Wind:</th><td><span id="Dir"> </span> ° @ <span id="Wind"> </span> m/s</td>
-                                               <th>Wind Minute Avg:</th><td> <span id="Dir_1m"> </span> ° @ <span id="Wind_1m"> </span> m/s </td>
-                                               <th>Day Max Speed:</th><td> <span id="Wind_Max"> </span> m/s @ <span id="Wind_Max_T"> </span></td>
+                                       <tr><th>Wind:</th><td><span id="Dir"> </span> ° @ <span id="Wind"> </span> mph</td>
+                                               <th>Wind Minute Avg:</th><td> <span id="Dir_1m"> </span> ° @ <span id="Wind_1m"> </span> mph </td>
+                                               <th>Day Max Speed:</th><td> <span id="Wind_Max"> </span> mph @ <span id="Wind_Max_T"> </span></td>
                                        </tr>
                                        <tr>
                                                <th>Rain 30mins:</th><td> <span id="Rain_1h"> </span> mm</td>