summaryrefslogtreecommitdiff
path: root/src/webserver
diff options
context:
space:
mode:
authordavidovski <david@sendula.com>2022-11-30 10:06:56 +0000
committerdavidovski <david@sendula.com>2022-11-30 10:06:56 +0000
commit290c68795d8100cc97b8b53d80f331e536fc71b1 (patch)
treebf0068c4c9121406df9bc90f5c159fd93de8a61e /src/webserver
Added files to repositoryHEADmain
Diffstat (limited to 'src/webserver')
-rw-r--r--src/webserver/dist/index.html122
-rw-r--r--src/webserver/dist/map/afghanistan.pngbin0 -> 23211 bytes
-rw-r--r--src/webserver/dist/map/albania.pngbin0 -> 6638 bytes
-rw-r--r--src/webserver/dist/map/angolia.pngbin0 -> 27027 bytes
-rw-r--r--src/webserver/dist/map/argentina.pngbin0 -> 34781 bytes
-rw-r--r--src/webserver/dist/map/austria.pngbin0 -> 8881 bytes
-rw-r--r--src/webserver/dist/map/azerbaijan.pngbin0 -> 22534 bytes
-rw-r--r--src/webserver/dist/map/background.pngbin0 -> 685688 bytes
-rw-r--r--src/webserver/dist/map/bangladesh.pngbin0 -> 7277 bytes
-rw-r--r--src/webserver/dist/map/botswana.pngbin0 -> 24443 bytes
-rw-r--r--src/webserver/dist/map/brazil.pngbin0 -> 42215 bytes
-rw-r--r--src/webserver/dist/map/brunei.pngbin0 -> 6900 bytes
-rw-r--r--src/webserver/dist/map/bulgaria.pngbin0 -> 22835 bytes
-rw-r--r--src/webserver/dist/map/burundi.pngbin0 -> 7502 bytes
-rw-r--r--src/webserver/dist/map/cambodia.pngbin0 -> 8653 bytes
-rw-r--r--src/webserver/dist/map/cameroon.pngbin0 -> 25309 bytes
-rw-r--r--src/webserver/dist/map/canada.pngbin0 -> 116756 bytes
-rw-r--r--src/webserver/dist/map/chile.pngbin0 -> 19420 bytes
-rw-r--r--src/webserver/dist/map/colombia.pngbin0 -> 26597 bytes
-rw-r--r--src/webserver/dist/map/costa.pngbin0 -> 7024 bytes
-rw-r--r--src/webserver/dist/map/croatia.pngbin0 -> 8524 bytes
-rw-r--r--src/webserver/dist/map/cyprus.pngbin0 -> 8163 bytes
-rw-r--r--src/webserver/dist/map/czech.pngbin0 -> 8929 bytes
-rw-r--r--src/webserver/dist/map/denmark.pngbin0 -> 7671 bytes
-rw-r--r--src/webserver/dist/map/dibouti.pngbin0 -> 7311 bytes
-rw-r--r--src/webserver/dist/map/ecuador.pngbin0 -> 22644 bytes
-rw-r--r--src/webserver/dist/map/estonia.pngbin0 -> 8392 bytes
-rw-r--r--src/webserver/dist/map/ethopia.pngbin0 -> 26251 bytes
-rw-r--r--src/webserver/dist/map/fiji.pngbin0 -> 6769 bytes
-rw-r--r--src/webserver/dist/map/finland.pngbin0 -> 26057 bytes
-rw-r--r--src/webserver/dist/map/haiti.pngbin0 -> 8111 bytes
-rw-r--r--src/webserver/dist/map/honduras.pngbin0 -> 8963 bytes
-rw-r--r--src/webserver/dist/map/hungary.pngbin0 -> 8481 bytes
-rw-r--r--src/webserver/dist/map/iceland.pngbin0 -> 23212 bytes
-rw-r--r--src/webserver/dist/map/india.pngbin0 -> 32085 bytes
-rw-r--r--src/webserver/dist/map/indonesia.pngbin0 -> 36017 bytes
-rw-r--r--src/webserver/dist/map/iran.pngbin0 -> 29620 bytes
-rw-r--r--src/webserver/dist/map/ireland.pngbin0 -> 8956 bytes
-rw-r--r--src/webserver/dist/map/israel.pngbin0 -> 7630 bytes
-rw-r--r--src/webserver/dist/map/italy.pngbin0 -> 25329 bytes
-rw-r--r--src/webserver/dist/map/jamaica.pngbin0 -> 7326 bytes
-rw-r--r--src/webserver/dist/map/lithunia.pngbin0 -> 9185 bytes
-rw-r--r--src/webserver/dist/map/luxemburj.pngbin0 -> 6768 bytes
-rw-r--r--src/webserver/dist/map/macao.pngbin0 -> 6767 bytes
-rw-r--r--src/webserver/dist/map/malaysia.pngbin0 -> 24856 bytes
-rw-r--r--src/webserver/dist/map/malta.pngbin0 -> 6767 bytes
-rw-r--r--src/webserver/dist/map/mauritius.pngbin0 -> 6768 bytes
-rw-r--r--src/webserver/dist/map/mexico.pngbin0 -> 31649 bytes
-rw-r--r--src/webserver/dist/map/moldova.pngbin0 -> 7755 bytes
-rw-r--r--src/webserver/dist/map/namibia.pngbin0 -> 24016 bytes
-rw-r--r--src/webserver/dist/map/netherland.pngbin0 -> 7973 bytes
-rw-r--r--src/webserver/dist/map/nigeria.pngbin0 -> 24703 bytes
-rw-r--r--src/webserver/dist/map/norway.pngbin0 -> 25462 bytes
-rw-r--r--src/webserver/dist/map/panama.pngbin0 -> 8636 bytes
-rw-r--r--src/webserver/dist/map/peru.pngbin0 -> 27826 bytes
-rw-r--r--src/webserver/dist/map/philpine.pngbin0 -> 11118 bytes
-rw-r--r--src/webserver/dist/map/poland.pngbin0 -> 24402 bytes
-rw-r--r--src/webserver/dist/map/portugal.pngbin0 -> 8289 bytes
-rw-r--r--src/webserver/dist/map/puerto_rico.pngbin0 -> 8158 bytes
-rw-r--r--src/webserver/dist/map/russia.pngbin0 -> 98363 bytes
-rw-r--r--src/webserver/dist/map/serbia.pngbin0 -> 22624 bytes
-rw-r--r--src/webserver/dist/map/singapore.pngbin0 -> 7405 bytes
-rw-r--r--src/webserver/dist/map/slovenia.pngbin0 -> 7381 bytes
-rw-r--r--src/webserver/dist/map/south_africa.pngbin0 -> 28681 bytes
-rw-r--r--src/webserver/dist/map/spain.pngbin0 -> 23987 bytes
-rw-r--r--src/webserver/dist/map/sweden.pngbin0 -> 28746 bytes
-rw-r--r--src/webserver/dist/map/switzerland.pngbin0 -> 8243 bytes
-rw-r--r--src/webserver/dist/map/taiwan.pngbin0 -> 7412 bytes
-rw-r--r--src/webserver/dist/map/uk.pngbin0 -> 25004 bytes
-rw-r--r--src/webserver/dist/map/usa.pngbin0 -> 58284 bytes
-rw-r--r--src/webserver/dist/site.js129
-rw-r--r--src/webserver/dist/style.css138
-rw-r--r--src/webserver/dist/subdir/image.pngbin0 -> 226933 bytes
-rw-r--r--src/webserver/dist/subdir/index.html1
-rw-r--r--src/webserver/dist/subdir/test.txt1
-rw-r--r--src/webserver/pom.xml47
-rw-r--r--src/webserver/src/main/java/io/github/davidovski/names/APIRequestHandler.java112
-rw-r--r--src/webserver/src/main/java/io/github/davidovski/names/NameDatabaseManager.java75
-rw-r--r--src/webserver/src/main/java/io/github/davidovski/names/StaticRequestHandler.java85
-rw-r--r--src/webserver/src/main/java/io/github/davidovski/names/WebServer.java51
80 files changed, 761 insertions, 0 deletions
diff --git a/src/webserver/dist/index.html b/src/webserver/dist/index.html
new file mode 100644
index 0000000..cd016b2
--- /dev/null
+++ b/src/webserver/dist/index.html
@@ -0,0 +1,122 @@
+<!DOCTYPE HTML>
+<html lang="en">
+<head>
+ <meta charset="UTF-8">
+ <title>Name Generator</title>
+
+ <meta name="viewport" content="initial-scale=1,maximum-scale=1,user-scalable=no"/>
+
+ <script type="text/javascript" src="/site.js"></script>
+ <link rel="stylesheet" href="style.css">
+
+
+</head>
+<body onload="updateMap()">
+ <div class="main">
+ <h1 class="title box-item">Name Generator</h1>
+
+ <div id="namearea" class="box-item">
+ <!-- Area for generated names to show-->
+ </div>
+
+ <button class="box-item" id="generate" onclick="generateName()">Generate Name</button>
+
+ <div class="options box-item">
+ <select id="gender">
+ <option value="male">Male</option>
+ <option value="female">Female</option>
+ </select>
+
+ <select id="origin" onchange="if (this.selectedIndex) updateMap();">
+ <option value="uk">UK</option>
+ <option value="usa">USA</option>
+ <option value="taiwan">Taiwan</option>
+ <option value="switzerland">Switzerland</option>
+ <option value="sweden">Sweden</option>
+ <option value="spain">Spain</option>
+ <option value="south_africa">South Africa</option>
+ <option value="slovenia">Slovenia</option>
+ <option value="singapore">Singapore</option>
+ <option value="serbia">Serbia</option>
+ <option value="russia">Russia</option>
+ <option value="puerto_rico">Puerto Rico</option>
+ <option value="portugal">Portugal</option>
+ <option value="poland">Poland</option>
+ <option value="philpine">Philippines</option>
+ <option value="peru">Peru</option>
+ <option value="panama">Panama</option>
+ <option value="norway">Norway</option>
+ <option value="nigeria">Nigeria</option>
+ <option value="netherland">Netherlands</option>
+ <option value="namibia">Namibia</option>
+ <option value="moldova">Moldova</option>
+ <option value="mexico">Mexico</option>
+ <option value="mauritius">Mauritius</option>
+ <option value="malta">Malta</option>
+ <option value="malaysia">Malaysia</option>
+ <option value="macao">Macao</option>
+ <option value="luxemburj">Luxembourg</option>
+ <option value="lithunia">Lithuania</option>
+ <option value="jamaica">Jamaica</option>
+ <option value="italy">Italy</option>
+ <option value="israel">Israel</option>
+ <option value="ireland">Ireland</option>
+ <option value="iran">Iran</option>
+ <option value="indonesia">Indonesia</option>
+ <option value="india">India</option>
+ <option value="iceland">Iceland</option>
+ <option value="hungary">Hungary</option>
+ <option value="honduras">Honduras</option>
+ <option value="haiti">Haiti</option>
+ <option value="finland">Finland</option>
+ <option value="fiji">Fiji</option>
+ <option value="ethopia">Ethiopia</option>
+ <option value="estonia">Estonia</option>
+ <option value="ecuador">Ecuador</option>
+ <option value="dibouti">Djibouti</option>
+ <option value="denmark">Denmark</option>
+ <option value="czech">Czech</option>
+ <option value="cyprus">Cyprus</option>
+ <option value="croatia">Croatia</option>
+ <option value="costa">Costa Rica</option>
+ <option value="colombia">Colombia</option>
+ <option value="chile">Chile</option>
+ <option value="canada">Canada</option>
+ <option value="cameroon">Cameroon</option>
+ <option value="cambodia">Cambodia</option>
+ <option value="burundi">Burundi</option>
+ <option value="bulgaria">Bulgaria</option>
+ <option value="brunei">Brunei</option>
+ <option value="brazil">Brazil</option>
+ <option value="botswana">Botswana</option>
+ <option value="bangladesh">Bangladesh</option>
+ <option value="azerbaijan">Azerbaijan</option>
+ <option value="austria">Austria</option>
+ <option value="argentina">Argentina</option>
+ <option value="angolia">Angola</option>
+ <option value="albania">Albania</option>
+ <option value="afghanistan">Afghanistan</option>
+ </select>
+ </div>
+
+ <canvas id="worldmap" width="2947" height="1601"></canvas>
+
+
+ <div>
+ <button id="advanced" onclick="toggleAdvanced()">Advanced Options</button>
+ </div>
+
+ <div id="advancedoptions" style="display: none">
+ <p></p>
+ <label>number of names: </label><input id="number" type="number" value="1" min="1" max="99" maxlength="2" onkeyup="forceCount()">
+ <p></p>
+
+ <label>generate surnames: </label><input id="surnames" type="checkbox" checked="true">
+ <span class="indicator" onclick="checkBox(document.getElementById('surnames'))"></span>
+ </input>
+ </div>
+ </div>
+
+
+</body>
+</html>
diff --git a/src/webserver/dist/map/afghanistan.png b/src/webserver/dist/map/afghanistan.png
new file mode 100644
index 0000000..49abc92
--- /dev/null
+++ b/src/webserver/dist/map/afghanistan.png
Binary files differ
diff --git a/src/webserver/dist/map/albania.png b/src/webserver/dist/map/albania.png
new file mode 100644
index 0000000..c045c57
--- /dev/null
+++ b/src/webserver/dist/map/albania.png
Binary files differ
diff --git a/src/webserver/dist/map/angolia.png b/src/webserver/dist/map/angolia.png
new file mode 100644
index 0000000..2e415e5
--- /dev/null
+++ b/src/webserver/dist/map/angolia.png
Binary files differ
diff --git a/src/webserver/dist/map/argentina.png b/src/webserver/dist/map/argentina.png
new file mode 100644
index 0000000..458376c
--- /dev/null
+++ b/src/webserver/dist/map/argentina.png
Binary files differ
diff --git a/src/webserver/dist/map/austria.png b/src/webserver/dist/map/austria.png
new file mode 100644
index 0000000..f3ed00e
--- /dev/null
+++ b/src/webserver/dist/map/austria.png
Binary files differ
diff --git a/src/webserver/dist/map/azerbaijan.png b/src/webserver/dist/map/azerbaijan.png
new file mode 100644
index 0000000..430b9d6
--- /dev/null
+++ b/src/webserver/dist/map/azerbaijan.png
Binary files differ
diff --git a/src/webserver/dist/map/background.png b/src/webserver/dist/map/background.png
new file mode 100644
index 0000000..77802f6
--- /dev/null
+++ b/src/webserver/dist/map/background.png
Binary files differ
diff --git a/src/webserver/dist/map/bangladesh.png b/src/webserver/dist/map/bangladesh.png
new file mode 100644
index 0000000..8fdf65a
--- /dev/null
+++ b/src/webserver/dist/map/bangladesh.png
Binary files differ
diff --git a/src/webserver/dist/map/botswana.png b/src/webserver/dist/map/botswana.png
new file mode 100644
index 0000000..ec58775
--- /dev/null
+++ b/src/webserver/dist/map/botswana.png
Binary files differ
diff --git a/src/webserver/dist/map/brazil.png b/src/webserver/dist/map/brazil.png
new file mode 100644
index 0000000..8ba32c5
--- /dev/null
+++ b/src/webserver/dist/map/brazil.png
Binary files differ
diff --git a/src/webserver/dist/map/brunei.png b/src/webserver/dist/map/brunei.png
new file mode 100644
index 0000000..c518380
--- /dev/null
+++ b/src/webserver/dist/map/brunei.png
Binary files differ
diff --git a/src/webserver/dist/map/bulgaria.png b/src/webserver/dist/map/bulgaria.png
new file mode 100644
index 0000000..c8edece
--- /dev/null
+++ b/src/webserver/dist/map/bulgaria.png
Binary files differ
diff --git a/src/webserver/dist/map/burundi.png b/src/webserver/dist/map/burundi.png
new file mode 100644
index 0000000..3f8d894
--- /dev/null
+++ b/src/webserver/dist/map/burundi.png
Binary files differ
diff --git a/src/webserver/dist/map/cambodia.png b/src/webserver/dist/map/cambodia.png
new file mode 100644
index 0000000..c92c6f3
--- /dev/null
+++ b/src/webserver/dist/map/cambodia.png
Binary files differ
diff --git a/src/webserver/dist/map/cameroon.png b/src/webserver/dist/map/cameroon.png
new file mode 100644
index 0000000..b5b57ea
--- /dev/null
+++ b/src/webserver/dist/map/cameroon.png
Binary files differ
diff --git a/src/webserver/dist/map/canada.png b/src/webserver/dist/map/canada.png
new file mode 100644
index 0000000..7358637
--- /dev/null
+++ b/src/webserver/dist/map/canada.png
Binary files differ
diff --git a/src/webserver/dist/map/chile.png b/src/webserver/dist/map/chile.png
new file mode 100644
index 0000000..e0a3c50
--- /dev/null
+++ b/src/webserver/dist/map/chile.png
Binary files differ
diff --git a/src/webserver/dist/map/colombia.png b/src/webserver/dist/map/colombia.png
new file mode 100644
index 0000000..3859cc0
--- /dev/null
+++ b/src/webserver/dist/map/colombia.png
Binary files differ
diff --git a/src/webserver/dist/map/costa.png b/src/webserver/dist/map/costa.png
new file mode 100644
index 0000000..035badd
--- /dev/null
+++ b/src/webserver/dist/map/costa.png
Binary files differ
diff --git a/src/webserver/dist/map/croatia.png b/src/webserver/dist/map/croatia.png
new file mode 100644
index 0000000..1ce5650
--- /dev/null
+++ b/src/webserver/dist/map/croatia.png
Binary files differ
diff --git a/src/webserver/dist/map/cyprus.png b/src/webserver/dist/map/cyprus.png
new file mode 100644
index 0000000..ea90e2a
--- /dev/null
+++ b/src/webserver/dist/map/cyprus.png
Binary files differ
diff --git a/src/webserver/dist/map/czech.png b/src/webserver/dist/map/czech.png
new file mode 100644
index 0000000..9f89545
--- /dev/null
+++ b/src/webserver/dist/map/czech.png
Binary files differ
diff --git a/src/webserver/dist/map/denmark.png b/src/webserver/dist/map/denmark.png
new file mode 100644
index 0000000..bef926b
--- /dev/null
+++ b/src/webserver/dist/map/denmark.png
Binary files differ
diff --git a/src/webserver/dist/map/dibouti.png b/src/webserver/dist/map/dibouti.png
new file mode 100644
index 0000000..43015e8
--- /dev/null
+++ b/src/webserver/dist/map/dibouti.png
Binary files differ
diff --git a/src/webserver/dist/map/ecuador.png b/src/webserver/dist/map/ecuador.png
new file mode 100644
index 0000000..bf2e9d4
--- /dev/null
+++ b/src/webserver/dist/map/ecuador.png
Binary files differ
diff --git a/src/webserver/dist/map/estonia.png b/src/webserver/dist/map/estonia.png
new file mode 100644
index 0000000..fa6ac33
--- /dev/null
+++ b/src/webserver/dist/map/estonia.png
Binary files differ
diff --git a/src/webserver/dist/map/ethopia.png b/src/webserver/dist/map/ethopia.png
new file mode 100644
index 0000000..207b3e7
--- /dev/null
+++ b/src/webserver/dist/map/ethopia.png
Binary files differ
diff --git a/src/webserver/dist/map/fiji.png b/src/webserver/dist/map/fiji.png
new file mode 100644
index 0000000..b574fc9
--- /dev/null
+++ b/src/webserver/dist/map/fiji.png
Binary files differ
diff --git a/src/webserver/dist/map/finland.png b/src/webserver/dist/map/finland.png
new file mode 100644
index 0000000..1a2754e
--- /dev/null
+++ b/src/webserver/dist/map/finland.png
Binary files differ
diff --git a/src/webserver/dist/map/haiti.png b/src/webserver/dist/map/haiti.png
new file mode 100644
index 0000000..c0773a6
--- /dev/null
+++ b/src/webserver/dist/map/haiti.png
Binary files differ
diff --git a/src/webserver/dist/map/honduras.png b/src/webserver/dist/map/honduras.png
new file mode 100644
index 0000000..fa7442d
--- /dev/null
+++ b/src/webserver/dist/map/honduras.png
Binary files differ
diff --git a/src/webserver/dist/map/hungary.png b/src/webserver/dist/map/hungary.png
new file mode 100644
index 0000000..97d9e91
--- /dev/null
+++ b/src/webserver/dist/map/hungary.png
Binary files differ
diff --git a/src/webserver/dist/map/iceland.png b/src/webserver/dist/map/iceland.png
new file mode 100644
index 0000000..d1f0e7d
--- /dev/null
+++ b/src/webserver/dist/map/iceland.png
Binary files differ
diff --git a/src/webserver/dist/map/india.png b/src/webserver/dist/map/india.png
new file mode 100644
index 0000000..e0fc17b
--- /dev/null
+++ b/src/webserver/dist/map/india.png
Binary files differ
diff --git a/src/webserver/dist/map/indonesia.png b/src/webserver/dist/map/indonesia.png
new file mode 100644
index 0000000..c31bf40
--- /dev/null
+++ b/src/webserver/dist/map/indonesia.png
Binary files differ
diff --git a/src/webserver/dist/map/iran.png b/src/webserver/dist/map/iran.png
new file mode 100644
index 0000000..2ee5b2b
--- /dev/null
+++ b/src/webserver/dist/map/iran.png
Binary files differ
diff --git a/src/webserver/dist/map/ireland.png b/src/webserver/dist/map/ireland.png
new file mode 100644
index 0000000..92fd6dc
--- /dev/null
+++ b/src/webserver/dist/map/ireland.png
Binary files differ
diff --git a/src/webserver/dist/map/israel.png b/src/webserver/dist/map/israel.png
new file mode 100644
index 0000000..3c350f2
--- /dev/null
+++ b/src/webserver/dist/map/israel.png
Binary files differ
diff --git a/src/webserver/dist/map/italy.png b/src/webserver/dist/map/italy.png
new file mode 100644
index 0000000..fb18140
--- /dev/null
+++ b/src/webserver/dist/map/italy.png
Binary files differ
diff --git a/src/webserver/dist/map/jamaica.png b/src/webserver/dist/map/jamaica.png
new file mode 100644
index 0000000..0cc2224
--- /dev/null
+++ b/src/webserver/dist/map/jamaica.png
Binary files differ
diff --git a/src/webserver/dist/map/lithunia.png b/src/webserver/dist/map/lithunia.png
new file mode 100644
index 0000000..633fc4b
--- /dev/null
+++ b/src/webserver/dist/map/lithunia.png
Binary files differ
diff --git a/src/webserver/dist/map/luxemburj.png b/src/webserver/dist/map/luxemburj.png
new file mode 100644
index 0000000..c296bd0
--- /dev/null
+++ b/src/webserver/dist/map/luxemburj.png
Binary files differ
diff --git a/src/webserver/dist/map/macao.png b/src/webserver/dist/map/macao.png
new file mode 100644
index 0000000..8c3017b
--- /dev/null
+++ b/src/webserver/dist/map/macao.png
Binary files differ
diff --git a/src/webserver/dist/map/malaysia.png b/src/webserver/dist/map/malaysia.png
new file mode 100644
index 0000000..7c14b5a
--- /dev/null
+++ b/src/webserver/dist/map/malaysia.png
Binary files differ
diff --git a/src/webserver/dist/map/malta.png b/src/webserver/dist/map/malta.png
new file mode 100644
index 0000000..bdbfc49
--- /dev/null
+++ b/src/webserver/dist/map/malta.png
Binary files differ
diff --git a/src/webserver/dist/map/mauritius.png b/src/webserver/dist/map/mauritius.png
new file mode 100644
index 0000000..6e39be8
--- /dev/null
+++ b/src/webserver/dist/map/mauritius.png
Binary files differ
diff --git a/src/webserver/dist/map/mexico.png b/src/webserver/dist/map/mexico.png
new file mode 100644
index 0000000..ac7d570
--- /dev/null
+++ b/src/webserver/dist/map/mexico.png
Binary files differ
diff --git a/src/webserver/dist/map/moldova.png b/src/webserver/dist/map/moldova.png
new file mode 100644
index 0000000..aea9bb2
--- /dev/null
+++ b/src/webserver/dist/map/moldova.png
Binary files differ
diff --git a/src/webserver/dist/map/namibia.png b/src/webserver/dist/map/namibia.png
new file mode 100644
index 0000000..013eb0c
--- /dev/null
+++ b/src/webserver/dist/map/namibia.png
Binary files differ
diff --git a/src/webserver/dist/map/netherland.png b/src/webserver/dist/map/netherland.png
new file mode 100644
index 0000000..ea929f8
--- /dev/null
+++ b/src/webserver/dist/map/netherland.png
Binary files differ
diff --git a/src/webserver/dist/map/nigeria.png b/src/webserver/dist/map/nigeria.png
new file mode 100644
index 0000000..fbb8c81
--- /dev/null
+++ b/src/webserver/dist/map/nigeria.png
Binary files differ
diff --git a/src/webserver/dist/map/norway.png b/src/webserver/dist/map/norway.png
new file mode 100644
index 0000000..8246c98
--- /dev/null
+++ b/src/webserver/dist/map/norway.png
Binary files differ
diff --git a/src/webserver/dist/map/panama.png b/src/webserver/dist/map/panama.png
new file mode 100644
index 0000000..2a080cb
--- /dev/null
+++ b/src/webserver/dist/map/panama.png
Binary files differ
diff --git a/src/webserver/dist/map/peru.png b/src/webserver/dist/map/peru.png
new file mode 100644
index 0000000..c0c759b
--- /dev/null
+++ b/src/webserver/dist/map/peru.png
Binary files differ
diff --git a/src/webserver/dist/map/philpine.png b/src/webserver/dist/map/philpine.png
new file mode 100644
index 0000000..4301c70
--- /dev/null
+++ b/src/webserver/dist/map/philpine.png
Binary files differ
diff --git a/src/webserver/dist/map/poland.png b/src/webserver/dist/map/poland.png
new file mode 100644
index 0000000..f16d57f
--- /dev/null
+++ b/src/webserver/dist/map/poland.png
Binary files differ
diff --git a/src/webserver/dist/map/portugal.png b/src/webserver/dist/map/portugal.png
new file mode 100644
index 0000000..bdec23d
--- /dev/null
+++ b/src/webserver/dist/map/portugal.png
Binary files differ
diff --git a/src/webserver/dist/map/puerto_rico.png b/src/webserver/dist/map/puerto_rico.png
new file mode 100644
index 0000000..e7c0b10
--- /dev/null
+++ b/src/webserver/dist/map/puerto_rico.png
Binary files differ
diff --git a/src/webserver/dist/map/russia.png b/src/webserver/dist/map/russia.png
new file mode 100644
index 0000000..e77b48f
--- /dev/null
+++ b/src/webserver/dist/map/russia.png
Binary files differ
diff --git a/src/webserver/dist/map/serbia.png b/src/webserver/dist/map/serbia.png
new file mode 100644
index 0000000..c3debe2
--- /dev/null
+++ b/src/webserver/dist/map/serbia.png
Binary files differ
diff --git a/src/webserver/dist/map/singapore.png b/src/webserver/dist/map/singapore.png
new file mode 100644
index 0000000..59e3aec
--- /dev/null
+++ b/src/webserver/dist/map/singapore.png
Binary files differ
diff --git a/src/webserver/dist/map/slovenia.png b/src/webserver/dist/map/slovenia.png
new file mode 100644
index 0000000..1dd5ebf
--- /dev/null
+++ b/src/webserver/dist/map/slovenia.png
Binary files differ
diff --git a/src/webserver/dist/map/south_africa.png b/src/webserver/dist/map/south_africa.png
new file mode 100644
index 0000000..ecdccb7
--- /dev/null
+++ b/src/webserver/dist/map/south_africa.png
Binary files differ
diff --git a/src/webserver/dist/map/spain.png b/src/webserver/dist/map/spain.png
new file mode 100644
index 0000000..b6947e3
--- /dev/null
+++ b/src/webserver/dist/map/spain.png
Binary files differ
diff --git a/src/webserver/dist/map/sweden.png b/src/webserver/dist/map/sweden.png
new file mode 100644
index 0000000..6b7ba10
--- /dev/null
+++ b/src/webserver/dist/map/sweden.png
Binary files differ
diff --git a/src/webserver/dist/map/switzerland.png b/src/webserver/dist/map/switzerland.png
new file mode 100644
index 0000000..6a8180a
--- /dev/null
+++ b/src/webserver/dist/map/switzerland.png
Binary files differ
diff --git a/src/webserver/dist/map/taiwan.png b/src/webserver/dist/map/taiwan.png
new file mode 100644
index 0000000..ca08390
--- /dev/null
+++ b/src/webserver/dist/map/taiwan.png
Binary files differ
diff --git a/src/webserver/dist/map/uk.png b/src/webserver/dist/map/uk.png
new file mode 100644
index 0000000..51f6e4d
--- /dev/null
+++ b/src/webserver/dist/map/uk.png
Binary files differ
diff --git a/src/webserver/dist/map/usa.png b/src/webserver/dist/map/usa.png
new file mode 100644
index 0000000..06cabde
--- /dev/null
+++ b/src/webserver/dist/map/usa.png
Binary files differ
diff --git a/src/webserver/dist/site.js b/src/webserver/dist/site.js
new file mode 100644
index 0000000..2e9bac3
--- /dev/null
+++ b/src/webserver/dist/site.js
@@ -0,0 +1,129 @@
+
+
+// the function to be called when the generate name button is pressed
+function generateName() {
+
+ // get the values of the various buttons and selectors and store them as variables
+ var gender = document.getElementById("gender").value;
+ var origin = document.getElementById("origin").value;
+
+ var count = parseInt(document.getElementById("number").value);
+ var surnames = document.getElementById("surnames").checked;
+
+ // create a request object
+ var request = {
+ "origin": origin,
+ "gender": gender,
+ "count": count,
+ "surname": surnames
+ };
+
+ // turn the request json into a string
+ request = JSON.stringify(request)
+
+ console.log(request)
+
+ // Make the http request using ajax
+ const http = new XMLHttpRequest();
+ const url = "/api/name";
+ http.open("POST", url);
+ http.send(request);
+
+ // create a listener for when the request is returned
+ http.onreadystatechange = (e) => {
+ showNames(JSON.parse(http.responseText))
+ }
+}
+
+// Change the page's html to show the generated names
+function showNames(names) {
+
+ // get the name area element
+ var nameArea = document.getElementById("namearea");
+
+ // delete all existing name entries
+ while (nameArea.lastChild) {
+ nameArea.removeChild(nameArea.lastChild);
+ }
+
+ // iterate through all of the given names
+ names.names.forEach((name) => {
+
+ // create the name element
+ var nameElement = document.createElement("p");
+ nameElement.textContent = name;
+ nameElement.classList.add("name");
+
+ // add the name element to the name area
+ nameArea.appendChild(nameElement);
+ });
+}
+
+function updateMap() {
+ // Load the current country of origin
+ var origin = document.getElementById("origin").value;
+
+ console.log(origin)
+
+ // get the canvas context for the worldmap
+ var canvas = document.getElementById("worldmap");
+ var context = canvas.getContext("2d");
+
+ // clear the canvas
+ context.clearRect(0, 0, canvas.width, canvas.height);
+
+ // create the background image
+ var background = new Image();
+ background.src = "/map/background.png"
+
+ // wait for the image to load before trying to draw it
+ background.onload = function() {
+ context.drawImage(background, 0, 0)
+
+ // only draw the country after the background has been drawn
+ var country = new Image();
+ country.src = "/map/" + origin + ".png"
+
+ // wait for the image to load before trying to draw it
+ country.onload = function() {
+ context.drawImage(country, 0, 0)
+ };
+
+ };
+
+}
+
+// force the count to be between 1 and 99
+function forceCount() {
+ var count = parseInt(document.getElementById("number").value);
+ if (count > 99) {
+ document.getElementById("number").value = 99
+ } else if (count < 1) {
+ document.getElementById("number").value = 1
+ }
+}
+
+// toggle the visibility of advanced options
+function toggleAdvanced() {
+ // get the advanced options div
+ var element = document.getElementById("advancedoptions");
+
+ // if display: none, make it visible and vice versa
+ if (element.style.display == "none") {
+ element.style.display = ""
+ } else {
+ element.style.display = "none"
+ }
+
+}
+
+// toggle the checkbox from checked to unchecked and vice versa
+function checkBox(checkbox) {
+ if (checkbox.getAttribute("checked")) {
+ // uncheck the box
+ checkbox.removeAttribute("checked");
+ } else {
+ // set the box to checked
+ checkbox.setAttribute("checked", true);
+ }
+}
diff --git a/src/webserver/dist/style.css b/src/webserver/dist/style.css
new file mode 100644
index 0000000..1ba596d
--- /dev/null
+++ b/src/webserver/dist/style.css
@@ -0,0 +1,138 @@
+#worldmap {
+ width: 50%;
+}
+
+body {
+ font-family: sans-serif;
+ background-color: #191919;
+ color: #f0c674;
+ width:auto;
+}
+
+.main {
+ padding: 0;
+ margin-left: 10%;
+ margin-right: 10%;
+ width: 80%;
+ font-size: 2rem;
+}
+
+#worldmap {
+ width: 50%;
+}
+
+@media (orientation : portrait) {
+ .main {
+ padding: 0;
+ margin: 0;
+ width: 100%;
+ font-size: 1.5rem;
+ }
+
+ #worldmap {
+ width: 100%;
+ }
+}
+
+
+.main {
+ display: inline-block;
+ text-align: center;
+
+}
+
+.box-item {
+ margin-top: 1rem;
+ margin-bottom: 1rem;
+}
+
+
+button,select,input[type=number] {
+ font-size: inherit;
+ background-color: #191919;
+ color: #f0c674;
+ border-radius: 0.5em;
+ text-decoration: none;
+ padding: 0.5rem;
+ border: 0.05rem solid #373b41;
+ box-shadow: 0 0.2em #373b41;
+}
+
+#number {
+ width: 3rem;
+}
+img {
+ width: 2rem;
+}
+
+button:active {
+ background-color: #373b41;
+ box-shadow: 0 0.1em #373b41;
+ transform: translateY(0.1em);
+}
+
+
+.box {
+ margin-top: 10%;
+ padding: 1%;
+ text-align: center;
+ display: inline-block;
+ box-sizing: border-box;
+ margin-left:15%;
+ width: 70%;
+ height: 50%;
+
+ background: transparent;
+ border: 0;
+ outline: 0;
+ border-bottom: 0.25rem solid #0f7d7b;
+ color: #e8922a;
+ font-size: 100%;
+ outline: none !important;
+
+}
+input:focus, textarea {
+ outline: none !important;
+}
+button:focus, textarea {
+ outline: none !important;
+}
+
+
+input[type=checkbox]{
+ position:absolute;
+ opacity: 0;
+ z-index: -9999;
+}
+
+input[type=checkbox] + .indicator {
+ width: 1.5rem;
+ height: 1.5rem;
+ margin-left: 0.5rem;
+ position: absolute;
+
+
+ font-size: inherit;
+ background-color: #191919;
+ color: #191919;
+ border-radius: 0.5em;
+ text-decoration: none;
+ padding: 0.5rem;
+ border: 0.05rem solid #373b41;
+ box-shadow: 0 0.2em #373b41;
+
+ content: "";
+}
+
+input[type=checkbox]:checked + .indicator {
+ background-color: #373b41;
+ box-shadow: 0 0.1em #373b41;
+ transform: translateY(0.1em);
+}
+
+input[type=checkbox]+ .indicator::after {
+ content: "";
+}
+input[type=checkbox]:checked + .indicator::after {
+ content: "X";
+}
diff --git a/src/webserver/dist/subdir/image.png b/src/webserver/dist/subdir/image.png
new file mode 100644
index 0000000..80fb972
--- /dev/null
+++ b/src/webserver/dist/subdir/image.png
Binary files differ
diff --git a/src/webserver/dist/subdir/index.html b/src/webserver/dist/subdir/index.html
new file mode 100644
index 0000000..b7e784a
--- /dev/null
+++ b/src/webserver/dist/subdir/index.html
@@ -0,0 +1 @@
+index of the sub dir
diff --git a/src/webserver/dist/subdir/test.txt b/src/webserver/dist/subdir/test.txt
new file mode 100644
index 0000000..6ee329a
--- /dev/null
+++ b/src/webserver/dist/subdir/test.txt
@@ -0,0 +1 @@
+this is text.txt
diff --git a/src/webserver/pom.xml b/src/webserver/pom.xml
new file mode 100644
index 0000000..c4a716d
--- /dev/null
+++ b/src/webserver/pom.xml
@@ -0,0 +1,47 @@
+<project xmlns="http://maven.apache.org/POM/4.0.0"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
+ <modelVersion>4.0.0</modelVersion>
+ <groupId>io.github.davidovski.names</groupId>
+ <artifactId>NameGenerator</artifactId>
+ <version>0.0.1-SNAPSHOT</version>
+ <packaging>jar</packaging>
+ <dependencies>
+ <dependency>
+ <groupId>org.xerial</groupId>
+ <artifactId>sqlite-jdbc</artifactId>
+ <version>3.32.3</version>
+ </dependency>
+ <dependency>
+ <groupId>org.json</groupId>
+ <artifactId>json</artifactId>
+ <version>20210307</version>
+ </dependency>
+ </dependencies>
+
+ <build>
+ <plugins>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-shade-plugin</artifactId>
+ <executions>
+ <execution>
+ <goals>
+ <goal>shade</goal>
+ </goals>
+ <configuration>
+ <shadedArtifactAttached>true</shadedArtifactAttached>
+ <transformers>
+ <transformer implementation=
+ "org.apache.maven.plugins.shade.resource.ManifestResourceTransformer">
+ <mainClass>io.github.davidovski.names.WebServer</mainClass>
+ </transformer>
+ </transformers>
+ </configuration>
+ </execution>
+ </executions>
+ </plugin>
+
+ </plugins>
+ </build>
+</project>
diff --git a/src/webserver/src/main/java/io/github/davidovski/names/APIRequestHandler.java b/src/webserver/src/main/java/io/github/davidovski/names/APIRequestHandler.java
new file mode 100644
index 0000000..5ef2cfe
--- /dev/null
+++ b/src/webserver/src/main/java/io/github/davidovski/names/APIRequestHandler.java
@@ -0,0 +1,112 @@
+package io.github.davidovski.names;
+
+import java.io.File;
+import java.io.IOException;
+import java.io.OutputStream;
+import java.util.List;
+
+import org.json.JSONArray;
+import org.json.JSONException;
+import org.json.JSONObject;
+import org.json.JSONTokener;
+
+import com.sun.net.httpserver.HttpExchange;
+import com.sun.net.httpserver.HttpHandler;
+
+@SuppressWarnings("restriction")
+public class APIRequestHandler implements HttpHandler {
+
+ private NameDatabaseManager nameDatabaseManager;
+
+ public APIRequestHandler() {
+ nameDatabaseManager = new NameDatabaseManager(new File("names.db"));
+ }
+
+ @Override
+ public void handle(HttpExchange exchange) throws IOException {
+ // get the requested path
+ String path = exchange.getRequestURI().getPath();
+
+ System.out.println(path);
+
+ if (path.startsWith("/api/name")) {
+
+ // parse the body as a json object
+ JSONTokener jsonParser = new JSONTokener(exchange.getRequestBody());
+ JSONObject json = (JSONObject) jsonParser.nextValue();
+
+ System.out.println(json.toString(2));
+
+ if (json == null) {
+ // Malformed JSON request, 400
+ sendJSON(exchange, (new JSONObject()).put("message", "Malformed JSON body"), 400);
+ return;
+ }
+
+ // generate name(s) and send it
+ generateName(exchange, json);
+ } else {
+ sendJSON(exchange, (new JSONObject()).put("message", "Not Found"), 404);
+ }
+ }
+
+ public void generateName(HttpExchange exchange, JSONObject options) throws JSONException, IOException {
+ String origin = options.optString("origin", "none").toLowerCase();
+
+ int count = options.optInt("count", 1);
+
+ // ensure that the count is between 1-100
+ if (count < 1 || count > 100) {
+ sendJSON(exchange, (new JSONObject()).put("message", "Name count is out of range: Ensure that the request is between 1 and 100 names"), 400);
+ return;
+ }
+
+ String gender = options.optString("gender", "female");
+
+ // ensure that the gender is either male or female
+ if (!gender.equals("male") && !gender.equals("female")) {
+ sendJSON(exchange, (new JSONObject()).put("message", "Requested gender is invalid"), 400);
+ return;
+ }
+
+ // Store the names in an array
+ List<String> names = nameDatabaseManager.getRandomNames(origin, gender, count);
+
+ if (options.optBoolean("surname")) {
+ List<String> surnames = nameDatabaseManager.getRandomNames(origin, "surname", count);
+
+ // Add surnames to the end of each firstname in the names list
+ for (int i = 0; i < count; i++) {
+ String fullname = names.get(i) + " " + surnames.get(i);
+ names.set(i, fullname);
+ }
+ }
+
+ // Create the response json object
+ JSONObject response = new JSONObject();
+ response.put("message", "Generated " + count + " names");
+ response.put("names", new JSONArray(names));
+
+ // send the json back to the client
+ sendJSON(exchange, response, 200);
+ }
+
+ public void sendJSON(HttpExchange exchange, JSONObject json, int responseCode) throws IOException {
+ // convert the json to a string
+ String response = json.toString(2);
+
+ // calculate the response content size
+ int contentSize = response.toString().getBytes().length;
+
+ // set the response headers
+ exchange.getResponseHeaders().add("Content-Type", "text/json");
+ exchange.sendResponseHeaders(responseCode, contentSize);
+
+ // write the response to the output stream
+ OutputStream outputStream = exchange.getResponseBody();
+
+ outputStream.write(response.toString().getBytes());
+ outputStream.close();
+ }
+
+}
diff --git a/src/webserver/src/main/java/io/github/davidovski/names/NameDatabaseManager.java b/src/webserver/src/main/java/io/github/davidovski/names/NameDatabaseManager.java
new file mode 100644
index 0000000..8822d9c
--- /dev/null
+++ b/src/webserver/src/main/java/io/github/davidovski/names/NameDatabaseManager.java
@@ -0,0 +1,75 @@
+package io.github.davidovski.names;
+
+import java.io.File;
+import java.sql.Connection;
+import java.sql.DriverManager;
+import java.sql.PreparedStatement;
+import java.sql.ResultSet;
+import java.sql.SQLException;
+import java.util.ArrayList;
+import java.util.List;
+
+public class NameDatabaseManager {
+ private File databaseFile;
+ private Connection connection;
+
+ private static final String TABLE = "names";
+
+ public NameDatabaseManager(File databaseFile) {
+ this.databaseFile = databaseFile;
+
+ connect();
+ }
+
+ /**
+ * Creates a connection to the database. If one could not be created, the connection will remain as null
+ */
+ private void connect() {
+ connection = null;
+ try {
+ connection = DriverManager.getConnection("jdbc:sqlite:" + databaseFile.getPath());
+ } catch (SQLException e) {
+ e.printStackTrace();
+ }
+ }
+
+ public List<String> getRandomNames(String origin, String category, int quantitiy) {
+ // create the set to return, even if empty
+ List<String> names = new ArrayList<String>();
+
+ if (connection != null) {
+ // Create an sql statement
+ String sql = "SELECT Name FROM " + TABLE + " WHERE Origin=? AND Category=? ORDER BY RANDOM() LIMIT ?;";
+ PreparedStatement statement;
+ try {
+ statement = connection.prepareStatement(sql);
+
+ // insert relevant values into the statement
+ statement.setString(1, origin);
+ statement.setString(2, category);
+ statement.setInt(3, quantitiy);
+
+ // execute the query and get the result
+ ResultSet result = statement.executeQuery();
+
+ // Add all of the results to the names set
+ while (result.next()) {
+ String name = result.getString("Name");
+ names.add(name);
+ }
+ } catch (SQLException e) {
+ e.printStackTrace();
+ }
+
+ }
+ return names;
+ }
+
+ public static void main(String[] args) {
+ NameDatabaseManager dbManager = new NameDatabaseManager(new File("names.db"));
+ List<String> names = dbManager.getRandomNames("spain", "female", 10);
+ for (String name : names) {
+ System.out.println(name);
+ }
+ }
+}
diff --git a/src/webserver/src/main/java/io/github/davidovski/names/StaticRequestHandler.java b/src/webserver/src/main/java/io/github/davidovski/names/StaticRequestHandler.java
new file mode 100644
index 0000000..d10d0b1
--- /dev/null
+++ b/src/webserver/src/main/java/io/github/davidovski/names/StaticRequestHandler.java
@@ -0,0 +1,85 @@
+package io.github.davidovski.names;
+
+import java.io.File;
+import java.io.IOException;
+import java.io.OutputStream;
+import java.nio.file.Files;
+
+import com.sun.net.httpserver.HttpExchange;
+import com.sun.net.httpserver.HttpHandler;
+
+@SuppressWarnings("restriction")
+public class StaticRequestHandler implements HttpHandler {
+ private File root;
+
+ public StaticRequestHandler(File root) {
+ this.root = root;
+ }
+
+ @Override
+ public void handle(HttpExchange exchange) throws IOException {
+ // get the requested path
+ String path = exchange.getRequestURI().getPath();
+
+ File requested = new File(root, path);
+
+ // automatically send the index of a directory
+ if (requested.isDirectory()) {
+ requested = new File(requested, "index.html");
+ }
+
+ // ensure that the file is in the intended document root
+ if (!isInRoot(requested, root)) {
+ sendText(exchange, "Access Denied", 403);
+ } else if (requested.exists()) {
+ sendFile(exchange, requested);
+ } else {
+ // send 404 if the file isnt found
+ sendText(exchange, "File Not Found", 404);
+ }
+ }
+
+ private void sendFile(HttpExchange exchange, File file) throws IOException {
+ // read the file as into an array of bytes
+ byte[] bytes = Files.readAllBytes(file.toPath());
+
+ // send the file headers
+ exchange.sendResponseHeaders(200, bytes.length);
+
+ // send the file body
+ OutputStream os = exchange.getResponseBody();
+ os.write(bytes);
+ os.close();
+ }
+
+ private void sendText(HttpExchange exchange, String response, int responseCode) throws IOException {
+ // calculate the response content size
+ int contentSize = response.toString().getBytes().length;
+
+ // set the response headers
+ exchange.getResponseHeaders().add("Content-Type", "text/json");
+ exchange.sendResponseHeaders(responseCode, contentSize);
+
+ // write the response to the output stream
+ OutputStream outputStream = exchange.getResponseBody();
+
+ outputStream.write(response.toString().getBytes());
+ outputStream.close();
+ }
+
+ public static boolean isInRoot(File request, File root) {
+ File parentFile = request;
+
+ // start from the requested file and traverse upwards until reaching the root directory
+ while (parentFile != null) {
+ if (root.equals(parentFile)) {
+ return true;
+ }
+ parentFile = parentFile.getParentFile();
+ }
+
+ // If there isn't a parent file, return false
+ return false;
+ }
+
+}
diff --git a/src/webserver/src/main/java/io/github/davidovski/names/WebServer.java b/src/webserver/src/main/java/io/github/davidovski/names/WebServer.java
new file mode 100644
index 0000000..60b311f
--- /dev/null
+++ b/src/webserver/src/main/java/io/github/davidovski/names/WebServer.java
@@ -0,0 +1,51 @@
+package io.github.davidovski.names;
+
+import java.io.File;
+import java.io.IOException;
+import java.net.InetSocketAddress;
+
+import com.sun.net.httpserver.HttpServer;
+
+@SuppressWarnings("restriction")
+public class WebServer {
+ private int port;
+ private HttpServer server;
+
+ public WebServer(int port) throws IOException {
+ this.port = port;
+
+ // create an HTTP server instance
+ InetSocketAddress socketAddress = new InetSocketAddress(port);
+ server = HttpServer.create(socketAddress, 0);
+
+ // create a context for the static request handler
+ server.createContext("/", new StaticRequestHandler(new File("dist")));
+ // create a context for the api request handler
+ server.createContext("/api", new APIRequestHandler());
+
+ }
+
+ public void start() {
+ server.start();
+
+ // tell the user that the webserver has been started, and the port used
+ System.out.println("Webserver started on port " + port);
+ }
+
+
+ public static void main(String[] args) throws IOException {
+
+ // set a default port number
+ int port = 8080;
+
+ // parse the arguments for a port number
+ if (args.length > 0)
+ port = Integer.parseInt(args[0]);
+
+ // Create the webserver instance
+ WebServer webServer = new WebServer(port);
+
+ // start the webserver
+ webServer.start();
+ }
+}