feat(webui): add item by ItemType #2704
@ -689,6 +689,7 @@ export const addItem = async (
 | 
			
		||||
    // Path-based duck typing
 | 
			
		||||
    switch (typeName.substr(1).split("/")[1]) {
 | 
			
		||||
        case "Powersuits":
 | 
			
		||||
            if (typeName.endsWith("AugmentCard")) break;
 | 
			
		||||
            switch (typeName.substr(1).split("/")[2]) {
 | 
			
		||||
                default: {
 | 
			
		||||
                    return {
 | 
			
		||||
@ -773,6 +774,10 @@ export const addItem = async (
 | 
			
		||||
                        }
 | 
			
		||||
                    }
 | 
			
		||||
                    break;
 | 
			
		||||
 | 
			
		||||
                case "Skins": {
 | 
			
		||||
                    return addSkin(inventory, typeName);
 | 
			
		||||
                }
 | 
			
		||||
            }
 | 
			
		||||
            break;
 | 
			
		||||
        }
 | 
			
		||||
@ -869,6 +874,26 @@ export const addItem = async (
 | 
			
		||||
                    break;
 | 
			
		||||
            }
 | 
			
		||||
            break;
 | 
			
		||||
        case "Weapons": {
 | 
			
		||||
            if (typeName.substr(1).split("/")[4] == "MeleeTrees") break;
 | 
			
		||||
            const productCategory = typeName.substr(1).split("/")[3];
 | 
			
		||||
            switch (productCategory) {
 | 
			
		||||
                case "Pistols":
 | 
			
		||||
                case "LongGuns":
 | 
			
		||||
                case "Melee": {
 | 
			
		||||
                    const inventoryChanges = addEquipment(inventory, productCategory, typeName);
 | 
			
		||||
                    return {
 | 
			
		||||
                        ...inventoryChanges,
 | 
			
		||||
                        ...occupySlot(
 | 
			
		||||
                            inventory,
 | 
			
		||||
                            productCategoryToInventoryBin(productCategory) ?? InventorySlot.WEAPONS,
 | 
			
		||||
                            premiumPurchase
 | 
			
		||||
                        )
 | 
			
		||||
                    };
 | 
			
		||||
                }
 | 
			
		||||
            }
 | 
			
		||||
            break;
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
    throw new Error(`unable to add item: ${typeName}`);
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
@ -92,12 +92,36 @@
 | 
			
		||||
            <div data-route="/webui/inventory" data-title="Inventory | OpenWF WebUI">
 | 
			
		||||
                <p class="mb-3" data-loc="general_inventoryUpdateNote"></p>
 | 
			
		||||
                <div class="card mb-3">
 | 
			
		||||
                    <h5 class="card-header" data-loc="inventory_addItems"></h5>
 | 
			
		||||
                    <form class="card-body input-group" onsubmit="doAcquireMiscItems();return false;">
 | 
			
		||||
                        <input class="form-control" id="miscitem-count" type="number" value="1" />
 | 
			
		||||
                        <input class="form-control w-50" id="miscitem-type" list="datalist-miscitems" />
 | 
			
		||||
                        <button class="btn btn-primary" type="submit" data-loc="general_addButton"></button>
 | 
			
		||||
                    </form>
 | 
			
		||||
                    <div class="card-header">
 | 
			
		||||
                        <ul class="nav nav-tabs card-header-tabs">
 | 
			
		||||
                            <li class="nav-item">
 | 
			
		||||
                                <button class="nav-link" id="miscItems-tab" data-bs-toggle="tab" data-bs-target="#miscItems-tab-content" data-loc="inventory_addItems"></button>
 | 
			
		||||
                            </li>
 | 
			
		||||
                            <li class="nav-item">
 | 
			
		||||
                                <button class="nav-link" id="typeName-tab" data-bs-toggle="tab" data-bs-target="#typeName-tab-content" data-loc="inventory_addItemByItemType"></button>
 | 
			
		||||
                            </li>
 | 
			
		||||
                        </ul>
 | 
			
		||||
                    </div>
 | 
			
		||||
                    <div class="card-body">
 | 
			
		||||
                        <div class="tab-content">
 | 
			
		||||
                            <div class="tab-pane" id="miscItems-tab-content">
 | 
			
		||||
                                <form class="card-body input-group" onsubmit="doAcquireMiscItems();return false;">
 | 
			
		||||
                                    <input class="form-control" id="miscitem-count" type="number" value="1" />
 | 
			
		||||
                                    <input class="form-control w-50" id="miscitem-type" list="datalist-miscitems" />
 | 
			
		||||
                                    <button class="btn btn-primary" type="submit" data-loc="general_addButton"></button>
 | 
			
		||||
                                </form>
 | 
			
		||||
                            </div>
 | 
			
		||||
                            <div class="tab-pane" id="typeName-tab-content">
 | 
			
		||||
                                <form class="card-body" onsubmit="addItemByItemType();return false;">
 | 
			
		||||
                                    <p data-loc="inventory_addItemByItemType_warning"></p>
 | 
			
		||||
                                    <div class="input-group">
 | 
			
		||||
                                        <input class="form-control" id="typeName-type" />
 | 
			
		||||
                                        <button class="btn btn-primary" type="submit" data-loc="general_addButton"></button>
 | 
			
		||||
                                    </div>
 | 
			
		||||
                                </form>
 | 
			
		||||
                            </div>
 | 
			
		||||
                        </div>
 | 
			
		||||
                    </div>
 | 
			
		||||
                </div>
 | 
			
		||||
                <div class="row g-3 mb-3">
 | 
			
		||||
                    <div class="col-md-3">
 | 
			
		||||
 | 
			
		||||
@ -649,6 +649,14 @@ function updateInventory() {
 | 
			
		||||
            ];
 | 
			
		||||
 | 
			
		||||
            // Populate inventory route
 | 
			
		||||
 | 
			
		||||
            document.getElementById("typeName-tab").classList.remove("active");
 | 
			
		||||
            document.getElementById("typeName-tab-content").classList.remove("active", "show");
 | 
			
		||||
            document.getElementById("typeName-type").value = "";
 | 
			
		||||
 | 
			
		||||
            document.getElementById("miscItems-tab").classList.add("active");
 | 
			
		||||
            document.getElementById("miscItems-tab-content").classList.add("active", "show");
 | 
			
		||||
 | 
			
		||||
            ["RegularCredits", "PremiumCredits", "FusionPoints", "PrimeTokens"].forEach(currency => {
 | 
			
		||||
                document.getElementById(currency + "-owned").textContent = loc("currency_owned")
 | 
			
		||||
                    .split("|COUNT|")
 | 
			
		||||
@ -1685,7 +1693,7 @@ function doAcquireEvolution() {
 | 
			
		||||
    setEvolutionProgress([{ ItemType: uniqueName, Rank: permanentEvolutionWeapons.has(uniqueName) ? 0 : 1 }]);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
$(document).on("input", "input[list]", function () {
 | 
			
		||||
$(document).on("input", "input", function () {
 | 
			
		||||
    $(this).removeClass("is-invalid");
 | 
			
		||||
});
 | 
			
		||||
 | 
			
		||||
@ -2008,6 +2016,35 @@ function doAcquireMiscItems() {
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
function addItemByItemType() {
 | 
			
		||||
    const ItemType = document.getElementById("typeName-type").value;
 | 
			
		||||
    // Must start with "/Lotus/", contain only A–Z letters, no "//", and not end with "/"
 | 
			
		||||
    if (!ItemType || !/^\/Lotus\/(?:[A-Za-z]+(?:\/[A-Za-z]+)*)$/.test(ItemType)) {
 | 
			
		||||
        $("#typeName-type").addClass("is-invalid").focus();
 | 
			
		||||
        return;
 | 
			
		||||
    }
 | 
			
		||||
    revalidateAuthz().then(() => {
 | 
			
		||||
        $.post({
 | 
			
		||||
            url: "/custom/addItems?" + window.authz,
 | 
			
		||||
            contentType: "application/json",
 | 
			
		||||
            data: JSON.stringify([
 | 
			
		||||
                {
 | 
			
		||||
                    ItemType,
 | 
			
		||||
                    ItemCount: 1
 | 
			
		||||
                }
 | 
			
		||||
            ])
 | 
			
		||||
        })
 | 
			
		||||
            .done(function (_, _, jqXHR) {
 | 
			
		||||
                if (jqXHR.status === 200) {
 | 
			
		||||
                    updateInventory();
 | 
			
		||||
                }
 | 
			
		||||
            })
 | 
			
		||||
            .fail(function () {
 | 
			
		||||
                $("#typeName-type").addClass("is-invalid").focus();
 | 
			
		||||
            });
 | 
			
		||||
    });
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
function doAcquireRiven() {
 | 
			
		||||
    let fingerprint;
 | 
			
		||||
    try {
 | 
			
		||||
 | 
			
		||||
@ -79,6 +79,8 @@ dict = {
 | 
			
		||||
    navbar_cheats: `Cheats`,
 | 
			
		||||
    navbar_import: `Importieren`,
 | 
			
		||||
    inventory_addItems: `Gegenstände hinzufügen`,
 | 
			
		||||
    inventory_addItemByItemType: `[UNTRANSLATED] Raw`,
 | 
			
		||||
    inventory_addItemByItemType_warning: `[UNTRANSLATED] Use this feature at your own risk. It may break your inventory, and you will need to remove items manually if something goes wrong.`,
 | 
			
		||||
    inventory_suits: `Warframes`,
 | 
			
		||||
    inventory_longGuns: `Primärwaffen`,
 | 
			
		||||
    inventory_pistols: `Sekundärwaffen`,
 | 
			
		||||
 | 
			
		||||
@ -78,6 +78,8 @@ dict = {
 | 
			
		||||
    navbar_cheats: `Cheats`,
 | 
			
		||||
    navbar_import: `Import`,
 | 
			
		||||
    inventory_addItems: `Add Items`,
 | 
			
		||||
    inventory_addItemByItemType: `Raw`,
 | 
			
		||||
    inventory_addItemByItemType_warning: `Use this feature at your own risk. It may break your inventory, and you will need to remove items manually if something goes wrong.`,
 | 
			
		||||
    inventory_suits: `Warframes`,
 | 
			
		||||
    inventory_longGuns: `Primary Weapons`,
 | 
			
		||||
    inventory_pistols: `Secondary Weapons`,
 | 
			
		||||
 | 
			
		||||
@ -79,6 +79,8 @@ dict = {
 | 
			
		||||
    navbar_cheats: `Trucos`,
 | 
			
		||||
    navbar_import: `Importar`,
 | 
			
		||||
    inventory_addItems: `Agregar objetos`,
 | 
			
		||||
    inventory_addItemByItemType: `[UNTRANSLATED] Raw`,
 | 
			
		||||
    inventory_addItemByItemType_warning: `[UNTRANSLATED] Use this feature at your own risk. It may break your inventory, and you will need to remove items manually if something goes wrong.`,
 | 
			
		||||
    inventory_suits: `Warframes`,
 | 
			
		||||
    inventory_longGuns: `Armas primarias`,
 | 
			
		||||
    inventory_pistols: `Armas secundarias`,
 | 
			
		||||
 | 
			
		||||
@ -79,6 +79,8 @@ dict = {
 | 
			
		||||
    navbar_cheats: `Cheats`,
 | 
			
		||||
    navbar_import: `Importer`,
 | 
			
		||||
    inventory_addItems: `Ajouter des items`,
 | 
			
		||||
    inventory_addItemByItemType: `[UNTRANSLATED] Raw`,
 | 
			
		||||
    inventory_addItemByItemType_warning: `[UNTRANSLATED] Use this feature at your own risk. It may break your inventory, and you will need to remove items manually if something goes wrong.`,
 | 
			
		||||
    inventory_suits: `Warframes`,
 | 
			
		||||
    inventory_longGuns: `Armes principales`,
 | 
			
		||||
    inventory_pistols: `Armes secondaires`,
 | 
			
		||||
 | 
			
		||||
@ -79,6 +79,8 @@ dict = {
 | 
			
		||||
    navbar_cheats: `Читы`,
 | 
			
		||||
    navbar_import: `Импорт`,
 | 
			
		||||
    inventory_addItems: `Добавить предметы`,
 | 
			
		||||
    inventory_addItemByItemType: `[UNTRANSLATED] Raw`,
 | 
			
		||||
    inventory_addItemByItemType_warning: `Используйте эту функцию на свой страх и риск. Она может повредить ваш инвентарь, и в случае проблем вам придётся удалять предметы вручную.`,
 | 
			
		||||
    inventory_suits: `Варфреймы`,
 | 
			
		||||
    inventory_longGuns: `Основное оружие`,
 | 
			
		||||
    inventory_pistols: `Вторичное оружие`,
 | 
			
		||||
 | 
			
		||||
@ -79,6 +79,8 @@ dict = {
 | 
			
		||||
    navbar_cheats: `Чити`,
 | 
			
		||||
    navbar_import: `Імпорт`,
 | 
			
		||||
    inventory_addItems: `Додати предмети`,
 | 
			
		||||
    inventory_addItemByItemType: `[UNTRANSLATED] Raw`,
 | 
			
		||||
    inventory_addItemByItemType_warning: `[UNTRANSLATED] Use this feature at your own risk. It may break your inventory, and you will need to remove items manually if something goes wrong.`,
 | 
			
		||||
    inventory_suits: `Ворфрейми`,
 | 
			
		||||
    inventory_longGuns: `Основна зброя`,
 | 
			
		||||
    inventory_pistols: `Допоміжна зброя`,
 | 
			
		||||
 | 
			
		||||
@ -79,6 +79,8 @@ dict = {
 | 
			
		||||
    navbar_cheats: `作弊选项`,
 | 
			
		||||
    navbar_import: `导入`,
 | 
			
		||||
    inventory_addItems: `添加物品`,
 | 
			
		||||
    inventory_addItemByItemType: `[UNTRANSLATED] Raw`,
 | 
			
		||||
    inventory_addItemByItemType_warning: `[UNTRANSLATED] Use this feature at your own risk. It may break your inventory, and you will need to remove items manually if something goes wrong.`,
 | 
			
		||||
    inventory_suits: `战甲`,
 | 
			
		||||
    inventory_longGuns: `主要武器`,
 | 
			
		||||
    inventory_pistols: `次要武器`,
 | 
			
		||||
 | 
			
		||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user