Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
145 commits
Select commit Hold shift + click to select a range
9d792a3
Rename index.html to data-viewer/index.html
DespicableGoose Feb 19, 2022
df5d39b
Create index.html
DespicableGoose Feb 19, 2022
4b64897
Rename calculate.js to data-viewer/calculate.js
DespicableGoose Feb 19, 2022
2696007
Rename inventory.css to data-viewer/inventory.css
DespicableGoose Feb 19, 2022
875b1e0
Rename nbt.js to data-viewer/nbt.js
DespicableGoose Feb 19, 2022
5df0cd7
Delete items.webp
DespicableGoose Feb 19, 2022
b91c93b
Add files via upload
DespicableGoose Feb 19, 2022
e205e57
Update index.html
DespicableGoose Feb 19, 2022
9a69151
Rename data-viewer/nbt.js to profile-viewer/nbt.js
DespicableGoose Feb 19, 2022
0653bd7
Rename data-viewer/inventory.css to profile-viewer/inventory.css
DespicableGoose Feb 19, 2022
4ecc085
Rename data-viewer/index.html to profile-viewer/index.html
DespicableGoose Feb 19, 2022
504ad22
Rename data-viewer/calculate.js to profile-viewer/calculate.js
DespicableGoose Feb 19, 2022
b00f7c3
Delete items.webp
DespicableGoose Feb 19, 2022
4d50122
Add files via upload
DespicableGoose Feb 19, 2022
2019a7a
Update index.html
DespicableGoose Feb 19, 2022
6e964c5
Update index.html
DespicableGoose Feb 19, 2022
973cd05
Update index.html
DespicableGoose Feb 19, 2022
6ff291a
Update index.html
DespicableGoose Feb 19, 2022
6a1710c
Update index.html
DespicableGoose Feb 19, 2022
92db8d1
Update index.html
DespicableGoose Feb 19, 2022
1bd7a88
Update index.html
DespicableGoose Feb 19, 2022
e543d06
Update index.html
DespicableGoose Feb 19, 2022
f819ba3
Update index.html
DespicableGoose Feb 19, 2022
fc44598
Update index.html
DespicableGoose Feb 19, 2022
4e5c8b5
Rename profile-viewer/nbt.js to nbt.js
DespicableGoose Feb 19, 2022
046f3d9
Update index.html
DespicableGoose Feb 19, 2022
1d2f719
Update index.html
DespicableGoose Feb 19, 2022
b8611b1
Rename nbt.js to profile-viewer/nbt.js
DespicableGoose Feb 19, 2022
42fa51e
Update index.html
DespicableGoose Feb 19, 2022
9dfa90a
Create index.html
DespicableGoose Feb 19, 2022
ee80bf2
Create nbt.js
DespicableGoose Feb 19, 2022
34db9fc
Add files via upload
DespicableGoose Feb 19, 2022
da321c2
Create inventory.css
DespicableGoose Feb 19, 2022
0a637d7
Create calculate.js
DespicableGoose Feb 19, 2022
44498ae
Update index.html
DespicableGoose Feb 19, 2022
07a25af
Update calculate.js
DespicableGoose Feb 19, 2022
8be6de7
Update calculate.js
DespicableGoose Feb 19, 2022
4ca749b
Update index.html
DespicableGoose Feb 19, 2022
231fc8a
Update index.html
DespicableGoose Feb 19, 2022
8b922d8
Update index.html
DespicableGoose Feb 19, 2022
1f42042
Update index.html
DespicableGoose Feb 19, 2022
c8620f2
Update index.html
DespicableGoose Feb 19, 2022
9b8b801
Update index.html
DespicableGoose Feb 19, 2022
4a6426e
Update index.html
DespicableGoose Feb 19, 2022
e7eaf09
Update index.html
DespicableGoose Feb 19, 2022
10d5cb2
I put it in the wrong place :/
DespicableGoose Feb 19, 2022
0adfefc
Update index.html
DespicableGoose Feb 20, 2022
56a1320
Update calculate.js
DespicableGoose Feb 20, 2022
ee1741b
Update calculate.js
DespicableGoose Feb 20, 2022
b15f0ba
Update calculate.js
DespicableGoose Feb 20, 2022
8da5471
Update calculate.js
DespicableGoose Feb 20, 2022
55dab35
Update calculate.js
DespicableGoose Feb 20, 2022
552e199
I was pulling from the wrong API endpoint.
DespicableGoose Feb 20, 2022
8d3bcb7
Update index.html
DespicableGoose Feb 20, 2022
0064052
Update calculate.js
DespicableGoose Feb 20, 2022
81c84c1
Update index.html
DespicableGoose Feb 20, 2022
790f00d
Update index.html
DespicableGoose Feb 20, 2022
c722fc0
Adding the search function and a test
DespicableGoose Feb 20, 2022
0a2c91c
Update calculate.js
DespicableGoose Feb 20, 2022
11b7f1a
Update calculate.js
DespicableGoose Feb 20, 2022
4970328
Update calculate.js
DespicableGoose Feb 20, 2022
313999d
Update calculate.js
DespicableGoose Feb 21, 2022
5fb66b1
Update calculate.js
DespicableGoose Feb 21, 2022
cd09331
Update calculate.js
DespicableGoose Feb 21, 2022
71ccaa2
Update calculate.js
DespicableGoose Feb 22, 2022
b366931
Update calculate.js
DespicableGoose Feb 22, 2022
bcb5ca2
Update calculate.js
DespicableGoose Feb 22, 2022
031b44a
Update calculate.js
DespicableGoose Mar 19, 2022
02ee827
Update calculate.js
DespicableGoose Mar 19, 2022
6ae1472
Update calculate.js
DespicableGoose Mar 19, 2022
f44f808
Update calculate.js
DespicableGoose Mar 19, 2022
9351bd4
Update calculate.js
DespicableGoose Mar 19, 2022
592f3bc
Update calculate.js
DespicableGoose Mar 19, 2022
98f07ef
Update index.html
DespicableGoose Mar 19, 2022
e31d8b9
Update index.html
DespicableGoose Mar 19, 2022
cdb387c
Update index.html
DespicableGoose Mar 19, 2022
b9862e1
Update index.html
DespicableGoose Mar 19, 2022
2404b6f
Update index.html
DespicableGoose Mar 19, 2022
b457d8b
Update index.html
DespicableGoose Mar 19, 2022
f27edb5
Trying to make settings and search bar line up.
DespicableGoose Mar 19, 2022
1a1c643
It puts search and settings on the same row.
DespicableGoose Mar 19, 2022
f96181a
Update index.html
DespicableGoose Mar 19, 2022
6bfb5bb
Update index.html
DespicableGoose Mar 19, 2022
00e50ee
Update index.html
DespicableGoose Mar 19, 2022
6338ab2
Update index.html
DespicableGoose Mar 19, 2022
6c81acc
Update index.html
DespicableGoose Mar 20, 2022
0e29b34
Update index.html
DespicableGoose Mar 20, 2022
6800a95
Update index.html
DespicableGoose Mar 30, 2022
7e7e966
Text will be added through JS later.
DespicableGoose Mar 30, 2022
b5dfe15
Update index.html
DespicableGoose Mar 30, 2022
27db05f
Update index.html
DespicableGoose Mar 30, 2022
2a227c6
Update index.html
DespicableGoose Mar 30, 2022
791681c
Update calculate.js
DespicableGoose Mar 30, 2022
25190b1
Update index.html
DespicableGoose Mar 30, 2022
340f011
Update index.html
DespicableGoose Mar 30, 2022
106167b
Update index.html
DespicableGoose Mar 30, 2022
ab6cf3e
Update calculate.js
DespicableGoose Mar 30, 2022
a02cd43
Update calculate.js
DespicableGoose Mar 30, 2022
608300b
Update calculate.js
DespicableGoose Mar 30, 2022
36835cc
Update index.html
DespicableGoose Mar 30, 2022
94a5330
Update calculate.js
DespicableGoose Mar 30, 2022
9f6085e
Debugging because I seem to have messed up.
DespicableGoose Mar 30, 2022
b8dffbb
I'm dumb :/
DespicableGoose Mar 30, 2022
fe98742
Update calculate.js
DespicableGoose Mar 30, 2022
e903e45
Why must JS be annoying?
DespicableGoose Mar 30, 2022
5fb34df
Update calculate.js
DespicableGoose Mar 30, 2022
5322d87
Update calculate.js
DespicableGoose Mar 30, 2022
f0151ac
I keep forgetting quotation marks.
DespicableGoose Mar 30, 2022
57e2b57
That actually works surprisingly.
DespicableGoose Mar 30, 2022
130b7b8
Update calculate.js
DespicableGoose Mar 30, 2022
863e7db
Update calculate.js
DespicableGoose Mar 30, 2022
11b555c
Update calculate.js
DespicableGoose Mar 30, 2022
f9fe700
Update calculate.js
DespicableGoose Mar 30, 2022
6d027b6
Update calculate.js
DespicableGoose Mar 30, 2022
936839e
It's so painful...
DespicableGoose Mar 30, 2022
584e5ec
Update calculate.js
DespicableGoose Mar 30, 2022
43a4aba
Update calculate.js
DespicableGoose Mar 30, 2022
6f13d28
Fixing case sensitivity
DespicableGoose Mar 30, 2022
1a82d96
Update index.html
DespicableGoose Mar 30, 2022
4e92043
Update calculate.js
DespicableGoose Mar 30, 2022
7a5ff10
Update calculate.js
DespicableGoose Mar 30, 2022
b2bb306
Update calculate.js
DespicableGoose Mar 30, 2022
2b6e448
This works as intended.
DespicableGoose Mar 30, 2022
c00f7ee
Created slots, next step is to fill them.
DespicableGoose Mar 30, 2022
519efc9
Update calculate.js
DespicableGoose Mar 30, 2022
f4d1e44
Update calculate.js
DespicableGoose Mar 30, 2022
391aa85
Update calculate.js
DespicableGoose Mar 30, 2022
a239b48
Update calculate.js
DespicableGoose Mar 30, 2022
d099a68
Update index.html
DespicableGoose Mar 30, 2022
a65ad9f
Update calculate.js
DespicableGoose Mar 30, 2022
e9dfebc
Replacing spaces with tabs
DespicableGoose Mar 30, 2022
13a78c4
Update calculate.js
DespicableGoose Mar 30, 2022
2467ede
Putting in slot drawing code.
DespicableGoose Mar 30, 2022
1f4838b
Fixing indentation and other stuff.
DespicableGoose Mar 30, 2022
4619e71
Update calculate.js
DespicableGoose Mar 30, 2022
f9e08cb
Update calculate.js
DespicableGoose Mar 31, 2022
edeacda
Update calculate.js
DespicableGoose Mar 31, 2022
2bc364d
Update calculate.js
DespicableGoose Mar 31, 2022
17430b4
I have no reason to believe this will fix it.
DespicableGoose Mar 31, 2022
814e1f1
Please just work
DespicableGoose Mar 31, 2022
370dc92
Update calculate.js
DespicableGoose Mar 31, 2022
27c1cd1
Update calculate.js
DespicableGoose Mar 31, 2022
df064f8
Update calculate.js
DespicableGoose Mar 31, 2022
e0beab3
Allowing to see more items.
DespicableGoose Mar 31, 2022
14b7c82
Update calculate.js
DespicableGoose Mar 31, 2022
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
275 changes: 275 additions & 0 deletions auctions-viewer/calculate.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,275 @@
/*
Note to future Shaman:
Auctions do not need API keys, unless you are searching for auctions by a specific player.
Implement both, but prioritize the normal one rather than the player auctions search. Make sure both fit on the page and make sense.
Put the first in auctions-viewer, put the second in player-auctions-viewer.
*/

