JavaScript Game Select

  • Hello Guest! Welcome to ConsoleCrunch, to help support our site check out the premium upgrades HERE! to get exclusive access to our hidden content.
  • Unable to load portions of the website...
    If you use an ad blocker addon, you should disable it because it interferes with several elements of the site and blocks more than just adverts.
  • Read Rules Before Posting Post Virus Scans with every program.

PliskinDev

Avid Poster
CC Dev Team
Determined Poster
Active Member
Console ID Poster
Jun 19, 2019
322
788
153
Minnesota
-----------------------------------------------



javascript.png




----------------------------------------


[hide-reply][/hide-reply]
[hide-reply]
var NFIGDB = window.NFIGDB || {};

!function($, window, document, _undefined)
{
"use strict";

NFIGDB.GameSelect = XF.Element.newHandler({

options: {
platforms: true,
showFaves: true
},

init: function()
{
function formatGame (game) {
if (!game.id) {
return game.text;
}
var $game = $(
'<span><img src="' + game.cover + '" style="height:auto;width:40px;" /> ' + game.text + '</span>'
);
return $game;
};

var showFaves = this.options.showFaves;

this.$target.select2({
ajax: {
url: XF.canonicalizeUrl('index.php?igdb/search.json'),
delay: 750,
data: function (params) {
var query = {
term: params.term,
faves: showFaves,
_xfToken: XF.config.csrf
}
return query;
},
processResults: function (data) {
return {
results: data.results
};
},
cache: true
},
placeholder: 'Search for a game',
allowClear: true,
//templateResult: formatGame
//minimumInputLength: 1
});

if (this.$target.data('platform-picker'))
{
var rows = this.$target.data('rows')
var admin = this.$target.data('admin')
var noGroups = this.$target.data('no-groups')

this.$target.on('select2:select', function (e) {
var data = e.params.data;
var gameId = data.id;
if (gameId == 0)
{
return;
}

XF.ajax('get', XF.canonicalizeUrl('index.php?igdb/platforms'), {'game_id': gameId, 'rows': rows, 'admin': admin, 'no_groups': noGroups}, function (data) {
XF.setupHtmlInsert(data.html, function($html, container, onComplete)
{
$('.formHiderTarget').replaceWith($html);
});
})
});
}
}
});

XF.Element.register('game-select', 'NFIGDB.GameSelect');
}
(jQuery, window, document);
[/hide-reply]


-----------------------------------------

 
General chit-chat
Help Users
  • No one is chatting at the moment.
      Chat Bot: QM|T_JinX has joined the room.