2019-10-15 23:42:47 -03:00
< head >
< title > Level Search< / title >
< meta charset = "utf-8" >
2019-10-23 19:40:31 -03:00
< link href = "../css/browser.css" type = "text/css" rel = "stylesheet" >
2019-10-15 23:42:47 -03:00
< script async src = "https://www.googletagmanager.com/gtag/js?id=UA-135255146-3" > < / script > < script > window . dataLayer = window . dataLayer || [ ] ; function gtag ( ) { dataLayer . push ( arguments ) ; } gtag ( 'js' , new Date ( ) ) ; gtag ( 'config' , 'UA-135255146-3' ) ; < / script >
< link rel = "icon" href = "../assets/coin.png" >
< meta id = "meta-title" property = "og:title" content = "Level Search" >
< meta id = "meta-desc" property = "og:description" content = "Search for Geometry Dash levels, and filter by length, difficulty, song + more!" >
2019-10-24 23:27:09 -03:00
< meta id = "meta-image" name = "og:image" itemprop = "image" content = "../assets/dragscroll.js" >
2019-10-15 23:42:47 -03:00
< / head >
2019-10-22 20:54:19 -03:00
< body class = "levelBG" onbeforeunload = "saveUrl()" >
2019-10-15 23:42:47 -03:00
< div id = "everything" style = "overflow: auto;" >
< div class = "popup" id = "pageDiv" >
2019-10-21 12:40:56 -03:00
< div class = "brownbox bounce center supercenter" style = "width: 60vh; height: 34%" >
2019-10-15 23:42:47 -03:00
< h2 class = "smaller center" style = "font-size: 5.5vh; margin-top: 1%" > Jump to Page< / h2 >
< input type = "number" id = "pageSelect" placeholder = "1" > < br >
< img src = "../assets/ok.png" height = 20%; id = "pageJump" class = "gdButton center closeWindow" >
< img class = "closeWindow gdButton" src = "../assets/close.png" height = "25%" style = "position: absolute; top: -13.5%; left: -6vh" >
< div class = "supercenter" style = "left: 25%; top: 43%; height: 10%;" >
< img class = "gdButton" src = "../assets/whitearrow-left.png" height = "160%" onclick = "$('#pageSelect').val(parseInt($('#pageSelect').val() || 0) - 1); $('#pageSelect').trigger('input');" >
< / div >
< div class = "supercenter" style = "left: 75%; top: 43%; height: 10%;" >
< img class = "gdButton" src = "../assets/whitearrow-right.png" height = "160%" onclick = "$('#pageSelect').val(parseInt($('#pageSelect').val() || 0) + 1); $('#pageSelect').trigger('input');" >
< / div >
< / div >
< / div >
< div class = "popup" id = "purgeDiv" >
2019-10-21 12:40:56 -03:00
< div class = "fancybox bounce center supercenter" style = "width: 35%; height: 28%" >
2019-10-15 23:42:47 -03:00
< h2 class = "smaller center" style = "font-size: 5.5vh" > Delete All< / h2 >
< p class = "bigger center" style = "line-height: 5vh; margin-top: 1.5vh;" >
2019-10-26 00:08:54 -03:00
Delete all saved online levels?< br > < span style = "color:yellow" > Levels will be cleared from your browser.< / span >
2019-10-15 23:42:47 -03:00
< / p >
< img src = "../assets/btn-cancel.png" height = 25%; class = "gdButton center closeWindow" >
< img src = "../assets/btn-delete.png" height = 25%; id = "purgeSaved" class = "gdButton center sideSpaceB" >
< / div >
< / div >
2019-12-14 17:00:46 -03:00
< div class = "popup" id = "shuffleDiv" >
< div class = "fancybox bounce center supercenter" >
< h2 class = "smaller center" style = "font-size: 5.5vh" > Random Level< / h2 >
< p class = "bigger center" id = "levelInfo" style = "line-height: 5vh; margin-top: 1.5vh;" >
A random level cannot be picked with your current < span style = "color:yellow" > search filters!< / span >
This is because there is no way to tell how many results were found, due to the GD servers inaccurately saying there's < span style = "color:lime" > 9999< / span > .
< / p >
< img src = "../assets/ok.png" width = 20%; class = "gdButton center closeWindow" >
< / div >
< / div >
2019-10-15 23:42:47 -03:00
< div style = "position:absolute; bottom: 0%; left: 0%; width: 100%" >
2019-10-18 17:48:33 -03:00
< img class = "cornerPiece" src = "../assets/corner.png" width = 7%; >
2019-10-15 23:42:47 -03:00
< / div >
< div style = "position:absolute; bottom: 0%; right: 0%; width: 100%; text-align: right;" >
2019-10-18 17:48:33 -03:00
< img class = "cornerPiece" src = "../assets/corner.png" width = 7%; style = "transform: scaleX(-1)" >
2019-10-15 23:42:47 -03:00
< / div >
< div id = "searchBox" class = "supercenter dragscroll" >
< div style = "height: 4.5%" > < / div >
< / div >
< div class = "epicbox supercenter gs" style = "width: 120vh; height: 80%; pointer-events: none;" > < / div >
< div class = "center" style = "position:absolute; top: 8%; left: 0%; right: 0%" >
< h1 id = "header" > < / h1 >
< / div >
2019-12-14 02:36:01 -03:00
< div style = "text-align: right; position:absolute; top: 1%; right: 2%" >
< h2 class = "smaller" style = "font-size: 4.5vh" id = "pagenum" > < / h2 >
2019-10-15 23:42:47 -03:00
< / div >
< div style = "text-align: right; position:absolute; top: 7.5%; right: 2%; height: 12%;" >
2019-12-14 17:00:46 -03:00
< img src = "../assets/magnify.png" height = "60%" class = "gdButton" style = "margin-top: 5%" onclick = "$('#pageDiv').show(); $('#pageSelect').focus().select()" >
< / div >
< div id = "shuffle" style = "display: none; text-align: right; position:absolute; top: 7.5%; right: 6.5%; height: 12%;" >
< img src = "../assets/random.png" height = "60%" class = "gdButton" style = "margin-top: 5%" >
2019-10-15 23:42:47 -03:00
< / div >
< div style = "position:absolute; top: 2%; left: 1.5%; width: 10%; height: 25%; pointer-events: none" >
< img class = "gdButton yesClick" id = "backButton" src = "../assets/back.png" height = "30%" onclick = "backButton()" >
< / div >
< div id = "purge" style = "position:absolute; bottom: 1%; right: -3%; width: 10%; display:none;" >
< img class = "gdButton" src = "../assets/delete.png" width = "60%" onclick = "$('#purgeDiv').show()" >
< / div >
< div style = "position: absolute; left: 7%; top: 45%; height: 10%;" >
< img class = "gdButton" id = "pageDown" src = "../assets/arrow-left.png" height = "90%" >
< / div >
< div style = "position: absolute; right: 7%; top: 45%; height: 10%;" >
< img class = "gdButton" id = "pageUp" src = "../assets/arrow-right.png" height = "90%" >
< / div >
< div class = "supercenter" id = "loading" style = "height: 10%; top: 47%; display: none;" >
< img class = "spin noSelect" src = "../assets/loading.png" height = "105%" >
< / div >
< / div >
< / body >
2019-10-21 12:20:25 -03:00
< script type = "text/javascript" src = "https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js" > < / script >
< script async type = "text/javascript" src = "../assets/sizecheck.js" > < / script >
< script type = "text/javascript" src = "https://asvd.github.io/dragscroll/dragscroll.js" > < / script >
2019-10-15 23:42:47 -03:00
< script >
$('#pageDown').hide()
$('#pageUp').hide()
let accID;
let path = location.pathname.replace('/search/', "")
let url = new URL(window.location.href)
let gauntlet = url.searchParams.get('gauntlet')
let mappack = url.searchParams.get('mappack')
let userMode = url.searchParams.get('user')
let type = url.searchParams.get('type')
2020-11-02 01:11:37 -03:00
let list = url.searchParams.get('list')
let count = url.searchParams.get('count')
2020-11-02 02:40:33 -03:00
let header = url.searchParams.get('header')
2019-10-15 23:42:47 -03:00
let loading = false;
let gauntlets = ["Fire", "Ice", "Poison", "Shadow", "Lava", "Bonus", "Chaos", "Demon", "Time", "Crystal", "Magic", "Spike", "Monster", "Doom", "Death"]
2019-12-14 02:36:01 -03:00
let page = 0
let pages = 0
2019-12-14 17:00:46 -03:00
let results = 0
2019-12-14 02:36:01 -03:00
let legalPages = true
2019-12-14 17:01:53 -03:00
let superSearch = ['*', '*?type=mostliked', '*?type=mostdownloaded', '*?type=recent'].includes(window.location.href.split('/')[4].toLowerCase())
2019-12-14 17:00:46 -03:00
2020-11-02 01:11:37 -03:00
let searchFilters = `../api/search/${type == 'saved' ? JSON.parse(localStorage.getItem('saved') || '[]').reverse().toString() : accID || path}?page=[PAGE]${count ? "" : "& count=10"}${window.location.search.replace(/\?/g, "& ").replace("page", "nope")}`
2020-03-13 22:07:54 -03:00
if (type == "followed") {
let followed = localStorage.followed ? JSON.parse(localStorage.followed) : []
searchFilters += ("& creators=" + followed.join())
}
2019-12-14 02:36:01 -03:00
function Append(firstLoad) {
2019-10-15 23:42:47 -03:00
loading = true;
2019-12-14 02:36:01 -03:00
if (!firstLoad) $('#pagenum').text(`Page ${(page + 1)}${pages ? ` of ${pages}` : ""}`)
2019-10-15 23:42:47 -03:00
$('#searchBox').html('< div style = "height: 4.5%" > < / div > ')
$('#pageSelect').val(page + 1)
$('#loading').show()
if (page == 0) $('#pageDown').hide()
else $('#pageDown').show()
2019-12-15 21:11:35 -03:00
fetch(searchFilters.replace("[PAGE]", page)).then(res => res.json()).then(res => {
2019-12-14 02:36:01 -03:00
if (firstLoad) {
pages = res[0].pages
2019-12-14 17:00:46 -03:00
results = res[0].results
2020-11-02 02:40:33 -03:00
if (pages > 999 || pages < 1 ) {
2019-12-14 17:00:46 -03:00
pages = null
if (!superSearch) $('#shuffle').addClass('grayscale')
else $('#shuffle').css('filter', 'hue-rotate(100deg)')
}
$('#shuffle').show()
2019-12-14 02:36:01 -03:00
$('#pagenum').text(`Page 1${pages ? ` of ${pages}` : ""}`)
}
2019-10-15 23:42:47 -03:00
2020-11-02 02:40:33 -03:00
if (res == '-1' || (pages & & page >= pages) || (!pages & & res.length < 9 & & type ! = " recent " ) ) $ ( ' # pageUp ' ) . hide ( )
else $('#pageUp').show()
if (res == '-1' || res.length == 0) { $('#loading').hide(); return loading = false }
2019-10-15 23:42:47 -03:00
res.forEach((x, y) => {
let hasAuthor = (x.accountID != "0")
if (y == 0 & & (type == 5 || typeof userMode == 'string')) {
2019-11-05 20:43:04 -03:00
$('#header').text(((x.author == "-" ? "Someone" : x.author)) + (x.author.toLowerCase().endsWith('s') ? "'" : "'s") + " levels")
2019-10-15 23:42:47 -03:00
document.title = $('#header').text()
accID = x.authorID
}
$('#searchBox').append(`< div class = "searchresult" >
2020-11-02 01:11:37 -03:00
< h1 class = "lessspaced pre" > ${x.name}< / h1 >
< h2 class = "lessSpaced pre smaller inline gdButton ${hasAuthor ? " " : " green unregistered " } " > ${hasAuthor ? `< a href = "../u/${x.author}" > By ${x.author}< / a > ` : `< a href = "../search/${x.authorID}?user" > By ${x.author}< / a > `}< / h2 > < h2 class = "inline" style = "margin-left: 1.5%; transform:translateY(30%)" > ${x.copiedID == '0' ? "" : '< img class = "valign sideSpace" src = "../assets/copied.png" height = "12%" > '}${x.large ? '< img class = "valign sideSpaceD" src = "../assets/large.png" height = "12%" > ' : ''}< / h2 >
< h3 class = "lessSpaced pre ${x.customSong == 0 ? " blue " : " whatIfItWasPurple " } " style = "overflow: hidden;" > ${x.songName.replace(/[^ -~]/g, "")}< / h3 >
2019-10-15 23:42:47 -03:00
< h3 class = "lessSpaced" >
< img class = "valign" src = "../assets/time.png" height = "14%" > ${x.length}
< img class = "valign" src = "../assets/download.png" height = "14%" > ${x.downloads}
< img class = "valign" src = "../assets/${x.disliked ? 'dis' : ''}like.png" height = "14%" > ${x.likes}
${x.orbs != 0 ? `< img class = "valign" src = "../assets/orbs.png" height = "14%" > ${x.orbs}` : ""}
< / h3 >
< div class = "center" style = "position:absolute; top: ${6.5 + (y * 33.5) + (x.coins == 0 ? 2.5 : 0)}%; left: 4.4%; transform:scale(0.82); height: 10%; width: 12.5%;" >
< img class = "spaced" id = "dFace" src = "../difficulty/${x.difficultyFace}.png" height = "150%" style = "margin-bottom: 0%; ${x.epic ? 'transform:scale(1.2)' : x.featured ? 'transform:scale(1.1)' : ''}" >
< h3 > ${x.difficulty.includes('Demon') ? "Demon" : x.difficulty}< / h3 >
${x.stars != 0 ? `< h3 > ${x.stars}< img class = "valign sideSpaceB" src = "../assets/star.png" height = "35%" style = "transform:translateY(-8%)" > < / h3 > ` : ""}
< div id = "coins" style = "margin-top: 3%" >
${x.coins > 0 ? `< img src = "../assets/${x.verifiedCoins ? 'silver' : 'brown'}coin.png" height = "50%" > ` : ""}
${x.coins > 1 ? `< img src = "../assets/${x.verifiedCoins ? 'silver' : 'brown'}coin.png" height = "50%" class = "squeezeB" > ` : ""}
${x.coins > 2 ? `< img src = "../assets/${x.verifiedCoins ? 'silver' : 'brown'}coin.png" height = "50%" class = "squeezeB" > ` : ""}
< / div >
< / div >
< div class = "center" style = "position:absolute; top: ${15 + (y * 33.5)}%; right: 7%; height: 10%" >
< a href = "../${x.id}" " > < img class = "valign gdButton" src = "../assets/view.png" height = "105%" > < / a >
< / div >
< / div > `)
})
$('#searchBox').append('< div style = "height: 4.5%" > < / div > ')
$('#loading').hide()
loading = false;
})
}
2019-12-14 02:36:01 -03:00
Append(true)
2019-10-15 23:42:47 -03:00
$('#pageUp').click(function() {page += 1; if (!loading) Append()})
$('#pageDown').click(function() {page -= 1; if (!loading) Append()})
$('#pageJump').click(function() {if (loading) return; page = parseInt(($('#pageSelect').val() || 1) - 1); Append()})
2020-11-02 02:40:33 -03:00
if (header) {
header = header.slice(0, 32) || "Level Search"
$('#header').text(header)
document.title = header
}
else {
if (type == 1 || type == 'mostdownloaded') $('#header').text("Most Downloaded")
if (type == 2 || type == 'mostliked') $('#header').text("Most Liked")
if (type == 3 || type == 'trending') $('#header').text("Trending Levels")
if (type == 4 || type == 'recent') $('#header').text("Recent Levels")
if (type == 6 || type == 'featured') $('#header').text("Featured")
if (type == 7 || type == 'magic') $('#header').text("Magic Levels")
if (type == 11 || type == 'awarded' || type == 'starred') $('#header').text("Awarded Levels")
if (type == 16 || type == 'halloffame' || type == 'hof') $('#header').text("Hall of Fame")
if (path != "*" & & (type == 10 || list != null)) $('#header').text("Custom List")
if (type == 'followed') $('#header').text("Followed Creators")
document.title = $('#header').text() || "Level Search"
$('#meta-title').attr('content', $('#header').text() || "Level Search")
if ($('#header').text()) $('#meta-desc').attr('content', `View Geometry Dash's ${$('#header').text()}${$('#header').text() == "Hall of Fame" ? "" : "list"}!`)
}
2019-10-15 23:42:47 -03:00
if (type == 'saved') {
$('#header').text("Saved Levels")
$('#purge').show()
document.title = "Saved Levels"
$('#meta-title').attr('content', `Saved Levels`)
$('#meta-desc').attr('content', `View your collection of saved Geometry Dash levels!`)
}
if (gauntlet) {
$('body').addClass('darkBG')
2019-10-18 17:48:33 -03:00
$('.cornerPiece').addClass('grayscale')
2019-10-15 23:42:47 -03:00
$('#header').text((gauntlets[parseInt(gauntlet) - 1] || "Unknown") + " Gauntlet")
$('#meta-title').attr('content', (gauntlets[parseInt(gauntlet) - 1] || "Unknown") + " Gauntlet")
$('#meta-desc').attr('content', `View the 5 levels in the ${(gauntlets[parseInt(gauntlet) - 1] || "Unknown") + " Gauntlet"}!`)
}
if (!$('#header').text() & & typeof userMode != "string") $('#header').text(path == "*" ? "Online Levels" : decodeURIComponent(path))
$('.closeWindow').click(function() {$(".popup").attr('style', 'display: none;')})
$('#purgeSaved').click(function() {
2019-10-24 01:51:20 -03:00
localStorage.removeItem('saved');
2019-10-15 23:42:47 -03:00
location.reload()
})
var max = 9999
var min = 1
$('#pageSelect').on('input', function () {
var x = $(this).val();
if ($(this).val() != "") $(this).val(Math.max(Math.min(Math.floor(x), max), min));
});
$('#pageSelect').on('blur', function () {
var x = $(this).val();
if ($(this).val() != "") $(this).val(Math.max(Math.min(Math.floor(x), max), min));
});
2019-12-14 17:00:46 -03:00
$('#shuffle').click(function() {
if (superSearch) {
$('#searchBox').html('< div style = "height: 4.5%" > < / div > ')
$('#loading').show()
fetch("../api/search/*?page=0& type=recent").then(res => res.json()).then(recent => {
let mostRecent = recent[0].id
function fetchRandom() {
fetch(`../api/level/${Math.floor(Math.random() * (mostRecent)) + 1}`).then(res => res.json()).then(res => {
if (res == "-1" || !res.id) return fetchRandom()
else window.location.href = "../" + res.id
})
}
fetchRandom()
})
}
else if (pages) {
let random = {}
2020-11-02 02:40:33 -03:00
let pageCount = +count || 10
2019-12-14 17:00:46 -03:00
randomResult = Math.floor(Math.random() * (results)) + 1
2020-11-02 02:40:33 -03:00
randomPage = Math.ceil(randomResult / pageCount)
randomIndex = randomResult % pageCount
if (randomIndex == 0) randomIndex = pageCount
2019-12-14 17:00:46 -03:00
$('#searchBox').html('< div style = "height: 4.5%" > < / div > ')
$('#loading').show()
2020-01-29 14:43:41 -03:00
fetch(searchFilters.replace('[PAGE]', randomPage-1)).then(res => res.json()).then(res => {
2019-12-14 20:15:27 -03:00
window.location.href = "../" + res[randomIndex-1].id
2019-12-14 17:00:46 -03:00
})
}
else return $('#shuffleDiv').show()
})
2019-10-15 23:42:47 -03:00
$(document).keydown(function(k) {
if (loading) return;
if ($('#pageDiv').is(':visible')) {
if (k.which == 13) $('#pageJump').trigger('click') //enter
else return;
}
2020-11-01 17:29:32 -03:00
if (k.which == 37 & & $('#pageDown').is(":visible")) $('#pageDown').trigger('click') // left
if (k.which == 39 & & $('#pageUp').is(":visible")) $('#pageUp').trigger('click') // right
2019-10-15 23:42:47 -03:00
});
< / script >