feat(webui): add list of owned warframes & weapons with "Make Rank 30" option (#170)
This commit is contained in:
parent
676c3b1616
commit
70c9a5013d
@ -18,7 +18,7 @@ const loginController: RequestHandler = async (request, response) => {
|
||||
|
||||
const account = await Account.findOne({ email: loginRequest.email }); //{ _id: 0, __v: 0 }
|
||||
|
||||
if (!account && config.autoCreateAccount) {
|
||||
if (!account && config.autoCreateAccount && loginRequest.ClientType != "webui") {
|
||||
try {
|
||||
const newAccount = await createAccount({
|
||||
email: loginRequest.email,
|
||||
|
@ -26,32 +26,38 @@
|
||||
</div>
|
||||
<div id="main-view" class="d-none">
|
||||
<p>Hello, <b class="displayname"></b>! <a href="#" onclick="logout();">Logout</a></p>
|
||||
<div class="d-flex">
|
||||
<div class="card m-1 w-50">
|
||||
<h5 class="card-header">Acquire Warframe</h5>
|
||||
<form class="card-body row" onsubmit="doAcquireWarframe();return false;">
|
||||
<div class="col-xxl-10">
|
||||
<div class="row">
|
||||
<div class="col-lg-6">
|
||||
<div class="card mb-3">
|
||||
<h5 class="card-header">Warframes</h5>
|
||||
<div class="card-body">
|
||||
<table class="table table-striped w-100">
|
||||
<tbody id="warframe-list"></tbody>
|
||||
</table>
|
||||
<form class="input-group" onsubmit="doAcquireWarframe();return false;">
|
||||
<button class="btn btn-primary" type="submit">Add</button>
|
||||
<input class="form-control" id="warframe-to-acquire" list="datalist-warframes" />
|
||||
</div>
|
||||
<div class="col-xxl-2">
|
||||
<button class="btn btn-primary" type="submit">Acquire</button>
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
<div class="card m-1 w-50">
|
||||
<h5 class="card-header">Acquire Weapon</h5>
|
||||
<form class="card-body row" onsubmit="doAcquireWeapon();return false;">
|
||||
<div class="col-xxl-10">
|
||||
<input class="form-control" id="weapon-to-acquire" list="datalist-weapons" />
|
||||
</div>
|
||||
<div class="col-xxl-2">
|
||||
<button class="btn btn-primary" type="submit">Acquire</button>
|
||||
</div>
|
||||
<div class="col-lg-6">
|
||||
<div class="card mb-3">
|
||||
<h5 class="card-header">Weapons</h5>
|
||||
<div class="card-body">
|
||||
<table class="table table-striped w-100">
|
||||
<tbody id="weapon-list"></tbody>
|
||||
</table>
|
||||
<form class="input-group" onsubmit="doAcquireWeapon();return false;">
|
||||
<button class="btn btn-primary" type="submit">Add</button>
|
||||
<input class="form-control" id="weapon-to-acquire" list="datalist-warframes" />
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<datalist id="datalist-warframes"></datalist>
|
||||
<datalist id="datalist-weapons"></datalist>
|
||||
<script
|
||||
|
@ -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,17 +43,81 @@ if (localStorage.getItem("email") && localStorage.getItem("password")) {
|
||||
loginFromLocalStorage();
|
||||
}
|
||||
|
||||
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
|
||||
@ -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();
|
||||
});
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user