feat(webui): add option to rename items
This commit is contained in:
		
							parent
							
								
									389140a935
								
							
						
					
					
						commit
						f572a601c4
					
				@ -15,9 +15,13 @@ export const nameWeaponController: RequestHandler = async (req, res) => {
 | 
				
			|||||||
    const item = inventory[req.query.Category as string as TEquipmentKey].find(
 | 
					    const item = inventory[req.query.Category as string as TEquipmentKey].find(
 | 
				
			||||||
        item => item._id.toString() == (req.query.ItemId as string)
 | 
					        item => item._id.toString() == (req.query.ItemId as string)
 | 
				
			||||||
    )!;
 | 
					    )!;
 | 
				
			||||||
    item.ItemName = body.ItemName;
 | 
					    if (body.ItemName != "") {
 | 
				
			||||||
 | 
					        item.ItemName = body.ItemName;
 | 
				
			||||||
 | 
					    } else {
 | 
				
			||||||
 | 
					        item.ItemName = undefined;
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
    await inventory.save();
 | 
					    await inventory.save();
 | 
				
			||||||
    res.json({
 | 
					    res.json({
 | 
				
			||||||
        InventoryChanges: await updateCurrency(15, true, accountId)
 | 
					        InventoryChanges: await updateCurrency("webui" in req.query ? 0 : 15, true, accountId)
 | 
				
			||||||
    });
 | 
					    });
 | 
				
			||||||
};
 | 
					};
 | 
				
			||||||
 | 
				
			|||||||
