feat(webui): add list of owned warframes & weapons with "Make Rank 30" option #170
@ -26,28 +26,34 @@
 | 
				
			|||||||
            </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>
 | 
				
			||||||
                <div class="d-flex">
 | 
					                <div class="row">
 | 
				
			||||||
                    <div class="card m-1 w-50">
 | 
					                    <div class="col-lg-6">
 | 
				
			||||||
                        <h5 class="card-header">Acquire Warframe</h5>
 | 
					                        <div class="card mb-3">
 | 
				
			||||||
                        <form class="card-body row" onsubmit="doAcquireWarframe();return false;">
 | 
					                            <h5 class="card-header">Warframes</h5>
 | 
				
			||||||
                            <div class="col-xxl-10">
 | 
					                            <div class="card-body">
 | 
				
			||||||
                                <input class="form-control" id="warframe-to-acquire" list="datalist-warframes" />
 | 
					                                <table class="table table-striped w-100">
 | 
				
			||||||
 | 
					                                    <tbody id="warframe-list"></tbody>
 | 
				
			||||||
 | 
					                                </table>
 | 
				
			||||||
 | 
					                                <form class="input-group" onsubmit="doAcquireWarframe();return false;">
 | 
				
			||||||
 | 
					                                    <button class="btn btn-primary" type="submit">Add</button>
 | 
				
			||||||
 | 
					                                    <input class="form-control" id="warframe-to-acquire" list="datalist-warframes" />
 | 
				
			||||||
 | 
					                                </form>
 | 
				
			||||||
                            </div>
 | 
					                            </div>
 | 
				
			||||||
                            <div class="col-xxl-2">
 | 
					                        </div>
 | 
				
			||||||
                                <button class="btn btn-primary" type="submit">Acquire</button>
 | 
					 | 
				
			||||||
                            </div>
 | 
					 | 
				
			||||||
                        </form>
 | 
					 | 
				
			||||||
                    </div>
 | 
					                    </div>
 | 
				
			||||||
                    <div class="card m-1 w-50">
 | 
					                    <div class="col-lg-6">
 | 
				
			||||||
                        <h5 class="card-header">Acquire Weapon</h5>
 | 
					                        <div class="card mb-3">
 | 
				
			||||||
                        <form class="card-body row" onsubmit="doAcquireWeapon();return false;">
 | 
					                            <h5 class="card-header">Weapons</h5>
 | 
				
			||||||
                            <div class="col-xxl-10">
 | 
					                            <div class="card-body">
 | 
				
			||||||
                                <input class="form-control" id="weapon-to-acquire" list="datalist-weapons" />
 | 
					                                <table class="table table-striped w-100">
 | 
				
			||||||
 | 
					                                    <tbody id="weapon-list"></tbody>
 | 
				
			||||||
 | 
					                                </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" />
 | 
				
			||||||
 | 
					                                </form>
 | 
				
			||||||
                            </div>
 | 
					                            </div>
 | 
				
			||||||
                            <div class="col-xxl-2">
 | 
					                        </div>
 | 
				
			||||||
                                <button class="btn btn-primary" type="submit">Acquire</button>
 | 
					 | 
				
			||||||
                            </div>
 | 
					 | 
				
			||||||
                        </form>
 | 
					 | 
				
			||||||
                    </div>
 | 
					                    </div>
 | 
				
			||||||
                </div>
 | 
					                </div>
 | 
				
			||||||
            </div>
 | 
					            </div>
 | 
				
			||||||
 | 
				
			|||||||
