Jump to content

Bugs/Oddities in the "Games" search feature.


dernop

Recommended Posts

hi,

i noticed some odd behavior in the game search feature for some while now and thought i'd just report it.

didn't find anything about it in the forum, but i kinda guess it's already known.

Summary:

basically two things:

  • State of the search isn't recovered after navigating back.
  • Sort order and platform filter without function.
My main concern is the search state, after i use the "back" button of the browser. I often search for multi-region games, which are not really well flagged (but that's another topic) and i get a big list of games where i click on an entry, check the forum posts or w/e and then go back, because it wasn't the right one: Game list is reset to the default view and the search state is lost.

 

Reproduce:

  • Go to https://psnprofiles.com/games
  • Enter "steins;gate" in the search box.
  • Click on the first entry
  • When the game's page has been loaded, use the back button of your browser.
  • Expected result: The result list for "steins;gate" is shown again.
  • Actual result: The default game list is shown.
Suggested fix:

 

Well, chrome at least puts the search string in the box again, but to make it generally available, you could add a window.location.hash (or better HTML5 history feature, but i don't know what kind of browser compatibility you try to achieve?) and reevaluate the query on load:

 

Modify the the search trigger, to save the query as hashbang:

    $('#searchGames').keyup(function() {
[...]
	var q = encodeURIComponent(input.val()) // get the query
	$.ajax({
		url: "/php/liveSearch.php?t=g&q=" + q,
		success: function(html){
			window.location.hash = '#!' + q // save query as hashbang
			$('#game_list').html(html);
			$('#loading').hide();
			$('#closeButton').show();
		}
[...]
    });    
Add a DOM load handler to reevaluate the hashbang:

$(function()  {
    var query = decodeURIComponent(window.location.hash.replace('#!',''));
    if(query.length>0)
    {
        $('#searchGames').val(query).keyup(); // put query in searchbox and call keyup event
    }
});
that's just a quick and dirty fix and i didn't test it thoroughly, but it should do the trick.

 

and for anyone who also wants a quick fix and uses userscripts / greasemonkey:

// ==UserScript==
// @name         PSNProfiles Game Search Fix
// @namespace    https://psnprofiles.com
// @version      0.1
// @description  Improves the search function of the game search feature.
// @author       dernop
// @match        https://psnprofiles.com/games
// @grant        none
// ==/UserScript==

$(function()  {
    $('#searchGames').off('keyup');
    $('#searchGames').keyup(function() {
        window.clearTimeout('searchInt');
        var input = $(this);

        if (input.val().length > 1)
        {
            $('#loading').show();
            $('#closeButton').hide();

            var searchInt = window.setTimeout(
                function() {

                    $('#pagination').hide();
                    var q = encodeURIComponent(input.val());
                    $.ajax({
                        url: "/php/liveSearch.php?t=g&q=" + q,
                        success: function(html){
                            window.location.hash = '#!' + q
                            $('#game_list').html(html);
                            $('#loading').hide();
                            $('#closeButton').show();
                        }
                    });
                }, 500);
        }
        else
        {
            $('#loading').hide();
        }

    });    
    var query = decodeURIComponent(window.location.hash.replace('#!',''));
    
    if(query.length>0)
    {
        $('#searchGames').val(query).keyup();
    }
});

the sort order and filtering isn't fixed with this, but this should be done in the liveSearch.php script on the server-side :)

thanks for reading,

dernop

Edited by dernop
  • Like 1
Link to comment
Share on other sites

I usually just delete last letter and the search is refreshed, but yea, I agree that one would usually expect the search result to stay.

this is a minor bug, absolutely. but if it happens often, it can get annoying. plus it's always good to improve UX, no matter how small the issue ;)

edit: replacing the last latter is definitely a good workaround, but firefox for example doesn't even keep the query in the search box. only chrome does that for me. so on ff you'd have to reenter the whole search term :(

Edited by dernop
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...