function loadOne() {
document.getElementById("loadone").innerHTML = "Reload One";
document.getElementById("loadall").innerHTML = "Load All";
getAuctions(0);
}

function loadAll() {
document.getElementById("loadone").innerHTML = "Load One";
document.getElementById("loadall").innerHTML = "Reload All";
getAuctions(1);
}

async function getAuctions(type) {
window.SB_Item_List = [];
window.SB_Item_List.push(await getPage(0));
if (type == 1) {
let pages = window.SB_Item_List[0]['totalPages']
for (let i = 1; i < pages; i++) {
window.SB_Item_List.push(await getPage(i));
}
}
}

async function getPage(page) {
let auctionsURL = new URL('https://api.hypixel.net/skyblock/auctions')
auctionsURL.searchParams.set('page', page);
const auctionPageData = await fetch(auctionsURL);
const auctionPageJSON = await auctionPageData.json();
console.log(auctionPageJSON);
return auctionPageJSON;
}

function settings(setting) {
const id = "option" + setting.toString();
window.search_settings[setting-1] = !window.search_settings[setting-1];
if (window.search_settings[setting-1] == false) {
document.getElementById(id).innerHTML = "Off"
} else {
document.getElementById(id).innerHTML = "On"
}
}

function search() {
if (!window.SB_Item_List) {
window.SB_Item_List = [];
}
window.search_input = document.getElementById("search_bar").value;
if (window.search_input != '') {
console.log(window.search_input);
const settings = JSON.stringify(window.search_settings);
let search_results = [];
if (settings == JSON.stringify([true, true, true])) {
console.log("Search 1");
} else if (settings == JSON.stringify([true, true, false])) {
console.log("Search 2");
search_results = window.SB_Item_List.map(search_map_title_lore);
} else if (settings == JSON.stringify([true, false, true])) {
console.log("Search 3");
} else if (settings == JSON.stringify([true, false, false])) {
console.log("Search 4");
} else if (settings == JSON.stringify([false, true, true])) {
console.log("Search 5");
} else if (settings == JSON.stringify([false, true, false])) {
console.log("Search 6");
} else {
console.log("Search not possible.");
}
console.log(search_results);
display_results(search_results);
} else {
document.getElementById('main').innerHTML = '';
}
}

