setTimeout(function () {
$('').insertBefore('.trades-filter');
$('
').insertBefore('.trades-filter');
$( "#data-card-toggle" ).click(function() {
$('#data-card').toggle();
});
$( "#toggle-images" ).click(function() {
const table = $('#example').DataTable();
if (table.column(0).visible() === true) {
table.column(0).visible(false);
}
else {
table.column(0).visible(true);
}
});
}, 2000);
setTimeout(async function () {
try {
const getCookieValue = (name) => (
document.cookie.match('(^|;)\\s*' + name + '\\s*=\\s*([^;]+)')?.pop() || ''
);
const bountyIdCookie = getCookieValue('bountyId');
// data to be sent to the POST request
let _data = {
"bounty_id": bountyIdCookie
};
let dataSet = [];
await fetch('https://api2.hirezstudios.com/bounty/get-user-info-sales-2', {
method: "POST",
body: JSON.stringify(_data),
mode: 'cors',
credentials: 'same-origin',
headers: {
"content-type": "application/json"
}
})
.then(response => response.json())
.then(json => {
json.stackables.forEach( item => {
// convert to lowercase and replace spaces with underscores
let imageFileName = `${item.metadata.champion.toLowerCase()}_${item.metadata.name.toLowerCase().replaceAll(' ', '-')}`;
let imageFilePath = `https://webcdn.hirezstudios.com/web/bounty/icons/${imageFileName}.jpg`;
let newObj = [
`
`,
item.metadata.champion,
item.metadata.name,
item.price
];
dataSet.push(newObj);
});
$('#example').DataTable( {
data: dataSet,
columns: [
{ title: "Image", 'visible' : false },
{ title: "Champion" },
{ title: "Skin Name" },
{ title: "Price" }
]
} );
$('#data-card').hide();
})
.catch(err => console.log(err));
} catch (error) {
console.log(error);
}
}, 3000);