0
0
Fork 0

Implement the Vue version of the app

This commit is contained in:
Oliver-Akins 2023-02-01 20:57:25 -06:00
parent 0001dca6e7
commit 80d85e057e
3 changed files with 123 additions and 43 deletions

View file

@ -1,43 +1,57 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<title>Weighted Choice Maker</title>
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<title>Weighted Choice Maker</title>
<!-- CSS -->
<link rel="stylesheet" href="https://cdn.jsdelivr.net/gh/kognise/water.css@latest/dist/dark.css">
<link rel="stylesheet" href="style.css">
<!-- CSS -->
<link rel="stylesheet" href="https://cdn.jsdelivr.net/gh/kognise/water.css@latest/dist/dark.css">
<link rel="stylesheet" href="style.css">
<!-- JAVASCRIPT -->
<script src="https://cdn.jsdelivr.net/npm/vue@2/dist/vue.js"></script>
</head>
<body>
<template id="choice-template">
<div class="choice">
<input type="text" class="left" placeholder="Choice Name">
<input class="right" type="text" placeholder="Choice Weighting">
<button class="delete" onclick="delete_choice(this)">X</button>
<div class="line"></div>
</div>
</template>
<h1>Weighted Choice Maker</h1>
<div class="container">
<h2>Choices:</h2>
<button onclick="add_choice()">Add New Choice</button>
<br>
<!-- JAVASCRIPT -->
<script src="https://cdn.jsdelivr.net/npm/vue@2/dist/vue.js"></script>
<script src="./app.js" defer></script>
</head>
<body>
<template id="choice-template">
<div class="choice">
<input type="text" class="left" placeholder="Choice Name">
<input class="right" type="text" placeholder="Choice Weighting">
<button class="delete" onclick="delete_choice(this)">X</button>
<div class="line"></div>
<div id="choices">
<div class="choice">
<input class="left" type="text" id="text-in-0" placeholder="Choice Name">
<input class="right" type="text" id="weight-in-0" placeholder="Choice Weighting">
<button class="delete" onclick="delete_choice(this)">X</button>
<div class="line"></div>
</div>
</div>
<button onclick="choose_option()">Choose</button>
<h2>Chosen Entry: <span id="result"></span></h2>
</div>
</body>
</template>
<h1>Weighted Choice Maker</h1>
<div id="app" v-cloak class="container">
<h2>Choices:</h2>
<button @click.stop="addOption">Add New Choice</button>
<br>
<hr>
<ul>
<li
v-for="option, i in options"
:key="i"
>
<input type="text" class="left" placeholder="Choice Name" v-model="option.name">
<input
type="number"
class="right"
placeholder="Choice Weighting"
v-model="option.weight"
min="1"
@change="updateChanceValues"
>
<span v-if="option.chance">
({{option.chance}}%)
</span>
<button class="delete" @click.stop="removeOption(i)">X</button>
</li>
</ul>
<hr v-if="options.length > 0">
<button @click.stop="pickAnOption">Choose</button>
<h2 v-if="chosen">Chosen Entry: <span id="result">{{chosen.name}}</span></h2>
</div>
</body>
</html>