Better UI, wynndata styling

This commit is contained in:
b 2021-01-07 19:02:12 -06:00
parent 4312515a11
commit 1623b422b2
3 changed files with 186 additions and 56 deletions

View file

@ -44,6 +44,7 @@ function expandItem(item){
function displayExpandedItem(item, parent_id){ function displayExpandedItem(item, parent_id){
// Commands to "script" the creation of nice formatting. // Commands to "script" the creation of nice formatting.
// #commands create a new element. // #commands create a new element.
// !elemental is some janky hack for elemental damage.
// normals just display a thing. // normals just display a thing.
let display_commands = [ let display_commands = [
"#cdiv", "#cdiv",
@ -51,14 +52,18 @@ function displayExpandedItem(item, parent_id){
"#ldiv", "#ldiv",
"atkSpd", "atkSpd",
"#ldiv", "#ldiv",
"nDam", "eDam", "tDam", "wDam", "tDam", "aDam"]
let rest_TMP = [
"lvl",
"classReq",
"strReq", "dexReq", "intReq", "defReq","agiReq",
"hp", "hp",
"!elemental",
"nDam", "eDam", "tDam", "wDam", "tDam", "aDam",
"eDef", "tDef", "wDef", "fDef", "aDef", "eDef", "tDef", "wDef", "fDef", "aDef",
"!elemental",
"#ldiv",
"classReq",
"lvl",
"strReq", "dexReq", "intReq", "defReq","agiReq",
"#ldiv",
"str", "dex", "int", "agi", "def", "str", "dex", "int", "agi", "def",
"#table",
"hpBonus", "hpBonus",
"hprRaw", "hprPct", "hprRaw", "hprPct",
"sdRaw", "sdPct", "sdRaw", "sdPct",
@ -70,8 +75,10 @@ function displayExpandedItem(item, parent_id){
"exploding", "exploding",
"spd", "spd",
"atkTier", "atkTier",
"!elemental",
"eDamPct", "tDamPct", "wDamPct", "fDamPct", "aDamPct", "eDamPct", "tDamPct", "wDamPct", "fDamPct", "aDamPct",
"eDefPct", "tDefPct", "wDefPct", "fDefPct", "aDefPct", "eDefPct", "tDefPct", "wDefPct", "fDefPct", "aDefPct",
"!elemental",
"spPct1", "spRaw1", "spPct2", "spRaw2", "spPct3", "spRaw3", "spPct4", "spRaw4", "spPct1", "spRaw1", "spPct2", "spRaw2", "spPct3", "spRaw3", "spPct4", "spRaw4",
"rainbowRaw", "rainbowRaw",
"sprint", "sprintReg", "sprint", "sprintReg",
@ -80,20 +87,38 @@ function displayExpandedItem(item, parent_id){
"spRegen", "spRegen",
"eSteal", "eSteal",
"gXp", "gSpd", "gXp", "gSpd",
"#ldiv",
"slots", "slots",
"set", "set",
"quest", "quest",
"restrict"]; "restrict"];
let idPrefixes = {"displayName": "", "lvl":"Combat Level Min: ", "classReq":"Class Req: ","strReq":"Strength Min: ","dexReq":"Dexterity Min: ","intReq":"Intelligence Min: ","defReq":"Defense Min: ","agiReq":"Agility Min: ", "nDam":"Neutral Damage: ", "eDam":"Earth Damage: ", "tDam":"Thunder Damage: ", "wDam":"Water Damage: ", "fDam":"Fire Damage: ", "aDam":"Air Damage: ", "atkSpd":"Attack Speed: ", "hp":"Health: ", "eDef":"Earth Defense: ", "tDef":"Thunder Defense: ", "wDef":"Water Defense: ", "fDef":"Fire Defense: ", "aDef":"Air Defense: ", "str":"Strength: ", "dex":"Dexterity: ", "int":"Intelligence: ", "def":"Defense: ","agi":"Agility: ", "hpBonus":"Health Bonus: ", "hprRaw":"Health Regen Raw: ", "hprPct":"Health Regen %: ", "sdRaw":"Raw Spell Damage: ", "sdPct":"Spell Damage %: ", "mdRaw":"Main Attack Neutral Damage: ", "mdPct":"Main Attack Damage %: ", "mr":"Mana Regen: ", "ms":"Mana Steal: ", "ref":"Reflection: ", "ls":"Life Steal: ", "poison":"Poison: ", "thorns":"Thorns: ", "exploding":"Expoding: ", "spd":"Walk Speed Bonus: ", "atkTier":"Attack Speed Bonus: ", "eDamPct":"Earth Damage %: ", "tDamPct":"Thunder Damage %: ", "wDamPct":"Water Damage %: ", "fDamPct":"Fire Damage %: ", "aDamPct":"Air Damage %: ", "eDefPct":"Earth Defense %: ", "tDefPct":"Thunder Defense %: ", "wDefPct":"Water Defense %: ", "fDefPct":"Fire Defense %: ", "aDefPct":"Air Defense %: ", "spPct1":"1st Spell Cost %: ", "spRaw1":"1st Spell Cost Raw: ", "spPct2":"2nd Spell Cost %: ", "spRaw2":"2nd Spell Cost Raw: ", "spPct3":"3rd Spell Cost %: ", "spRaw3":"3rd Spell Cost Raw: ", "spPct4":"4th Spell Cost %: ", "spRaw4":"4th Spell Cost Raw: ", "rainbowRaw":"Rainbow Spell Damage Raw: ", "sprint":"Sprint Bonus: ", "sprintReg":"Sprint Regen Bonus: ", "jh":"Jump Height: ", "xpb":"Combat XP Bonus: ", "lb":"Loot Bonus: ", "lq":"Loot Quality: ", "spRegen":"Soul Point Regen: ", "eSteal":"Stealing: ", "gXp":"Gathering XP Bonus: ", "gSpd":"Gathering Speed Bonus: ", "slots":"Powder Slots: ", "set":"This item belongs to the ", "quest":"This item is from the quest<br>", "restrict":""}; let idPrefixes = {"displayName": "", "lvl":"Combat Level Min: ", "classReq":"Class Req: ","strReq":"Strength Min: ","dexReq":"Dexterity Min: ","intReq":"Intelligence Min: ","defReq":"Defense Min: ","agiReq":"Agility Min: ", "nDam":"Neutral Damage: ", "eDam":"Earth Damage: ", "tDam":"Thunder Damage: ", "wDam":"Water Damage: ", "fDam":"Fire Damage: ", "aDam":"Air Damage: ", "atkSpd":"Attack Speed: ", "hp":"Health: ", "eDef":"Earth Defense: ", "tDef":"Thunder Defense: ", "wDef":"Water Defense: ", "fDef":"Fire Defense: ", "aDef":"Air Defense: ", "str":"Strength: ", "dex":"Dexterity: ", "int":"Intelligence: ", "def":"Defense: ","agi":"Agility: ", "hpBonus":"Health Bonus: ", "hprRaw":"Health Regen Raw: ", "hprPct":"Health Regen %: ", "sdRaw":"Raw Spell Damage: ", "sdPct":"Spell Damage %: ", "mdRaw":"Main Attack Neutral Damage: ", "mdPct":"Main Attack Damage %: ", "mr":"Mana Regen: ", "ms":"Mana Steal: ", "ref":"Reflection: ", "ls":"Life Steal: ", "poison":"Poison: ", "thorns":"Thorns: ", "exploding":"Expoding: ", "spd":"Walk Speed Bonus: ", "atkTier":"Attack Speed Bonus: ", "eDamPct":"Earth Damage %: ", "tDamPct":"Thunder Damage %: ", "wDamPct":"Water Damage %: ", "fDamPct":"Fire Damage %: ", "aDamPct":"Air Damage %: ", "eDefPct":"Earth Defense %: ", "tDefPct":"Thunder Defense %: ", "wDefPct":"Water Defense %: ", "fDefPct":"Fire Defense %: ", "aDefPct":"Air Defense %: ", "spPct1":"1st Spell Cost %: ", "spRaw1":"1st Spell Cost Raw: ", "spPct2":"2nd Spell Cost %: ", "spRaw2":"2nd Spell Cost Raw: ", "spPct3":"3rd Spell Cost %: ", "spRaw3":"3rd Spell Cost Raw: ", "spPct4":"4th Spell Cost %: ", "spRaw4":"4th Spell Cost Raw: ", "rainbowRaw":"Rainbow Spell Damage Raw: ", "sprint":"Sprint Bonus: ", "sprintReg":"Sprint Regen Bonus: ", "jh":"Jump Height: ", "xpb":"Combat XP Bonus: ", "lb":"Loot Bonus: ", "lq":"Loot Quality: ", "spRegen":"Soul Point Regen: ", "eSteal":"Stealing: ", "gXp":"Gathering XP Bonus: ", "gSpd":"Gathering Speed Bonus: ", "slots":"Powder Slots: ", "set":"This item belongs to the ", "quest":"This item is from the quest: ", "restrict":""};
let idSuffixes = {"displayName": "", "lvl":"", "classReq":"","strReq":"","dexReq":"","intReq":"","defReq":"","agiReq":"", "nDam":"", "eDam":"", "tDam":"", "wDam":"", "fDam":"", "aDam":"", "atkSpd":"", "hp":"", "eDef":"", "tDef":"", "wDef":"", "fDef":"", "aDef":"", "str":"", "dex":"", "int":"", "def":"","agi":"", "hpBonus":"", "hprRaw":"", "hprPct":"%", "sdRaw":"", "sdPct":"%", "mdRaw":"", "mdPct":"%", "mr":"/4s", "ms":"/4s", "ref":"%", "ls":"/4s", "poison":"/3s", "thorns":"%", "exploding":"%", "spd":"%", "atkTier":" tier", "eDamPct":"%", "tDamPct":"%", "wDamPct":"%", "fDamPct":"%", "aDamPct":"%", "eDefPct":"%", "tDefPct":"%", "wDefPct":"%", "fDefPct":"%", "aDefPct":"%", "spPct1":"%", "spRaw1":"", "spPct2":"%", "spRaw2":"", "spPct3":"%", "spRaw3":"", "spPct4":"%", "spRaw4":"", "rainbowRaw":"", "sprint":"%", "sprintReg":"%", "jh":"", "xpb":"%", "lb":"%", "lq":"%", "spRegen":"%", "eSteal":"%", "gXp":"%", "gSpd":"%", "slots":"", "set":" set.", "quest":".", "restrict":""}; let idSuffixes = {"displayName": "", "lvl":"", "classReq":"","strReq":"","dexReq":"","intReq":"","defReq":"","agiReq":"", "nDam":"", "eDam":"", "tDam":"", "wDam":"", "fDam":"", "aDam":"", "atkSpd":"", "hp":"", "eDef":"", "tDef":"", "wDef":"", "fDef":"", "aDef":"", "str":"", "dex":"", "int":"", "def":"","agi":"", "hpBonus":"", "hprRaw":"", "hprPct":"%", "sdRaw":"", "sdPct":"%", "mdRaw":"", "mdPct":"%", "mr":"/4s", "ms":"/4s", "ref":"%", "ls":"/4s", "poison":"/3s", "thorns":"%", "exploding":"%", "spd":"%", "atkTier":" tier", "eDamPct":"%", "tDamPct":"%", "wDamPct":"%", "fDamPct":"%", "aDamPct":"%", "eDefPct":"%", "tDefPct":"%", "wDefPct":"%", "fDefPct":"%", "aDefPct":"%", "spPct1":"%", "spRaw1":"", "spPct2":"%", "spRaw2":"", "spPct3":"%", "spRaw3":"", "spPct4":"%", "spRaw4":"", "rainbowRaw":"", "sprint":"%", "sprintReg":"%", "jh":"", "xpb":"%", "lb":"%", "lq":"%", "spRegen":"%", "eSteal":"%", "gXp":"%", "gSpd":"%", "slots":"", "set":" set.", "quest":".", "restrict":""};
function apply_elemental_format(p_elem, id, suffix) {
suffix = (typeof suffix !== 'undefined') ? suffix : "";
// THIS IS SO JANK BUT IM TOO LAZY TO FIX IT TODO
let parts = idPrefixes[id].split(/ (.*)/);
let element_prefix = parts[0];
let desc = parts[1];
let i_elem = document.createElement('b');
i_elem.classList.add(element_prefix);
i_elem.textContent = element_prefix;
p_elem.appendChild(i_elem);
let i_elem2 = document.createElement('b');
i_elem2.textContent = " " + desc + suffix;
p_elem.appendChild(i_elem2);
}
// Clear the parent div. // Clear the parent div.
setHTML(parent_id, ""); setHTML(parent_id, "");
let parent_div = document.getElementById(parent_id); let parent_div = document.getElementById(parent_id);
let active_elem; let active_elem;
let fix_id = item.has("fixID") && item.get("fixID");
let elemental_format = false;
for (const command of display_commands) { for (const command of display_commands) {
if (command.charAt(0) === "#") { if (command.charAt(0) === "#") {
if (command === "#cdiv") { if (command === "#cdiv") {
@ -104,49 +129,84 @@ function displayExpandedItem(item, parent_id){
active_elem = document.createElement('div'); active_elem = document.createElement('div');
active_elem.classList.add('itemleft'); active_elem.classList.add('itemleft');
} }
else if (command === "#table") {
active_elem = document.createElement('table');
active_elem.classList.add('itemtable');
}
parent_div.appendChild(active_elem); parent_div.appendChild(active_elem);
} }
else if (command.charAt(0) === "!") {
// TODO: This is sooo incredibly janky.....
if (command === "!elemental") {
elemental_format = !elemental_format;
}
}
else { else {
let id = command; let id = command;
console.log(id);
let new_elem;
if(nonRolledIDs.includes(id) && item.get(id)){//nonRolledID & non-0/non-null/non-und ID if(nonRolledIDs.includes(id) && item.get(id)){//nonRolledID & non-0/non-null/non-und ID
new_elem = document.createElement('p'); let p_elem = document.createElement('p');
new_elem.textContent = idPrefixes[id].concat(item.get(id), idSuffixes[id]); p_elem.classList.add('itemp');
if (elemental_format) {
apply_elemental_format(p_elem, id, item.get(id));
} }
// if(rolledIDs.includes(id)&& item.get("minRolls").get(id) && item.get("maxRolls").get(id) ){//rolled ID & non-0/non-null/non-und ID else {
// itemString = itemString.concat(idPrefixes[id]); p_elem.textContent = idPrefixes[id].concat(item.get(id), idSuffixes[id]);
// itemString = itemString.concat(item.get("minRolls").get(id), idSuffixes[id],"<br>");
// }//Just don't do anything if else
if (new_elem) {
active_elem.appendChild(new_elem);
} }
active_elem.appendChild(p_elem);
} }
else if(rolledIDs.includes(id)&& item.get("minRolls").get(id)){ // && item.get("maxRolls").get(id) ){//rolled ID & non-0/non-null/non-und ID
let row = document.createElement('tr');
let style = "positive";
if (item.get("minRolls").get(id) < 0) {
style = "negative";
} }
if (fix_id) {
let desc_elem = document.createElement('td');
desc_elem.classList.add('left');
if (elemental_format) {
apply_elemental_format(desc_elem, id);
}
else {
desc_elem.textContent = idPrefixes[id];
}
row.appendChild(desc_elem);
let value_elem = document.createElement('td');
// if(item.has("fixID") && item.get("fixID")){//fixed IDs value_elem.classList.add('right');
// for(i = 0; i < ids.length; i++){ //iterate the ids value_elem.classList.add(style);
// if(nonRolledIDs.includes(ids[i]) && item.get(ids[i])){//nonRolledID & non-0/non-null/non-und ID value_elem.textContent = item.get("minRolls").get(id) + idSuffixes[id];
// itemString = itemString.concat(idPrefixes[ids[i]]); row.appendChild(value_elem);
// itemString = itemString.concat(item.get(ids[i]), idSuffixes[ids[i]],"<br>"); }
// } else {
// if(rolledIDs.includes(ids[i])&& item.get("minRolls").get(ids[i]) && item.get("maxRolls").get(ids[i]) ){//rolled ID & non-0/non-null/non-und ID let min_elem = document.createElement('td');
// itemString = itemString.concat(idPrefixes[ids[i]]); min_elem.classList.add('left');
// itemString = itemString.concat(item.get("minRolls").get(ids[i]), idSuffixes[ids[i]],"<br>"); min_elem.classList.add(style);
// }//Just don't do anything if else min_elem.textContent = item.get("minRolls").get(id) + idSuffixes[id];
// } row.appendChild(min_elem);
// }else{//non-fixed IDs
// for(i = 0; i < ids.length; i++){ //iterate the ids let desc_elem = document.createElement('td');
// if(nonRolledIDs.includes(ids[i]) && item.get(ids[i])){//nonRolledID & non-0/non-null/non-und ID desc_elem.classList.add('center');
// itemString = itemString.concat(idPrefixes[ids[i]]); if (elemental_format) {
// itemString = itemString.concat(item.get(ids[i]), idSuffixes[ids[i]],"<br>"); apply_elemental_format(desc_elem, id);
// } }
// if(rolledIDs.includes(ids[i])&& item.get("minRolls").get(ids[i]) && item.get("maxRolls").get(ids[i]) ){//rolled ID & non-0/non-null/non-und ID else {
// itemString = itemString.concat(idPrefixes[ids[i]]); desc_elem.textContent = idPrefixes[id];
// itemString = itemString.concat(item.get("minRolls").get(ids[i]), idSuffixes[ids[i]], " -> ", idRound(item.get("maxRolls").get(ids[i])),idSuffixes[ids[i]],"<br>"); }
// }//Just don't do anything if else row.appendChild(desc_elem);
// }
// } let max_elem = document.createElement('td');
// itemString = itemString.concat("<br>",item.get("tier")," ", item.get("type")); max_elem.classList.add('right');
max_elem.classList.add(style);
max_elem.textContent = item.get("maxRolls").get(id) + idSuffixes[id];
row.appendChild(max_elem);
}
active_elem.appendChild(row);
}//Just don't do anything if else
}
}
let item_desc_elem = document.createElement('p');
item_desc_elem.classList.add('itemp');
item_desc_elem.classList.add('left');
item_desc_elem.textContent = item.get("tier")+" "+item.get("type");
parent_div.append(item_desc_elem);
} }

View file

@ -1,12 +1,16 @@
<!DOCTYPE html> <!DOCTYPE html>
<html scroll-behavior="smooth"> <html scroll-behavior="smooth">
<head> <head>
<!-- nunito font, copying wynndata -->
<link rel="preconnect" href="https://fonts.gstatic.com">
<link href="https://fonts.googleapis.com/css2?family=Nunito&display=swap" rel="stylesheet">
<link rel="stylesheet" href="styles.css"> <link rel="stylesheet" href="styles.css">
<link rel="icon" href="favicon.png"> <link rel="icon" href="favicon.png">
<link rel="manifest" href="manifest.json"> <link rel="manifest" href="manifest.json">
<title>Wynn Clientside</title> <title>Wynn Clientside</title>
</head> </head>
<body> <body class="all">
<div class="header" id="header"> <div class="header" id="header">
Wynn build calculator Wynn build calculator
</div> </div>

View file

@ -3,6 +3,11 @@
text-align: center; text-align: center;
} }
.all {
font-family: 'Nunito',sans-serif;
font-weight: 700;
}
.equipment { .equipment {
padding: 4%; padding: 4%;
display: grid; display: grid;
@ -23,6 +28,30 @@
text-align: center; text-align: center;
} }
.right {
text-align: right;
}
.left {
text-align: left;
}
.build{
padding: 1%;
display: grid;
grid-template-columns: repeat(4, 1fr);
gap: 10px;
grid-auto-rows: minmax(60px, auto);
width: 98%;
}
.build-helmet, .build-chestplate, .build-leggings, .build-boots, .build-ring1, .build-ring2, .build-bracelet, .build-necklace, .build-weapon, .build-order {
color: #aaa;
background: #110110;
border: 2px solid black;
border-radius: 3px;
width: 100%;
}
.itemcenter { .itemcenter {
text-align: center; text-align: center;
margin-bottom: 16px; margin-bottom: 16px;
@ -33,16 +62,53 @@
margin-bottom: 16px; margin-bottom: 16px;
} }
.build{ .itemtable {
padding: 1%; margin: 2px 2%;
display: grid; width: 96%;
grid-template-columns: repeat(4, 1fr); margin-bottom: 16px;
gap: 10px;
grid-auto-rows: minmax(60px, auto);
width: 90vw;
} }
.build-helmet, .build-chestplate, .build-leggings, .build-boots, .build-ring1, .build-ring2, .build-bracelet, .build-necklace, .build-weapon, .build-order {
border: 2px solid black; .itemp {
border-radius: 3px; margin: 2px 2%;
width: 20vw; padding: 0;
}
.positive {
color: #5f5;
/*text-shadow: 2px 2px 0 #153f15;*/
}
.negative {
color: #f55;
/*text-shadow: 2px 2px 0 #1f1515;*/
}
.Earth {
color: #0a0;
/*text-shadow: 2px 2px 0 #002a00;*/
}
.Thunder {
color: #ff5;
/*text-shadow: 2px 2px 0 #3f3f15;*/
}
.Water {
color: #5ff;
/*text-shadow: 2px 2px 0 #153f3f;*/
}
.Fire {
color: #f55;
/*text-shadow: 2px 2px 0 #1f1515;*/
}
.Air {
color: #fff;
/*text-shadow: 2px 2px 0 #3f3f3f;*/
}
.Neutral {
color: #fa0;
/*text-shadow: 2px 2px 0 #2a2a00;*/
} }