From c8a75a5fec45cf3cc5d0957b062f77ebaf4dd5b8 Mon Sep 17 00:00:00 2001 From: bvdoord Date: Mon, 11 Feb 2019 08:13:57 +0100 Subject: Initial commit --- client/admin.html | 49 ++++++++ client/img/favicon.ico | Bin 0 -> 6261 bytes client/img/logo_sogyo_rgb_199x200-1.jpg | Bin 0 -> 5184 bytes client/index.html | 196 ++++++++++++++++++++++++++++++++ client/map.html | 54 +++++++++ client/orderplaced.html | 50 ++++++++ client/orders.html | 50 ++++++++ client/shoppingbasket.html | 57 ++++++++++ client/src/admin.js | 0 client/src/index.js | 0 client/src/myorders.js | 0 client/src/shoppingbasket.js | 0 client/style/main.css | 66 +++++++++++ client/style/map.css | 15 +++ client/style/shoppingbasket.css | 3 + main.js | 119 +++++++++++++++++++ package.json | 9 ++ readme.md | 114 +++++++++++++++++++ 18 files changed, 782 insertions(+) create mode 100644 client/admin.html create mode 100644 client/img/favicon.ico create mode 100644 client/img/logo_sogyo_rgb_199x200-1.jpg create mode 100644 client/index.html create mode 100644 client/map.html create mode 100644 client/orderplaced.html create mode 100644 client/orders.html create mode 100644 client/shoppingbasket.html create mode 100644 client/src/admin.js create mode 100644 client/src/index.js create mode 100644 client/src/myorders.js create mode 100644 client/src/shoppingbasket.js create mode 100644 client/style/main.css create mode 100644 client/style/map.css create mode 100644 client/style/shoppingbasket.css create mode 100644 main.js create mode 100644 package.json create mode 100644 readme.md diff --git a/client/admin.html b/client/admin.html new file mode 100644 index 0000000..291f79f --- /dev/null +++ b/client/admin.html @@ -0,0 +1,49 @@ + + + + + + + Sogyo Adventure + + + + + + + +
+ +
+
+ Sogyo Adventure +
+ + +
+ + + +
+ + \ No newline at end of file diff --git a/client/img/favicon.ico b/client/img/favicon.ico new file mode 100644 index 0000000..a4fe44e Binary files /dev/null and b/client/img/favicon.ico differ diff --git a/client/img/logo_sogyo_rgb_199x200-1.jpg b/client/img/logo_sogyo_rgb_199x200-1.jpg new file mode 100644 index 0000000..9104922 Binary files /dev/null and b/client/img/logo_sogyo_rgb_199x200-1.jpg differ diff --git a/client/index.html b/client/index.html new file mode 100644 index 0000000..41f966b --- /dev/null +++ b/client/index.html @@ -0,0 +1,196 @@ + + + + + + + Sogyo Adventure + + + + + + + +
+ +
+
+ Sogyo Adventure +
+ + +
+ +
+
De Efteling
+
+ The Netherlands's most famous theme park. Located in Kaatsheuvel. +
+
+
+
Adults: 32,-
+
Kids: 32,-
+
+ Family ticket: + Buy 2 adult tickets & 2 kid tickets for a 15% discount! +
+
+ + +
0,-
+ +
+
+ +
+
Madurodam
+
+ The Netherlands smallest theme park. +
+
+
+
Adults: 25,-
+
Kids: 20,-
+
+ Family ticket: + Buy 1 adult tickets & 2 kid tickets for a 25% discount! +
+
+ + +
0,-
+ +
+
+ +
+
Toverland
+
+ Experience magic and wonder. +
+
+
+
Adults: 30,-
+
Kids: 30,-
+
+ Family ticket: + Buy 2 adult tickets & 2 kid tickets for a 33% discount! +
+
+ + +
0,-
+ +
+
+ +
+
Walibi Holland
+
+ Need an Adrenaline Rush? +
+
+
+
Adults: 37,-
+
Kids: 37,-
+
+ Family ticket: + Buy 4 adult tickets & 0 kid tickets for a 10% discount! +
+
+ + +
0,-
+ +
+
+ +
+
Duinrell
+
+ From the Kikkerbaan to the Tikibad. +
+
+
+
Adults: 22,-
+
Kids: 19,-
+
+ Family ticket: + Buy 1 adult tickets & 3 kid tickets for a 20% discount! +
+
+ + +
0,-
+ +
+
+ +
+
Slagharen
+
+ Fun for the whole family in a true western style. +
+
+
+
Adults: 28,-
+
Kids: 20,-
+
+ Family ticket: + Buy 2 adult tickets & 2 kid tickets for a 50% discount! +
+
+ + +
0,-
+ +
+
+ +
+
Drievliet
+
+ Come and experience our wonderful attractions. +
+
+
+
Adults: 26,-
+
Kids: 24,-
+
+ Family ticket: + Buy 1 adult tickets & 2 kid tickets for a 25% discount! +
+
+ + +
0,-
+ +
+
+ +
+ + + + \ No newline at end of file diff --git a/client/map.html b/client/map.html new file mode 100644 index 0000000..35347a8 --- /dev/null +++ b/client/map.html @@ -0,0 +1,54 @@ + + + + + + + Sogyo Adventure + + + + + + + + +
+ +
+
+ Sogyo Adventure +
+ + +
+ +
+ +
+ +
+ + + + \ No newline at end of file diff --git a/client/orderplaced.html b/client/orderplaced.html new file mode 100644 index 0000000..e012cd7 --- /dev/null +++ b/client/orderplaced.html @@ -0,0 +1,50 @@ + + + + + + + Sogyo Adventure + + + + + + + +
+ +
+
+ Sogyo Adventure +
+ + +
+ + Your order has been placed. + +
+ + + \ No newline at end of file diff --git a/client/orders.html b/client/orders.html new file mode 100644 index 0000000..ab936be --- /dev/null +++ b/client/orders.html @@ -0,0 +1,50 @@ + + + + + + + Sogyo Adventure + + + + + + + +
+ +
+
+ Sogyo Adventure +
+ + +
+ + +
+ + + + \ No newline at end of file diff --git a/client/shoppingbasket.html b/client/shoppingbasket.html new file mode 100644 index 0000000..707e147 --- /dev/null +++ b/client/shoppingbasket.html @@ -0,0 +1,57 @@ + + + + + + + Sogyo Adventure + + + + + + + +
+ +
+
+ Sogyo Adventure +
+ + +
+ +
+ + + + + \ No newline at end of file diff --git a/client/src/admin.js b/client/src/admin.js new file mode 100644 index 0000000..e69de29 diff --git a/client/src/index.js b/client/src/index.js new file mode 100644 index 0000000..e69de29 diff --git a/client/src/myorders.js b/client/src/myorders.js new file mode 100644 index 0000000..e69de29 diff --git a/client/src/shoppingbasket.js b/client/src/shoppingbasket.js new file mode 100644 index 0000000..e69de29 diff --git a/client/style/main.css b/client/style/main.css new file mode 100644 index 0000000..b7edb5b --- /dev/null +++ b/client/style/main.css @@ -0,0 +1,66 @@ +body { + font-family: 'Lato', sans-serif; + padding: 0px; + margin: 0px; + + --primary-color: #007936; + --accent-color: #eee; + --light-text-color: rgb(107, 107, 107); +} + +/* Describes the styling of the one and only emenent with id="mainheader", note the # in front of mainheader */ +#mainheader { + background-color: var(--primary-color); + font-size: 3rem; + color: white; +} + +#logo-header { + display: flex; + justify-content: flex-start; + align-items: center; +} + +#logo-header img { + margin-left: 30px; +} + +main { + padding: 25px; +} + +nav +{ + height: 2rem; + line-height: 2rem; + background-color: var(--accent-color); +} + +/* Describes the styling of all elements with class="parkname", note the . in front of parkname */ +.parkname { + background-color: var(--primary-color); + color: white; + font-size: 2rem; + font-weight: bold; + text-transform: uppercase; +} + +/* Describes the styling of all
elements */ +article { + border: 1px solid var(--primary-color); + color: var(--light-text-color); + margin: 5px; +} + +.order { + padding-top: 25px; +} + +.badge { + background-color: red; + display: none; + color: white; + font-weight: bold; + width: 25px; + border-radius: 25px; +} \ No newline at end of file diff --git a/client/style/map.css b/client/style/map.css new file mode 100644 index 0000000..f8254d3 --- /dev/null +++ b/client/style/map.css @@ -0,0 +1,15 @@ +#discoverablemap { + height: 100%; + width: 100%; + background-color: brown; +} + +body { + height: 100vh; + width: 100vw; +} + +main { + height: 100%; + width: 100%; +} \ No newline at end of file diff --git a/client/style/shoppingbasket.css b/client/style/shoppingbasket.css new file mode 100644 index 0000000..44990ad --- /dev/null +++ b/client/style/shoppingbasket.css @@ -0,0 +1,3 @@ +article { + height: auto; +} \ No newline at end of file diff --git a/main.js b/main.js new file mode 100644 index 0000000..9cdc9df --- /dev/null +++ b/main.js @@ -0,0 +1,119 @@ +const express = require('express'); +const app = express(); +/** Host alle bestanden in de client folder als static resources */ +app.use(express.static('client')); + +app.use(express.json()); + +const attractions = [ + { + name: "De Efteling", + description: "The Dutch fairy tale themed park. In high demand!", + adultPrice: 32, + kidsPrice: 32, + minimumNumberOfAdults: 2, + minimumNumberOfKids: 1, + discount: 15, + available: 1, + location: { lon: 5.043689, lat: 51.649718, }, + }, + + { + name: "Madurodam", + description: "The Netherlands smallest theme park.", + adultPrice: 25, + kidsPrice: 20, + minimumNumberOfAdults: 1, + minimumNumberOfKids: 2, + discount: 25, + available: 5, + location: { lat: 52.0994779, lon: 4.299619900000039 }, + }, + + { + name: "Toverland", + description: "Experience magic and wonder.", + adultPrice: 30, + kidsPrice: 30, + minimumNumberOfAdults: 2, + minimumNumberOfKids: 2, + discount: 33, + available: 3, + location: { lat: 52.0994779, lon: 4.299619900000039 }, + }, + + { + name: "Walibi Holland", + description: "Need an Adrenaline Rush?", + adultPrice: 37, + kidsPrice: 37, + minimumNumberOfAdults: 4, + minimumNumberOfKids: 0, + discount: 10, + available: 20, + location: { lon: 5.766986, lat: 52.438554, }, + }, + + { + name: "Duinrell", + description: "From the Kikkerbaan to the Tikibad.", + adultPrice: 22, + kidsPrice: 19, + minimumNumberOfAdults: 1, + minimumNumberOfKids: 3, + discount: 7, + available: 20, + location: { lon: 4.383922, lat: 52.147433, }, + }, + + { + name: "Slagharen", + description: "Fun for the whole family in a true western style.", + adultPrice: 28, + kidsPrice: 20, + minimumNumberOfAdults: 2, + minimumNumberOfKids: 2, + discount: 50, + available: 2, + location: { lat: 52.6249522, lon: 6.563149500000009 }, + }, + + { + name: "Drievliet", + description: "Come and experience our wonderful attractions.", + adultPrice: 26, + kidsPrice: 24, + minimumNumberOfAdults: 1, + minimumNumberOfKids: 2, + discount: 25, + available: 0, + location: { lon: 4.352633, lat: 52.052608, }, + }, +] + +app.post("/api/attractions", (request, response) => { + console.log("Api call received for /attractions"); + response.json(attractions) +}) + +app.post("/api/tickets", (request, response) => { + console.log("Api call received for /placeorder"); + response.json(attractions) +}) + +app.post("/api/placeorder", (request, response) => { + console.log("Api call received for /placeorder"); + response.sendStatus(200); +}); + +app.get("/api/myorders", (request, response) => { + console.log("Api call received for /myorders"); + response.sendStatus(200); +}); + +app.get("/api/admin/edit", (request, response) => { + console.log("Api call received for /admin/edit"); + response.sendStatus(200); +}); + +app.listen(8000, () => console.log('Example app listening on port 8000!')); \ No newline at end of file diff --git a/package.json b/package.json new file mode 100644 index 0000000..0997564 --- /dev/null +++ b/package.json @@ -0,0 +1,9 @@ +{ + "name": "ticketshop", + "version": "1.0.0", + "description": "Het project voor de Ticketshop opdracht", + "main": "main.js", + "dependencies": { + "express": "^4.16.4" + } +} diff --git a/readme.md b/readme.md new file mode 100644 index 0000000..5508eb5 --- /dev/null +++ b/readme.md @@ -0,0 +1,114 @@ +** Introduction ** + +Sogyo Adventure is a new service for Sogyo employees to buy family tickets for amusement parks with attractive discounts. The goal of Sogyo Adventure is to make it as easy as possible to buy tickets. That means that the webshop itself should be as easy to use as possible. According to market research the user base is split almost exactly between desktop, tablet and mobile devices. This means the site should work on every device - large and small. + +Because Sogyo Adventure wants a single, consistent theme throughout their site, the styling defined in `main.css` should be used across all pages. The stylesheet has already been referenced on the index page (also known as a home page) and should be included in the same manner on all other pages. + +The target market being Sogyo employees the webshop can get away with assuming its userbase uses the latest version of Chrome, Firefox, Edge and other up to date browsers. This means that even though it's commonly advised to support as many older browsers as possible, Sogyo Adventure has the freedom to use the latest web technology. This includes (but is not limited to): +* Flexbox +* CSS grid +* CSS variables +* JavaScript modules +* Classes +* Interpolated string literals +* Promises +* Async await + +To get an idea of what Sogyo Adventure could look like, a prototype will first be build. Your assignment is to make that first prototype. For now you won't have to worry about security, authorisation, payment and other such things. Of course all of those are important in real life applications, but not in the prototype. + +Open `index.html` in your browser of choice to see what the the application looks like to users. Also open `index.html` in your favorite editor. If you make changes to the html file, you'll need to reload that page in your browser. By using the developer tools within your browser, you can usually edit the html and/or css on the go, but changes aren't saved. + +** Task 1: styling ** + +There's a few requirements to the look and feel of the page: +* The header should always be at the top of the page, even if the user scrolls down, so that the shopping basket is easily accessible +* The links in the menu should be center aligned +* The links in the menu should be white, whether they've been visited before or not +* The links in the menu should be highlighted in a contrasting color when hovering over them +* Style the 'add to shopping basket' button so it doesn't look like the default. +* Set a favicon (the tiny icon shown in the browsers tab bar next to the tab name) + +The layout should be responsive, i.e. work on desktop, tablet and phone. Use CSS media queries to set three breakpoints in your layout: smaller than 480px in width, smaller than 780px in width and bigger than that. + +On small devices: +* The Sogyo Adventure title bar should use 1.5rem size fonts and be 45px in height +* The blocks with available parks should take up the whole screen width +* The white bar with the Sogyo logo shouldn't be shown +* The navigation bar should be 32px in height + +On medium devices: +* The Sogyo Adventure title bar should use 2rem size fonts and be 60px in height +* Two parks should be shown next to each other +* The white bar with the Sogyo should be 200px high +* The navigation bar should be 32px in height + +On large devices: +* The Sogyo Adventure title bar should use 3rem size fonts and be 80px in height +* At least three parks should be shown next to each other +* The white bar with the Sogyo should be 200px high +* The navigation bar should be 32px in height + +On `map.html`: +* The div `#discoverablemap` should be 100vw (view width) wide and 100vh (view height) tall, minus the whole width of the white logo bar, the title bar and the navigation bar. This should result in the map taking up all remaining space. + +Otherwise get creative! Try changing colors, fonts, color gradients, borders, rounded corners, shadows, transforms, animations, etc. Don't forget that the different pages should look and feel similar, yet clearly distinct from each other. It helps if you get comfortable with the idea of CSS selectors. `main.css` uses different three different kinds of CSS selectors by default, with comments describing what they do, but CSS selectors can be composed and there's more advanced ones as well. + +You have about a day for this task (working on the requirements first before getting creative). + +** Task 2: the index page ** + +The buttons to order tickets will all get the same functionality. A so called event listener that gets fired when the user clicks on one of those buttons. The following steps will guide you through the process of registering event listeners and implementing their behavior. Don't worry about the discounts for family tickets just yet. + +1. Define a function on the top level of your script that will act as the event listener for the "order" buttons. Name this function `orderButtonClicked`. Register it on every button using `document.querySelectorAll()` with a CSS selector as the first argument, iterating over all matching elements and finally calling `.addEventListener()` of type `"click"`. +2. Add a call to `console.log()`to the body of `orderButtonClicked`. Open the developer tools in your browser. Click on the order the buttons. Is the call properly logged? If not: debug! +3. Write a separate function named `saveOrderInShoppingBasket` that will be called from `orderButtonClicked`. This function should receive three arguments: the name of the chosen attraction, the number of adults and the number of children. Give each of the parameters a sensible name. +4. Your event listener receives information on the event as the first argument. Add it to the parameter list, so it can be accessed from within the function. This object has a `.target` property, in our case the element the user clicked on (the order button.) Use this element reference as a starting point and walk the DOM tree using methods and properties like `parentNode`, `classList.contains()`, `nextElementSibling`, `previousElementSibling`, among others. We are interested in three nodes: the `
` containing the attraction name as the text content and two `` elements for the user to enter numbers. +5. From your event listener pass the following information to `saveOrderInShoppingBasket`: the name of the attraction (obtained by calling `.innerText` on the `
` element), the number of adults (obtained by calling `.value` on the `` element and casting the result to a number) and the number of children (obtained the same way). +6. Implement `saveOrderInShoppingBasket`. The order should be saved locally on the clients machine in a way that allows the user to close the browser without the order being lost by using `localStorage`. The `localStorage` is a key-value pair store that works with string values only. You'll need to think of a way to persist/save several orders at once. +7. Once the order is added to the shopping basket the number of items in the shopping basket should be updated. It's displayed in the element with class `"badge"` under the `"#shoppingbasket"`. + +** Task 3: Shopping Basket ** + +We'll now implement the shopping basket, in `shoppingbasket.html` and `shoppingbasket.js`. + +1. The shopping basket page will have to show the user the current state of their shopping basket. To do this, first read their current orders from the `localStorage`, essentially reversing the process you used to persist it. Make sure to cast any numbers in your data back from a string to a number. +2. `shoppingbasket.html` defines a template, i.e. the HTML that should be used for each of the users ordered tickets, but the template itself is never shown to the user. Iterate over each ticket in the shopping basket and add a node to the `
` element for each ticket, based on the pre-defined `