diff --git a/index.html b/index.html index 6f3b68b..b108200 100644 --- a/index.html +++ b/index.html @@ -1,45 +1,43 @@ - - - - - Weighted Choice Maker + + + + + Weighted Choice Maker - - - + + + - - - - - - - -

Weighted Choice Maker

-
-

Choices:

- -
-
-
-
- - - -
-
-
- -

Chosen Entry:

-
- + + + + + +

Weighted Choice Maker

+
+

Choices:

+ +
+
+
+
+ + + +
+
+
+ +

Chosen Entry:

+
+ \ No newline at end of file diff --git a/js/add_choice.js b/js/add_choice.js deleted file mode 100644 index 62e0e8f..0000000 --- a/js/add_choice.js +++ /dev/null @@ -1,12 +0,0 @@ -const add_choice = () => { - let index = document.getElementsByClassName("choice").length; - - - let choice_div = document.getElementById("choice-template"); - let clone = choice_div.content.cloneNode(true); - clone.children[0].children[0].id = `text-in-${index}`; - clone.children[0].children[1].id = `weight-in-${index}`; - - // Add to document without resetting the other ones - document.getElementById("choices").appendChild(clone); -}; \ No newline at end of file diff --git a/js/choosing.js b/js/choosing.js deleted file mode 100644 index 38a06ac..0000000 --- a/js/choosing.js +++ /dev/null @@ -1,55 +0,0 @@ -const construct_choices = () => { - let choices = document.getElementById("choices").children; - let start_of_next_range = 1; - let options = []; - - // Construct the array for choosing - for (choice of choices) { - let name = choice.children[0].value; - let weight = parseInt(choice.children[1].value); - - if (Number.isNaN(weight)) { - break; - }; - - options.push({ - "name": name, - "min": start_of_next_range, - "max": start_of_next_range + weight - 1 - }); - start_of_next_range += weight; - }; - - return { - "choices": options, - "max_value": start_of_next_range - 1 - }; -}; - - -const choose_option = () => { - let {choices, max_value} = construct_choices(); - - // No options, error - if (choices.length === 0 && max_value === 0) { - document.getElementById("result").innerText = "\nERROR: No Choices to pick from"; - return; - } - - // Only one option exists, no need to waste time with randomness - else if (choices.length === 1) { - document.getElementById("result").innerText = choices[0].name - }; - - - let chosen_value = Math.round(Math.random() * max_value); - - - // Find the choice which the randomly chosen number fits within - for (choice of choices) { - if (choice.min <= chosen_value <= choice.max) { - document.getElementById("result").innerText = choice.name; - return; - }; - }; -}; \ No newline at end of file diff --git a/js/delete_choice.js b/js/delete_choice.js deleted file mode 100644 index 363a8a3..0000000 --- a/js/delete_choice.js +++ /dev/null @@ -1,3 +0,0 @@ -const delete_choice = (node) => { - node.parentElement.parentElement.removeChild(node.parentElement) -}; \ No newline at end of file diff --git a/style.css b/style.css index f1c98a7..9bb9060 100644 --- a/style.css +++ b/style.css @@ -2,36 +2,36 @@ h1, h2, h3 { text-align: center; } div.container { - text-align: center; - border-radius: 7px; - margin: 5px auto; - padding: 10px; - width: 95%; + text-align: center; + border-radius: 7px; + margin: 5px auto; + padding: 10px; + width: 95%; } button.delete { - width: 10%; - margin: 0 auto; + width: 10%; + margin: 0 auto; } div.line { - background-color: #7289da; - margin-bottom: 15px; - margin-top: 15px; - height: 2px; + background-color: #7289da; + margin-bottom: 15px; + margin-top: 15px; + height: 2px; } input[type="text"] { - display: inline-block !important; - margin-bottom: 0px; - margin-right: 0px; - margin-left: 0px; - margin-top: 0px; - width: 40%; + display: inline-block !important; + margin-bottom: 0px; + margin-right: 0px; + margin-left: 0px; + margin-top: 0px; + width: 40%; } /* Move boxes further apart */