atlas/web/_js/minified.js

103 lines
528 KiB
JavaScript
Raw Normal View History

/*
This file contains compressed versions of the following files:
https://draemm.li/various/place-atlas/_js/atlas.js
https://draemm.li/various/place-atlas/_js/main.js
https://draemm.li/various/place-atlas/_js/view.js
https://draemm.li/various/place-atlas/_js/draw.js
These files are released under the AGPL v3 license (see below)
This file also contains the function pointIsInPolygon,
which was released under the MIT license by James Halliday.
*/
/*
The MIT License (MIT)
pointIsInPolygon function
Copyright (c) 2016 James Halliday
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
*/
function pointIsInPolygon (point, polygon) {
// ray-casting algorithm based on
// http://www.ecse.rpi.edu/Homepages/wrf/Research/Short_Notes/pnpoly.html
var x = point[0], y = point[1];
var inside = false;
for (var i = 0, j = polygon.length - 1; i < polygon.length; j = i++) {
var xi = polygon[i][0], yi = polygon[i][1];
var xj = polygon[j][0], yj = polygon[j][1];
var intersect = ((yi > y) != (yj > y))
&& (x < (xj - xi) * (y - yi) / (yj - yi) + xi);
if (intersect) inside = !inside;
}
return inside;
};
/*
========================================================================
The /r/place Atlas
An Atlas of Reddit's /r/place, with information to each
artwork of the canvas provided by the community.
Copyright (C) 2017 Roland Rytz <roland@draemm.li>
Licensed under the GNU Affero General Public License Version 3
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as
published by the Free Software Foundation, either version 3 of the
License, or (at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
For more information, see:
https://draemm.li/various/place-atlas/license.txt
========================================================================
*/
2017-04-06 12:26:49 +02:00
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 a=0;a<hovered.length;a++){var b=hovered[a].element;0!=b.getBoundingClientRect().left&&(linesContext.beginPath(),linesContext.moveTo(b.getBoundingClientRect().left+document.documentElement.scrollLeft+b.clientWidth/2,b.getBoundingClientRect().top+document.documentElement.scrollTop+20),linesContext.lineTo(~~(hovered[a].center[0]*zoom)+innerContainer.offsetLeft,~~(hovered[a].center[1]*zoom)+innerContainer.offsetTop),linesContext.stroke())}linesContext.lineWidth=Math.max(Math.min(zoom,16),4),linesContext.strokeStyle="#FFFFFF";for(var a=0;a<hovered.length;a++){var b=hovered[a].element;0!=b.getBoundingClientRect().left&&(linesContext.beginPath(),linesContext.moveTo(b.getBoundingClientRect().left+document.documentElement.scrollLeft+b.clientWidth/2,b.getBoundingClientRect().top+document.documentElement.scrollTop+20),linesContext.lineTo(~~(hovered[a].center[0]*zoom)+innerContainer.offsetLeft,~~(hovered[a].center[1]*zoom)+innerContainer.offsetTop),linesContext.stroke())}}function initView(){function s(a){var b=document.createElement("div");b.className="object";var c='<h2><a href="?id='+a.id+'">'+a.name+"</a></h2>";return a.description&&(c+="<p>"+a.description+"</p>"),a.website&&(c+='<a target="_blank" href='+a.website+">Website</a>"),a.subreddit&&("r/"==a.subreddit.substring(0,2)?a.subreddit="/"+a.subreddit:"/"!=a.subreddit.substring(0,1)&&(a.subreddit="/r/"+a.subreddit),c+='<a target="_blank" href=https://reddit.com'+a.subreddit+">"+a.subreddit+"</a>"),b.innerHTML+=c,b}function t(){var a=document.getElementById("objectsList"),b=0,d=window.location.search;d&&(b=d.split("id=")[1])&&(b=parseInt(b.split("&")[0]));var e=atlas.filter(function(a){return a.id===b});if(1===e.length){e=e[0];var f=s(e);a.innerHTML="",a.appendChild(f),zoom=4,applyView(),zoomOrigin=[innerContainer.clientWidth/2-e.center[0]*zoom,innerContainer.clientHeight/2-e.center[1]*zoom],applyView(),hovered=[e],x(),hovered[0].element=f,c.className="",updateLines(),q=!0}}function u(a){if(!dragging&&!q){var d=[(a.clientX-(container.clientWidth/2-innerContainer.clientWidth/2+zoomOrigin[0]+container.offsetLeft))/zoom,(a.clientY-(container.clientHeight/2-innerContainer.clientHeight/2+zoomOrigin[1]+container.offsetTop))/zoom];if(d[0]<=1100&&d[0]>=-100&&d[0]<=1100&&d[0]>=-100){for(var e=[],f=0;f<atlas.length;f++)pointIsInPolygon(d,atlas[f].path)&&e.push(atlas[f]);var g=!1;if(hovered.length==e.length){for(var f=0;f<hovered.length;f++)if(hovered[f].id!=e[f].id){g=!0;break}}else g=!0;if(g){hovered=e,b.innerHTML="";for(var f in hovered){var h=s(hovered[f]);b.appendChild(h),hovered[f].element=h}hovered.length>0?c.className="":c.className="hidden",x()}}}}function v(a){e.clearRect(0,0,canvas.width,canvas.height),e.fillStyle="rgba(0, 0, 0, 0.6)",e.fillRect(0,0,canvas.width,canvas.height);for(var b=0;b<a.length;b++){var c=a[b].path;e.beginPath(),c[0]&&e.moveTo(c[0][0],c[0][1]);for(var d=1;d<c.length;d++)e.lineTo(c[d][0],c[d][1]);e.closePath(),e.strokeStyle="rgba(255, 255, 255, 0.8)",e.stroke()}}function w(a,c){g.contains(l)&&g.removeChild(l);var d;a?(d=atlas.filter(function(b){return-1!==b.name.toLowerCase().indexOf(a)||-1!==b.description.toLowerCase().indexOf(a)}),document.getElementById("atlasSize").innerHTML="Found "+d.length+" entries."):(d=atlas.concat(),document.getElementById("atlasSize").innerHTML="The Atlas contains "+d.length+" entries."),null===c&&(c=m),v(d),x(),document.getElementById("sort").value=c;var e;switch(c){case"alphaAsc":e=function(a,b){return a.name.toLowerCase().localeCompare(b.name.toLowerCase())};break;case"alphaDesc":e=function(a,b){return b.name.toLowerCase().localeCompare(a.name.toLowerCase())};break;case"newest":e=function(a,b){return a.id>b.id?-1:a.id<b.id?1:0};break;case"oldest":e=function(a,b){return a.id<b.id?-1:a.id>b.id?1:0};break;case"relevant":e=function(b,c){return-1!==b.name.toLowerCase().indexOf(a)&&-1!==c.name.to