atlas/web/_js/minified.js

1 line
26 KiB
JavaScript
Raw Normal View History

function pointIsInPolygon(point,polygon){for(var x=point[0],y=point[1],inside=!1,i=0,j=polygon.length-1;i<polygon.length;j=i++){var xi=polygon[i][0],yi=polygon[i][1],xj=polygon[j][0],yj=polygon[j][1],intersect;yi>y!=yj>y&&x<(xj-xi)*(y-yi)/(yj-yi)+xi&&(inside=!inside)}return inside}window.addEventListener("error",(function(e){console.log(e);var errorMessage='<p class="error">An error has occurred:</p>';errorMessage+='<p class="errorBody">'+e.message+"</p>",errorMessage+='<p class="errorBody">on line '+e.lineno+"</p>",errorMessage+='<p class="error">If this keeps happening, feel free to send me a <a href="mailto:roland.rytz@gmail.com">mail</a>.</p>',document.getElementById("loadingContent").innerHTML=errorMessage}));var atlas=[{id:0,name:"r/place still has to be indexed",description:"To make sure this project doesn't get flooded with a million requests or changes, I wait until april 4th so I can submit all the ",website:"https://place-atlas.stefanocoding.me/",subreddit:"r/placeAtlas2",center:[502.5,513.5],path:[[2.5,343.5],[994.5,339.5],[996.5,690.5],[2.5,678.5]]}];atlas.sort((function(a,b){return a.center[1]<b.center[1]?-1:a.center[1]>b.center[1]?1:0}));var linesCanvas=document.getElementById("linesCanvas"),linesContext=linesCanvas.getContext("2d"),hovered=[],previousZoomOrigin=[0,0],previousScaleZoomOrigin=[0,0],backgroundCanvas=document.createElement("canvas");backgroundCanvas.width=1e3,backgroundCanvas.height=1e3;var backgroundContext=backgroundCanvas.getContext("2d");function updateLines(){linesCanvas.width=linesCanvas.clientWidth,linesCanvas.height=linesCanvas.clientHeight,linesContext.lineCap="round",linesContext.lineWidth=Math.max(Math.min(1.5*zoom,24),6),linesContext.strokeStyle="#000000";for(var i=0;i<hovered.length;i++){var element;0!=(element=hovered[i].element).getBoundingClientRect().left&&(linesContext.beginPath(),linesContext.moveTo(element.getBoundingClientRect().left+document.documentElement.scrollLeft+element.clientWidth/2,element.getBoundingClientRect().top+document.documentElement.scrollTop+20),linesContext.lineTo(~~(hovered[i].center[0]*zoom)+innerContainer.offsetLeft,~~(hovered[i].center[1]*zoom)+innerContainer.offsetTop),linesContext.stroke())}linesContext.lineWidth=Math.max(Math.min(zoom,16),4),linesContext.strokeStyle="#FFFFFF";for(var i=0;i<hovered.length;i++){var element;0!=(element=hovered[i].element).getBoundingClientRect().left&&(linesContext.beginPath(),linesContext.moveTo(element.getBoundingClientRect().left+document.documentElement.scrollLeft+element.clientWidth/2,element.getBoundingClientRect().top+document.documentElement.scrollTop+20),linesContext.lineTo(~~(hovered[i].center[0]*zoom)+innerContainer.offsetLeft,~~(hovered[i].center[1]*zoom)+innerContainer.offsetTop),linesContext.stroke())}}function renderBackground(atlas){backgroundContext.clearRect(0,0,canvas.width,canvas.height),backgroundContext.fillStyle="rgba(0, 0, 0, 0.6)",backgroundContext.fillRect(0,0,backgroundCanvas.width,backgroundCanvas.height);for(var i=0;i<atlas.length;i++){var path=atlas[i].path;backgroundContext.beginPath(),path[0]&&backgroundContext.moveTo(path[0][0],path[0][1]);for(var p=1;p<path.length;p++)backgroundContext.lineTo(path[p][0],path[p][1]);backgroundContext.closePath(),backgroundContext.strokeStyle="rgba(255, 255, 255, 0.8)",backgroundContext.stroke()}}function initView(){var wrapper=document.getElementById("wrapper"),objectsContainer=document.getElementById("objectsList"),closeObjectsListButton=document.getElementById("closeObjectsListButton"),filterInput=document.getElementById("searchList"),entriesList=document.getElementById("entriesList"),hideListButton=document.getElementById("hideListButton"),entriesListShown=!0,sortedAtlas,entriesLimit=50,entriesOffset=0,moreEntriesButton=document.createElement("button");moreEntriesButton.innerHTML="Show 50 more",moreEntriesButton.id="moreEntriesButton",moreEntriesButton.onclick=function(){buildObjectsList(null,null)};var defaultSort="shuffle";document.getElementById("sort").value=defaultSort;var lastPos=[0,0],fixed=!1;renderBackground(atlas),render(),buildObjects