@ -24,6 +24,7 @@ function loginFromLocalStorage() {
 | 
				
			|||||||
        $("#main-view").removeClass("d-none");
 | 
					        $("#main-view").removeClass("d-none");
 | 
				
			||||||
        $(".displayname").text(data.DisplayName);
 | 
					        $(".displayname").text(data.DisplayName);
 | 
				
			||||||
        window.accountId = data.id;
 | 
					        window.accountId = data.id;
 | 
				
			||||||
 | 
					        updateInventory();
 | 
				
			||||||
    });
 | 
					    });
 | 
				
			||||||
    req.fail(() => {
 | 
					    req.fail(() => {
 | 
				
			||||||
        logout();
 | 
					        logout();
 | 
				
			||||||
@ -42,18 +43,82 @@ if (localStorage.getItem("email") && localStorage.getItem("password")) {
 | 
				
			|||||||
    loginFromLocalStorage();
 | 
					    loginFromLocalStorage();
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
const req = $.get("/custom/getItemLists");
 | 
					window.itemListPromise = new Promise(resolve => {
 | 
				
			||||||
req.done(data => {
 | 
					    const req = $.get("/custom/getItemLists");
 | 
				
			||||||
    for (const [type, items] of Object.entries(data)) {
 | 
					    req.done(data => {
 | 
				
			||||||
        items.forEach(item => {
 | 
					        const itemMap = {};
 | 
				
			||||||
            const option = document.createElement("option");
 | 
					        for (const [type, items] of Object.entries(data)) {
 | 
				
			||||||
            option.setAttribute("data-key", item.uniqueName);
 | 
					            items.forEach(item => {
 | 
				
			||||||
            option.value = item.name;
 | 
					                const option = document.createElement("option");
 | 
				
			||||||
            document.getElementById("datalist-" + type).appendChild(option);
 | 
					                option.setAttribute("data-key", item.uniqueName);
 | 
				
			||||||
        });
 | 
					                option.value = item.name;
 | 
				
			||||||
    }
 | 
					                document.getElementById("datalist-" + type).appendChild(option);
 | 
				
			||||||
 | 
					                itemMap[item.uniqueName] = { ...item, type };
 | 
				
			||||||
 | 
					            });
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					        resolve(itemMap);
 | 
				
			||||||
 | 
					    });
 | 
				
			||||||
});
 | 
					});
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					function updateInventory() {
 | 
				
			||||||
 | 
					    const req = $.get("/api/inventory.php?accountId=" + window.accountId);
 | 
				
			||||||
 | 
					    req.done(data => {
 | 
				
			||||||
 | 
					        window.itemListPromise.then(itemMap => {
 | 
				
			||||||
 | 
					            document.getElementById("warframe-list").innerHTML = "";
 | 
				
			||||||
 | 
					            data.Suits.forEach(item => {
 | 
				
			||||||
 | 
					                const tr = document.createElement("tr");
 | 
				
			||||||
 | 
					                {
 | 
				
			||||||
 | 
					                    const td = document.createElement("td");
 | 
				
			||||||
 | 
					                    td.textContent = itemMap[item.ItemType].name;
 | 
				
			||||||
 | 
					                    tr.appendChild(td);
 | 
				
			||||||
 | 
					                }
 | 
				
			||||||
 | 
					                {
 | 
				
			||||||
 | 
					                    const td = document.createElement("td");
 | 
				
			||||||
 | 
					                    td.classList = "text-end";
 | 
				
			||||||
 | 
					                    if (item.XP < 1_600_000) {
 | 
				
			||||||
 | 
					                        const a = document.createElement("a");
 | 
				
			||||||
 | 
					                        a.href = "#";
 | 
				
			||||||
 | 
					                        a.onclick = function () {
 | 
				
			||||||
 | 
					                            addGearExp("Suits", item.ItemId.$oid, 1_600_000 - item.XP);
 | 
				
			||||||
 | 
					                        };
 | 
				
			||||||
 | 
					                        a.textContent = "Make Rank 30";
 | 
				
			||||||
 | 
					                        td.appendChild(a);
 | 
				
			||||||
 | 
					                    }
 | 
				
			||||||
 | 
					                    tr.appendChild(td);
 | 
				
			||||||
 | 
					                }
 | 
				
			||||||
 | 
					                document.getElementById("warframe-list").appendChild(tr);
 | 
				
			||||||
 | 
					            });
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					            document.getElementById("weapon-list").innerHTML = "";
 | 
				
			||||||
 | 
					            ["LongGuns", "Pistols", "Melee"].forEach(category => {
 | 
				
			||||||
 | 
					                data[category].forEach(item => {
 | 
				
			||||||
 | 
					                    const tr = document.createElement("tr");
 | 
				
			||||||
 | 
					                    {
 | 
				
			||||||
 | 
					                        const td = document.createElement("td");
 | 
				
			||||||
 | 
					                        td.textContent = itemMap[item.ItemType].name;
 | 
				
			||||||
 | 
					                        tr.appendChild(td);
 | 
				
			||||||
 | 
					                    }
 | 
				
			||||||
 | 
					                    {
 | 
				
			||||||
 | 
					                        const td = document.createElement("td");
 | 
				
			||||||
 | 
					                        td.classList = "text-end";
 | 
				
			||||||
 | 
					                        if (item.XP < 800_000) {
 | 
				
			||||||
 | 
					                            const a = document.createElement("a");
 | 
				
			||||||
 | 
					                            a.href = "#";
 | 
				
			||||||
 | 
					                            a.onclick = function () {
 | 
				
			||||||
 | 
					                                addGearExp(category, item.ItemId.$oid, 800_000 - item.XP);
 | 
				
			||||||
 | 
					                            };
 | 
				
			||||||
 | 
					                            a.textContent = "Make Rank 30";
 | 
				
			||||||
 | 
					                            td.appendChild(a);
 | 
				
			||||||
 | 
					                        }
 | 
				
			||||||
 | 
					                        tr.appendChild(td);
 | 
				
			||||||
 | 
					                    }
 | 
				
			||||||
 | 
					                    document.getElementById("weapon-list").appendChild(tr);
 | 
				
			||||||
 | 
					                });
 | 
				
			||||||
 | 
					            });
 | 
				
			||||||
 | 
					        });
 | 
				
			||||||
 | 
					    });
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
function getKey(input) {
 | 
					function getKey(input) {
 | 
				
			||||||
    return document
 | 
					    return document
 | 
				
			||||||
        .getElementById(input.getAttribute("list"))
 | 
					        .getElementById(input.getAttribute("list"))
 | 
				
			||||||
@ -77,8 +142,8 @@ function doAcquireWarframe() {
 | 
				
			|||||||
        })
 | 
					        })
 | 
				
			||||||
    });
 | 
					    });
 | 
				
			||||||
    req.done(() => {
 | 
					    req.done(() => {
 | 
				
			||||||
        alert("Warframe added to your inventory! Visit navigation to force an inventory update.");
 | 
					 | 
				
			||||||
        document.getElementById("warframe-to-acquire").value = "";
 | 
					        document.getElementById("warframe-to-acquire").value = "";
 | 
				
			||||||
 | 
					        updateInventory();
 | 
				
			||||||
    });
 | 
					    });
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@ -102,11 +167,33 @@ function doAcquireWeapon() {
 | 
				
			|||||||
        })
 | 
					        })
 | 
				
			||||||
    });
 | 
					    });
 | 
				
			||||||
    req.done(() => {
 | 
					    req.done(() => {
 | 
				
			||||||
        alert("Weapon added to your inventory! Visit navigation to force an inventory update.");
 | 
					 | 
				
			||||||
        document.getElementById("weapon-to-acquire").value = "";
 | 
					        document.getElementById("weapon-to-acquire").value = "";
 | 
				
			||||||
 | 
					        updateInventory();
 | 
				
			||||||
    });
 | 
					    });
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
$("#weapon-to-acquire").on("input", () => {
 | 
					$("#weapon-to-acquire").on("input", () => {
 | 
				
			||||||
    $("#weapon-to-acquire").removeClass("is-invalid");
 | 
					    $("#weapon-to-acquire").removeClass("is-invalid");
 | 
				
			||||||
});
 | 
					});
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					function addGearExp(category, oid, xp) {
 | 
				
			||||||
 | 
					    const data = {
 | 
				
			||||||
 | 
					        Missions: {
 | 
				
			||||||
 | 
					            Tag: "SolNode0",
 | 
				
			||||||
 | 
					            Completes: 0
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					    };
 | 
				
			||||||
 | 
					    data[category] = [
 | 
				
			||||||
 | 
					        {
 | 
				
			||||||
 | 
					            ItemId: { $oid: oid },
 | 
				
			||||||
 | 
					            XP: xp
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					    ];
 | 
				
			||||||
 | 
					    $.post({
 | 
				
			||||||
 | 
					        url: "/api/missionInventoryUpdate.php?accountId=" + window.accountId,
 | 
				
			||||||
 | 
					        contentType: "text/plain",
 | 
				
			||||||
 | 
					        data: JSON.stringify(data)
 | 
				
			||||||
 | 
					    }).done(function () {
 | 
				
			||||||
 | 
					        updateInventory();
 | 
				
			||||||
 | 
					    });
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
				
			|||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user