The original commit only applied its changes to the source file and did not rebuild the minified file, therefore the change never went live.
1 line
8.2 KiB
JavaScript
1 line
8.2 KiB
JavaScript
"use strict";!function(){var a=JSON.parse(document.body.getAttribute("data-translations"));function r(t,e){return t.toFixed(e).replace(/\./,a["."])}function o(t,e){e--;for(var n=t;10<=n&&0<e;n/=10)e--;return r(t,e)}function i(t){return function(t,e,n){var i=0;if(void 0===n)return"- ";for(;e<n&&i<t.length-1;)n/=e,i++;return(n=o(n,3))+" "+t[i]}(["","K","M","G","T"],1024,t)}String.prototype.sprintf=function(){var t=0,e=arguments;return this.replace(/%s/g,function(){return e[t++]})};var u={id:function(t){return t},decimal:function(t){return r(t,2)},percent:function(t){return a["%s used"].sprintf(o(100*t,3)+"%")},memory:function(t){var e=1-t.available/t.total;return u.percent(e)},time:function(t){var e=Math.round(t/60),n=Math.floor(e/1440),i=Math.floor(e%1440/60);e=Math.floor(e%60);var r="";return 1===n?r+=a["1 day"]+", ":1<n&&(r+=a["%s days"].sprintf(n)+", "),r+=i+":",e<10&&(r+="0"),r+=e},packetsDiff:function(t,e,n){if(0<n)return i=(t-e)/n,a["%s packets/s"].sprintf(r(i,0));var i},bytesDiff:function(t,e,n){if(0<n)return i(8*((t-e)/n))+"bps"},bytes:function(t){return i(t)+"B"}};function l(e,t){return t.split("/").forEach(function(t){e&&(e=e[t])}),e}function f(t,n){var e=new EventSource(t),i={};e.onmessage=function(t){var e=JSON.parse(t.data);n(e,i),i=e},e.onerror=function(){e.close(),window.setTimeout(function(){f(t,n)},3e3)}}var y,C=document.body.getAttribute("data-node-address");try{y=JSON.parse(document.body.getAttribute("data-node-location"))}catch(t){}var t=document.querySelectorAll("[data-statistics]");f("/cgi-bin/dyn/statistics",function(o,c){var s=o.uptime-c.uptime;t.forEach(function(t){var e=t.getAttribute("data-statistics"),n=t.getAttribute("data-format"),i=l(c,e),r=l(o,e);try{var a=u[n](r,i,s);void 0!==a&&(t.textContent=a)}catch(t){console.error(t)}});try{!function(t){var e=document.getElementById("mesh-vpn");if(t){e.style.display="";for(var r=document.getElementById("mesh-vpn-peers");r.lastChild;)r.removeChild(r.lastChild);var n=function e(n,i){return Object.keys(i.peers||{}).forEach(function(t){n.push([t,i.peers[t]])}),Object.keys(i.groups||{}).forEach(function(t){e(n,i.groups[t])}),n}([],t);n.sort(),n.forEach(function(t){var e=document.createElement("tr"),n=document.createElement("th");n.textContent=t[0],e.appendChild(n);var i=document.createElement("td");t[1]?i.textContent=a.connected+" ("+u.time(t[1].established)+")":i.textContent=a["not connected"],e.appendChild(i),r.appendChild(e)})}else e.style.display="none"}(o.mesh_vpn)}catch(t){console.error(t)}});var c={};function w(a){var o=document.createElement("canvas"),c=o.getContext("2d"),s=null;return{canvas:o,highlight:!1,resize:function(t,e){try{c.getImageData(0,0,t,e)}catch(t){}o.width=t,o.height=e},draw:function(t,e){var n,i,r=e(s);c.clearRect(t,0,5,o.height),r&&(n=t,i=r,c.beginPath(),c.fillStyle=a,c.arc(n,i,1.2,0,2*Math.PI,!1),c.closePath(),c.fill())},set:function(t){s=t}}}function h(){var s=-100,u=0,n=0,i=[],l=document.createElement("canvas");l.className="signalgraph",l.height=200;var f=l.getContext("2d");function t(){l.width=l.clientWidth,i.forEach(function(t){t.resize(l.width,l.height)})}function r(){if(0!==l.clientWidth){l.width!==l.clientWidth&&t(),f.clearRect(0,0,l.width,l.height);var e=!1;i.forEach(function(t){t.highlight&&(e=!0)}),f.save(),i.forEach(function(t){e&&(f.globalAlpha=.2),t.highlight&&(f.globalAlpha=1),t.draw(n,function(t){return e=t,n=s,i=u,r=l.height,(1-(e-n)/(i-n))*r;var e,n,i,r}),f.drawImage(t.canvas,0,0)}),f.restore(),f.save(),f.beginPath(),f.strokeStyle="rgba(255, 180, 0, 0.15)",f.lineWidth=5,f.moveTo(n+2.5,0),f.lineTo(n+2.5,l.height),f.stroke(),function(){var t,e,n,i,r=Math.floor(l.height/40);f.save(),f.lineWidth=.5,f.strokeStyle="rgba(0, 0, 0, 0.25)",f.fillStyle="rgba(0, 0, 0, 0.5)",f.textAlign="end",f.textBaseline="bottom",f.beginPath();for(var a=0;a<r;a++){var o=l.height-40*a;f.moveTo(0,o-.5),f.lineTo(l.width,o-.5);var c=Math.round((t=o,e=s,n=u,i=l.height,(e*t+n*(i-t))/i))+" dBm";f.save(),f.strokeStyle="rgba(255, 255, 255, 0.9)",f.lineWidth=4,f.miterLimit=2,f.strokeText(c,l.width-5,o-2.5),f.fillText(c,l.width-5,o-2.5),f.restore()}f.stroke(),f.strokeStyle="rgba(0, 0, 0, 0.83)",f.lineWidth=1.5,f.strokeRect(.5,.5,l.width-1,l.height-1),f.restore()}()}}t(),window.addEventListener("resize",r);var a=0;return window.requestAnimationFrame(function t(e){40<e-a&&(r(),n=(n+1)%l.width,a=e),window.requestAnimationFrame(t)}),{el:l,addSignal:function(t){i.push(t),t.resize(l.width,l.height)},removeSignal:function(t){i.splice(i.indexOf(t),1)}}}function d(t,e,n,i){var r=t.table.firstElementChild,a=t.table.insertRow(),o=a.insertCell();if(t.wireless){var c=document.createElement("span");c.textContent="⬤ ",c.style.color=n,o.appendChild(c)}var h=document.createElement("span");h.textContent=e,o.appendChild(h);var s,d,u,l,f,v={};function g(t){var e=t.getAttribute("data-key");if(e){var n=t.getAttribute("data-suffix")||"",i=a.insertCell();i.textContent="-",v[e]={td:i,suffix:n}}}for(var m=0;m<r.children.length;m++)g(r.children[m]);function p(){f&&window.clearTimeout(f),f=window.setTimeout(function(){l&&t.signalgraph.removeSignal(l),a.parentNode.removeChild(a),i()},6e4)}function b(t){var e=function(t){"::"==t.slice(0,2)&&(t="0"+t),"::"==t.slice(-2)&&(t+="0");var e=t.split(":"),n=e.length,i=[];return e.forEach(function(t,e){if(""===t)for(;n++<=8;)i.push(0);else{if(!/^[a-f0-9]{1,4}$/i.test(t))return;i.push(parseInt(t,16))}}),i}(t);if(e){var n="";return e.forEach(function(t){n+=("0000000000000000"+t.toString(2)).slice(-16)}),n}}return t.wireless&&((s=a.insertCell()).textContent="-",(d=a.insertCell()).textContent="-",(u=a.insertCell()).textContent="-",l=w(n),t.signalgraph.addSignal(l)),a.onmouseenter=function(){a.classList.add("highlight"),l&&(l.highlight=!0)},a.onmouseleave=function(){a.classList.remove("highlight"),l&&(l.highlight=!1)},p(),{update_nodeinfo:function(t){var e,n,i,r,a,o,c,s,u=function(t){var i=b(C);if(t&&t[0]){(t=t.map(function(t){var e=b(t);if(!e)return[-1];var n=0;return i&&(n=function(t,e){var n;for(n=0;n<t.length&&n<e.length&&t[n]===e[n];n++);return n}(i,e)),[n,e,t]})).sort(function(t,e){return t[0]<e[0]?1:t[0]>e[0]?-1:t[1]<e[1]?-1:t[1]>e[1]?1:0});var e=t[0][2];return e&&!/^fe80:/i.test(e)?e:void 0}}(t.network.addresses);if(u){if("span"===h.nodeName.toLowerCase()){var l=h;h=document.createElement("a"),l.parentNode.replaceChild(h,l)}h.href="http://["+u+"]/"}if(h.textContent=t.hostname,y&&t.location){var f=(e=y.latitude,n=y.longitude,i=t.location.latitude,r=t.location.longitude,a=Math.PI/180,o=(i*=a)-(e*=a),c=(r*=a)-(n*=a),s=Math.sin(o/2)*Math.sin(o/2)+Math.sin(c/2)*Math.sin(c/2)*Math.cos(e)*Math.cos(i),2*Math.asin(Math.sqrt(s))*6372.8);d.textContent=Math.round(1e3*f)+" m"}p()},update_mesh:function(n){Object.keys(v).forEach(function(t){var e=v[t];e.td.textContent=n[t]+e.suffix}),p()},update_wifi:function(t){s.textContent=t.signal,u.textContent=Math.round(t.inactive/1e3)+" s",a.classList.toggle("inactive",200<t.inactive),l.set(200<t.inactive?null:t.signal),p()}}}function s(t,e,n){var i,a={};n&&(i=h(),t.appendChild(i.el));var r={table:t.firstElementChild,signalgraph:i,ifname:e,wireless:n},o=!1,c={},s=[];function u(){if(!o){o=!0;var t=new EventSource("/cgi-bin/dyn/neighbours-nodeinfo?"+encodeURIComponent(e));t.addEventListener("neighbour",function(t){try{var n=JSON.parse(t.data);(e=n,i=[],r=e.network.mesh,Object.keys(r).forEach(function(t){var e=r[t].interfaces;Object.keys(e).forEach(function(t){e[t].forEach(function(t){i.push(t)})})}),i).forEach(function(t){var e=a[t];if(e){delete c[t];try{e.update_nodeinfo(n)}catch(t){console.error(t)}}})}catch(t){console.error(t)}var e,i,r},!1),t.onerror=function(){t.close(),o=!1,Object.keys(c).forEach(function(t){0<c[t]&&(c[t]--,u())})}}}function l(t){var e=a[t];return e||(c[t]=3,e=a[t]=d(r,t,(s[0]||(s=["#396AB1","#DA7C30","#3E9651","#CC2529","#535154","#6B4C9A","#922428","#948B3D"]),s.shift()),function(){delete c[t],delete a[t]}),u()),e}return n&&f("/cgi-bin/dyn/stations?"+encodeURIComponent(e),function(n){Object.keys(n).forEach(function(t){var e=n[t];l(t).update_wifi(e)})}),{get_neigh:l}}document.querySelectorAll("[data-interface]").forEach(function(t){var e=t.getAttribute("data-interface"),n=(t.getAttribute("data-interface-address"),!!t.getAttribute("data-interface-wireless"));c[e]=s(t,e,n)});var e=document.body.getAttribute("data-mesh-provider");e&&f(e,function(i){Object.keys(i).forEach(function(t){var e=i[t],n=c[e.ifname];n&&n.get_neigh(t).update_mesh(e)})})}(); |