function search_map_title_lore(element, index) {
const includes = [];
const auctions = element["auctions"];
const regex = new RegExp(window.search_input, 'i');
for (let a=0; a<auctions.length; a++) {
const auction = auctions[a];
const text = (auction["item_lore"] + auction["item_name"]).replaceAll(/§([a-z]|[0-9])/g, '');
if (text.search(regex) != -1) {
includes.push([index,a]);
}
}
return includes;
}

function display_results(results) {
if (results.length != 0) {
document.getElementById('main').innerHTML = '<div id="itemview"></div><div id="inventoryview"></div><div class="selection" style="width: calc(calc(9 * calc(var(--inv-size) + calc(var(--inv-size)/8))) + calc(var(--inv-size)/2))"><button id="previous" onclick="previous()">Not Possible</button><button id="next" onclick="next()">Not Possible</button></div>';
let results_amount = 0;
let better_results = [];
for (let a = 0; a < results.length; a++) {
results_amount += results[a].length;
better_results = better_results.concat(results[a]);
}
console.log(better_results);
window.index = 0;
window.items = []
for (let i = 0; i < better_results.length; i++) {
window.items.push(window.SB_Item_List[better_results[i][0]]['auctions'][better_results[i][1]]);
}
if (window.items.length > 54) {
document.getElementById('next').innerHTML = 'Next';
}
draw_inventory();
}
}

