mirror of
https://github.com/placeAtlas/atlas.git
synced 2024-06-09 06:49:49 +02:00
Sort results alphabetically if they're of the same relevance
This commit is contained in:
parent
c77e176f19
commit
dd92df8ae6
75
combined.js
75
combined.js
|
@ -422,7 +422,7 @@ var atlas = [
|
|||
"name": "Lego",
|
||||
"description": "Lego is a line of plastic construction toys made in Denmark.",
|
||||
"website": "https://www.lego.com/",
|
||||
"subreddit": "/r/lego",
|
||||
"subreddit": "/r/lego, /r/denmark",
|
||||
"center": [
|
||||
725.5,
|
||||
287.5
|
||||
|
@ -22642,7 +22642,7 @@ var atlas = [
|
|||
815.5
|
||||
]
|
||||
]
|
||||
}, {
|
||||
}, /* {
|
||||
"id": 351,
|
||||
"name": "Erase The Place",
|
||||
"description": "The cult of nihilists who wished to return the place to a primordial state of nothingness. Because destruction and conservatism are apparently the same thing.",
|
||||
|
@ -22690,7 +22690,7 @@ var atlas = [
|
|||
403.5
|
||||
]
|
||||
]
|
||||
}, {
|
||||
}, */ {
|
||||
"id": 352,
|
||||
"name": "Jollibee",
|
||||
"description": "Jollibee is a popular fast food chain in the Philippines that serves Burger, Spaghetti, and Fried Chicken. Its mascot is a smiling red bee wearing a red suit and a chef's hat.",
|
||||
|
@ -77458,8 +77458,8 @@ var atlas = [
|
|||
}, {
|
||||
"id": 1297,
|
||||
"submitted_by": "Empty_Engie",
|
||||
"name": "The Purity Triangle",
|
||||
"description": "Made by r/EraseThePlace, this triangle represents what was once the grand white circle, and formed when EraseThePlace started making alliances and wasn't focused on cleaning the entire canvas.",
|
||||
"name": "Erase The Place",
|
||||
"description": "The Purity Triangle represents what was once the grand white circle, and formed when EraseThePlace started making alliances and wasn't focused on cleaning the entire canvas.",
|
||||
"website": "",
|
||||
"subreddit": "r/EraseThePlace",
|
||||
"center": [
|
||||
|
@ -85694,7 +85694,7 @@ function updateLines(){
|
|||
}
|
||||
|
||||
function initView(){
|
||||
|
||||
|
||||
var wrapper = document.getElementById("wrapper");
|
||||
|
||||
var objectsContainer = document.getElementById("objectsList");
|
||||
|
@ -85717,9 +85717,12 @@ function initView(){
|
|||
moreEntriesButton.innerHTML = "Show "+entriesLimit+" more";
|
||||
moreEntriesButton.id = "moreEntriesButton";
|
||||
moreEntriesButton.onclick = function(){
|
||||
buildObjectsList();
|
||||
buildObjectsList(null, null);
|
||||
};
|
||||
|
||||
var defaultSort = "alphaAsc";
|
||||
document.getElementById("sort").value = defaultSort;
|
||||
|
||||
var viewportWidth = document.documentElement.clientWidth;
|
||||
|
||||
var lastPos = [0, 0];
|
||||
|
@ -85730,7 +85733,7 @@ function initView(){
|
|||
renderBackground();
|
||||
render();
|
||||
|
||||
buildObjectsList();
|
||||
buildObjectsList(null, null);
|
||||
|
||||
// parse linked atlas entry id from link hash
|
||||
/*if (window.location.hash.substring(3)){
|
||||
|
@ -85772,7 +85775,13 @@ function initView(){
|
|||
entriesList.innerHTML = "";
|
||||
entriesList.appendChild(moreEntriesButton);
|
||||
|
||||
buildObjectsList(this.value.toLowerCase());
|
||||
if(this.value === ""){
|
||||
document.getElementById("relevantOption").disabled = true;
|
||||
buildObjectsList(null, null);
|
||||
} else {
|
||||
document.getElementById("relevantOption").disabled = false;
|
||||
buildObjectsList(this.value.toLowerCase(), "relevant");
|
||||
}
|
||||
|
||||
});
|
||||
|
||||
|
@ -85781,7 +85790,11 @@ function initView(){
|
|||
entriesList.innerHTML = "";
|
||||
entriesList.appendChild(moreEntriesButton);
|
||||
|
||||
buildObjectsList(filterInput.value.toLowerCase());
|
||||
if(this.value != "relevant"){
|
||||
defaultSort = this.value;
|
||||
}
|
||||
|
||||
buildObjectsList(filterInput.value.toLowerCase(), this.value);
|
||||
|
||||
});
|
||||
|
||||
|
@ -85963,7 +85976,7 @@ function initView(){
|
|||
}
|
||||
}
|
||||
|
||||
function buildObjectsList(filter){
|
||||
function buildObjectsList(filter, sort){
|
||||
|
||||
if(entriesList.contains(moreEntriesButton)){
|
||||
entriesList.removeChild(moreEntriesButton);
|
||||
|
@ -85973,7 +85986,10 @@ function initView(){
|
|||
|
||||
if(filter){
|
||||
sortedAtlas = atlas.filter(function(value){
|
||||
return (value.name.toLowerCase().indexOf(filter) !== -1);
|
||||
return (
|
||||
value.name.toLowerCase().indexOf(filter) !== -1
|
||||
|| value.description.toLowerCase().indexOf(filter) !== -1
|
||||
);
|
||||
});
|
||||
document.getElementById("atlasSize").innerHTML = "Found "+sortedAtlas.length+" entries.";
|
||||
} else {
|
||||
|
@ -85981,7 +85997,13 @@ function initView(){
|
|||
document.getElementById("atlasSize").innerHTML = "The Atlas contains "+sortedAtlas.length+" entries.";
|
||||
}
|
||||
|
||||
var sort = document.getElementById("sort").value;
|
||||
if(sort === null){
|
||||
sort = defaultSort;
|
||||
}
|
||||
|
||||
document.getElementById("sort").value = sort;
|
||||
|
||||
//console.log(sort);
|
||||
|
||||
var sortFunction;
|
||||
|
||||
|
@ -86022,6 +86044,33 @@ function initView(){
|
|||
return 0;
|
||||
}
|
||||
break;
|
||||
case "relevant":
|
||||
sortFunction = function(a, b){
|
||||
if(a.name.toLowerCase().indexOf(filter) !== -1 && b.name.toLowerCase().indexOf(filter) !== -1){
|
||||
if (a.name.toLowerCase().indexOf(filter) < b.name.toLowerCase().indexOf(filter)) {
|
||||
return -1;
|
||||
}
|
||||
else if (a.name.toLowerCase().indexOf(filter) > b.name.toLowerCase().indexOf(filter)) {
|
||||
return 1;
|
||||
} else {
|
||||
return a.name.toLowerCase().localeCompare(b.name.toLowerCase());
|
||||
}
|
||||
} else if(a.name.toLowerCase().indexOf(filter) !== -1){
|
||||
return -1;
|
||||
} else if(b.name.toLowerCase().indexOf(filter) !== -1){
|
||||
return 1;
|
||||
} else {
|
||||
if (a.description.toLowerCase().indexOf(filter) < b.description.toLowerCase().indexOf(filter)) {
|
||||
return -1;
|
||||
}
|
||||
else if (a.description.toLowerCase().indexOf(filter) > b.description.toLowerCase().indexOf(filter)) {
|
||||
return 1;
|
||||
} else {
|
||||
return a.name.toLowerCase().localeCompare(b.name.toLowerCase());
|
||||
}
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
sortedAtlas.sort(sortFunction);
|
||||
|
|
File diff suppressed because one or more lines are too long
|
@ -103,7 +103,7 @@ function initView(){
|
|||
buildObjectsList(null, null);
|
||||
};
|
||||
|
||||
var defaultSort = "alphaDesc";
|
||||
var defaultSort = "alphaAsc";
|
||||
document.getElementById("sort").value = defaultSort;
|
||||
|
||||
var viewportWidth = document.documentElement.clientWidth;
|
||||
|
@ -386,7 +386,7 @@ function initView(){
|
|||
|
||||
document.getElementById("sort").value = sort;
|
||||
|
||||
console.log(sort);
|
||||
//console.log(sort);
|
||||
|
||||
var sortFunction;
|
||||
|
||||
|
@ -436,7 +436,7 @@ function initView(){
|
|||
else if (a.name.toLowerCase().indexOf(filter) > b.name.toLowerCase().indexOf(filter)) {
|
||||
return 1;
|
||||
} else {
|
||||
return 0;
|
||||
return a.name.toLowerCase().localeCompare(b.name.toLowerCase());
|
||||
}
|
||||
} else if(a.name.toLowerCase().indexOf(filter) !== -1){
|
||||
return -1;
|
||||
|
@ -449,7 +449,7 @@ function initView(){
|
|||
else if (a.description.toLowerCase().indexOf(filter) > b.description.toLowerCase().indexOf(filter)) {
|
||||
return 1;
|
||||
} else {
|
||||
return 0;
|
||||
return a.name.toLowerCase().localeCompare(b.name.toLowerCase());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -169,19 +169,19 @@ <h2>Tux</h2>
|
|||
|
||||
|
||||
|
||||
<!--
|
||||
<script type="text/javascript" src="./_js/pointInPolygon.js?version=1.0"></script>
|
||||
<script type="text/javascript" src="./_js/atlas.js?version=1.0.49"></script>
|
||||
<script type="text/javascript" src="./_js/view.js?version=1.0.4"></script>
|
||||
<script type="text/javascript" src="./_js/overlap.js?version=1.0.4"></script>
|
||||
<script type="text/javascript" src="./_js/draw.js?version=1.0.3"></script>
|
||||
<script type="text/javascript" src="./_js/main.js?version=1.0.3"></script>
|
||||
-->
|
||||
|
||||
|
||||
|
||||
|
||||
<!--
|
||||
<script type="text/javascript" src="./_js/minified.js?version=1.0.62"></script>
|
||||
-->
|
||||
<script type="text/javascript" src="./_js/minified.js?version=1.0.64"></script>
|
||||
|
||||
|
||||
</body>
|
||||
|
|
Loading…
Reference in a new issue