Projekt

Obecné

Profil

Stáhnout (8.83 KB) Statistiky
| Větev: | Revize:
1 af7609b5 Tomáš Ballák
var js;js=function(){var t={157:function(t){var e,a,n=null,o=null,s=49.7248,p=13.3521,r=17;let l,i,c;var u,d=!1,m=[],h=[];let g=0;const y={};var b=[];let f=!1,v=0;const w={},x={};let k={};const C={coord:{lat:0,lng:0},_popup:null},N=async(t,e)=>{const a=new Headers,n=new Request(t,{method:e,headers:a});return(await fetch(n)).json()},P=async(t,e,a,n)=>await N(t+"/"+e+"/"+a+"/"+n,"GET");preload=async(t,e,n)=>{it();for(let o=t+e;o>=0&&o<=23;o+=e)m[o]||(m[o]={}),b.forEach((async t=>{m[o][t]||(m[o][t]=await P(a,t,n,o))}));ct()};const j=async(t,e,n=1e3)=>{pt(),a=t,l=e;const o=[];m[i]={};b.forEach((t=>{o.push((async t=>{t in w||(w[t]=await(async(t,e)=>await N(t+"/"+e,"GET"))(e,t));const n=await P(a,t,W(),i);m[i][t]=n})(t))})),it(n),await Promise.all(o).then((()=>{ct(0),O(w),I(m[i]),preload(i,1,W()),preload(i,-1,W())}))},I=t=>{const a=t,o=[];let s=0;Object.keys(k).length&&(Object.keys(k).forEach((function(t){k[t][0].bindPopup(k[t][1])})),k={}),Object.keys(a).forEach((t=>{const p=a[t];if(s=Math.max(s,p.max),null!=p){const t=p.items.map((t=>{const{x:e,y:a,number:n}=t,o=e+""+a,s=x[o];return!k[o]&&n&&(s[0]=s[0].unbindPopup(),k[o]=s),[e,a,n]}));o.push(...t)}else null!=n&&e.removeLayer(n)})),null!=n&&e.removeLayer(n),o.length&&(n=L.heatLayer(o,{max:s,minOpacity:.5,radius:35,blur:30}).addTo(e)),Z()},O=t=>{null!=o&&e.removeLayer(o),o=L.layerGroup(),Object.keys(t).forEach((e=>{for(var a in t[e]){const{x:n,y:s,name:p}=t[e][a],r=G(n,s,1,`popup-${e}`).setContent(A(y[e],p,0,0,1,1)),l=L.circle([n,s],{radius:2,fillOpacity:.8,color:"#004fb3",fillColor:"#004fb3",bubblingMouseEvents:!0}).bindPopup(r);x[n+""+s]=[l,r],o.addLayer(l)}})),o.setZIndex(-1).addTo(e)},S=(t=null)=>{i=null!==t?t:parseInt($('#dropdown-time input[type="radio"]:checked').val())},T=(t=null)=>{const e=$("#date");c=new Date(t||e.val()),e.val(W()),$("#player-date span").html(`${c.getDate()}. ${c.getMonth()+1}. ${c.getFullYear()}`),m=[]},D=t=>{C._popup.setContent(t),C._popup.openOn(e)},E=(t,e)=>({previousButton:'<button type="button" id="btn-popup-previous-page" onclick="js.setPreviousPageInPopup()"></button>',pagesList:`<p id="pages">${t} z ${e}</p>`,nextButton:'<button type="button" id="btn-popup-next-page" class="next" onclick="js.setNextPageInPopup()"></button>'}),M=()=>{$("#btn-popup-previous-page").prop("disabled",!0),$("#btn-popup-next-page").prop("disabled",!0),$(".popup-pagination").hide()},_=t=>`<div class="popup-pagination">${t?t.reduce(((t,e)=>t+e),""):""}</div>`,B=()=>{const t=Object.keys(h);return 1===t.length?h[t[0]].items.length:t.length},z=t=>{const e=Object.keys(h);return h[e[t]]},G=(t,e,a,n)=>L.popup({autoPan:!1,className:n}).setLatLng([t/a,e/a]),A=(t,e,a,n,o,s)=>{const p=`\n    <strong>${t}</strong>\n    <div id="place-name">${e}</div>`,r=`\n    <div id="place-intesity">\n      <span id="current-number">${a}</span>\n      <span id="sum-number">${n&&n!==Number(a)?"/"+n:""}</span>\n    </div>`,{previousButton:l,nextButton:i,pagesList:c}=E(o,s);return`\n  ${p}\n  ${r}\n  ${_(s>1?[l,c,i]:null)}\n  `},F=()=>Object.keys(h).length>1,H=t=>{const e=$(".leaflet-popup");e.removeClass((function(t,e){return(e.match(/(^|\s)popup-\S+/g)||[]).join(" ")})),e.addClass("popup-"+t)},V=t=>{h=[],g=0;const a=40075016.686*Math.cos(s)/Math.pow(2,e.getZoom())*25/256;let n=0,o=0,p=0,r=0;const l={},c={lng:t.latlng.lng,lat:t.latlng.lat};Object.keys(m[i]).forEach((e=>{m[i][e].items.forEach((s=>{t.latlng.distanceTo(new L.LatLng(s.x,s.y))<a&&(o+=s.x,p+=s.y,h[n]={place:s.place,number:s.number,datasetName:e},r+=parseInt(s.number),n++,l[e]=!0)}))})),h=h.reduce(((t,e)=>(t[e.datasetName]||(t[e.datasetName]={items:[],number:0,datasetName:e.datasetName}),t[e.datasetName].items.push(e),t[e.datasetName].number+=Number(e.number),t)),{});const u=Object.keys(l).length;if(u)if(1===u){const t=z(0),e=t.items,{place:a,number:s}=e[g];C._popup&&tt(C.coord,c)?H(t.datasetName):(C._popup=G(o,p,n,`popup-${t.datasetName}`),C.coord=c),D(A(y[t.datasetName],a,s,r,1,e.length)),1===e.length&&M()}else{const{datasetName:t,number:e}=z(g);C._popup&&tt(C.coord,c)?H(t):(C._popup=G(o,p,n,`popup-${t}`),C.coord=c),D(((t,e,a,n)=>{const o=`<strong id="dataset-name">${n}</strong>`,s=`<div id="place-intesity"><span id="current-number">${t}</span></div>`,{previousButton:p,nextButton:r,pagesList:l}=E(1,a);return`\n  ${o}\n  ${s}\n  ${_([p,l,r])}\n  `})(e,0,B(),y[t]))}else e._popup&&($("#sum-number").text(""),$("#current-number").html(0),M())},Y=t=>{const e=F()?z(t):z(0).items[t],a=F()?z(g):z(0).items[g],n=$("#dataset-name");n&&n.html(y[a.datasetName]),$("#place-name").html(a.place?a.place:a.datasetName),$("#current-number").html(a.number),$("#pages").html(g+1+" z "+B()),$(".leaflet-popup").removeClass(`popup-${e.datasetName}`).addClass(`popup-${a.datasetName}`)},Z=()=>{const{_popup:t}=e;t&&V({latlng:t.getLatLng()})},R=async()=>{v||(i=(i+23)%24,K(i),f||23!==i?I(m[i]):(X(-1),await j(a,l)),Z())},q=async()=>{v||(i=(i+1)%24,K(i),f||0!==i?I(m[i]):(X(1),await j(a,l)),Z())},J=t=>{K(t),I(m[i])},K=t=>{$("#player-time").removeAttr("style"),S(t),at(),nt(),Q(),Z()},Q=()=>{window.history.pushState("",document.title,window.location.origin+window.location.pathname+`?date=${W()}&time=${i}${b.reduce(((t,e)=>t+"&type[]="+e),"")}`)},U=(t,e=!1)=>(e&&t<10?"0":"")+t+":00",W=()=>`${c.getFullYear()}-${(()=>{const t=c.getMonth()+1;return t>9?`${t}`:`0${t}`})()}-${(()=>{const t=c.getDate();return t>9?`${t}`:`0${t}`})()}`,X=t=>{c.setDate(c.getDate()+t),T(c)},tt=(t,e)=>t.lat===e.lat&&t.lng===e.lng,et=(t,e)=>{let a;return function(){const n=this,o=arguments;clearTimeout(a),a=setTimeout((()=>t.apply(n,o)),e)}},at=()=>{$(`#time_${i}`).prop("checked",!0),$("#dropdownMenuButtonTime").html(U(i,!0))},nt=()=>{$("#player-time > span").text(U(i)),$("#player-time").attr("class","time hour-"+i)},ot=()=>{$("#date").change((function(){T($(this).val()),j(a,l,0),Q()})),$('#dropdown-time input[type="radio"]').each((function(){$(this).change((function(){K(parseInt($(this).val())),I(m[i])}))})),$('#dropdown-dataset input[type="checkbox"]').each((function(){$(this).change(et((()=>st(this)),1e3))}))},st=async t=>{$(t).prop("checked")?await j(a,l,0):(pt(),m.forEach(((e,a)=>{Object.keys(e).forEach((e=>{e===$(t).val()&&delete m[a][e]})),I(m[i])}))),Z(),Q()},pt=()=>{b=[],$("#dropdown-dataset .dropdown-item").each((function(){const t=$(this).find("input"),e=t[0].value;t[0].checked&&b.push(e),y[e]=$(t).data("dataset-display-name")}))},rt=async t=>{let e=!1;$("#dropdown-dataset .dropdown-item").each((function(){const a=$(this).find("input");a[0].value in t?(e=!0,$(this).removeClass("disabled")):($(this).addClass("disabled"),$(a).prop("checked",!1))})),$("#btn-update-heatmap").prop("disabled",!e)},lt=(t,e)=>{setTimeout((()=>{t(v),v&&lt(t,e)}),e)},it=(t=1e3)=>{v++,lt((()=>lt((t=>ut(t)),t)))},ct=(t=1e3)=>{v--,lt((()=>lt((t=>ut(t)))),t)},ut=t=>{t?dt():mt()},dt=()=>{$("#player-time > .spinner-border").removeClass("d-none"),$("#player-time > span").text("")},mt=()=>{$("#player-time > .spinner-border").addClass("d-none"),nt()};t.exports={initDatepicker:async t=>{const e=await N(t,"GET"),a=String(e).split(",");$("#date").datepicker({format:"yyyy-mm-dd",language:"cs",beforeShowDay:function(t){return a.indexOf((t=>{var e=String(t.getDate()),a=String(t.getMonth()+1);return 1===e.length&&(e="0"+e),1===a.length&&(a="0"+a),t.getFullYear()+"-"+a+"-"+e})(t))<0?{enabled:!1,tooltip:"Žádná data"}:{enabled:!0}},autoclose:!0})},initLocationsMenu:()=>{const t=$(".locations"),e="show";$(window).width()<=480?t.removeClass(e):t.addClass(e)},initMap:()=>{s=localStorage.getItem("lat")||s,p=localStorage.getItem("lng")||p,r=localStorage.getItem("zoom")||r,e=L.map("heatmap").setView([s,p],r),L.tileLayer("https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png",{attribution:"",maxZoom:19}).addTo(e),e.on("click",(function(t){V(t)}))},onDocumentReady:()=>{$("#dropdown-dataset").on("click",(function(t){t.stopPropagation()})),$("#btn-update-heatmap").prop("name",""),S(),T(),ot(),$(document).keydown((function(t){const{which:e}=t;37===e?(R(),t.preventDefault()):39===e&&(q(),t.preventDefault())}))},checkDataSetsAvailability:async t=>{const e=await N(t+"/"+W(),"POST");rt(e)},loadCurrentTimeHeatmap:j,dragTimeline:()=>{const t=$("#player-time"),e=t.offset().left-t.parent().offset().left;if(e>=0&&e<=t.parent().width()){const a=Math.round(e/26);a!==i&&(t.attr("class","time hour-"+a),$("#player-time span").html(U(a)),J(a))}},setPreviousPageInPopup:()=>{const t=B(),e=g;g=(g+t-1)%t,Y(e)},setNextPageInPopup:()=>{const t=B(),e=g;g=(g+1)%t,Y(e)},previous:R,next:q,toggleDayLock:()=>{f=!f,$("#player-date").toggleClass("lock")},changeAnimationState:()=>{const t=$("#animate-btn");(d=!d)?(t.removeClass("play").addClass("pause"),u=setInterval((function(){q()}),800)):(clearTimeout(u),t.removeClass("pause").addClass("play"))},onChangeHour:J,setMapView:(t,a,n)=>{localStorage.setItem("lat",t),localStorage.setItem("lng",a),localStorage.setItem("zoom",n),e.setView([t,a],n)}}}},e={};return function a(n){if(e[n])return e[n].exports;var o=e[n]={exports:{}};return t[n](o,o.exports,a),o.exports}(157)}();