function draw_inventory() {
let results_amount= window.items.length;
if (results_amount % 9 != 0) {
results_amount += (9 - (results_amount % 9));
}
document.getElementById('inventoryview').innerHTML = '';
for (let i = 0; i < Math.min((results_amount - window.index), 54); i++) {
document.getElementById('inventoryview').innerHTML = document.getElementById('inventoryview').innerHTML + '<div class="inventoryslot"></div>';
}
for (let i = window.index; i < Math.min((window.items.length - window.index), 54 + window.index); i++) {
let command = "write_slot(" + JSON.stringify(convertNbtToJson(window.items[i]['item_bytes'])[0]) + ")";
document.getElementsByClassName("inventoryslot")[i].setAttribute("onmouseover", command);
document.getElementsByClassName("inventoryslot")[i].setAttribute("onmouseout", "document.getElementById('itemview').innerHTML = '';");
document.getElementsByClassName("inventoryslot")[i].innerHTML = draw_slot(convertNbtToJson(window.items[i]['item_bytes'])[0]);
}
}


function write_slot(slot) {
if (slot.tag) {
let display = "";
let line = "";
let stylecodes = {
"§0": "color: #000000",
"§1": "color: #0000aa",
"§2": "color: #00aa00",
"§3": "color: #00aaaa",
"§4": "color: #aa0000",
"§5": "color: #aa00aa",
"§6": "color: #ffaa00",
"§7": "color: #aaaaaa",
"§8": "color: #555555",
"§9": "color: #5555ff",
"§a": "color: #55ff55",
"§b": "color: #55ffff",
"§c": "color: #ff5555",
"§d": "color: #ff55ff",
"§e": "color: #ffff55",
"§f": "color: #ffffff",
"§l": "font-weight:bold"
}
display = display + format_line(slot.tag.display.Name, stylecodes);
display = display + format_line("", stylecodes);
for (let i = 0; i < slot.tag.display.Lore.length; i++) {
display = display + format_line(slot.tag.display.Lore[i], stylecodes);
}
document.getElementById("itemview").innerHTML = display;
}
}