@ -151,6 +151,18 @@ function updateInventory() {
 | 
				
			|||||||
                        a.innerHTML = `<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 384 512"><!--!Font Awesome Free 6.5.2 by @fontawesome - https://fontawesome.com License - https://fontawesome.com/license/free Copyright 2024 Fonticons, Inc.--><path d="M214.6 41.4c-12.5-12.5-32.8-12.5-45.3 0l-160 160c-12.5 12.5-12.5 32.8 0 45.3s32.8 12.5 45.3 0L160 141.2V448c0 17.7 14.3 32 32 32s32-14.3 32-32V141.2L329.4 246.6c12.5 12.5 32.8 12.5 45.3 0s12.5-32.8 0-45.3l-160-160z"/></svg>`;
 | 
					                        a.innerHTML = `<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 384 512"><!--!Font Awesome Free 6.5.2 by @fontawesome - https://fontawesome.com License - https://fontawesome.com/license/free Copyright 2024 Fonticons, Inc.--><path d="M214.6 41.4c-12.5-12.5-32.8-12.5-45.3 0l-160 160c-12.5 12.5-12.5 32.8 0 45.3s32.8 12.5 45.3 0L160 141.2V448c0 17.7 14.3 32 32 32s32-14.3 32-32V141.2L329.4 246.6c12.5 12.5 32.8 12.5 45.3 0s12.5-32.8 0-45.3l-160-160z"/></svg>`;
 | 
				
			||||||
                        td.appendChild(a);
 | 
					                        td.appendChild(a);
 | 
				
			||||||
                    }
 | 
					                    }
 | 
				
			||||||
 | 
					                    {
 | 
				
			||||||
 | 
					                        const a = document.createElement("a");
 | 
				
			||||||
 | 
					                        a.href = "#";
 | 
				
			||||||
 | 
					                        a.onclick = function (event) {
 | 
				
			||||||
 | 
					                            event.preventDefault();
 | 
				
			||||||
 | 
					                            const name = prompt("Enter new custom name:");
 | 
				
			||||||
 | 
					                            renameGear("Suits", item.ItemId.$oid, name);
 | 
				
			||||||
 | 
					                        };
 | 
				
			||||||
 | 
					                        a.title = "Rename";
 | 
				
			||||||
 | 
					                        a.innerHTML = `<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 448 512"><!--!Font Awesome Free 6.5.2 by @fontawesome - https://fontawesome.com License - https://fontawesome.com/license/free Copyright 2024 Fonticons, Inc.--><path d="M0 80V229.5c0 17 6.7 33.3 18.7 45.3l176 176c25 25 65.5 25 90.5 0L418.7 317.3c25-25 25-65.5 0-90.5l-176-176c-12-12-28.3-18.7-45.3-18.7H48C21.5 32 0 53.5 0 80zm112 32a32 32 0 1 1 0 64 32 32 0 1 1 0-64z"/></svg>`;
 | 
				
			||||||
 | 
					                        td.appendChild(a);
 | 
				
			||||||
 | 
					                    }
 | 
				
			||||||
                    {
 | 
					                    {
 | 
				
			||||||
                        const a = document.createElement("a");
 | 
					                        const a = document.createElement("a");
 | 
				
			||||||
                        a.href = "#";
 | 
					                        a.href = "#";
 | 
				
			||||||
@ -193,6 +205,18 @@ function updateInventory() {
 | 
				
			|||||||
                            a.innerHTML = `<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 384 512"><!--!Font Awesome Free 6.5.2 by @fontawesome - https://fontawesome.com License - https://fontawesome.com/license/free Copyright 2024 Fonticons, Inc.--><path d="M214.6 41.4c-12.5-12.5-32.8-12.5-45.3 0l-160 160c-12.5 12.5-12.5 32.8 0 45.3s32.8 12.5 45.3 0L160 141.2V448c0 17.7 14.3 32 32 32s32-14.3 32-32V141.2L329.4 246.6c12.5 12.5 32.8 12.5 45.3 0s12.5-32.8 0-45.3l-160-160z"/></svg>`;
 | 
					                            a.innerHTML = `<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 384 512"><!--!Font Awesome Free 6.5.2 by @fontawesome - https://fontawesome.com License - https://fontawesome.com/license/free Copyright 2024 Fonticons, Inc.--><path d="M214.6 41.4c-12.5-12.5-32.8-12.5-45.3 0l-160 160c-12.5 12.5-12.5 32.8 0 45.3s32.8 12.5 45.3 0L160 141.2V448c0 17.7 14.3 32 32 32s32-14.3 32-32V141.2L329.4 246.6c12.5 12.5 32.8 12.5 45.3 0s12.5-32.8 0-45.3l-160-160z"/></svg>`;
 | 
				
			||||||
                            td.appendChild(a);
 | 
					                            td.appendChild(a);
 | 
				
			||||||
                        }
 | 
					                        }
 | 
				
			||||||
 | 
					                        {
 | 
				
			||||||
 | 
					                            const a = document.createElement("a");
 | 
				
			||||||
 | 
					                            a.href = "#";
 | 
				
			||||||
 | 
					                            a.onclick = function (event) {
 | 
				
			||||||
 | 
					                                event.preventDefault();
 | 
				
			||||||
 | 
					                                const name = prompt("Enter new custom name:");
 | 
				
			||||||
 | 
					                                renameGear(category, item.ItemId.$oid, name);
 | 
				
			||||||
 | 
					                            };
 | 
				
			||||||
 | 
					                            a.title = "Rename";
 | 
				
			||||||
 | 
					                            a.innerHTML = `<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 448 512"><!--!Font Awesome Free 6.5.2 by @fontawesome - https://fontawesome.com License - https://fontawesome.com/license/free Copyright 2024 Fonticons, Inc.--><path d="M0 80V229.5c0 17 6.7 33.3 18.7 45.3l176 176c25 25 65.5 25 90.5 0L418.7 317.3c25-25 25-65.5 0-90.5l-176-176c-12-12-28.3-18.7-45.3-18.7H48C21.5 32 0 53.5 0 80zm112 32a32 32 0 1 1 0 64 32 32 0 1 1 0-64z"/></svg>`;
 | 
				
			||||||
 | 
					                            td.appendChild(a);
 | 
				
			||||||
 | 
					                        }
 | 
				
			||||||
                        {
 | 
					                        {
 | 
				
			||||||
                            const a = document.createElement("a");
 | 
					                            const a = document.createElement("a");
 | 
				
			||||||
                            a.href = "#";
 | 
					                            a.href = "#";
 | 
				
			||||||
@ -426,6 +450,20 @@ function addGearExp(category, oid, xp) {
 | 
				
			|||||||
    });
 | 
					    });
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					function renameGear(category, oid, name) {
 | 
				
			||||||
 | 
					    revalidateAuthz(() => {
 | 
				
			||||||
 | 
					        $.post({
 | 
				
			||||||
 | 
					            url: "/api/nameWeapon.php?" + window.authz + "&Category=" + category + "&ItemId=" + oid + "&webui=1",
 | 
				
			||||||
 | 
					            contentType: "text/plain",
 | 
				
			||||||
 | 
					            data: JSON.stringify({
 | 
				
			||||||
 | 
					                ItemName: name
 | 
				
			||||||
 | 
					            })
 | 
				
			||||||
 | 
					        }).done(function () {
 | 
				
			||||||
 | 
					            updateInventory();
 | 
				
			||||||
 | 
					        });
 | 
				
			||||||
 | 
					    });
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
function disposeOfGear(category, oid) {
 | 
					function disposeOfGear(category, oid) {
 | 
				
			||||||
    const data = {
 | 
					    const data = {
 | 
				
			||||||
        SellCurrency: "SC_RegularCredits",
 | 
					        SellCurrency: "SC_RegularCredits",
 | 
				
			||||||
 | 
				
			|||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user