57 lines
No EOL
1.6 KiB
HTML
57 lines
No EOL
1.6 KiB
HTML
<!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>
|
|
|
|
<!-- 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>
|
|
<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>
|
|
</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> |