function format_line(line, stylecodes) {
let display_line = "<span class=\"loreline\">";
let where = line.search("§");
let style;
let styles = {};
let close = false;
let lineadd = false;
let y;
while (where != -1) {
y = 1;
styles = {};
while (stylecodes[line.slice(where+(2*(y-1)), where+(2*y))] != undefined) {
if (!(line.slice(where+(2*(y-1)), where+(2*y)) in styles)) {
let newstyle = line.slice(where+(2*(y-1)), where+(2*y))
styles[newstyle] = 1;
}
y = y + 1;
}

if (close == true) {
display_line = display_line + line.slice(0, where) + "</span>";
} else {
close = true;
}

let styles_string = "";
for (const property in styles) {
styles_string = styles_string + stylecodes[`${property}`] + "; ";
}
if (styles_string != "") {
display_line = display_line + "<span style=\"" + styles_string + "\">"
} else {
display_line = display_line + "<span>"
}

line = line.slice(where + (2*(y-1)));
where = line.search("§");
lineadd = true;
}
if (lineadd == true) {
display_line = display_line + line + "</span>";
}
display_line = display_line + "</span>\n";
return display_line;
}

document.documentElement.addEventListener("mousemove", e => {
document.documentElement.style.setProperty('--mouse-x', e.clientX + "px");
document.documentElement.style.setProperty('--mouse-y', e.clientY + "px");
});

function draw_slot(slot) {
if (slot.id) {
let text = "<div class=\"item-icon icon-" + slot.id + "_0";
text = text + "\"></div>";
if (slot.Count != 1) {
text = text + "<div class=\"item-count\">" + slot.Count + "</div>";
}
return text;
} else {
return "";
}
}

function convertNbtToJson(t) {
let data;
try {
const n=Uint8Array.from(atob(t),t=>t.charCodeAt(0)),a=new Zlib.Gunzip(n).decompress();
nbt.parse(a,function(t,n){if(t)throw t;data=n})
} catch(t) {
console.log("Invalid input: couldn't parse nbt data");
}
return data;
}

function next() {
if (window.index + 54 < window.items.length) {
window.index += 54;
draw_inventory();
if (window.index > 0) {
document.getElementById('previous').innerHTML = 'Previous';
} else {
document.getElementById('previous').innerHTML = 'Not Possible';
}
if (window.index + 54 < window.items.length) {
document.getElementById('next').innerHTML = 'Next';
} else {
document.getElementById('next').innerHTML = 'Not Possible';
}
}
}

function previous() {
if (window.index > 0) {
window.index -= 54;
draw_inventory();
if (window.index > 0) {
document.getElementById('previous').innerHTML = 'Previous';
} else {
document.getElementById('previous').innerHTML = 'Not Possible';
}
if (window.index + 54 < window.items.length) {
document.getElementById('next').innerHTML = 'Next';
} else {
document.getElementById('next').innerHTML = 'Not Possible';
}
}
}
Loading