Compare commits
29 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
c66040f51f | ||
|
|
3bf3ab9096 | ||
|
|
cf4bc99816 | ||
|
|
aa718a512d | ||
|
|
51f650352e | ||
|
|
c22b305fcb | ||
|
|
5d5a616702 | ||
|
|
8afc50b459 | ||
|
|
2c27570e2b | ||
|
|
e023ee2453 | ||
|
|
8b2be9b5d1 | ||
|
|
544aac895a | ||
|
|
6845f9afd3 | ||
|
|
df43802b61 | ||
|
|
1936c50465 | ||
|
|
d8670f653c | ||
|
|
e5a5f7f60e | ||
|
|
33496a7ebd | ||
|
|
884734b23e | ||
|
|
29633a94c0 | ||
|
|
3d3a177b7c | ||
|
|
07b84586b6 | ||
|
|
5267eb6ab1 | ||
|
|
5daa64d962 | ||
|
|
b939f4d4f3 | ||
|
|
8e04cc97ba | ||
|
|
5b66e1907c | ||
|
|
55bea1a923 | ||
|
|
83bfe51282 |
17
.editorconfig
Normal file
@@ -0,0 +1,17 @@
|
||||
# Editor configuration, see https://editorconfig.org
|
||||
root = true
|
||||
|
||||
[*]
|
||||
charset = utf-8
|
||||
indent_style = space
|
||||
indent_size = 2
|
||||
insert_final_newline = true
|
||||
trim_trailing_whitespace = true
|
||||
|
||||
[*.ts]
|
||||
quote_type = single
|
||||
ij_typescript_use_double_quotes = false
|
||||
|
||||
[*.md]
|
||||
max_line_length = off
|
||||
trim_trailing_whitespace = false
|
||||
245
.gitignore
vendored
Normal file
@@ -0,0 +1,245 @@
|
||||
# Created by https://www.toptal.com/developers/gitignore/api/angular,sonarqube,node,visualstudiocode,sass,yarn,bazel
|
||||
# Edit at https://www.toptal.com/developers/gitignore?templates=angular,sonarqube,node,visualstudiocode,sass,yarn,bazel
|
||||
|
||||
### Angular ###
|
||||
## Angular ##
|
||||
# compiled output
|
||||
dist/
|
||||
tmp/
|
||||
app/**/*.js
|
||||
app/**/*.js.map
|
||||
|
||||
# dependencies
|
||||
node_modules/
|
||||
bower_components/
|
||||
|
||||
# IDEs and editors
|
||||
.idea/
|
||||
|
||||
# misc
|
||||
.sass-cache/
|
||||
connect.lock/
|
||||
coverage/
|
||||
libpeerconnection.log/
|
||||
npm-debug.log
|
||||
testem.log
|
||||
typings/
|
||||
.angular/
|
||||
|
||||
# e2e
|
||||
e2e/*.js
|
||||
e2e/*.map
|
||||
|
||||
# System Files
|
||||
.DS_Store/
|
||||
|
||||
### Bazel ###
|
||||
# gitignore template for Bazel build system
|
||||
# website: https://bazel.build/
|
||||
|
||||
# Ignore all bazel-* symlinks. There is no full list since this can change
|
||||
# based on the name of the directory bazel is cloned into.
|
||||
/bazel-*
|
||||
|
||||
# Directories for the Bazel IntelliJ plugin containing the generated
|
||||
# IntelliJ project files and plugin configuration. Seperate directories are
|
||||
# for the IntelliJ, Android Studio and CLion versions of the plugin.
|
||||
/.ijwb/
|
||||
/.aswb/
|
||||
/.clwb/
|
||||
|
||||
### Node ###
|
||||
# Logs
|
||||
logs
|
||||
*.log
|
||||
npm-debug.log*
|
||||
yarn-debug.log*
|
||||
yarn-error.log*
|
||||
lerna-debug.log*
|
||||
.pnpm-debug.log*
|
||||
|
||||
# Diagnostic reports (https://nodejs.org/api/report.html)
|
||||
report.[0-9]*.[0-9]*.[0-9]*.[0-9]*.json
|
||||
|
||||
# Runtime data
|
||||
pids
|
||||
*.pid
|
||||
*.seed
|
||||
*.pid.lock
|
||||
|
||||
# Directory for instrumented libs generated by jscoverage/JSCover
|
||||
lib-cov
|
||||
|
||||
# Coverage directory used by tools like istanbul
|
||||
coverage
|
||||
*.lcov
|
||||
|
||||
# nyc test coverage
|
||||
.nyc_output
|
||||
|
||||
# Grunt intermediate storage (https://gruntjs.com/creating-plugins#storing-task-files)
|
||||
.grunt
|
||||
|
||||
# Bower dependency directory (https://bower.io/)
|
||||
bower_components
|
||||
|
||||
# node-waf configuration
|
||||
.lock-wscript
|
||||
|
||||
# Compiled binary addons (https://nodejs.org/api/addons.html)
|
||||
build/Release
|
||||
|
||||
# Dependency directories
|
||||
jspm_packages/
|
||||
|
||||
# Snowpack dependency directory (https://snowpack.dev/)
|
||||
web_modules/
|
||||
|
||||
# TypeScript cache
|
||||
*.tsbuildinfo
|
||||
|
||||
# Optional npm cache directory
|
||||
.npm
|
||||
|
||||
# Optional eslint cache
|
||||
.eslintcache
|
||||
|
||||
# Optional stylelint cache
|
||||
.stylelintcache
|
||||
|
||||
# Microbundle cache
|
||||
.rpt2_cache/
|
||||
.rts2_cache_cjs/
|
||||
.rts2_cache_es/
|
||||
.rts2_cache_umd/
|
||||
|
||||
# Optional REPL history
|
||||
.node_repl_history
|
||||
|
||||
# Output of 'npm pack'
|
||||
*.tgz
|
||||
|
||||
# Yarn Integrity file
|
||||
.yarn-integrity
|
||||
|
||||
# dotenv environment variable files
|
||||
.env
|
||||
.env.development.local
|
||||
.env.test.local
|
||||
.env.production.local
|
||||
.env.local
|
||||
|
||||
# parcel-bundler cache (https://parceljs.org/)
|
||||
.cache
|
||||
.parcel-cache
|
||||
|
||||
# Next.js build output
|
||||
.next
|
||||
out
|
||||
|
||||
# Nuxt.js build / generate output
|
||||
.nuxt
|
||||
dist
|
||||
|
||||
# Gatsby files
|
||||
.cache/
|
||||
# Comment in the public line in if your project uses Gatsby and not Next.js
|
||||
# https://nextjs.org/blog/next-9-1#public-directory-support
|
||||
# public
|
||||
|
||||
# vuepress build output
|
||||
.vuepress/dist
|
||||
|
||||
# vuepress v2.x temp and cache directory
|
||||
.temp
|
||||
|
||||
# Docusaurus cache and generated files
|
||||
.docusaurus
|
||||
|
||||
# Serverless directories
|
||||
.serverless/
|
||||
|
||||
# FuseBox cache
|
||||
.fusebox/
|
||||
|
||||
# DynamoDB Local files
|
||||
.dynamodb/
|
||||
|
||||
# TernJS port file
|
||||
.tern-port
|
||||
|
||||
# Stores VSCode versions used for testing VSCode extensions
|
||||
.vscode-test
|
||||
|
||||
# yarn v2
|
||||
.yarn/cache
|
||||
.yarn/unplugged
|
||||
.yarn/build-state.yml
|
||||
.yarn/install-state.gz
|
||||
.pnp.*
|
||||
|
||||
### Node Patch ###
|
||||
# Serverless Webpack directories
|
||||
.webpack/
|
||||
|
||||
# Optional stylelint cache
|
||||
|
||||
# SvelteKit build / generate output
|
||||
.svelte-kit
|
||||
|
||||
### Sass ###
|
||||
*.css.map
|
||||
*.sass.map
|
||||
*.scss.map
|
||||
|
||||
### SonarQube ###
|
||||
# SonarQube ignore files.
|
||||
#
|
||||
# https://docs.sonarqube.org/display/SCAN/Analyzing+with+SonarQube+Scanner
|
||||
# Sonar Scanner working directories
|
||||
.sonar/
|
||||
.sonarqube/
|
||||
.scannerwork/
|
||||
|
||||
# http://www.sonarlint.org/commandline/
|
||||
# SonarLint working directories, configuration files (including credentials)
|
||||
.sonarlint/
|
||||
|
||||
### VisualStudioCode ###
|
||||
.vscode/*
|
||||
!.vscode/settings.json
|
||||
!.vscode/tasks.json
|
||||
!.vscode/launch.json
|
||||
!.vscode/extensions.json
|
||||
!.vscode/*.code-snippets
|
||||
|
||||
# Local History for Visual Studio Code
|
||||
.history/
|
||||
|
||||
# Built Visual Studio Code Extensions
|
||||
*.vsix
|
||||
|
||||
### VisualStudioCode Patch ###
|
||||
# Ignore all local history of files
|
||||
.history
|
||||
.ionide
|
||||
|
||||
### yarn ###
|
||||
# https://yarnpkg.com/getting-started/qa#which-files-should-be-gitignored
|
||||
|
||||
.yarn/*
|
||||
!.yarn/releases
|
||||
!.yarn/patches
|
||||
!.yarn/plugins
|
||||
!.yarn/sdks
|
||||
!.yarn/versions
|
||||
|
||||
# if you are NOT using Zero-installs, then:
|
||||
# comment the following lines
|
||||
!.yarn/cache
|
||||
|
||||
# and uncomment the following lines
|
||||
# .pnp.*
|
||||
|
||||
# End of https://www.toptal.com/developers/gitignore/api/angular,sonarqube,node,visualstudiocode,sass,yarn,bazel
|
||||
|
||||
4
.vscode/extensions.json
vendored
Normal file
@@ -0,0 +1,4 @@
|
||||
{
|
||||
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=827846
|
||||
"recommendations": ["angular.ng-template"]
|
||||
}
|
||||
20
.vscode/launch.json
vendored
Normal file
@@ -0,0 +1,20 @@
|
||||
{
|
||||
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
|
||||
"version": "0.2.0",
|
||||
"configurations": [
|
||||
{
|
||||
"name": "ng serve",
|
||||
"type": "chrome",
|
||||
"request": "launch",
|
||||
"preLaunchTask": "npm: start",
|
||||
"url": "http://localhost:4200/"
|
||||
},
|
||||
{
|
||||
"name": "ng test",
|
||||
"type": "chrome",
|
||||
"request": "launch",
|
||||
"preLaunchTask": "npm: test",
|
||||
"url": "http://localhost:9876/debug.html"
|
||||
}
|
||||
]
|
||||
}
|
||||
42
.vscode/tasks.json
vendored
Normal file
@@ -0,0 +1,42 @@
|
||||
{
|
||||
// For more information, visit: https://go.microsoft.com/fwlink/?LinkId=733558
|
||||
"version": "2.0.0",
|
||||
"tasks": [
|
||||
{
|
||||
"type": "npm",
|
||||
"script": "start",
|
||||
"isBackground": true,
|
||||
"problemMatcher": {
|
||||
"owner": "typescript",
|
||||
"pattern": "$tsc",
|
||||
"background": {
|
||||
"activeOnStart": true,
|
||||
"beginsPattern": {
|
||||
"regexp": "(.*?)"
|
||||
},
|
||||
"endsPattern": {
|
||||
"regexp": "bundle generation complete"
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
"type": "npm",
|
||||
"script": "test",
|
||||
"isBackground": true,
|
||||
"problemMatcher": {
|
||||
"owner": "typescript",
|
||||
"pattern": "$tsc",
|
||||
"background": {
|
||||
"activeOnStart": true,
|
||||
"beginsPattern": {
|
||||
"regexp": "(.*?)"
|
||||
},
|
||||
"endsPattern": {
|
||||
"regexp": "bundle generation complete"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
33
README.md
Normal file
@@ -0,0 +1,33 @@
|
||||
# Vb
|
||||
A Team Randomizer built using Angular and Bootstrap, installable as a progressive web app (PWA).
|
||||
Supports setting names using URL query parameters:
|
||||
```url
|
||||
https://vb.example.org?names=Me,Myself,I
|
||||
```
|
||||
|
||||
## Development
|
||||
|
||||
To start a local development server, run:
|
||||
|
||||
```bash
|
||||
ng serve
|
||||
```
|
||||
|
||||
Once the server is running, open your browser and navigate to `http://localhost:4200/`. The application will automatically reload whenever you modify any of the source files.
|
||||
|
||||
Alternatively, to open the server to the network instead of just localhost, use
|
||||
|
||||
```bash
|
||||
npm run serve
|
||||
```
|
||||
|
||||
## Building
|
||||
|
||||
To build the project run:
|
||||
|
||||
```bash
|
||||
ng build
|
||||
```
|
||||
|
||||
This will compile your project and store the build artifacts in the `dist/` directory.
|
||||
As this is a static site, simply move the contents of `dist/vb/browser/` to a directory that can be served by nginx or apache.
|
||||
112
angular.json
Normal file
@@ -0,0 +1,112 @@
|
||||
{
|
||||
"$schema": "./node_modules/@angular/cli/lib/config/schema.json",
|
||||
"version": 1,
|
||||
"newProjectRoot": "projects",
|
||||
"projects": {
|
||||
"vb": {
|
||||
"projectType": "application",
|
||||
"schematics": {
|
||||
"@schematics/angular:component": {
|
||||
"style": "less"
|
||||
}
|
||||
},
|
||||
"root": "",
|
||||
"sourceRoot": "src",
|
||||
"prefix": "app",
|
||||
"architect": {
|
||||
"build": {
|
||||
"builder": "@angular-devkit/build-angular:application",
|
||||
"options": {
|
||||
"outputPath": "dist/vb",
|
||||
"index": "src/index.html",
|
||||
"browser": "src/main.ts",
|
||||
"polyfills": [
|
||||
"zone.js",
|
||||
"@angular/localize/init"
|
||||
],
|
||||
"tsConfig": "tsconfig.app.json",
|
||||
"inlineStyleLanguage": "less",
|
||||
"assets": [
|
||||
{
|
||||
"glob": "**/*",
|
||||
"input": "public"
|
||||
},
|
||||
"src/sw.js"
|
||||
],
|
||||
"styles": [
|
||||
"node_modules/bootstrap/dist/css/bootstrap.min.css",
|
||||
"src/styles.less"
|
||||
],
|
||||
"scripts": [],
|
||||
"server": "src/main.server.ts",
|
||||
"prerender": true,
|
||||
"ssr": {
|
||||
"entry": "src/server.ts"
|
||||
}
|
||||
},
|
||||
"configurations": {
|
||||
"production": {
|
||||
"budgets": [
|
||||
{
|
||||
"type": "initial",
|
||||
"maximumWarning": "500kB",
|
||||
"maximumError": "1MB"
|
||||
},
|
||||
{
|
||||
"type": "anyComponentStyle",
|
||||
"maximumWarning": "4kB",
|
||||
"maximumError": "8kB"
|
||||
}
|
||||
],
|
||||
"outputHashing": "all",
|
||||
"serviceWorker": "ngsw-config.json"
|
||||
},
|
||||
"development": {
|
||||
"optimization": false,
|
||||
"extractLicenses": false,
|
||||
"sourceMap": true
|
||||
}
|
||||
},
|
||||
"defaultConfiguration": "production"
|
||||
},
|
||||
"serve": {
|
||||
"builder": "@angular-devkit/build-angular:dev-server",
|
||||
"configurations": {
|
||||
"production": {
|
||||
"buildTarget": "vb:build:production"
|
||||
},
|
||||
"development": {
|
||||
"buildTarget": "vb:build:development"
|
||||
}
|
||||
},
|
||||
"defaultConfiguration": "development"
|
||||
},
|
||||
"extract-i18n": {
|
||||
"builder": "@angular-devkit/build-angular:extract-i18n"
|
||||
},
|
||||
"test": {
|
||||
"builder": "@angular-devkit/build-angular:karma",
|
||||
"options": {
|
||||
"polyfills": [
|
||||
"zone.js",
|
||||
"zone.js/testing",
|
||||
"@angular/localize/init"
|
||||
],
|
||||
"tsConfig": "tsconfig.spec.json",
|
||||
"inlineStyleLanguage": "less",
|
||||
"assets": [
|
||||
{
|
||||
"glob": "**/*",
|
||||
"input": "public"
|
||||
}
|
||||
],
|
||||
"styles": [
|
||||
"src/styles.less"
|
||||
],
|
||||
"scripts": []
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
52
index.html
@@ -1,52 +0,0 @@
|
||||
<!DOCTYPE html>
|
||||
<html><head>
|
||||
<meta http-equiv="content-type" content="text/html; charset=windows-1252">
|
||||
<title>Volleyball Team Randomizer</title>
|
||||
<link rel="stylesheet" href="style.css">
|
||||
<script src="script.js"></script>
|
||||
</head>
|
||||
<body>
|
||||
|
||||
|
||||
<h1>Please select the number of teams:</h1>
|
||||
|
||||
|
||||
<label class="radioButtons" for="twoTeams">
|
||||
<input class="radioButtons" type="radio" name="teams" id="twoTeams" checked="checked">
|
||||
Two teams
|
||||
</label>
|
||||
|
||||
|
||||
<label class="radioButtons" for="threeTeams">
|
||||
<input class="radioButtons" type="radio" name="teams" id="threeTeams">
|
||||
Three teams
|
||||
</label>
|
||||
|
||||
<label class="radioButtons" for="nTeams">
|
||||
<input class="radioButtons" type="radio" name="teams" id="nTeams">
|
||||
n Teams
|
||||
|
||||
</label>
|
||||
<input id="nTeamsTextField" style="display: none;" type="number" value=4>
|
||||
|
||||
<br>
|
||||
<h1>Enter player names (each row represents one player)</h1>
|
||||
|
||||
<textarea rows="18" cols="30" name="playerNames" required="required" id="playerNames"></textarea>
|
||||
|
||||
<br>
|
||||
<button id="generateTeams" onclick="randomizeTeams()">Generate Teams</button>
|
||||
|
||||
|
||||
<p id="teamOutput"></p>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
</body></html>
|
||||
30
ngsw-config.json
Normal file
@@ -0,0 +1,30 @@
|
||||
{
|
||||
"$schema": "./node_modules/@angular/service-worker/config/schema.json",
|
||||
"index": "/index.html",
|
||||
"assetGroups": [
|
||||
{
|
||||
"name": "app",
|
||||
"installMode": "prefetch",
|
||||
"resources": {
|
||||
"files": [
|
||||
"/favicon.ico",
|
||||
"/index.csr.html",
|
||||
"/index.html",
|
||||
"/manifest.webmanifest",
|
||||
"/*.css",
|
||||
"/*.js"
|
||||
]
|
||||
}
|
||||
},
|
||||
{
|
||||
"name": "assets",
|
||||
"installMode": "lazy",
|
||||
"updateMode": "prefetch",
|
||||
"resources": {
|
||||
"files": [
|
||||
"/**/*.(svg|cur|jpg|jpeg|png|apng|webp|avif|gif|otf|ttf|woff|woff2)"
|
||||
]
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
15350
package-lock.json
generated
Normal file
53
package.json
Normal file
@@ -0,0 +1,53 @@
|
||||
{
|
||||
"name": "vb",
|
||||
"version": "1.0.0",
|
||||
"scripts": {
|
||||
"ng": "ng",
|
||||
"start": "ng serve",
|
||||
"build": "ng build",
|
||||
"watch": "ng build --watch --configuration development",
|
||||
"test": "ng test",
|
||||
"serve": "ng serve --host 0.0.0.0 --port 4200",
|
||||
"serve:ssr:vb": "node dist/vb/server/server.mjs"
|
||||
},
|
||||
"private": true,
|
||||
"dependencies": {
|
||||
"@angular/animations": "^19.2.7",
|
||||
"@angular/cdk": "~19.2.10",
|
||||
"@angular/common": "^19.2.7",
|
||||
"@angular/compiler": "^19.2.7",
|
||||
"@angular/core": "^19.2.7",
|
||||
"@angular/forms": "^19.2.7",
|
||||
"@angular/platform-browser": "^19.2.7",
|
||||
"@angular/platform-browser-dynamic": "^19.2.7",
|
||||
"@angular/platform-server": "^19.2.7",
|
||||
"@angular/router": "^19.2.7",
|
||||
"@angular/service-worker": "^19.2.7",
|
||||
"@angular/ssr": "^19.2.9",
|
||||
"@ng-bootstrap/ng-bootstrap": "^18.0.0",
|
||||
"@popperjs/core": "^2.11.8",
|
||||
"bootstrap": "^5.3.3",
|
||||
"express": "^4.18.2",
|
||||
"rxjs": "~7.8.0",
|
||||
"sonarqube-scanner": "^4.3.0",
|
||||
"tslib": "^2.3.0",
|
||||
"zone.js": "~0.15.0"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@angular-devkit/build-angular": "^19.2.9",
|
||||
"@angular/cli": "^19.2.9",
|
||||
"@angular/compiler-cli": "^19.2.7",
|
||||
"@angular/localize": "^19.2.7",
|
||||
"@sonar/scan": "^4.3.0",
|
||||
"@types/express": "^4.17.17",
|
||||
"@types/jasmine": "~5.1.0",
|
||||
"@types/node": "^18.18.0",
|
||||
"jasmine-core": "~5.4.0",
|
||||
"karma": "~6.4.0",
|
||||
"karma-chrome-launcher": "~3.2.0",
|
||||
"karma-coverage": "~2.2.0",
|
||||
"karma-jasmine": "~5.1.0",
|
||||
"karma-jasmine-html-reporter": "~2.1.0",
|
||||
"typescript": "~5.6.2"
|
||||
}
|
||||
}
|
||||
BIN
public/favicon.ico
Normal file
|
After Width: | Height: | Size: 9.4 KiB |
BIN
public/icons/icon-128x128.png
Normal file
|
After Width: | Height: | Size: 9.8 KiB |
BIN
public/icons/icon-144x144.png
Normal file
|
After Width: | Height: | Size: 11 KiB |
BIN
public/icons/icon-152x152.png
Normal file
|
After Width: | Height: | Size: 12 KiB |
BIN
public/icons/icon-192x192.png
Normal file
|
After Width: | Height: | Size: 15 KiB |
BIN
public/icons/icon-384x384.png
Normal file
|
After Width: | Height: | Size: 32 KiB |
BIN
public/icons/icon-512x512.png
Normal file
|
After Width: | Height: | Size: 28 KiB |
BIN
public/icons/icon-72x72.png
Normal file
|
After Width: | Height: | Size: 5.3 KiB |
BIN
public/icons/icon-96x96.png
Normal file
|
After Width: | Height: | Size: 7.2 KiB |
59
public/manifest.webmanifest
Normal file
@@ -0,0 +1,59 @@
|
||||
{
|
||||
"name": "vb",
|
||||
"short_name": "vb",
|
||||
"theme_color": "#1976d2",
|
||||
"background_color": "#fafafa",
|
||||
"display": "standalone",
|
||||
"scope": "./",
|
||||
"start_url": "./",
|
||||
"icons": [
|
||||
{
|
||||
"src": "icons/icon-72x72.png",
|
||||
"sizes": "72x72",
|
||||
"type": "image/png",
|
||||
"purpose": "maskable any"
|
||||
},
|
||||
{
|
||||
"src": "icons/icon-96x96.png",
|
||||
"sizes": "96x96",
|
||||
"type": "image/png",
|
||||
"purpose": "maskable any"
|
||||
},
|
||||
{
|
||||
"src": "icons/icon-128x128.png",
|
||||
"sizes": "128x128",
|
||||
"type": "image/png",
|
||||
"purpose": "maskable any"
|
||||
},
|
||||
{
|
||||
"src": "icons/icon-144x144.png",
|
||||
"sizes": "144x144",
|
||||
"type": "image/png",
|
||||
"purpose": "maskable any"
|
||||
},
|
||||
{
|
||||
"src": "icons/icon-152x152.png",
|
||||
"sizes": "152x152",
|
||||
"type": "image/png",
|
||||
"purpose": "maskable any"
|
||||
},
|
||||
{
|
||||
"src": "icons/icon-192x192.png",
|
||||
"sizes": "192x192",
|
||||
"type": "image/png",
|
||||
"purpose": "maskable any"
|
||||
},
|
||||
{
|
||||
"src": "icons/icon-384x384.png",
|
||||
"sizes": "384x384",
|
||||
"type": "image/png",
|
||||
"purpose": "maskable any"
|
||||
},
|
||||
{
|
||||
"src": "icons/icon-512x512.png",
|
||||
"sizes": "512x512",
|
||||
"type": "image/png",
|
||||
"purpose": "maskable any"
|
||||
}
|
||||
]
|
||||
}
|
||||
68
script.js
@@ -1,68 +0,0 @@
|
||||
|
||||
|
||||
function randomizeTeams() {
|
||||
let teamCount = 2;
|
||||
if(document.getElementById("threeTeams").checked){
|
||||
teamCount = 3;
|
||||
}
|
||||
if(document.getElementById("nTeams").checked){
|
||||
teamCount = document.getElementById("nTeamsTextField").value;
|
||||
}
|
||||
const outputField = document.getElementById("teamOutput");
|
||||
let textinput = document.getElementById("playerNames").value;
|
||||
let names = textinput
|
||||
.split('\n')
|
||||
.map(function(str){return str.trim();})
|
||||
.filter(function(str){return str}); // boolean interpretation is same as non-empty
|
||||
// remove duplicates by using a Set
|
||||
names = [...new Set(names)];
|
||||
|
||||
teams = Array.from({ length: teamCount }, () => []);
|
||||
playersPerTeam = Math.floor(names.length / teamCount);
|
||||
|
||||
let nameslen = names.length;
|
||||
iterator = iter(teams);
|
||||
for(let i =0; i < nameslen; i++){
|
||||
index = Math.floor(Math.random()* names.length);
|
||||
n = names[index];
|
||||
names.splice(index,1);
|
||||
team = iterator.next().value;
|
||||
team.push(n);
|
||||
|
||||
}
|
||||
|
||||
outputField.innerHTML = teamstotext(teams)
|
||||
}
|
||||
function teamstotext(teams){
|
||||
textinput = "";
|
||||
for(let i =0; i < teams.length; i++){
|
||||
textinput += `Team${i+1}(${teams[i].length}) :${teamtotext(teams[i])} <br>`;
|
||||
}
|
||||
return textinput;
|
||||
}
|
||||
|
||||
function teamtotext(team){
|
||||
return team;
|
||||
}
|
||||
|
||||
function* iter(list){
|
||||
let index = 0;
|
||||
while(true){
|
||||
yield list[index % list.length];
|
||||
index++;
|
||||
}
|
||||
}
|
||||
|
||||
function textchangelistener(){
|
||||
let elem = document.getElementById("nTeamsTextField");
|
||||
if(this.checked && this.id == "nTeams"){
|
||||
elem.style.display = "block";
|
||||
}
|
||||
else {
|
||||
elem.style.display = "none";
|
||||
}
|
||||
}
|
||||
document.addEventListener('DOMContentLoaded', () => {
|
||||
buttons = document.querySelectorAll("input[type='radio']");
|
||||
buttons.forEach((x) => x.addEventListener("change", textchangelistener));
|
||||
});
|
||||
59
src/app/app.component.html
Normal file
@@ -0,0 +1,59 @@
|
||||
<main class="main">
|
||||
<div class="row justify-content-md-center">
|
||||
<h1>Please select the number of teams:</h1>
|
||||
<div class="btn-toolbar mb-3 col justify-content-center" role="toolbar">
|
||||
<div class="btn-group me-2" id="numTeamsSelector" role="group"
|
||||
value="2">
|
||||
<input value="2" [(ngModel)]="numTeamsSelectorValue" type="radio" class="btn-check" name="btnradio" id="btnradio1" autocomplete="off" checked>
|
||||
<label class="btn btn-outline-primary" for="btnradio1">Two</label>
|
||||
|
||||
<input value="3" [(ngModel)]="numTeamsSelectorValue" type="radio" class="btn-check" name="btnradio" id="btnradio2" autocomplete="off">
|
||||
<label class="btn btn-outline-primary" for="btnradio2">Three</label>
|
||||
|
||||
<input value="n" [(ngModel)]="numTeamsSelectorValue" type="radio" class="btn-check" name="btnradio" id="btnradio3" autocomplete="off">
|
||||
<label class="btn btn-outline-primary" for="btnradio3">n</label>
|
||||
</div>
|
||||
<div *ngIf="numTeamsSelectorValue === 'n'" id="nTeamsText" class="col-md-auto">
|
||||
<label for="nTeamsField">n Teams</label>
|
||||
<input type="number" pattern="\d*" [(ngModel)]="nTeamsValue" id="nTeamsField" class="form-control" >
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<form>
|
||||
<div class="container">
|
||||
<label for="playerNames">Names</label>
|
||||
<textarea [(ngModel)]="playerNamesValue"
|
||||
class="form-control mb-3"
|
||||
rows="18"
|
||||
cols="30"
|
||||
style="text-align: left;"
|
||||
name="playerNames"
|
||||
#playerNames
|
||||
id="playerNames"
|
||||
></textarea>
|
||||
</div>
|
||||
<button type="button" (click)="onButtonGenerate(playerNames.value)" class="btn btn-primary">Generate</button>
|
||||
</form>
|
||||
|
||||
<table class="table table-striped custom-table">
|
||||
<caption *ngIf="duplicateNames.length >0">Removed: {{ duplicateNames }}</caption>
|
||||
<thead>
|
||||
<tr>
|
||||
<th scope="col">Size</th>
|
||||
<th scope="col">Names</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
@for (team of teamsArray; track $index) {
|
||||
<tr>
|
||||
<td style="text-wrap: wrap;">{{ team.length | number }}</td>
|
||||
<td class="wrap-cell">{{ team }}</td>
|
||||
</tr>
|
||||
}
|
||||
</tbody>
|
||||
</table>
|
||||
|
||||
</div>
|
||||
</main>
|
||||
|
||||
<router-outlet />
|
||||
18
src/app/app.component.less
Normal file
@@ -0,0 +1,18 @@
|
||||
html, body{
|
||||
max-width: 100%;
|
||||
overflow-x: hidden;
|
||||
}
|
||||
*{
|
||||
text-align: center;
|
||||
}
|
||||
.custom-table {
|
||||
//table-layout: fixed;
|
||||
max-width: 100%;
|
||||
}
|
||||
tr{
|
||||
padding-right: .2em;
|
||||
}
|
||||
.wrap-cell{
|
||||
word-break: break-all;
|
||||
white-space: normal;
|
||||
}
|
||||
29
src/app/app.component.spec.ts
Normal file
@@ -0,0 +1,29 @@
|
||||
import { TestBed } from '@angular/core/testing';
|
||||
import { AppComponent } from './app.component';
|
||||
|
||||
describe('AppComponent', () => {
|
||||
beforeEach(async () => {
|
||||
await TestBed.configureTestingModule({
|
||||
imports: [AppComponent],
|
||||
}).compileComponents();
|
||||
});
|
||||
|
||||
it('should create the app', () => {
|
||||
const fixture = TestBed.createComponent(AppComponent);
|
||||
const app = fixture.componentInstance;
|
||||
expect(app).toBeTruthy();
|
||||
});
|
||||
|
||||
it(`should have the 'vb' title`, () => {
|
||||
const fixture = TestBed.createComponent(AppComponent);
|
||||
const app = fixture.componentInstance;
|
||||
expect(app.title).toEqual('vb');
|
||||
});
|
||||
|
||||
it('should render title', () => {
|
||||
const fixture = TestBed.createComponent(AppComponent);
|
||||
fixture.detectChanges();
|
||||
const compiled = fixture.nativeElement as HTMLElement;
|
||||
expect(compiled.querySelector('h1')?.textContent).toContain('Hello, vb');
|
||||
});
|
||||
});
|
||||
73
src/app/app.component.ts
Normal file
@@ -0,0 +1,73 @@
|
||||
import { AfterViewInit, Component, OnInit} from '@angular/core';
|
||||
import { FormsModule } from '@angular/forms';
|
||||
import { RouterOutlet, ActivatedRoute } from '@angular/router';
|
||||
import { NgbModule } from '@ng-bootstrap/ng-bootstrap';
|
||||
|
||||
import { CommonModule } from '@angular/common';
|
||||
|
||||
@Component({
|
||||
selector: 'app-root',
|
||||
imports: [NgbModule, RouterOutlet, CommonModule, FormsModule],
|
||||
templateUrl: './app.component.html',
|
||||
styleUrl: './app.component.less'
|
||||
})
|
||||
export class AppComponent implements OnInit {
|
||||
title = 'vb';
|
||||
playerNamesValue = "";
|
||||
numTeamsSelectorValue = "2";
|
||||
numTeamsSelected = 2;
|
||||
nTeamsValue = "4";
|
||||
teamsArray: string[][] = [];
|
||||
duplicateNames: string[] = [];
|
||||
|
||||
constructor(private activatedRoute: ActivatedRoute){}
|
||||
|
||||
ngOnInit(): void {
|
||||
this.activatedRoute.queryParams.subscribe(params => {
|
||||
const names = params['names']?.replaceAll(',', '\n');
|
||||
if (names) {
|
||||
this.playerNamesValue = names;
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
onButtonGenerate(textinput: string): void{
|
||||
if(this.numTeamsSelectorValue === 'n'){
|
||||
this.numTeamsSelected = Number(this.nTeamsValue);
|
||||
}
|
||||
else{
|
||||
this.numTeamsSelected = Number(this.numTeamsSelectorValue);
|
||||
}
|
||||
let nameslist = this.playerNamesValue
|
||||
.split('\n')
|
||||
.map(function(str){return str.trim();})
|
||||
.filter(function(str){return str}); // boolean interpretation is same as non-empty
|
||||
// remove duplicates by using a Set
|
||||
let namesset = new Set(nameslist);
|
||||
let names = [...namesset];
|
||||
|
||||
|
||||
var teams = Array.from({ length: this.numTeamsSelected }, () => []);
|
||||
var playersPerTeam = Math.floor(names.length / this.numTeamsSelected);
|
||||
|
||||
let nameslen = names.length;
|
||||
function* iter(list: any[]){
|
||||
let index = 0;
|
||||
while(true){
|
||||
yield list[index % list.length];
|
||||
index++;
|
||||
}
|
||||
}
|
||||
var iterator = iter(teams);
|
||||
for(let i =0; i < nameslen; i++){
|
||||
var index = Math.floor(Math.random()* names.length);
|
||||
var n = names[index];
|
||||
names.splice(index,1);
|
||||
var team = iterator.next().value;
|
||||
team.push(n);
|
||||
|
||||
}
|
||||
this.teamsArray = teams;
|
||||
}
|
||||
|
||||
}
|
||||
11
src/app/app.config.server.ts
Normal file
@@ -0,0 +1,11 @@
|
||||
import { mergeApplicationConfig, ApplicationConfig } from '@angular/core';
|
||||
import { provideServerRendering } from '@angular/platform-server';
|
||||
import { appConfig } from './app.config';
|
||||
|
||||
const serverConfig: ApplicationConfig = {
|
||||
providers: [
|
||||
provideServerRendering(),
|
||||
]
|
||||
};
|
||||
|
||||
export const config = mergeApplicationConfig(appConfig, serverConfig);
|
||||
13
src/app/app.config.ts
Normal file
@@ -0,0 +1,13 @@
|
||||
import { ApplicationConfig, provideZoneChangeDetection, isDevMode } from '@angular/core';
|
||||
import { provideRouter } from '@angular/router';
|
||||
|
||||
import { routes } from './app.routes';
|
||||
import { provideAnimationsAsync } from '@angular/platform-browser/animations/async';
|
||||
import { provideServiceWorker } from '@angular/service-worker';
|
||||
|
||||
export const appConfig: ApplicationConfig = {
|
||||
providers: [provideZoneChangeDetection({ eventCoalescing: true }), provideRouter(routes), provideAnimationsAsync('noop'), provideServiceWorker('./sw.js', {
|
||||
enabled: !isDevMode(),
|
||||
registrationStrategy: 'registerWhenStable:30000'
|
||||
})]
|
||||
};
|
||||
3
src/app/app.routes.ts
Normal file
@@ -0,0 +1,3 @@
|
||||
import { Routes } from '@angular/router';
|
||||
|
||||
export const routes: Routes = [];
|
||||
16
src/index.html
Normal file
@@ -0,0 +1,16 @@
|
||||
<!doctype html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<title>Volleyball Team Randomizer</title>
|
||||
<base href="/">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1">
|
||||
<link rel="icon" type="image/x-icon" href="favicon.ico">
|
||||
<link rel="manifest" href="manifest.webmanifest">
|
||||
<meta name="theme-color" content="#1976d2">
|
||||
</head>
|
||||
<body>
|
||||
<app-root></app-root>
|
||||
<noscript>Please enable JavaScript to continue using this application.</noscript>
|
||||
</body>
|
||||
</html>
|
||||
7
src/main.server.ts
Normal file
@@ -0,0 +1,7 @@
|
||||
import { bootstrapApplication } from '@angular/platform-browser';
|
||||
import { AppComponent } from './app/app.component';
|
||||
import { config } from './app/app.config.server';
|
||||
|
||||
const bootstrap = () => bootstrapApplication(AppComponent, config);
|
||||
|
||||
export default bootstrap;
|
||||
8
src/main.ts
Normal file
@@ -0,0 +1,8 @@
|
||||
/// <reference types="@angular/localize" />
|
||||
|
||||
import { bootstrapApplication } from '@angular/platform-browser';
|
||||
import { appConfig } from './app/app.config';
|
||||
import { AppComponent } from './app/app.component';
|
||||
|
||||
bootstrapApplication(AppComponent, appConfig)
|
||||
.catch((err) => console.error(err));
|
||||
65
src/server.ts
Normal file
@@ -0,0 +1,65 @@
|
||||
import { APP_BASE_HREF } from '@angular/common';
|
||||
import { CommonEngine, isMainModule } from '@angular/ssr/node';
|
||||
import express from 'express';
|
||||
import { dirname, join, resolve } from 'node:path';
|
||||
import { fileURLToPath } from 'node:url';
|
||||
import bootstrap from './main.server';
|
||||
|
||||
const serverDistFolder = dirname(fileURLToPath(import.meta.url));
|
||||
const browserDistFolder = resolve(serverDistFolder, '../browser');
|
||||
const indexHtml = join(serverDistFolder, 'index.server.html');
|
||||
|
||||
const app = express();
|
||||
const commonEngine = new CommonEngine();
|
||||
|
||||
/**
|
||||
* Example Express Rest API endpoints can be defined here.
|
||||
* Uncomment and define endpoints as necessary.
|
||||
*
|
||||
* Example:
|
||||
* ```ts
|
||||
* app.get('/api/**', (req, res) => {
|
||||
* // Handle API request
|
||||
* });
|
||||
* ```
|
||||
*/
|
||||
|
||||
/**
|
||||
* Serve static files from /browser
|
||||
*/
|
||||
app.get(
|
||||
'**',
|
||||
express.static(browserDistFolder, {
|
||||
maxAge: '1y',
|
||||
index: 'index.html'
|
||||
}),
|
||||
);
|
||||
|
||||
/**
|
||||
* Handle all other requests by rendering the Angular application.
|
||||
*/
|
||||
app.get('**', (req, res, next) => {
|
||||
const { protocol, originalUrl, baseUrl, headers } = req;
|
||||
|
||||
commonEngine
|
||||
.render({
|
||||
bootstrap,
|
||||
documentFilePath: indexHtml,
|
||||
url: `${protocol}://${headers.host}${originalUrl}`,
|
||||
publicPath: browserDistFolder,
|
||||
providers: [{ provide: APP_BASE_HREF, useValue: baseUrl }],
|
||||
})
|
||||
.then((html) => res.send(html))
|
||||
.catch((err) => next(err));
|
||||
});
|
||||
|
||||
/**
|
||||
* Start the server if this module is the main entry point.
|
||||
* The server listens on the port defined by the `PORT` environment variable, or defaults to 4000.
|
||||
*/
|
||||
if (isMainModule(import.meta.url)) {
|
||||
const port = process.env['PORT'] || 4000;
|
||||
app.listen(port, () => {
|
||||
console.log(`Node Express server listening on http://localhost:${port}`);
|
||||
});
|
||||
}
|
||||
17
src/styles.less
Normal file
@@ -0,0 +1,17 @@
|
||||
/* You can add global styles to this file, and also import other style files */
|
||||
|
||||
html, body {
|
||||
height: 100%;
|
||||
max-width: 100%;
|
||||
overflow-x: hidden;
|
||||
text-align: center;
|
||||
}
|
||||
body {
|
||||
margin:3em auto;
|
||||
font-family: Roboto, "Helvetica Neue", sans-serif;
|
||||
padding:0 .5em;
|
||||
}
|
||||
h1,h2,h3{
|
||||
line-height:1.2;
|
||||
letter-spacing: -2%;
|
||||
}
|
||||
12
src/sw.js
Normal file
@@ -0,0 +1,12 @@
|
||||
self.addEventListener('fetch', event => {
|
||||
if (event &&
|
||||
event.request &&
|
||||
event.request.url &&
|
||||
// check if basename includes a dot, i.e. if it is not a file
|
||||
! event.request.url.split(/[\\/]/).pop().includes(".")
|
||||
) {
|
||||
event.stopImmediatePropagation();
|
||||
}
|
||||
});
|
||||
|
||||
self.importScripts('./ngsw-worker.js');
|
||||
47
style.css
@@ -1,47 +0,0 @@
|
||||
*{
|
||||
font-family: 'Gill Sans', 'Gill Sans MT', Calibri, 'Trebuchet MS', sans-serif;
|
||||
background-color: aquamarine;
|
||||
}
|
||||
|
||||
textarea{
|
||||
font-size: 1vh;
|
||||
width: 100%;
|
||||
height:50vh;
|
||||
padding:0;
|
||||
}
|
||||
h1{
|
||||
text-align: center;
|
||||
font-size: 2vh;
|
||||
}
|
||||
.radioButtons, #nTeamsTextField{
|
||||
height:2vh;
|
||||
font-size: 2vh;
|
||||
line-height: 2vh;
|
||||
display: grid;
|
||||
grid-template-columns: 1em auto;
|
||||
gap: 0.5em;
|
||||
}
|
||||
#teamOutput{
|
||||
|
||||
margin-top:10vh;
|
||||
text-align: center;
|
||||
font-size: 2vh;
|
||||
line-height: 4.5vh;
|
||||
}
|
||||
button{
|
||||
position: absolute;
|
||||
left:50%;
|
||||
margin-top: 5vh;
|
||||
-ms-transform: translate(-50%, -50%);
|
||||
transform: translate(-50%, -50%);
|
||||
height: 5vh;
|
||||
font-size: 2vh;
|
||||
padding-left: 10%;
|
||||
padding-right: 10%;
|
||||
font-weight:bold;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
20
tsconfig.app.json
Normal file
@@ -0,0 +1,20 @@
|
||||
/* To learn more about Typescript configuration file: https://www.typescriptlang.org/docs/handbook/tsconfig-json.html. */
|
||||
/* To learn more about Angular compiler options: https://angular.dev/reference/configs/angular-compiler-options. */
|
||||
{
|
||||
"extends": "./tsconfig.json",
|
||||
"compilerOptions": {
|
||||
"outDir": "./out-tsc/app",
|
||||
"types": [
|
||||
"node",
|
||||
"@angular/localize"
|
||||
]
|
||||
},
|
||||
"files": [
|
||||
"src/main.ts",
|
||||
"src/main.server.ts",
|
||||
"src/server.ts"
|
||||
],
|
||||
"include": [
|
||||
"src/**/*.d.ts"
|
||||
]
|
||||
}
|
||||
27
tsconfig.json
Normal file
@@ -0,0 +1,27 @@
|
||||
/* To learn more about Typescript configuration file: https://www.typescriptlang.org/docs/handbook/tsconfig-json.html. */
|
||||
/* To learn more about Angular compiler options: https://angular.dev/reference/configs/angular-compiler-options. */
|
||||
{
|
||||
"compileOnSave": false,
|
||||
"compilerOptions": {
|
||||
"outDir": "./dist/out-tsc",
|
||||
"strict": true,
|
||||
"noImplicitOverride": true,
|
||||
"noPropertyAccessFromIndexSignature": true,
|
||||
"noImplicitReturns": true,
|
||||
"noFallthroughCasesInSwitch": true,
|
||||
"skipLibCheck": true,
|
||||
"isolatedModules": true,
|
||||
"esModuleInterop": true,
|
||||
"experimentalDecorators": true,
|
||||
"moduleResolution": "bundler",
|
||||
"importHelpers": true,
|
||||
"target": "ES2022",
|
||||
"module": "ES2022"
|
||||
},
|
||||
"angularCompilerOptions": {
|
||||
"enableI18nLegacyMessageIdFormat": false,
|
||||
"strictInjectionParameters": true,
|
||||
"strictInputAccessModifiers": true,
|
||||
"strictTemplates": true
|
||||
}
|
||||
}
|
||||
16
tsconfig.spec.json
Normal file
@@ -0,0 +1,16 @@
|
||||
/* To learn more about Typescript configuration file: https://www.typescriptlang.org/docs/handbook/tsconfig-json.html. */
|
||||
/* To learn more about Angular compiler options: https://angular.dev/reference/configs/angular-compiler-options. */
|
||||
{
|
||||
"extends": "./tsconfig.json",
|
||||
"compilerOptions": {
|
||||
"outDir": "./out-tsc/spec",
|
||||
"types": [
|
||||
"jasmine",
|
||||
"@angular/localize"
|
||||
]
|
||||
},
|
||||
"include": [
|
||||
"src/**/*.spec.ts",
|
||||
"src/**/*.d.ts"
|
||||
]
|
||||
}
|
||||