返回提交历史
Modified
src/controllers/api/loginController.ts
+1
-1
Modified
static/webui/index.html
+25
-19
Modified
static/webui/script.js
+104
-15
XFEstudio/SpaceNinjaServer
feat(webui): add list of owned warframes & weapons with "Make Rank 30" option (#170)
70c9a501
代码差异
3 个文件
+130
-35
@@ -18,7 +18,7 @@ const loginController: RequestHandler = async (request, response) => {
18
18
19
19
const account = await Account.findOne({ email: loginRequest.email }); //{ _id: 0, __v: 0 }
20
20
21
if (!account && config.autoCreateAccount) {
21
if (!account && config.autoCreateAccount && loginRequest.ClientType != "webui") {
22
22
try {
23
23
const newAccount = await createAccount({
24
24
email: loginRequest.email,
@@ -26,28 +26,34 @@
26
26
</div>
27
27
<div id="main-view" class="d-none">
28
28
<p>Hello, <b class="displayname"></b>! <a href="#" onclick="logout();">Logout</a></p>
29
<div class="d-flex">
30
<div class="card m-1 w-50">
31
<h5 class="card-header">Acquire Warframe</h5>
32
<form class="card-body row" onsubmit="doAcquireWarframe();return false;">
33
<div class="col-xxl-10">
34
<input class="form-control" id="warframe-to-acquire" list="datalist-warframes" />
29
<div class="row">
30
<div class="col-lg-6">
31
<div class="card mb-3">
32
<h5 class="card-header">Warframes</h5>
33
<div class="card-body">
34
<table class="table table-striped w-100">
35
<tbody id="warframe-list"></tbody>
36
</table>
37
<form class="input-group" onsubmit="doAcquireWarframe();return false;">
38
<button class="btn btn-primary" type="submit">Add</button>
39
<input class="form-control" id="warframe-to-acquire" list="datalist-warframes" />
40
</form>
35
41
</div>
36
<div class="col-xxl-2">
37
<button class="btn btn-primary" type="submit">Acquire</button>
38
</div>
39
</form>
42
</div>
40
43
</div>
41
<div class="card m-1 w-50">
42
<h5 class="card-header">Acquire Weapon</h5>
43
<form class="card-body row" onsubmit="doAcquireWeapon();return false;">
44
<div class="col-xxl-10">
45
<input class="form-control" id="weapon-to-acquire" list="datalist-weapons" />
46
</div>
47
<div class="col-xxl-2">
48
<button class="btn btn-primary" type="submit">Acquire</button>
44
<div class="col-lg-6">
45
<div class="card mb-3">
46
<h5 class="card-header">Weapons</h5>
47
<div class="card-body">
48
<table class="table table-striped w-100">
49
<tbody id="weapon-list"></tbody>
50
</table>
51
<form class="input-group" onsubmit="doAcquireWeapon();return false;">
52
<button class="btn btn-primary" type="submit">Add</button>
53
<input class="form-control" id="weapon-to-acquire" list="datalist-warframes" />
54
</form>
49
55
</div>
50
</form>
56
</div>
51
57
</div>
52
58
</div>
53
59
</div>
@@ -15,7 +15,7 @@ function loginFromLocalStorage() {
15
15
s: "W0RFXVN0ZXZlIGxpa2VzIGJpZyBidXR0cw==", // signature of some kind
16
16
lang: "en",
17
17
date: 1501230947855458660, // ???
18
ClientType: "",
18
ClientType: "webui",
19
19
PS: "W0RFXVN0ZXZlIGxpa2VzIGJpZyBidXR0cw==" // anti-cheat data
20
20
})
21
21
});
@@ -24,6 +24,7 @@ function loginFromLocalStorage() {
24
24
$("#main-view").removeClass("d-none");
25
25
$(".displayname").text(data.DisplayName);
26
26
window.accountId = data.id;
27
updateInventory();
27
28
});
28
29
req.fail(() => {
29
30
logout();
@@ -42,18 +43,82 @@ if (localStorage.getItem("email") && localStorage.getItem("password")) {
42
43
loginFromLocalStorage();
43
44
}
44
45
45
const req = $.get("/custom/getItemLists");
46
req.done(data => {
47
for (const [type, items] of Object.entries(data)) {
48
items.forEach(item => {
49
const option = document.createElement("option");
50
option.setAttribute("data-key", item.uniqueName);
51
option.value = item.name;
52
document.getElementById("datalist-" + type).appendChild(option);
53
});
54
}
46
window.itemListPromise = new Promise(resolve => {
47
const req = $.get("/custom/getItemLists");
48
req.done(data => {
49
const itemMap = {};
50
for (const [type, items] of Object.entries(data)) {
51
items.forEach(item => {
52
const option = document.createElement("option");
53
option.setAttribute("data-key", item.uniqueName);
54
option.value = item.name;
55
document.getElementById("datalist-" + type).appendChild(option);
56
itemMap[item.uniqueName] = { ...item, type };
57
});
58
}
59
resolve(itemMap);
60
});
55
61
});
56
62
63
function updateInventory() {
64
const req = $.get("/api/inventory.php?accountId=" + window.accountId);
65
req.done(data => {
66
window.itemListPromise.then(itemMap => {
67
document.getElementById("warframe-list").innerHTML = "";
68
data.Suits.forEach(item => {
69
const tr = document.createElement("tr");
70
{
71
const td = document.createElement("td");
72
td.textContent = itemMap[item.ItemType].name;
73
tr.appendChild(td);
74
}
75
{
76
const td = document.createElement("td");
77
td.classList = "text-end";
78
if (item.XP < 1_600_000) {
79
const a = document.createElement("a");
80
a.href = "#";
81
a.onclick = function () {
82
addGearExp("Suits", item.ItemId.$oid, 1_600_000 - item.XP);
83
};
84
a.textContent = "Make Rank 30";
85
td.appendChild(a);
86
}
87
tr.appendChild(td);
88
}
89
document.getElementById("warframe-list").appendChild(tr);
90
});
91
92
document.getElementById("weapon-list").innerHTML = "";
93
["LongGuns", "Pistols", "Melee"].forEach(category => {
94
data[category].forEach(item => {
95
const tr = document.createElement("tr");
96
{
97
const td = document.createElement("td");
98
td.textContent = itemMap[item.ItemType].name;
99
tr.appendChild(td);
100
}
101
{
102
const td = document.createElement("td");
103
td.classList = "text-end";
104
if (item.XP < 800_000) {
105
const a = document.createElement("a");
106
a.href = "#";
107
a.onclick = function () {
108
addGearExp(category, item.ItemId.$oid, 800_000 - item.XP);
109
};
110
a.textContent = "Make Rank 30";
111
td.appendChild(a);
112
}
113
tr.appendChild(td);
114
}
115
document.getElementById("weapon-list").appendChild(tr);
116
});
117
});
118
});
119
});
120
}
121
57
122
function getKey(input) {
58
123
return document
59
124
.getElementById(input.getAttribute("list"))
@@ -64,7 +129,7 @@ function getKey(input) {
64
129
function doAcquireWarframe() {
65
130
const uniqueName = getKey(document.getElementById("warframe-to-acquire"));
66
131
if (!uniqueName) {
67
$("#warframe-to-acquire").addClass("is-invalid");
132
$("#warframe-to-acquire").addClass("is-invalid").focus();
68
133
return;
69
134
}
70
135
const req = $.post({
@@ -77,7 +142,8 @@ function doAcquireWarframe() {
77
142
})
78
143
});
79
144
req.done(() => {
80
alert("Warframe added to your inventory! Visit navigation to force an inventory update.");
145
document.getElementById("warframe-to-acquire").value = "";
146
updateInventory();
81
147
});
82
148
}
83
149
@@ -88,7 +154,7 @@ $("#warframe-to-acquire").on("input", () => {
88
154
function doAcquireWeapon() {
89
155
const uniqueName = getKey(document.getElementById("weapon-to-acquire"));
90
156
if (!uniqueName) {
91
$("#weapon-to-acquire").addClass("is-invalid");
157
$("#weapon-to-acquire").addClass("is-invalid").focus();
92
158
return;
93
159
}
94
160
const req = $.post({
@@ -101,10 +167,33 @@ function doAcquireWeapon() {
101
167
})
102
168
});
103
169
req.done(() => {
104
alert("Weapon added to your inventory! Visit navigation to force an inventory update.");
170
document.getElementById("weapon-to-acquire").value = "";
171
updateInventory();
105
172
});
106
173
}
107
174
108
175
$("#weapon-to-acquire").on("input", () => {
109
176
$("#weapon-to-acquire").removeClass("is-invalid");
110
177
});
178
179
function addGearExp(category, oid, xp) {
180
const data = {
181
Missions: {
182
Tag: "SolNode0",
183
Completes: 0
184
}
185
};
186
data[category] = [
187
{
188
ItemId: { $oid: oid },
189
XP: xp
190
}
191
];
192
$.post({
193
url: "/api/missionInventoryUpdate.php?accountId=" + window.accountId,
194
contentType: "text/plain",
195
data: JSON.stringify(data)
196
}).done(function () {
197
updateInventory();
198
});
199
}