+
-
diff --git a/static/webui/script.js b/static/webui/script.js
index 6446c62c..52ff2ce3 100644
--- a/static/webui/script.js
+++ b/static/webui/script.js
@@ -15,7 +15,7 @@ function loginFromLocalStorage() {
s: "W0RFXVN0ZXZlIGxpa2VzIGJpZyBidXR0cw==", // signature of some kind
lang: "en",
date: 1501230947855458660, // ???
- ClientType: "",
+ ClientType: "webui",
PS: "W0RFXVN0ZXZlIGxpa2VzIGJpZyBidXR0cw==" // anti-cheat data
})
});
@@ -24,6 +24,7 @@ function loginFromLocalStorage() {
$("#main-view").removeClass("d-none");
$(".displayname").text(data.DisplayName);
window.accountId = data.id;
+ updateInventory();
});
req.fail(() => {
logout();
@@ -42,18 +43,82 @@ if (localStorage.getItem("email") && localStorage.getItem("password")) {
loginFromLocalStorage();
}
-const req = $.get("/custom/getItemLists");
-req.done(data => {
- for (const [type, items] of Object.entries(data)) {
- items.forEach(item => {
- const option = document.createElement("option");
- option.setAttribute("data-key", item.uniqueName);
- option.value = item.name;
- document.getElementById("datalist-" + type).appendChild(option);
- });
- }
+window.itemListPromise = new Promise(resolve => {
+ const req = $.get("/custom/getItemLists");
+ req.done(data => {
+ const itemMap = {};
+ for (const [type, items] of Object.entries(data)) {
+ items.forEach(item => {
+ const option = document.createElement("option");
+ option.setAttribute("data-key", item.uniqueName);
+ option.value = item.name;
+ document.getElementById("datalist-" + type).appendChild(option);
+ itemMap[item.uniqueName] = { ...item, type };
+ });
+ }
+ resolve(itemMap);
+ });
});
+function updateInventory() {
+ const req = $.get("/api/inventory.php?accountId=" + window.accountId);
+ req.done(data => {
+ window.itemListPromise.then(itemMap => {
+ document.getElementById("warframe-list").innerHTML = "";
+ data.Suits.forEach(item => {
+ const tr = document.createElement("tr");
+ {
+ const td = document.createElement("td");
+ td.textContent = itemMap[item.ItemType].name;
+ tr.appendChild(td);
+ }
+ {
+ const td = document.createElement("td");
+ td.classList = "text-end";
+ if (item.XP < 1_600_000) {
+ const a = document.createElement("a");
+ a.href = "#";
+ a.onclick = function () {
+ addGearExp("Suits", item.ItemId.$oid, 1_600_000 - item.XP);
+ };
+ a.textContent = "Make Rank 30";
+ td.appendChild(a);
+ }
+ tr.appendChild(td);
+ }
+ document.getElementById("warframe-list").appendChild(tr);
+ });
+
+ document.getElementById("weapon-list").innerHTML = "";
+ ["LongGuns", "Pistols", "Melee"].forEach(category => {
+ data[category].forEach(item => {
+ const tr = document.createElement("tr");
+ {
+ const td = document.createElement("td");
+ td.textContent = itemMap[item.ItemType].name;
+ tr.appendChild(td);
+ }
+ {
+ const td = document.createElement("td");
+ td.classList = "text-end";
+ if (item.XP < 800_000) {
+ const a = document.createElement("a");
+ a.href = "#";
+ a.onclick = function () {
+ addGearExp(category, item.ItemId.$oid, 800_000 - item.XP);
+ };
+ a.textContent = "Make Rank 30";
+ td.appendChild(a);
+ }
+ tr.appendChild(td);
+ }
+ document.getElementById("weapon-list").appendChild(tr);
+ });
+ });
+ });
+ });
+}
+
function getKey(input) {
return document
.getElementById(input.getAttribute("list"))
@@ -64,7 +129,7 @@ function getKey(input) {
function doAcquireWarframe() {
const uniqueName = getKey(document.getElementById("warframe-to-acquire"));
if (!uniqueName) {
- $("#warframe-to-acquire").addClass("is-invalid");
+ $("#warframe-to-acquire").addClass("is-invalid").focus();
return;
}
const req = $.post({
@@ -77,7 +142,8 @@ function doAcquireWarframe() {
})
});
req.done(() => {
- alert("Warframe added to your inventory! Visit navigation to force an inventory update.");
+ document.getElementById("warframe-to-acquire").value = "";
+ updateInventory();
});
}
@@ -88,7 +154,7 @@ $("#warframe-to-acquire").on("input", () => {
function doAcquireWeapon() {
const uniqueName = getKey(document.getElementById("weapon-to-acquire"));
if (!uniqueName) {
- $("#weapon-to-acquire").addClass("is-invalid");
+ $("#weapon-to-acquire").addClass("is-invalid").focus();
return;
}
const req = $.post({
@@ -101,10 +167,33 @@ function doAcquireWeapon() {
})
});
req.done(() => {
- alert("Weapon added to your inventory! Visit navigation to force an inventory update.");
+ document.getElementById("weapon-to-acquire").value = "";
+ updateInventory();
});
}
$("#weapon-to-acquire").on("input", () => {
$("#weapon-to-acquire").removeClass("is-invalid");
});
+
+function addGearExp(category, oid, xp) {
+ const data = {
+ Missions: {
+ Tag: "SolNode0",
+ Completes: 0
+ }
+ };
+ data[category] = [
+ {
+ ItemId: { $oid: oid },
+ XP: xp
+ }
+ ];
+ $.post({
+ url: "/api/missionInventoryUpdate.php?accountId=" + window.accountId,
+ contentType: "text/plain",
+ data: JSON.stringify(data)
+ }).done(function () {
+ updateInventory();
+ });
+}