Skip to content

Commit

Permalink
Modified
Browse files Browse the repository at this point in the history
  • Loading branch information
tposejank committed Jan 6, 2024
1 parent 94a8b95 commit a3b361e
Show file tree
Hide file tree
Showing 7 changed files with 13 additions and 6 deletions.
7 changes: 7 additions & 0 deletions js/backend.js
Original file line number Diff line number Diff line change
Expand Up @@ -121,4 +121,11 @@ function getRequestData(urlEndpoint) {
return {
url: geturllang(getApiURL(urlEndpoint), 1), data:{}
};
}

function itemFetch(params = '') {
var qMark = params == '' ? '' : '?';
return {
url: geturllang('https://fortniteapi.io/v2/items/list'+ qMark + params, 1), data:{headers:{'Authorization':atob('YTIyYjEyZGMtNzEzOTZkODUtMTM5N2UzZjktYTUwNDUxNGQ=')}}
};
}
2 changes: 1 addition & 1 deletion js/item.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ function init() {

content.innerHTML = '<h1>Loading...</h1><h3>Loading cosmetic list...</h3><img src="assets/images/loading.gif">';

let requestData = getRequestData('all-items&fields=name,id,set,images');
let requestData = itemFetch('fields=name,id,set,images');
fetch(requestData.url, requestData.data).then(data => data.json()).then(data => {
clearChildren(content);
content.innerHTML = '<h1>Loading...</h1><h3>Searching for ' + params.get('q') + '</h3><img src="assets/images/loading.gif">';
Expand Down
2 changes: 1 addition & 1 deletion js/itemshop.js
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ function constructItemShop() {
if (params.has('date')) {
let goalDate = params.get('date');
let listMatching = []
let requestData = getRequestData('all-items&fields=name,id,displayAssets,images,shopHistory,rarity,type,price');
let requestData = itemFetch('fields=name,id,displayAssets,images,shopHistory,rarity,type,price');
fetch(requestData.url, requestData.data).then(data => data.json()).then(data => {
listMatching = data.items.filter(item => item.shopHistory && item.shopHistory.includes(goalDate));

Expand Down
2 changes: 1 addition & 1 deletion js/predictions.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ function init() {

dateFirst.innerHTML = getFormatDate(new Date(times[0]));
dateSecond.innerHTML = getFormatDate(new Date(times[1]));
let requestData = getRequestData('all-items&fields=images,name,description,rarity,type,shopHistory,id');
let requestData = itemFetch('fields=images,name,description,rarity,type,shopHistory,id');
fetch(requestData.url, requestData.data).then(response => response.json()).then(response => {
if (response.items !== null) {
for (let item of response.items) {
Expand Down
2 changes: 1 addition & 1 deletion js/randomizer.js
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ let menuObjectTypes = {
}

function loadRandomPicker() {
let requestData = getRequestData('all-items&fields=images,name,type');
let requestData = itemFetch('fields=images,name,type');
fetch(requestData.url, requestData.data).then(response => response.json()).then(response => {
items = response.items;

Expand Down
2 changes: 1 addition & 1 deletion js/search.js
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ function downloadItems() {
mainFilters();

document.getElementById('objects').innerHTML = '<img src="assets/images/loading.gif">';
let requestData = getRequestData('all-items');
let requestData = itemFetch();
fetch(requestData.url, requestData.data).then(response => response.json()).then(response => {
items = response.items;
console.log(items);
Expand Down
2 changes: 1 addition & 1 deletion js/set.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ function loadSet() {
let content = document.getElementById('page-content');

content.innerHTML = '<h1>Loading...</h1><h3>Loading cosmetic list...</h3><img src="assets/images/loading.gif">';
let requestData = getRequestData('all-items&fields=name,id,set,images,displayAssets');
let requestData = itemFetch('fields=name,id,set,images,displayAssets');
fetch(requestData.url, requestData.data).then(data => data.json()).then(data => {
clearChildren(content);
content.innerHTML = '<h1>Loading...</h1><h3>Searching for ' + params.get('id') + '</h3><img src="assets/images/loading.gif">';
Expand Down

0 comments on commit a3b361e

Please sign in to comment.