var API_KEY, REGION, SUMMONER_NAME, SUMMONER_NAME_CONCAT, REAL_SUMMONER_NAME, SUMMONER_ID, stillProcessing, time;
var baseURL1 = 'https://api.pubg.com/shards/pc-na/';
var baseURL2 = 'players?filter[playerNames]=';
var ERRORS = [];
var $resultDiv = $("#results");
var $timer = $('#timer');
var $requests = $('#requests');
function summonerLookUp() {
//reset values
startSpinner();
SUMMONER_NAME = '';
API_KEY = '';
SUMMONER_ID = '';
ERRORS = '';
//get input values
API_KEY = $("#theKey").val();
SUMMONER_NAME = $("#summonerName").val();
REGION = $("#region").val();
$resultDiv.html('');
$timer.html('1');
$requests.html('0');
time = 1;
requestCount = 0;
//no api key detected in the input
if (!API_KEY.length) {
ERRORS+='<div class="alert alert-danger">API Key is required</div>';
}
//no summoner name detected in the input
if (!SUMMONER_NAME.length) {
ERRORS+='<div class="alert alert-danger">Summoner Name is required</div>';
}
//remove whitespaces from summoner name, this is used when we get the summoner name back from our first call.
//SUMMONER_NAME_CONCAT = SUMMONER_NAME.replace(/ /g,'').toLowerCase();
//if we have errors, show them. If not, begin our request queue.
if (ERRORS.length) {
$resultDiv.html(ERRORS);
stopSpinner();
} else {
console.log('Summoner: ' + SUMMONER_NAME + ' (' + SUMMONER_NAME_CONCAT + ')');
console.log('Region: ' + REGION);
console.log('KEY: ' + API_KEY);
ajaxQueue(1);
}
}
//start our spinner and disable button - to prevent firing multiple requests
function startSpinner() {
$("#spinnerIcon").addClass("fa fa-spinner fa-spin");
$("#submitButton").addClass("disabled");
$("#submitButton").prop("disabled",true);
stillProcessing = true;
updateTimer();
}
//re-enable button
function stopSpinner() {
$("#spinnerIcon").removeClass("fa fa-spinner...
Please Whitelist JSFiddle in your content blocker.
Help keep JSFiddle free for always by one of two ways:
Whitelist JSFiddle in your content blocker (two clicks)
Go PRO and get access to additional PRO features →
Join the 4+ million users, and keep the JSFiddle dream alive.
Ad-free
All ads in the editor and listing pages are turned completely off.
Use pre-released features
You get to try and use features (like the Palette Color Generator) months before everyone else.
Fiddle collections
Sort and categorize your Fiddles into multiple collections.
Private collections and fiddles
You can make as many Private Fiddles, and Private Collections as you wish!
Console
Debug your Fiddle with a minimal built-in JavaScript console.