diff --git a/src/index.ts b/src/index.ts index e134792..09a5110 100644 --- a/src/index.ts +++ b/src/index.ts @@ -8,7 +8,8 @@ import unknown from "~/assets/images/tab-icons/unknown.svg"; import { bindFunctions } from "./scripts/index"; // Enable single page mode for developing scripts -const devSinglePage = null; // ["Other", "Guide_to_food_and_drinks"]; +// const devSinglePage = ["Medical", "Guide_to_chemistry"]; +const devSinglePage = null; async function load() { const sectionListContainer = document.getElementById("section-list"); diff --git a/src/scripts/index.ts b/src/scripts/index.ts index 538d221..a95e405 100644 --- a/src/scripts/index.ts +++ b/src/scripts/index.ts @@ -1,6 +1,7 @@ import { chemistryScript, processChemistry } from "./pages/chemistry"; import { processVirology, virologyScript } from "./pages/virology"; import { processFood, foodScript } from "./pages/food"; +import { processDrinks, drinkScript } from "./pages/drinks"; import { genericScript } from "./pages/generic"; import { processGlobal } from "./pages/global"; import { welcomeScript } from "./pages/welcome"; @@ -10,8 +11,8 @@ import { welcomeScript } from "./pages/welcome"; export const PAGE_VERSIONS = { Infections: "fcebeda2fddb46d924f4538cd9c0daeb55aa4c9b", Guide_to_food_and_drinks: "131e010df66ed689d31df53c3ca17ad16635a827", - Guide_to_chemistry: "8583fc3b707920eb5cc3a814ec934cfff88803a5", - $DEFAULT: "bb7abd544a19369d4b6b7e3dde3eb3cc34c023d4", + Guide_to_chemistry: "5074d6180fc8b283bac00b99c6aa2325b797da6b", + $DEFAULT: "5074d6180fc8b283bac00b99c6aa2325b797da6b", }; const MAX_WIDTH = 440; @@ -26,9 +27,12 @@ export function processHTML(root: HTMLElement, docname: string): void { case "Infections": processVirology(root); break; - case "Guide_to_food_and_drinks": + case "Guide_to_food": processFood(root); break; + case "Guide_to_drinks": + processDrinks(root); + break; default: } } @@ -69,10 +73,14 @@ export function bindFunctions(root: HTMLElement, docname: string): void { case "$Welcome": welcomeScript(root); break; - case "Guide_to_food_and_drinks": + case "Guide_to_food": genericScript(root, docname); foodScript(root); break; + case "Guide_to_drinks": + genericScript(root, docname); + drinkScript(root); + break; default: genericScript(root, docname); break; diff --git a/src/scripts/pages/chemistry.ts b/src/scripts/pages/chemistry.ts index d80992d..a679649 100644 --- a/src/scripts/pages/chemistry.ts +++ b/src/scripts/pages/chemistry.ts @@ -76,6 +76,8 @@ export function processChemistry(root: HTMLElement): void { return; } const rows = Array.from(row.querySelectorAll("td")).slice(1); + let conditions: HTMLTableCellElement = null; + let explosive: HTMLTableCellElement = null; let ph: HTMLTableCellElement = null; let treatment: HTMLTableCellElement = null; let desc: HTMLTableCellElement = null; @@ -83,7 +85,6 @@ export function processChemistry(root: HTMLElement): void { let overdose: HTMLTableCellElement = null; let addiction: HTMLTableCellElement = null; // Handle special cases - console.log(section); switch (section) { case "Components": [ph, desc] = rows; @@ -98,6 +99,8 @@ export function processChemistry(root: HTMLElement): void { [ph, desc, metabolism] = rows; break; case "Explosive Strength": + [conditions, desc, explosive] = rows; + break; case "Mutation Toxins": [desc, metabolism] = rows; break; @@ -113,6 +116,12 @@ export function processChemistry(root: HTMLElement): void { if (metabolism) { content += `
`; } + if (conditions) { + content += `${conditions.innerHTML}
`; + } + if (explosive) { + content += `${explosive.innerHTML}
`; + } if (addiction && addiction.innerHTML.trim() !== "N/A") { content += `${addiction.innerHTML}
`; } @@ -130,6 +139,8 @@ export function processChemistry(root: HTMLElement): void { if (desc) desc.parentElement.removeChild(desc); if (treatment) treatment.parentElement.removeChild(treatment); if (metabolism) metabolism.parentElement.removeChild(metabolism); + if (conditions) conditions.parentElement.removeChild(conditions); + if (explosive) explosive.parentElement.removeChild(explosive); if (overdose) overdose.parentElement.removeChild(overdose); if (addiction) addiction.parentElement.removeChild(addiction); if (ph) ph.parentElement.removeChild(ph); diff --git a/src/scripts/pages/drinks.ts b/src/scripts/pages/drinks.ts new file mode 100644 index 0000000..08d9fb6 --- /dev/null +++ b/src/scripts/pages/drinks.ts @@ -0,0 +1,50 @@ +import { parseTable, makeTable } from "../utils"; +import { registerSearchEntries } from "../search"; + +export function processDrinks(root: HTMLElement): void { + const drinkTables = ["#Basic_Drink_Ingredients", "#Mixed_Drinks"]; + drinkTables.forEach((selector) => { + const table = root.querySelector${row["Strength"].innerHTML}
+${row["Drink Description"].innerHTML}
+${row["Notes"].innerHTML}
+`; + const ingredients = row["Ingredients"].innerHTML + .split(/,|\+/gi) + .map((s) => `${s.trim()}
`); + row["Ingredients"].innerHTML = ingredients.join(""); + return { Drink: foodBlock, Ingredients: row["Ingredients"] }; + }); + const betterTable = makeTable(["Drink", "Ingredients"], drinks); + betterTable.className = "drink-ext wikitable"; + table.replaceWith(betterTable); + }); +} + +export function drinkScript(root: HTMLElement): void { + // Init fuzzy search with elements + const foodEntries = Array.from( + root.querySelectorAll${row["Strength"].innerHTML}
-${row["Drink Description"].innerHTML}
-${row["Notes"].innerHTML}
-`; - const ingredients = row["Ingredients"].innerHTML - .split(/,|\+/gi) - .map((s) => `${s.trim()}
`); - row["Ingredients"].innerHTML = ingredients.join(""); - return { Drink: foodBlock, Ingredients: row["Ingredients"] }; - }); - const betterTable = makeTable(["Drink", "Ingredients"], drinks); - betterTable.className = "drink-ext wikitable"; - table.replaceWith(betterTable); - }); - const baseFoodTables = [ { selector: "#Butchering", @@ -56,16 +33,6 @@ export function processFood(root: HTMLElement): void { title: "Dispenses", process: "Description", }, - { - selector: "#Junk_Drinks", - title: "Dispenses", - process: "Description", - }, - { - selector: "#Hot_Drinks", - title: "Dispenses", - process: "Description", - }, { selector: "#Other_food", title: "Item", @@ -123,22 +90,21 @@ export function processFood(root: HTMLElement): void { const foodRecipesTables = [ "#Burgers", "#Breads", - "#Sandwiches", - "#Pizzas", - "#Pastas", - "#Soups_\\.26_Stews", - "#Seafood", - "#Meat", - "#Misc\\._Food", - "#Frozen", - "#Pies", - "#Salads", "#Cakes", - "#Side_Dishes", - "#Pastries", - "#Sweets", + "#Egg-Based_Food", + "#Snowcones", + "#Lizard_Cuisine", + "#Seafood", + "#Mexican", + "#Savory", + "#Waffles", + "#Pies", + "#Pizzas", + "#Salads", + "#Sandwiches", + "#Soups_\\.26_Stews", + "#Spaghettis", "#Icecream_Vat", - "#Exotic", ]; foodRecipesTables.forEach((selector) => { const table = root.querySelector