improve(webui): fix add weapon, improve handling of unknown items, maintain scroll position (#181)
Co-authored-by: Sainan <Sainan@users.noreply.github.com>
This commit is contained in:
		
							parent
							
								
									37ecf29c4d
								
							
						
					
					
						commit
						c3938169fa
					
				@ -18,7 +18,7 @@ function reduceItems(items: MinItem[]): ListedItem[] {
 | 
				
			|||||||
const getItemListsController: RequestHandler = (_req, res) => {
 | 
					const getItemListsController: RequestHandler = (_req, res) => {
 | 
				
			||||||
    res.json({
 | 
					    res.json({
 | 
				
			||||||
        warframes: reduceItems(warframes),
 | 
					        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 });
 | 
					            weaponIndex = inventory.Melee.push({ ItemType: weaponName, Configs: [], XP: 0 });
 | 
				
			||||||
            break;
 | 
					            break;
 | 
				
			||||||
        default:
 | 
					        default:
 | 
				
			||||||
            throw new Error("unknown weapon type");
 | 
					            throw new Error("unknown weapon type: " + weaponType);
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    const changedInventory = await inventory.save();
 | 
					    const changedInventory = await inventory.save();
 | 
				
			||||||
 | 
				
			|||||||
@ -26,6 +26,10 @@
 | 
				
			|||||||
            </div>
 | 
					            </div>
 | 
				
			||||||
            <div id="main-view" class="d-none">
 | 
					            <div id="main-view" class="d-none">
 | 
				
			||||||
                <p>Hello, <b class="displayname"></b>! <a href="#" onclick="logout();">Logout</a></p>
 | 
					                <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="row">
 | 
				
			||||||
                    <div class="col-lg-6">
 | 
					                    <div class="col-lg-6">
 | 
				
			||||||
                        <div class="card mb-3">
 | 
					                        <div class="card mb-3">
 | 
				
			||||||
@ -50,7 +54,7 @@
 | 
				
			|||||||
                                </table>
 | 
					                                </table>
 | 
				
			||||||
                                <form class="input-group" onsubmit="doAcquireWeapon();return false;">
 | 
					                                <form class="input-group" onsubmit="doAcquireWeapon();return false;">
 | 
				
			||||||
                                    <button class="btn btn-primary" type="submit">Add</button>
 | 
					                                    <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>
 | 
					                                </form>
 | 
				
			||||||
                            </div>
 | 
					                            </div>
 | 
				
			||||||
                        </div>
 | 
					                        </div>
 | 
				
			||||||
 | 
				
			|||||||
@ -69,7 +69,7 @@ function updateInventory() {
 | 
				
			|||||||
                const tr = document.createElement("tr");
 | 
					                const tr = document.createElement("tr");
 | 
				
			||||||
                {
 | 
					                {
 | 
				
			||||||
                    const td = document.createElement("td");
 | 
					                    const td = document.createElement("td");
 | 
				
			||||||
                    td.textContent = itemMap[item.ItemType].name;
 | 
					                    td.textContent = itemMap[item.ItemType]?.name ?? item.ItemType;
 | 
				
			||||||
                    tr.appendChild(td);
 | 
					                    tr.appendChild(td);
 | 
				
			||||||
                }
 | 
					                }
 | 
				
			||||||
                {
 | 
					                {
 | 
				
			||||||
@ -78,17 +78,22 @@ function updateInventory() {
 | 
				
			|||||||
                    if (item.XP < 1_600_000) {
 | 
					                    if (item.XP < 1_600_000) {
 | 
				
			||||||
                        const a = document.createElement("a");
 | 
					                        const a = document.createElement("a");
 | 
				
			||||||
                        a.href = "#";
 | 
					                        a.href = "#";
 | 
				
			||||||
                        a.onclick = function () {
 | 
					                        a.onclick = function (event) {
 | 
				
			||||||
 | 
					                            event.preventDefault();
 | 
				
			||||||
                            addGearExp("Suits", item.ItemId.$oid, 1_600_000 - item.XP);
 | 
					                            addGearExp("Suits", item.ItemId.$oid, 1_600_000 - item.XP);
 | 
				
			||||||
                        };
 | 
					                        };
 | 
				
			||||||
                        a.textContent = "Make Rank 30";
 | 
					                        a.textContent = "Make Rank 30";
 | 
				
			||||||
                        td.appendChild(a);
 | 
					                        td.appendChild(a);
 | 
				
			||||||
                        td.innerHTML += " · ";
 | 
					
 | 
				
			||||||
 | 
					                        const span = document.createElement("span");
 | 
				
			||||||
 | 
					                        span.innerHTML = " · ";
 | 
				
			||||||
 | 
					                        td.appendChild(span);
 | 
				
			||||||
                    }
 | 
					                    }
 | 
				
			||||||
                    {
 | 
					                    {
 | 
				
			||||||
                        const a = document.createElement("a");
 | 
					                        const a = document.createElement("a");
 | 
				
			||||||
                        a.href = "#";
 | 
					                        a.href = "#";
 | 
				
			||||||
                        a.onclick = function () {
 | 
					                        a.onclick = function (event) {
 | 
				
			||||||
 | 
					                            event.preventDefault();
 | 
				
			||||||
                            disposeOfGear("Suits", item.ItemId.$oid);
 | 
					                            disposeOfGear("Suits", item.ItemId.$oid);
 | 
				
			||||||
                        };
 | 
					                        };
 | 
				
			||||||
                        a.textContent = "Remove";
 | 
					                        a.textContent = "Remove";
 | 
				
			||||||
@ -105,7 +110,7 @@ function updateInventory() {
 | 
				
			|||||||
                    const tr = document.createElement("tr");
 | 
					                    const tr = document.createElement("tr");
 | 
				
			||||||
                    {
 | 
					                    {
 | 
				
			||||||
                        const td = document.createElement("td");
 | 
					                        const td = document.createElement("td");
 | 
				
			||||||
                        td.textContent = itemMap[item.ItemType].name;
 | 
					                        td.textContent = itemMap[item.ItemType]?.name ?? item.ItemType;
 | 
				
			||||||
                        tr.appendChild(td);
 | 
					                        tr.appendChild(td);
 | 
				
			||||||
                    }
 | 
					                    }
 | 
				
			||||||
                    {
 | 
					                    {
 | 
				
			||||||
@ -114,17 +119,22 @@ function updateInventory() {
 | 
				
			|||||||
                        if (item.XP < 800_000) {
 | 
					                        if (item.XP < 800_000) {
 | 
				
			||||||
                            const a = document.createElement("a");
 | 
					                            const a = document.createElement("a");
 | 
				
			||||||
                            a.href = "#";
 | 
					                            a.href = "#";
 | 
				
			||||||
                            a.onclick = function () {
 | 
					                            a.onclick = function (event) {
 | 
				
			||||||
 | 
					                                event.preventDefault();
 | 
				
			||||||
                                addGearExp(category, item.ItemId.$oid, 800_000 - item.XP);
 | 
					                                addGearExp(category, item.ItemId.$oid, 800_000 - item.XP);
 | 
				
			||||||
                            };
 | 
					                            };
 | 
				
			||||||
                            a.textContent = "Make Rank 30";
 | 
					                            a.textContent = "Make Rank 30";
 | 
				
			||||||
                            td.appendChild(a);
 | 
					                            td.appendChild(a);
 | 
				
			||||||
                            td.innerHTML += " · ";
 | 
					
 | 
				
			||||||
 | 
					                            const span = document.createElement("span");
 | 
				
			||||||
 | 
					                            span.innerHTML = " · ";
 | 
				
			||||||
 | 
					                            td.appendChild(span);
 | 
				
			||||||
                        }
 | 
					                        }
 | 
				
			||||||
                        {
 | 
					                        {
 | 
				
			||||||
                            const a = document.createElement("a");
 | 
					                            const a = document.createElement("a");
 | 
				
			||||||
                            a.href = "#";
 | 
					                            a.href = "#";
 | 
				
			||||||
                            a.onclick = function () {
 | 
					                            a.onclick = function (event) {
 | 
				
			||||||
 | 
					                                event.preventDefault();
 | 
				
			||||||
                                disposeOfGear(category, item.ItemId.$oid);
 | 
					                                disposeOfGear(category, item.ItemId.$oid);
 | 
				
			||||||
                            };
 | 
					                            };
 | 
				
			||||||
                            a.textContent = "Remove";
 | 
					                            a.textContent = "Remove";
 | 
				
			||||||
 | 
				
			|||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user