improve(webui): fix add weapon, improve handling of unknown items, maintain scroll position #181
@ -18,7 +18,7 @@ function reduceItems(items: MinItem[]): ListedItem[] {
 | 
			
		||||
const getItemListsController: RequestHandler = (_req, res) => {
 | 
			
		||||
    res.json({
 | 
			
		||||
        warframes: reduceItems(warframes),
 | 
			
		||||
        weapons: reduceItems(weapons)
 | 
			
		||||
        weapons: reduceItems(weapons.filter(item => item.productCategory != "OperatorAmps"))
 | 
			
		||||
    });
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
@ -178,7 +178,7 @@ export const addWeapon = async (
 | 
			
		||||
            weaponIndex = inventory.Melee.push({ ItemType: weaponName, Configs: [], XP: 0 });
 | 
			
		||||
            break;
 | 
			
		||||
        default:
 | 
			
		||||
            throw new Error("unknown weapon type");
 | 
			
		||||
            throw new Error("unknown weapon type: " + weaponType);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    const changedInventory = await inventory.save();
 | 
			
		||||
 | 
			
		||||
@ -26,6 +26,10 @@
 | 
			
		||||
            </div>
 | 
			
		||||
            <div id="main-view" class="d-none">
 | 
			
		||||
                <p>Hello, <b class="displayname"></b>! <a href="#" onclick="logout();">Logout</a></p>
 | 
			
		||||
                <p>
 | 
			
		||||
                    Note: Changes made here will only be reflected in-game when the game re-downloads your inventory.
 | 
			
		||||
                    Visiting the navigation should be the easiest way to trigger that.
 | 
			
		||||
                </p>
 | 
			
		||||
                <div class="row">
 | 
			
		||||
                    <div class="col-lg-6">
 | 
			
		||||
                        <div class="card mb-3">
 | 
			
		||||
@ -50,7 +54,7 @@
 | 
			
		||||
                                </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" />
 | 
			
		||||
                                    <input class="form-control" id="weapon-to-acquire" list="datalist-weapons" />
 | 
			
		||||
                                </form>
 | 
			
		||||
                            </div>
 | 
			
		||||
                        </div>
 | 
			
		||||
 | 
			
		||||
@ -69,7 +69,7 @@ function updateInventory() {
 | 
			
		||||
                const tr = document.createElement("tr");
 | 
			
		||||
                {
 | 
			
		||||
                    const td = document.createElement("td");
 | 
			
		||||
                    td.textContent = itemMap[item.ItemType].name;
 | 
			
		||||
                    td.textContent = itemMap[item.ItemType]?.name ?? item.ItemType;
 | 
			
		||||
                    tr.appendChild(td);
 | 
			
		||||
                }
 | 
			
		||||
                {
 | 
			
		||||
@ -78,17 +78,22 @@ function updateInventory() {
 | 
			
		||||
                    if (item.XP < 1_600_000) {
 | 
			
		||||
                        const a = document.createElement("a");
 | 
			
		||||
                        a.href = "#";
 | 
			
		||||
                        a.onclick = function () {
 | 
			
		||||
                        a.onclick = function (event) {
 | 
			
		||||
                            event.preventDefault();
 | 
			
		||||
                            addGearExp("Suits", item.ItemId.$oid, 1_600_000 - item.XP);
 | 
			
		||||
                        };
 | 
			
		||||
                        a.textContent = "Make Rank 30";
 | 
			
		||||
                        td.appendChild(a);
 | 
			
		||||
                        td.innerHTML += " · ";
 | 
			
		||||
 | 
			
		||||
                        const span = document.createElement("span");
 | 
			
		||||
                        span.innerHTML = " · ";
 | 
			
		||||
                        td.appendChild(span);
 | 
			
		||||
                    }
 | 
			
		||||
                    {
 | 
			
		||||
                        const a = document.createElement("a");
 | 
			
		||||
                        a.href = "#";
 | 
			
		||||
                        a.onclick = function () {
 | 
			
		||||
                        a.onclick = function (event) {
 | 
			
		||||
                            event.preventDefault();
 | 
			
		||||
                            disposeOfGear("Suits", item.ItemId.$oid);
 | 
			
		||||
                        };
 | 
			
		||||
                        a.textContent = "Remove";
 | 
			
		||||
@ -105,7 +110,7 @@ function updateInventory() {
 | 
			
		||||
                    const tr = document.createElement("tr");
 | 
			
		||||
                    {
 | 
			
		||||
                        const td = document.createElement("td");
 | 
			
		||||
                        td.textContent = itemMap[item.ItemType].name;
 | 
			
		||||
                        td.textContent = itemMap[item.ItemType]?.name ?? item.ItemType;
 | 
			
		||||
                        tr.appendChild(td);
 | 
			
		||||
                    }
 | 
			
		||||
                    {
 | 
			
		||||
@ -114,17 +119,22 @@ function updateInventory() {
 | 
			
		||||
                        if (item.XP < 800_000) {
 | 
			
		||||
                            const a = document.createElement("a");
 | 
			
		||||
                            a.href = "#";
 | 
			
		||||
                            a.onclick = function () {
 | 
			
		||||
                            a.onclick = function (event) {
 | 
			
		||||
                                event.preventDefault();
 | 
			
		||||
                                addGearExp(category, item.ItemId.$oid, 800_000 - item.XP);
 | 
			
		||||
                            };
 | 
			
		||||
                            a.textContent = "Make Rank 30";
 | 
			
		||||
                            td.appendChild(a);
 | 
			
		||||
                            td.innerHTML += " · ";
 | 
			
		||||
 | 
			
		||||
                            const span = document.createElement("span");
 | 
			
		||||
                            span.innerHTML = " · ";
 | 
			
		||||
                            td.appendChild(span);
 | 
			
		||||
                        }
 | 
			
		||||
                        {
 | 
			
		||||
                            const a = document.createElement("a");
 | 
			
		||||
                            a.href = "#";
 | 
			
		||||
                            a.onclick = function () {
 | 
			
		||||
                            a.onclick = function (event) {
 | 
			
		||||
                                event.preventDefault();
 | 
			
		||||
                                disposeOfGear(category, item.ItemId.$oid);
 | 
			
		||||
                            };
 | 
			
		||||
                            a.textContent = "Remove";
 | 
			
		||||
 | 
			
		||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user