| @@ -98,6 +98,9 @@ function updateEntityElement(entity, element, zIndex) { | |||
| const bonus = (entity.views[view].image.extra ? entity.views[view].image.extra : 1); | |||
| element.style.setProperty("--height", pixels * bonus + "px"); | |||
| if (entity.views[view].rename) | |||
| element.querySelector(".entity-name").innerText = entity.name == "" ? "" : entity.views[view].name; | |||
| else | |||
| element.querySelector(".entity-name").innerText = entity.name; | |||
| const bottomName = document.querySelector("#bottom-name-" + element.dataset.key); | |||
| @@ -570,6 +573,7 @@ function updateViewOptions(entity, view, changed) { | |||
| if (key != changed) { | |||
| const input = document.querySelector("#options-view-" + key + "-input"); | |||
| const select = document.querySelector("#options-view-" + key + "-select"); | |||
| const currentUnit = select.value; | |||
| const convertedAmount = entity.views[view][key].toNumber(currentUnit); | |||
| input.value = math.round(convertedAmount, 5); | |||
| @@ -946,7 +950,9 @@ document.addEventListener("DOMContentLoaded", () => { | |||
| }); | |||
| document.querySelector("#entity-view").addEventListener("input", e => { | |||
| entities[selected.dataset.key].view = e.target.value; | |||
| const entity = entities[selected.dataset.key]; | |||
| entity.view = e.target.value; | |||
| const image = entities[selected.dataset.key].views[e.target.value].image; | |||
| selected.querySelector(".entity-image").src = image.source; | |||
| @@ -565,6 +565,7 @@ const attributionData = { | |||
| { name: "nail-polish.svg", source: null }, | |||
| { name: "shot-glass.svg", source: null }, | |||
| { name: "beer-bottle.svg", source: null }, | |||
| { name: "circle.svg", source: null } | |||
| ], | |||
| authors: [ | |||
| "chemicalcrux" | |||
| @@ -0,0 +1,10 @@ | |||
| <?xml version="1.0" encoding="utf-8"?> | |||
| <!-- Generator: Adobe Illustrator 23.1.0, SVG Export Plug-In . SVG Version: 6.00 Build 0) --> | |||
| <svg version="1.1" id="Layer_1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px" | |||
| viewBox="0 0 195 195" style="enable-background:new 0 0 195 195;" xml:space="preserve"> | |||
| <g> | |||
| <circle cx="97.5" cy="97.5" r="97"/> | |||
| <path d="M97.5,1C150.71,1,194,44.29,194,97.5S150.71,194,97.5,194S1,150.71,1,97.5S44.29,1,97.5,1 M97.5,0C43.65,0,0,43.65,0,97.5 | |||
| S43.65,195,97.5,195S195,151.35,195,97.5S151.35,0,97.5,0L97.5,0z"/> | |||
| </g> | |||
| </svg> | |||
| @@ -12,11 +12,12 @@ function makeObject(name, viewInfo) { | |||
| } | |||
| }, | |||
| image: value.image, | |||
| name: value.name | |||
| name: value.name, | |||
| rename: value.rename | |||
| } | |||
| if (value.mass) { | |||
| views[key].attributes[key] = { | |||
| views[key].attributes.mass = { | |||
| name: "Mass", | |||
| power: 3, | |||
| type: "mass", | |||
| @@ -145,6 +146,50 @@ function makeObjects() { | |||
| } | |||
| ) | |||
| }); | |||
| results.push({ | |||
| name: "Coin", | |||
| constructor: () => makeObject( | |||
| "Coin", | |||
| { | |||
| penny: { | |||
| height: math.unit(0.75, "inches"), | |||
| mass: math.unit(2.5, "g"), | |||
| image: { source: "./media/objects/circle.svg" }, | |||
| name: "Penny", | |||
| rename: true | |||
| }, | |||
| nickel: { | |||
| height: math.unit(0.835, "inches"), | |||
| mass: math.unit(5, "g"), | |||
| image: { source: "./media/objects/circle.svg" }, | |||
| name: "Nickel", | |||
| rename: true | |||
| }, | |||
| dime: { | |||
| height: math.unit(0.705, "inches"), | |||
| mass: math.unit(2.268, "g"), | |||
| image: { source: "./media/objects/circle.svg" }, | |||
| name: "Dime", | |||
| rename: true | |||
| }, | |||
| quarter: { | |||
| height: math.unit(0.955, "inches"), | |||
| mass: math.unit(5.67, "g"), | |||
| image: { source: "./media/objects/circle.svg" }, | |||
| name: "Quarter", | |||
| rename: true | |||
| }, | |||
| dollar: { | |||
| height: math.unit(1.043, "inches"), | |||
| mass: math.unit(8.1, "g"), | |||
| image: { source: "./media/objects/circle.svg" }, | |||
| name: "Dollar Coin", | |||
| rename: true | |||
| }, | |||
| } | |||
| ) | |||
| }); | |||
| results.sort((b1, b2) => { | |||
| e1 = b1.constructor(); | |||