-
Notifications
You must be signed in to change notification settings - Fork 16
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #11 from JakeLegendXIII/feature/showcase-filters
Add filter by tags to showcase
- Loading branch information
Showing
5 changed files
with
128 additions
and
208 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
function init_filter() { | ||
var data = window.top.location.search; | ||
var container = document.getElementById('gamesList'); | ||
var filterTag = data ? remove_questionmark(data) : null; | ||
|
||
for (var i = 0; i < games.length; i++) { | ||
if (!filterTag || games[i].tags.includes(filterTag)) { | ||
add_to_screen(games[i], container); | ||
} | ||
} | ||
} | ||
|
||
function add_to_screen(game, container) { | ||
var gameDiv = document.createElement('div'); | ||
gameDiv.id = game.name; | ||
gameDiv.className = 'showcase-link-image'; | ||
gameDiv.style.backgroundImage = "url('" + BannerPath + game.screenshot + "')"; | ||
|
||
if (game.pixelart == true) | ||
{ | ||
gameDiv.style["image-rendering"] = "pixelated"; | ||
gameDiv.style["-ms-interpolation-mode"] = "nearest-neighbor"; | ||
} | ||
else | ||
{ | ||
gameDiv.style["image-rendering"] = "auto"; | ||
gameDiv.style["-ms-interpolation-mode"] = "bicubic"; | ||
} | ||
|
||
var link = document.createElement('a'); | ||
link.href = game.url; | ||
|
||
var logoDiv = document.createElement('div'); | ||
logoDiv.style = "width:100%;height:100%;background:url('" + BannerPath + game.logo + "') center center no-repeat"; | ||
logoDiv.title = game.title; | ||
|
||
link.appendChild(logoDiv); | ||
gameDiv.appendChild(link); | ||
container.appendChild(gameDiv); | ||
} | ||
|
||
function remove_questionmark(str) { | ||
var pattern = /\?/; | ||
var result = pattern.exec(str); | ||
if (result != null) { | ||
return str.replace('?', ''); | ||
} else { | ||
return str; | ||
} | ||
} | ||
|
||
init_filter(); |
Oops, something went wrong.