From 6e5c2cc04dbe78d8e5f7a9fd8cdee2803b0cced5 Mon Sep 17 00:00:00 2001 From: aburke921 Date: Wed, 8 Sep 2021 19:09:56 -0400 Subject: [PATCH 1/8] Working & Happy Working and Happy with the product at this point. Still things I want to do but incase things get messed up, here is a commit. --- node_modules/mime/README.md | 187 ++++++++ node_modules/mime/package.json | 81 ++++ node_modules/mime/types/standard.js | 1 + public/css/style.css | 209 +++++++- public/index.html | 164 +++++-- public/js/scripts.js | 707 +++++++++++++++++++++++++++- server.improved.js | 4 +- 7 files changed, 1312 insertions(+), 41 deletions(-) create mode 100644 node_modules/mime/README.md create mode 100644 node_modules/mime/package.json create mode 100644 node_modules/mime/types/standard.js diff --git a/node_modules/mime/README.md b/node_modules/mime/README.md new file mode 100644 index 00000000..b08316f2 --- /dev/null +++ b/node_modules/mime/README.md @@ -0,0 +1,187 @@ + +# Mime + +A comprehensive, compact MIME type module. + +[![Build Status](https://travis-ci.org/broofa/mime.svg?branch=master)](https://travis-ci.org/broofa/mime) + +## Version 2 Notes + +Version 2 is a breaking change from 1.x as the semver implies. Specifically: + +* `lookup()` renamed to `getType()` +* `extension()` renamed to `getExtension()` +* `charset()` and `load()` methods have been removed + +If you prefer the legacy version of this module please `npm install mime@^1`. Version 1 docs may be found [here](https://github.com/broofa/mime/tree/v1.4.0). + +## Install + +### NPM +``` +npm install mime +``` + +### Browser + +It is recommended that you use a bundler such as +[webpack](https://webpack.github.io/) or [browserify](http://browserify.org/) to +package your code. However, browser-ready versions are available via wzrd.in. +E.g. For the full version: + + + + +Or, for the `mime/lite` version: + + + + +## Quick Start + +For the full version (800+ MIME types, 1,000+ extensions): + +```javascript +const mime = require('mime'); + +mime.getType('txt'); // ⇨ 'text/plain' +mime.getExtension('text/plain'); // ⇨ 'txt' +``` + +See [Mime API](#mime-api) below for API details. + +## Lite Version + +There is also a "lite" version of this module that omits vendor-specific +(`*/vnd.*`) and experimental (`*/x-*`) types. It weighs in at ~2.5KB, compared +to 8KB for the full version. To load the lite version: + +```javascript +const mime = require('mime/lite'); +``` + +## Mime .vs. mime-types .vs. mime-db modules + +For those of you wondering about the difference between these [popular] NPM modules, +here's a brief rundown ... + +[`mime-db`](https://github.com/jshttp/mime-db) is "the source of +truth" for MIME type information. It is not an API. Rather, it is a canonical +dataset of mime type definitions pulled from IANA, Apache, NGINX, and custom mappings +submitted by the Node.js community. + +[`mime-types`](https://github.com/jshttp/mime-types) is a thin +wrapper around mime-db that provides an API drop-in compatible(ish) with `mime @ < v1.3.6` API. + +`mime` is, as of v2, a self-contained module bundled with a pre-optimized version +of the `mime-db` dataset. It provides a simplified API with the following characteristics: + +* Intelligently resolved type conflicts (See [mime-score](https://github.com/broofa/mime-score) for details) +* Method naming consistent with industry best-practices +* Compact footprint. E.g. The minified+compressed sizes of the various modules: + +Module | Size +--- | --- +`mime-db` | 18 KB +`mime-types` | same as mime-db +`mime` | 8 KB +`mime/lite` | 2 KB + +## Mime API + +Both `require('mime')` and `require('mime/lite')` return instances of the MIME +class, documented below. + +Note: Inputs to this API are case-insensitive. Outputs (returned values) will +be lowercase. + +### new Mime(typeMap, ... more maps) + +Most users of this module will not need to create Mime instances directly. +However if you would like to create custom mappings, you may do so as follows +... + +```javascript +// Require Mime class +const Mime = require('mime/Mime'); + +// Define mime type -> extensions map +const typeMap = { + 'text/abc': ['abc', 'alpha', 'bet'], + 'text/def': ['leppard'] +}; + +// Create and use Mime instance +const myMime = new Mime(typeMap); +myMime.getType('abc'); // ⇨ 'text/abc' +myMime.getExtension('text/def'); // ⇨ 'leppard' +``` + +If more than one map argument is provided, each map is `define()`ed (see below), in order. + +### mime.getType(pathOrExtension) + +Get mime type for the given path or extension. E.g. + +```javascript +mime.getType('js'); // ⇨ 'application/javascript' +mime.getType('json'); // ⇨ 'application/json' + +mime.getType('txt'); // ⇨ 'text/plain' +mime.getType('dir/text.txt'); // ⇨ 'text/plain' +mime.getType('dir\\text.txt'); // ⇨ 'text/plain' +mime.getType('.text.txt'); // ⇨ 'text/plain' +mime.getType('.txt'); // ⇨ 'text/plain' +``` + +`null` is returned in cases where an extension is not detected or recognized + +```javascript +mime.getType('foo/txt'); // ⇨ null +mime.getType('bogus_type'); // ⇨ null +``` + +### mime.getExtension(type) +Get extension for the given mime type. Charset options (often included in +Content-Type headers) are ignored. + +```javascript +mime.getExtension('text/plain'); // ⇨ 'txt' +mime.getExtension('application/json'); // ⇨ 'json' +mime.getExtension('text/html; charset=utf8'); // ⇨ 'html' +``` + +### mime.define(typeMap[, force = false]) + +Define [more] type mappings. + +`typeMap` is a map of type -> extensions, as documented in `new Mime`, above. + +By default this method will throw an error if you try to map a type to an +extension that is already assigned to another type. Passing `true` for the +`force` argument will suppress this behavior (overriding any previous mapping). + +```javascript +mime.define({'text/x-abc': ['abc', 'abcd']}); + +mime.getType('abcd'); // ⇨ 'text/x-abc' +mime.getExtension('text/x-abc') // ⇨ 'abc' +``` + +## Command Line + + mime [path_or_extension] + +E.g. + + > mime scripts/jquery.js + application/javascript + +---- +Markdown generated from [src/README_js.md](src/README_js.md) by [![RunMD Logo](http://i.imgur.com/h0FVyzU.png)](https://github.com/broofa/runmd) \ No newline at end of file diff --git a/node_modules/mime/package.json b/node_modules/mime/package.json new file mode 100644 index 00000000..b8eb58f9 --- /dev/null +++ b/node_modules/mime/package.json @@ -0,0 +1,81 @@ +{ + "_from": "mime@^2.4.4", + "_id": "mime@2.5.2", + "_inBundle": false, + "_integrity": "sha512-tqkh47FzKeCPD2PUiPB6pkbMzsCasjxAfC62/Wap5qrUWcb+sFasXUC5I3gYM5iBM8v/Qpn4UK0x+j0iHyFPDg==", + "_location": "/mime", + "_phantomChildren": {}, + "_requested": { + "type": "range", + "registry": true, + "raw": "mime@^2.4.4", + "name": "mime", + "escapedName": "mime", + "rawSpec": "^2.4.4", + "saveSpec": null, + "fetchSpec": "^2.4.4" + }, + "_requiredBy": [ + "/" + ], + "_resolved": "https://registry.npmjs.org/mime/-/mime-2.5.2.tgz", + "_shasum": "6e3dc6cc2b9510643830e5f19d5cb753da5eeabe", + "_spec": "mime@^2.4.4", + "_where": "/Users/ashley/Documents/Mobile/a2-shortstack", + "author": { + "name": "Robert Kieffer", + "email": "robert@broofa.com", + "url": "http://github.com/broofa" + }, + "bin": { + "mime": "cli.js" + }, + "bugs": { + "url": "https://github.com/broofa/mime/issues" + }, + "bundleDependencies": false, + "contributors": [], + "dependencies": {}, + "deprecated": false, + "description": "A comprehensive library for mime-type mapping", + "devDependencies": { + "benchmark": "*", + "chalk": "4.1.0", + "eslint": "7.20.0", + "mime-db": "1.46.0", + "mime-score": "1.2.0", + "mime-types": "2.1.28", + "mocha": "8.3.0", + "runmd": "*", + "standard-version": "9.1.0" + }, + "engines": { + "node": ">=4.0.0" + }, + "files": [ + "index.js", + "lite.js", + "Mime.js", + "cli.js", + "/types" + ], + "homepage": "https://github.com/broofa/mime#readme", + "keywords": [ + "util", + "mime" + ], + "license": "MIT", + "name": "mime", + "repository": { + "url": "git+https://github.com/broofa/mime.git", + "type": "git" + }, + "scripts": { + "benchmark": "node src/benchmark.js", + "md": "runmd --watch --output README.md src/README_js.md", + "prepare": "node src/build.js && runmd --output README.md src/README_js.md", + "release": "standard-version", + "test": "mocha src/test.js" + }, + "version": "2.5.2" +} diff --git a/node_modules/mime/types/standard.js b/node_modules/mime/types/standard.js new file mode 100644 index 00000000..cf282761 --- /dev/null +++ b/node_modules/mime/types/standard.js @@ -0,0 +1 @@ +module.exports = {"application/andrew-inset":["ez"],"application/applixware":["aw"],"application/atom+xml":["atom"],"application/atomcat+xml":["atomcat"],"application/atomdeleted+xml":["atomdeleted"],"application/atomsvc+xml":["atomsvc"],"application/atsc-dwd+xml":["dwd"],"application/atsc-held+xml":["held"],"application/atsc-rsat+xml":["rsat"],"application/bdoc":["bdoc"],"application/calendar+xml":["xcs"],"application/ccxml+xml":["ccxml"],"application/cdfx+xml":["cdfx"],"application/cdmi-capability":["cdmia"],"application/cdmi-container":["cdmic"],"application/cdmi-domain":["cdmid"],"application/cdmi-object":["cdmio"],"application/cdmi-queue":["cdmiq"],"application/cu-seeme":["cu"],"application/dash+xml":["mpd"],"application/davmount+xml":["davmount"],"application/docbook+xml":["dbk"],"application/dssc+der":["dssc"],"application/dssc+xml":["xdssc"],"application/ecmascript":["ecma","es"],"application/emma+xml":["emma"],"application/emotionml+xml":["emotionml"],"application/epub+zip":["epub"],"application/exi":["exi"],"application/fdt+xml":["fdt"],"application/font-tdpfr":["pfr"],"application/geo+json":["geojson"],"application/gml+xml":["gml"],"application/gpx+xml":["gpx"],"application/gxf":["gxf"],"application/gzip":["gz"],"application/hjson":["hjson"],"application/hyperstudio":["stk"],"application/inkml+xml":["ink","inkml"],"application/ipfix":["ipfix"],"application/its+xml":["its"],"application/java-archive":["jar","war","ear"],"application/java-serialized-object":["ser"],"application/java-vm":["class"],"application/javascript":["js","mjs"],"application/json":["json","map"],"application/json5":["json5"],"application/jsonml+json":["jsonml"],"application/ld+json":["jsonld"],"application/lgr+xml":["lgr"],"application/lost+xml":["lostxml"],"application/mac-binhex40":["hqx"],"application/mac-compactpro":["cpt"],"application/mads+xml":["mads"],"application/manifest+json":["webmanifest"],"application/marc":["mrc"],"application/marcxml+xml":["mrcx"],"application/mathematica":["ma","nb","mb"],"application/mathml+xml":["mathml"],"application/mbox":["mbox"],"application/mediaservercontrol+xml":["mscml"],"application/metalink+xml":["metalink"],"application/metalink4+xml":["meta4"],"application/mets+xml":["mets"],"application/mmt-aei+xml":["maei"],"application/mmt-usd+xml":["musd"],"application/mods+xml":["mods"],"application/mp21":["m21","mp21"],"application/mp4":["mp4s","m4p"],"application/mrb-consumer+xml":["*xdf"],"application/mrb-publish+xml":["*xdf"],"application/msword":["doc","dot"],"application/mxf":["mxf"],"application/n-quads":["nq"],"application/n-triples":["nt"],"application/node":["cjs"],"application/octet-stream":["bin","dms","lrf","mar","so","dist","distz","pkg","bpk","dump","elc","deploy","exe","dll","deb","dmg","iso","img","msi","msp","msm","buffer"],"application/oda":["oda"],"application/oebps-package+xml":["opf"],"application/ogg":["ogx"],"application/omdoc+xml":["omdoc"],"application/onenote":["onetoc","onetoc2","onetmp","onepkg"],"application/oxps":["oxps"],"application/p2p-overlay+xml":["relo"],"application/patch-ops-error+xml":["*xer"],"application/pdf":["pdf"],"application/pgp-encrypted":["pgp"],"application/pgp-signature":["asc","sig"],"application/pics-rules":["prf"],"application/pkcs10":["p10"],"application/pkcs7-mime":["p7m","p7c"],"application/pkcs7-signature":["p7s"],"application/pkcs8":["p8"],"application/pkix-attr-cert":["ac"],"application/pkix-cert":["cer"],"application/pkix-crl":["crl"],"application/pkix-pkipath":["pkipath"],"application/pkixcmp":["pki"],"application/pls+xml":["pls"],"application/postscript":["ai","eps","ps"],"application/provenance+xml":["provx"],"application/pskc+xml":["pskcxml"],"application/raml+yaml":["raml"],"application/rdf+xml":["rdf","owl"],"application/reginfo+xml":["rif"],"application/relax-ng-compact-syntax":["rnc"],"application/resource-lists+xml":["rl"],"application/resource-lists-diff+xml":["rld"],"application/rls-services+xml":["rs"],"application/route-apd+xml":["rapd"],"application/route-s-tsid+xml":["sls"],"application/route-usd+xml":["rusd"],"application/rpki-ghostbusters":["gbr"],"application/rpki-manifest":["mft"],"application/rpki-roa":["roa"],"application/rsd+xml":["rsd"],"application/rss+xml":["rss"],"application/rtf":["rtf"],"application/sbml+xml":["sbml"],"application/scvp-cv-request":["scq"],"application/scvp-cv-response":["scs"],"application/scvp-vp-request":["spq"],"application/scvp-vp-response":["spp"],"application/sdp":["sdp"],"application/senml+xml":["senmlx"],"application/sensml+xml":["sensmlx"],"application/set-payment-initiation":["setpay"],"application/set-registration-initiation":["setreg"],"application/shf+xml":["shf"],"application/sieve":["siv","sieve"],"application/smil+xml":["smi","smil"],"application/sparql-query":["rq"],"application/sparql-results+xml":["srx"],"application/srgs":["gram"],"application/srgs+xml":["grxml"],"application/sru+xml":["sru"],"application/ssdl+xml":["ssdl"],"application/ssml+xml":["ssml"],"application/swid+xml":["swidtag"],"application/tei+xml":["tei","teicorpus"],"application/thraud+xml":["tfi"],"application/timestamped-data":["tsd"],"application/toml":["toml"],"application/ttml+xml":["ttml"],"application/ubjson":["ubj"],"application/urc-ressheet+xml":["rsheet"],"application/urc-targetdesc+xml":["td"],"application/voicexml+xml":["vxml"],"application/wasm":["wasm"],"application/widget":["wgt"],"application/winhlp":["hlp"],"application/wsdl+xml":["wsdl"],"application/wspolicy+xml":["wspolicy"],"application/xaml+xml":["xaml"],"application/xcap-att+xml":["xav"],"application/xcap-caps+xml":["xca"],"application/xcap-diff+xml":["xdf"],"application/xcap-el+xml":["xel"],"application/xcap-error+xml":["xer"],"application/xcap-ns+xml":["xns"],"application/xenc+xml":["xenc"],"application/xhtml+xml":["xhtml","xht"],"application/xliff+xml":["xlf"],"application/xml":["xml","xsl","xsd","rng"],"application/xml-dtd":["dtd"],"application/xop+xml":["xop"],"application/xproc+xml":["xpl"],"application/xslt+xml":["*xsl","xslt"],"application/xspf+xml":["xspf"],"application/xv+xml":["mxml","xhvml","xvml","xvm"],"application/yang":["yang"],"application/yin+xml":["yin"],"application/zip":["zip"],"audio/3gpp":["*3gpp"],"audio/adpcm":["adp"],"audio/amr":["amr"],"audio/basic":["au","snd"],"audio/midi":["mid","midi","kar","rmi"],"audio/mobile-xmf":["mxmf"],"audio/mp3":["*mp3"],"audio/mp4":["m4a","mp4a"],"audio/mpeg":["mpga","mp2","mp2a","mp3","m2a","m3a"],"audio/ogg":["oga","ogg","spx","opus"],"audio/s3m":["s3m"],"audio/silk":["sil"],"audio/wav":["wav"],"audio/wave":["*wav"],"audio/webm":["weba"],"audio/xm":["xm"],"font/collection":["ttc"],"font/otf":["otf"],"font/ttf":["ttf"],"font/woff":["woff"],"font/woff2":["woff2"],"image/aces":["exr"],"image/apng":["apng"],"image/avif":["avif"],"image/bmp":["bmp"],"image/cgm":["cgm"],"image/dicom-rle":["drle"],"image/emf":["emf"],"image/fits":["fits"],"image/g3fax":["g3"],"image/gif":["gif"],"image/heic":["heic"],"image/heic-sequence":["heics"],"image/heif":["heif"],"image/heif-sequence":["heifs"],"image/hej2k":["hej2"],"image/hsj2":["hsj2"],"image/ief":["ief"],"image/jls":["jls"],"image/jp2":["jp2","jpg2"],"image/jpeg":["jpeg","jpg","jpe"],"image/jph":["jph"],"image/jphc":["jhc"],"image/jpm":["jpm"],"image/jpx":["jpx","jpf"],"image/jxr":["jxr"],"image/jxra":["jxra"],"image/jxrs":["jxrs"],"image/jxs":["jxs"],"image/jxsc":["jxsc"],"image/jxsi":["jxsi"],"image/jxss":["jxss"],"image/ktx":["ktx"],"image/ktx2":["ktx2"],"image/png":["png"],"image/sgi":["sgi"],"image/svg+xml":["svg","svgz"],"image/t38":["t38"],"image/tiff":["tif","tiff"],"image/tiff-fx":["tfx"],"image/webp":["webp"],"image/wmf":["wmf"],"message/disposition-notification":["disposition-notification"],"message/global":["u8msg"],"message/global-delivery-status":["u8dsn"],"message/global-disposition-notification":["u8mdn"],"message/global-headers":["u8hdr"],"message/rfc822":["eml","mime"],"model/3mf":["3mf"],"model/gltf+json":["gltf"],"model/gltf-binary":["glb"],"model/iges":["igs","iges"],"model/mesh":["msh","mesh","silo"],"model/mtl":["mtl"],"model/obj":["obj"],"model/stl":["stl"],"model/vrml":["wrl","vrml"],"model/x3d+binary":["*x3db","x3dbz"],"model/x3d+fastinfoset":["x3db"],"model/x3d+vrml":["*x3dv","x3dvz"],"model/x3d+xml":["x3d","x3dz"],"model/x3d-vrml":["x3dv"],"text/cache-manifest":["appcache","manifest"],"text/calendar":["ics","ifb"],"text/coffeescript":["coffee","litcoffee"],"text/css":["css"],"text/csv":["csv"],"text/html":["html","htm","shtml"],"text/jade":["jade"],"text/jsx":["jsx"],"text/less":["less"],"text/markdown":["markdown","md"],"text/mathml":["mml"],"text/mdx":["mdx"],"text/n3":["n3"],"text/plain":["txt","text","conf","def","list","log","in","ini"],"text/richtext":["rtx"],"text/rtf":["*rtf"],"text/sgml":["sgml","sgm"],"text/shex":["shex"],"text/slim":["slim","slm"],"text/spdx":["spdx"],"text/stylus":["stylus","styl"],"text/tab-separated-values":["tsv"],"text/troff":["t","tr","roff","man","me","ms"],"text/turtle":["ttl"],"text/uri-list":["uri","uris","urls"],"text/vcard":["vcard"],"text/vtt":["vtt"],"text/xml":["*xml"],"text/yaml":["yaml","yml"],"video/3gpp":["3gp","3gpp"],"video/3gpp2":["3g2"],"video/h261":["h261"],"video/h263":["h263"],"video/h264":["h264"],"video/iso.segment":["m4s"],"video/jpeg":["jpgv"],"video/jpm":["*jpm","jpgm"],"video/mj2":["mj2","mjp2"],"video/mp2t":["ts"],"video/mp4":["mp4","mp4v","mpg4"],"video/mpeg":["mpeg","mpg","mpe","m1v","m2v"],"video/ogg":["ogv"],"video/quicktime":["qt","mov"],"video/webm":["webm"]}; \ No newline at end of file diff --git a/public/css/style.css b/public/css/style.css index d5f842ab..4d9eef1b 100644 --- a/public/css/style.css +++ b/public/css/style.css @@ -1 +1,208 @@ -/*Style your own assignment! This is fun! */ \ No newline at end of file +/*Style your own assignment! This is fun! */ +header{ + text-align: center; +} + +header h1{ + font-family: Alex Brush; + font-size: 80px; + margin: auto; + text-shadow: 0px 0px 40px hsla(0, 100%, 30%, 0.8); +} + +.container { + background-color: #fffaf0; + + -webkit-clip-path: polygon(0% 0%, 0% 100%, 10% 99%, 15% 100%, 20% 98%, 25% 100%, + 30% 99%, 35% 100%, 40% 100%, 45% 100%, 50% 99%, 55% 100%, + 60% 99%, 65% 100%, 70% 98%, 75% 100%, 80% 98%, 85% 100%, + 90% 99%, 95% 100%, 100% 0%,0% 0%, 5% 100%, 10% 0%, 15% 100%, + 20% 0%, 25% 100%, 30% 0%, 35% 100%, 40% 0%, 45% 100%, 50% 0%, + 55% 100%, 60% 0%, 65% 100%, 70% 0%, 75% 100%, 80% 0%, 85% 100%, + 90% 0%, 95% 100%, 100% 0%,0% 0%, 5% 100%, 10% 0%, 15% 100%, + 20% 0%, 25% 100%, 30% 0%, 35% 60%, 40% 0%, 45% 100%, 50% 0%, + 55% 100%, 60% 0%, 65% 100%, 70% 0%, 75% 100%, 90% 90%, 95% 100%, + 98% 99%, 100% 100%, 100% 0%); + + margin: auto auto; + width: 650px; + height: 475px; + padding-top: 10px; + padding-bottom: 20px; + display: grid; + + /* column-gap: 10px; */ + + grid-template-areas: + ". . edit_button" + "total_people total_people total_people" + "provided_calculation_1 provided_calculation_2 provided_calculation_3" + "amount_due amount_due form_amount_due" + "tip tip form_tip" + "footer footer footer"; + + font-family: Special Elite; + font-size: 25px; +} + +.recalculate_button{ + justify-self: right; +} +.saved_container{ + background-color: #fffaf0; + + -webkit-clip-path: polygon(0% 0%, 0% 100%, 10% 99%, 15% 100%, 20% 98%, 25% 100%, + 30% 99%, 35% 100%, 40% 100%, 45% 100%, 50% 99%, 55% 100%, + 60% 99%, 65% 100%, 70% 98%, 75% 100%, 80% 98%, 85% 100%, + 90% 99%, 95% 100%, 100% 0%,0% 0%, 5% 100%, 10% 0%, 15% 100%, + 20% 0%, 25% 100%, 30% 0%, 35% 100%, 40% 0%, 45% 100%, 50% 0%, + 55% 100%, 60% 0%, 65% 100%, 70% 0%, 75% 100%, 80% 0%, 85% 100%, + 90% 0%, 95% 100%, 100% 0%,0% 0%, 5% 100%, 10% 0%, 15% 100%, + 20% 0%, 25% 100%, 30% 0%, 35% 60%, 40% 0%, 45% 100%, 50% 0%, + 55% 100%, 60% 0%, 65% 100%, 70% 0%, 75% 100%, 90% 90%, 95% 100%, + 98% 99%, 100% 100%, 100% 0%); + + margin-left: auto; + margin-right: auto; + margin-top: 25px; + width: 650px; + height: 475px; + padding-top: 10px; + padding-bottom: 20px; + display: grid; + + /* column-gap: 10px; */ + + grid-template-areas: + "time_stamp . edit_button" + "total_people total_people total_people" + "provided_calculation_1 provided_calculation_2 provided_calculation_3" + "amount_due amount_due form_amount_due" + "tip tip form_tip" + "footer footer final_calculation"; + + font-family: Special Elite; + font-size: 25px; +} + + +#time_stamp{ + font-family: Special Elite; + font-size: 10px; + grid-area: time_stamp; + justify-self: left; + margin-top: 10px; +} + + +input { + font-family: Special Elite; + font-size: 25px; + width:150px; + padding-top: 5px; +} + +#num_people_container { + grid-area: total_people; + place-self: center; +} + +#edit_button{ + grid-area: edit_button; + padding: 5px; + height: fit-content; + justify-self: right; + margin-right: 15px; +} + +.people_input{ + width: 80px; +} + +#provided_calculation_1{ + grid-area: provided_calculation_1; + place-self: center; +} + +#provided_calculation_2{ + grid-area: provided_calculation_2; + place-self: center; +} + +#provided_calculation_3{ + grid-area: provided_calculation_3; + place-self: center; +} + +#amount_due { + grid-area: amount_due; + justify-self: right; + margin-top: auto; + margin-bottom: auto; +} + +#form_amount_due { + grid-area: form_amount_due; + place-self: center; +} + +#tip { + grid-area: tip; + justify-self: right; + margin-top: auto; + margin-bottom: auto; +} + +#form_tip { + grid-area: form_tip; + place-self: center; +} + +#footer{ + font-family: Special Elite; + font-size: 25px; + grid-area: footer; + place-self: center; + text-align: center; +} + + +/* #total { + grid-area: total; + place-self: center; +} */ + +#final_calculation { + grid-area: final_calculation; + place-self: center; +} + + + +p { + width: fit-content; + margin-left: auto; + margin-right: auto; + margin-top: 0px; + margin-bottom: 0px; +} + +body { + background: + radial-gradient(hsl(0, 100%, 27%) 4%, hsl(0, 100%, 18%) 9%, hsla(0, 100%, 20%, 0) 9%) 0 0, + radial-gradient(hsl(0, 100%, 27%) 4%, hsl(0, 100%, 18%) 8%, hsla(0, 100%, 20%, 0) 10%) 50px 50px, + radial-gradient(hsla(0, 100%, 30%, 0.8) 20%, hsla(0, 100%, 20%, 0)) 50px 0, + radial-gradient(hsla(0, 100%, 30%, 0.8) 20%, hsla(0, 100%, 20%, 0)) 0 50px, + radial-gradient(hsla(0, 100%, 20%, 1) 35%, hsla(0, 100%, 20%, 0) 60%) 50px 0, + radial-gradient(hsla(0, 100%, 20%, 1) 35%, hsla(0, 100%, 20%, 0) 60%) 100px 50px, + radial-gradient(hsla(0, 100%, 15%, 0.7), hsla(0, 100%, 20%, 0)) 0 0, + radial-gradient(hsla(0, 100%, 15%, 0.7), hsla(0, 100%, 20%, 0)) 50px 50px, + linear-gradient(45deg, hsla(0, 100%, 20%, 0) 49%, hsla(0, 100%, 0%, 1) 50%, hsla(0, 100%, 20%, 0) 70%) 0 0, + linear-gradient(-45deg, hsla(0, 100%, 20%, 0) 49%, hsla(0, 100%, 0%, 1) 50%, hsla(0, 100%, 20%, 0) 70%) 0 0; + background-color: #300; + background-size: 100px 100px; + + /* // IMPORTANT PART #1 */ + filter: drop-shadow(-1px 6px 3px rgba(0, 0, 0, 0.5)); + padding-bottom: 25px; +} \ No newline at end of file diff --git a/public/index.html b/public/index.html index c56d620e..4d6c170f 100644 --- a/public/index.html +++ b/public/index.html @@ -1,41 +1,129 @@ + - - CS4241 Assignment 2 - - - -
- - -
- - + + CS4241 Assignment 2 + + + + + + + + +
+

Tip

+

Calculator

+
+ +
+ + +
+ + +
+ +
+

20%

+

$_.__

+
+ +
+

17.5%

+

$_.__

+
+ +
+

15%

+

$_.__

+
+ + + + +
+ +
+ + + +
+ +
+ + + + +
+ + + + + + + + +
+ +

Saved on September 8, 2021 at 11:19am

+ + + edit + +
+ + +
+ +
+

20%

+

$_.__

+
+ +
+

17.5%

+

$_.__

+
+ +
+

15%

+

$_.__

+
+ + + + +
+

$100.00

+
+ + + +
+

$20.00

+
+ + + +

$0.00

+ +
+ + + diff --git a/public/js/scripts.js b/public/js/scripts.js index de052eae..5daf3488 100644 --- a/public/js/scripts.js +++ b/public/js/scripts.js @@ -1,3 +1,708 @@ // Add some Javascript code here, to run on the front end. -console.log("Welcome to assignment 2!") \ No newline at end of file +console.log("Welcome to assignment 2!") + + + + + +/* +This function is called every time you click outside of the "Amount Due" form, and every time a key is pressed inside of it + +input: the "input" element (The input element containing the actual value) +blur: is a string ("blur") if the function is being called as a result of clicking outside of the input form +*/ +function handle_amount_due(input, blur){ + + // Which big white box are we talking about here? + let parent_container = input.parentElement.parentElement; + + //This is the form location for the "Tip" within the same big white box + let tip_location = parent_container.children[7]; + + if(parent_container.children.length === 10){ + tip_location = parent_container.children[8]; + } + + + if (blur === "blur"){ + // We are inside here because we deselected the amount due form + + //Lets make sure the input we gave is formatted (does it have 2 decimal places at the end?, ect) + formatCurrency(input, blur) + + // Now lets calculate some suggested tips. Lets give it the input element containing the actual value and + // which big whit box, it should be updating the percentages for + update_tip_suggestions(input, parent_container); + } + else{ + + // We are currently typing inside of the amount due form, so lets make sure we don't + // add any characters we shouldn't and make sure it is formatted properly. + formatCurrency(input) + } + + let tip = tip_location.children[0]; + + + // Now that we have an amount, let's make sure that if we already had a tip input, the tip percentage of the total cost + // will accurately be reflected. + calculate_tip_percentage(tip, parent_container); + +} + + +function handle_tip(input, blur){ + + // The tip is inside of a form, which is inside of the big white box + let parent_container = input.parentElement.parentElement; + + if (blur === "blur"){ + //Inside if means we clicked outside of the tip form + + // We want to make sure that the string is formatted properly even if we didn't + //leave it formatted + formatCurrency(input, blur) + + //We clicked outside of the tip form so, we can now calculate what percentage + // of the total cost our tip was + calculate_tip_percentage(input, parent_container); + } + else{ + + // We are currently typing inside of the tip form, so lets make sure we don't + // add any characters we shouldn't and make sure it is formatted properly. + formatCurrency(input) + } +} + +function generateNewForm(delete_container){ + + // console.log("delete container", delete_container); + + let previously_saved_form = document.body.children[2]; + // console.log("previously_saved_form:", previously_saved_form); + + let new_saved_container = document.createElement("div"); + new_saved_container.setAttribute("id", "box"); + new_saved_container.setAttribute("class", "saved_container"); + + + //Time Stamp + let d = new Date(); + const months = ["January","February","March","April","May","June","July","August","September","October","November","December"]; + let month = months[d.getMonth()] + let year = d.getFullYear(); + let date = d.getDate(); + let hours = d.getHours(); + let minutes = d.getMinutes(); + let tod = "am"; + + if(minutes < 10){ + minutes = "0" + minutes; + } + if(hours > 12) { + hours = hours - 12; + tod = "pm"; + } + + let saved_time = "Saved on " + month + " " + date + ", " + year + " at " + hours + ":" + minutes + tod; + + let new_time_stamp = document.createElement("p"); + new_time_stamp.setAttribute("id", "time_stamp"); + new_time_stamp.innerHTML = saved_time; + + new_saved_container.appendChild(new_time_stamp); + + + + + let new_edit_button = document.createElement("span"); + new_edit_button.setAttribute("id", "edit_button"); + new_edit_button.setAttribute("class", "material-icons"); + new_edit_button.setAttribute("onclick", "edit_mode(this)"); + new_edit_button.innerHTML = "edit"; + + new_saved_container.appendChild(new_edit_button); + + + let new_people_form = document.createElement("form"); + new_people_form.setAttribute("action", ""); + new_people_form.setAttribute("id", "num_people_container"); + + let new_num_people = document.createElement("label"); + new_num_people.setAttribute("id", "people_input"); + new_num_people.innerHTML = "?"; + + let new_people_label = document.createElement("label"); + new_people_label.innerHTML = " people"; + + + + new_people_form.appendChild(new_num_people); + new_people_form.appendChild(new_people_label); + new_saved_container.appendChild(new_people_form); + + + + let new_provided_calculation_1 = document.createElement("div"); + new_provided_calculation_1.setAttribute("id", "provided_calculation_1"); + new_provided_calculation_1.setAttribute("class", "calculation"); + + let new_20_p = document.createElement("p"); + new_20_p.innerHTML = "20%"; + + let new_calculated_20 = document.createElement("p"); + new_calculated_20.setAttribute("id", "20%_value"); + new_calculated_20.innerHTML = "$?.??"; + + new_provided_calculation_1.appendChild(new_20_p); + new_provided_calculation_1.appendChild(new_calculated_20); + new_saved_container.appendChild(new_provided_calculation_1); + + + + + let new_provided_calculation_2 = document.createElement("div"); + new_provided_calculation_2.setAttribute("id", "provided_calculation_2"); + new_provided_calculation_2.setAttribute("class", "calculation"); + + let new_17_p = document.createElement("p"); + new_17_p.innerHTML = "17.5%"; + + let new_calculated_17 = document.createElement("p"); + new_calculated_17.setAttribute("id", "17.5%_value"); + new_calculated_17.innerHTML = "$?.??"; + + + new_provided_calculation_2.appendChild(new_17_p); + new_provided_calculation_2.appendChild(new_calculated_17); + new_saved_container.appendChild(new_provided_calculation_2); + + + + let new_provided_calculation_3 = document.createElement("div"); + new_provided_calculation_3.setAttribute("id", "provided_calculation_3"); + new_provided_calculation_3.setAttribute("class", "calculation"); + + let new_15_p = document.createElement("p"); + new_15_p.innerHTML = "15%"; + + let new_calculated_15 = document.createElement("p"); + new_calculated_15.setAttribute("id", "15%_value"); + new_calculated_15.innerHTML = "$?.??"; + + new_provided_calculation_3.appendChild(new_15_p); + new_provided_calculation_3.appendChild(new_calculated_15); + new_saved_container.appendChild(new_provided_calculation_3); + + + + + let new_amount_due_label = document.createElement("label"); + new_amount_due_label.setAttribute("id","amount_due"); + new_amount_due_label.innerHTML = "Amount Due :"; + new_saved_container.appendChild(new_amount_due_label); + + + + let new_form_amount_due = document.createElement("form"); + new_form_amount_due.setAttribute("action", ""); + new_form_amount_due.setAttribute("id", "form_amount_due"); + new_form_amount_due.setAttribute("class", "form_container"); + + let new_amount_due = document.createElement("p"); + new_amount_due.setAttribute("id", "given_amount"); + new_amount_due.innerHTML = "$200.00"; + new_form_amount_due.appendChild(new_amount_due); + + new_saved_container.appendChild(new_form_amount_due); + + + + + let new_tip_label = document.createElement("label"); + new_tip_label.setAttribute("id","tip"); + new_tip_label.innerHTML = "+ Tip :"; + new_saved_container.appendChild(new_tip_label); + + + + + let new_form_tip = document.createElement("form"); + new_form_tip.setAttribute("action", ""); + new_form_tip.setAttribute("id", "form_tip"); + new_form_tip.setAttribute("class", "form_container"); + + let new_tip = document.createElement("p"); + new_tip.innerHTML = "$20.00"; + new_form_tip.appendChild(new_tip); + + new_saved_container.appendChild(new_form_tip); + + + + + let new_footer = document.createElement("p"); + new_footer.setAttribute("id", "footer"); + new_footer.innerHTML = " = Total / Person:"; + + + let new_total_cost = document.createElement("p"); + new_total_cost.setAttribute("id", "final_calculation"); + new_total_cost.innerHTML = "$?.??"; + + new_saved_container.appendChild(new_footer); + new_saved_container.appendChild(new_total_cost); + + + //Adds everything to the webpage + document.body.insertBefore(new_saved_container, previously_saved_form); + + // console.log(delete_container); + if(delete_container !== undefined){ + delete_container.remove(); + // console.log("removing"); + + + } + + return new_saved_container; + + + + + + + + + + + +} + +function delete_form(delete_button){ + let container = delete_button.parentElement; + container.remove(); +} + + + + + +function edit_mode(button){ + + // console.log(button); + + let container = button.parentElement; + + let previous_time_stamp = container.children[0]; + let total_calculation = container.children[11]; + + total_calculation.remove(); + + + let people_form = container.children[2]; + let amount_form = container.children[7]; + let tip_form = container.children[9]; + let calculation = container.children[10]; + + previous_time_stamp.remove(); + + // container.setAttribute("class", "container"); + // console.log(calculation); + + // console.log(people_form); + // console.log(amount_form); + // console.log(tip_form); + + let people_input = people_form.children[0]; + let amount_input = amount_form.children[0]; + let tip_input = tip_form.children[0]; + + // console.log(people_input); + // console.log(amount_input); + // console.log(tip_input); + + // console.log("people_input.innerHTML", people_input.innerHTML); + let num_of_people = people_input.innerHTML; + let amount_due = amount_input.innerHTML; + let tip = tip_input.innerHTML; + + // console.log(num_of_people); + // console.log(amount_due); + // console.log("tip value = ", tip); + + + amount_input.remove(); + tip_input.remove(); + // people_input.innerHTML = " people"; + + let new_people_input = document.createElement("input"); + + new_people_input.setAttribute("type", "text"); + new_people_input.setAttribute("value", num_of_people); + new_people_input.setAttribute("class", "people_input"); + + people_form.insertBefore(new_people_input, people_input); + + people_input.remove(); + + let new_amount_input = document.createElement("input"); + + new_amount_input.setAttribute("type", "text"); + new_amount_input.setAttribute("id", "given_amount"); + new_amount_input.setAttribute("value", amount_due); + new_amount_input.setAttribute("data", "currency"); + new_amount_input.setAttribute("placeholder", "$0.00"); + new_amount_input.setAttribute("onkeyup", "handle_amount_due(this)"); + new_amount_input.setAttribute("onblur", "handle_amount_due(this, 'blur')"); + + amount_form.appendChild(new_amount_input); + + + let new_tip_input = document.createElement("input"); + + + + new_tip_input.setAttribute("type", "text"); + new_tip_input.setAttribute("id", "tip_amount"); + new_tip_input.setAttribute("value", tip); + new_tip_input.setAttribute("data-type", 'currency'); + new_tip_input.setAttribute("placeholder", "$0.00"); + new_tip_input.setAttribute("onkeyup", "handle_tip(this)"); + new_tip_input.setAttribute("onblur", "handle_tip(this, 'blur')"); + + tip_form.appendChild(new_tip_input); + + calculation.remove(); + + let new_calculate_button = document.createElement("button"); + let new_save_icon = document.createElement("span"); + + new_save_icon.setAttribute("class", "material-icons"); + new_save_icon.innerHTML = "save_alt"; + + new_calculate_button.setAttribute("id", "footer"); + new_calculate_button.setAttribute("onclick","submit(this)"); + new_calculate_button.innerHTML = "Calculate "; + new_calculate_button.appendChild(new_save_icon); + + container.appendChild(new_calculate_button); + + + const get_date = function(){ + let d = new Date(); + const months = ["January","February","March","April","May","June","July","August","September","October","November","December"]; + let month = months[d.getMonth()] + let year = d.getFullYear(); + let date = d.getDate(); + let hours = d.getHours(); + let minutes = d.getMinutes(); + let tod = "am"; + + if(minutes < 10){ + minutes = "0" + minutes; + } + if(hours > 12) { + hours = hours - 12; + tod = "pm"; + } + + let saved_time = "Saved on " + month + " " + date + ", " + year + " at " + hours + ":" + minutes + tod; + + // console.log(saved_time); + + } + + button.innerHTML = "delete"; + button.setAttribute("onclick", "delete_form(this)"); + + + + +} + + + + +function formatNumber(n) { + + // format number 1000000 to 1,234,567 + return n.replace(/\D/g, "").replace(/\B(?=(\d{3})+(?!\d))/g, ",") +} + + +function formatCurrency(input, blur) { + // appends $ to value, validates decimal side + // and puts cursor back in right position. + + // get input value + + let input_val; + +// console.log("input", input.value); + + //If there is no input value, the placeholder value will showup again + if(input.value !== ''){ + input_val = '$' + input.value; + } + else{ + input_val = ''; + } + + + + + // don't validate empty input + if (input_val === "") { return; } + + // original length + var original_len = input_val.length; + + + // check for decimal + if (input_val.indexOf(".") >= 0) { + + // get position of first decimal + // this prevents multiple decimals from + // being entered + var decimal_pos = input_val.indexOf("."); + + // split number by decimal point + var left_side = input_val.substring(0, decimal_pos); + var right_side = input_val.substring(decimal_pos); + + // add commas to left side of number + left_side = formatNumber(left_side); + + // validate right side + right_side = formatNumber(right_side); + + // On blur make sure 2 numbers after decimal + // blur means when you are not focused on the input form (the input is not selected) + if (blur === "blur") { + right_side += "00"; + } + + // Limit decimal to only 2 digits + right_side = right_side.substring(0, 2); + + // join number by . + input_val = "$" + left_side + "." + right_side; + + } else { + // no decimal entered + // add commas to number + // remove all non-digits + input_val = formatNumber(input_val); + input_val = "$" + input_val; + + // final formatting + if (blur === "blur") { + input_val += ".00"; + } + } + + + // Updates the value that is inside of the form +// console.log("at the end:", input_val); + input.value = input_val; + +} + + +// Updates the pre-defined common tips +function update_tip_suggestions(input, parent_container) { + + // This is the actual use input string (Amount Due) + let val = input.value; + + // The input value was in currency format, so let's remove the $ and all the commas so we can perform math on it + val = val.replace(',', ''); + val = val.replace('$', ''); + + // We need the amount due to be a float rather than a string in order to perform calculations + let total_cost = parseFloat(val); + + // Now we calculate the percentages + let twenty_percent = total_cost * 0.2; + let seventeen_point_five_percent = total_cost * 0.175; + let fifteen_percent = total_cost * 0.15; + + + let twenty_p = parent_container.children[1]; + let seventeen_p = parent_container.children[2]; + let fifteen_p = parent_container.children[3]; + + if(parent_container.children.length === 10){ + twenty_p = parent_container.children[2]; + seventeen_p = parent_container.children[3]; + fifteen_p = parent_container.children[4]; + } + + let twenty_html = "$" + twenty_percent.toFixed(2); + let seventeen_html = "$" + seventeen_point_five_percent.toFixed(2); + let fifteen_html = "$" + fifteen_percent.toFixed(2); + + // If the user did not give any value for the Amount Due, keep the tip suggestions to their default value + if(twenty_html === "$NaN"){ + twenty_html = "$_.__"; + seventeen_html = "$_.__"; + fifteen_html = "$_.__"; + } + + twenty_p.children[1].innerHTML = twenty_html; + seventeen_p.children[1].innerHTML = seventeen_html; + fifteen_p.children[1].innerHTML = fifteen_html; + +} + +/* + This function adds the actual percentage of the Amount Due that the user gave + + input: the actual "input" element that contains the value the user gave + parent_container: the big white box element that the tip is being altered in +*/ +function calculate_tip_percentage(input, parent_container){ + + // Lets get the value the user actually gave for the tip + let input_val = input.value; + + console.log("parent_container.children", parent_container.children); + console.log("parent_container.children", parent_container.children.length); + console.log("input", input); + console.log("parent_container", parent_container); + + let num_of_elements = parent_container.children.length; + + //This is the element that writes out to the user "+ Tip" + let tip_label = parent_container.children[6]; + + if(num_of_elements === 10){ + // If the user is editing a calculation, the edit/delete button in the upper right hand corner, messes up which child + // we want to grab. Here, we are making up for that. + tip_label = parent_container.children[7]; + } + + + + if (input_val.length !== 0){ + // If we are inside here, it means the user actually gave a value for the tip + + // In order to perform calculations on the tip, we need to remove the commas and the $ + input_val = input_val.replace(',', ''); + input_val = input_val.replace('$', ''); + + // We also need to make the tip value a actual number rather than a string, so we can calculate things with it + let tip = parseFloat(input_val); + + + + // This gives us the form in which the total cost is located. The value for the cost is in one of it's child elements + let amount_form = parent_container.children[5]; + + if(num_of_elements === 10){ + + // If the user is editing a calculation, the edit/delete button in the upper right hand corner, messes up which child + // we want to grab. Here, we are making up for that. + amount_form = parent_container.children[6]; + } + + let cost_val = amount_form.children[0].value; + + //Default (for when the user doesn't give a total amount due value) + let percentage = 100; + + + // cost_val is a string containing the AmountDue input. If there is any user input, the length would be greater than 0, but + // if the user didn't give a value, the length of cost_val will be 0 + if(cost_val.length !== 0){ + + //We want to reformat the input to something that can have calculations performed on it + cost_val = cost_val.replace(',', ''); + cost_val = cost_val.replace('$', ''); + let total_cost = parseFloat(cost_val); + + // Lets make it not a decimal percentage + percentage = (tip / total_cost) * 100; + + } + + // Add two decimal places to the percentage + percentage = percentage.toFixed(2); + + + // Now we display to the user the percentage of the cost their tip is + tip_label.innerHTML = `+ Tip (%${percentage}) :`; + + } + else{ + + //There is no tip given so there is no need to write what percentage of the total cost there tip is + tip_label.innerHTML = "+ Tip :" + } +} + +function submit(calculate_button) { + + let container = calculate_button.parentElement; + + // console.log(calculate_button); + if(container.className === "container"){ + // console.log("main form"); + new_saved_container = generateNewForm(); + + } + else{ + // console.log("sub form"); + new_saved_container = generateNewForm(container); + } + + + // //prevents the default form action from being executed + // event.preventDefault() + + // console.log("total_cost_input", new_saved_container.querySelector('#given_amount')); + const total_cost_input = new_saved_container.querySelector('#given_amount'), + total_cost_json = { given_amount: total_cost_input.value }, + total_cost_body = JSON.stringify(total_cost_json) + + + // console.log(total_cost_json); + // console.log(total_cost_body); + + const tip_input = container.querySelector('#tip_amount'), + tip_json = { tip_amount: tip_input.value }, + tip_body = JSON.stringify(tip_json) + + // console.log(tip_input); + // console.log(tip_json); + // console.log(tip_body); + + const people_input = container.querySelector('#people_input'), + people_json = { people_input: people_input.value }, + people_body = JSON.stringify(tip_json) + + // console.log(people_input); + // console.log(people_json); + // console.log(people_body); + + + fetch('/submit', { + method: 'POST', + "body": total_cost_body // Same thing as: "body" : body + }) + .then(function( response ){ + //do something with the response + // console.log( response ) + }) + + return false +} + + + + + + diff --git a/server.improved.js b/server.improved.js index 26673fc0..d87f4f04 100644 --- a/server.improved.js +++ b/server.improved.js @@ -40,10 +40,12 @@ const handlePost = function( request, response ) { request.on( 'end', function() { console.log( JSON.parse( dataString ) ) + const json = JSON.parse(dataString); + // ... do something with the data here!!! response.writeHead( 200, "OK", {'Content-Type': 'text/plain' }) - response.end() + response.end(JSON.stringify(json)) }) } From 06a9f7335710a1999e1ad255a47570a41c73841f Mon Sep 17 00:00:00 2001 From: aburke921 Date: Wed, 8 Sep 2021 20:04:02 -0400 Subject: [PATCH 2/8] num of people constraint added num of people constraint --- public/css/style.css | 4 ++++ public/index.html | 2 +- public/js/scripts.js | 15 +++++++++++++++ 3 files changed, 20 insertions(+), 1 deletion(-) diff --git a/public/css/style.css b/public/css/style.css index 4d9eef1b..89f98bfd 100644 --- a/public/css/style.css +++ b/public/css/style.css @@ -166,6 +166,10 @@ input { text-align: center; } +.footer:disabled { + cursor: not-allowed; +} + /* #total { grid-area: total; diff --git a/public/index.html b/public/index.html index 4d6c170f..ea0e9bcc 100644 --- a/public/index.html +++ b/public/index.html @@ -20,7 +20,7 @@

Calculator

- +
diff --git a/public/js/scripts.js b/public/js/scripts.js index 5daf3488..87348c9c 100644 --- a/public/js/scripts.js +++ b/public/js/scripts.js @@ -343,6 +343,8 @@ function edit_mode(button){ new_people_input.setAttribute("type", "text"); new_people_input.setAttribute("value", num_of_people); new_people_input.setAttribute("class", "people_input"); + new_people_input.setAttribute("onkeyup", "formatPeople(this)"); + new_people_input.setAttribute("onblur", "checkForValue(this)"); people_form.insertBefore(new_people_input, people_input); @@ -432,6 +434,19 @@ function formatNumber(n) { return n.replace(/\D/g, "").replace(/\B(?=(\d{3})+(?!\d))/g, ",") } +function formatPeople(input_element){ + let input_val = input_element.value; + + input_element.value = formatNumber(input_val); +} + +function checkForValue(input_element){ + let input_val = input_element.value; + + if (input_val === "") { + input_element.value = 1; + } +} function formatCurrency(input, blur) { // appends $ to value, validates decimal side From 3ebe9af3d63ccb9145d573bd5240e8f5cd1b5b17 Mon Sep 17 00:00:00 2001 From: aburke921 Date: Wed, 8 Sep 2021 20:15:05 -0400 Subject: [PATCH 3/8] package-lock file --- package-lock.json | 11 +++++++++++ 1 file changed, 11 insertions(+) create mode 100644 package-lock.json diff --git a/package-lock.json b/package-lock.json new file mode 100644 index 00000000..4ad87b9a --- /dev/null +++ b/package-lock.json @@ -0,0 +1,11 @@ +{ + "requires": true, + "lockfileVersion": 1, + "dependencies": { + "mime": { + "version": "2.5.2", + "resolved": "https://registry.npmjs.org/mime/-/mime-2.5.2.tgz", + "integrity": "sha512-tqkh47FzKeCPD2PUiPB6pkbMzsCasjxAfC62/Wap5qrUWcb+sFasXUC5I3gYM5iBM8v/Qpn4UK0x+j0iHyFPDg==" + } + } +} From 41696ce7b921cd19c5ac1f0747f16f36ff2dbe43 Mon Sep 17 00:00:00 2001 From: aburke921 Date: Thu, 9 Sep 2021 02:04:19 -0400 Subject: [PATCH 4/8] proper server client communication passes variables and server creates new calculated server. Forms when saved now have correct information. --- public/js/scripts.js | 172 +++++++++++++++++++++++-------------------- server.improved.js | 26 +++++-- 2 files changed, 110 insertions(+), 88 deletions(-) diff --git a/public/js/scripts.js b/public/js/scripts.js index 87348c9c..0c214aa2 100644 --- a/public/js/scripts.js +++ b/public/js/scripts.js @@ -1,9 +1,5 @@ // Add some Javascript code here, to run on the front end. -console.log("Welcome to assignment 2!") - - - /* @@ -76,17 +72,21 @@ function handle_tip(input, blur){ } } -function generateNewForm(delete_container){ +function generateNewForm(delete_container, id){ - // console.log("delete container", delete_container); + let previously_saved_form = document.body.children[2]; - // console.log("previously_saved_form:", previously_saved_form); + let new_saved_container = document.createElement("div"); - new_saved_container.setAttribute("id", "box"); + new_saved_container.setAttribute("id", id); new_saved_container.setAttribute("class", "saved_container"); + let json = getAppropriateJSON(id); + + console.log("updated json: ", json); + //Time Stamp let d = new Date(); @@ -132,7 +132,7 @@ function generateNewForm(delete_container){ let new_num_people = document.createElement("label"); new_num_people.setAttribute("id", "people_input"); - new_num_people.innerHTML = "?"; + new_num_people.innerHTML = json.num_of_people; let new_people_label = document.createElement("label"); new_people_label.innerHTML = " people"; @@ -154,7 +154,7 @@ function generateNewForm(delete_container){ let new_calculated_20 = document.createElement("p"); new_calculated_20.setAttribute("id", "20%_value"); - new_calculated_20.innerHTML = "$?.??"; + new_calculated_20.innerHTML = json.calc_1; new_provided_calculation_1.appendChild(new_20_p); new_provided_calculation_1.appendChild(new_calculated_20); @@ -172,7 +172,7 @@ function generateNewForm(delete_container){ let new_calculated_17 = document.createElement("p"); new_calculated_17.setAttribute("id", "17.5%_value"); - new_calculated_17.innerHTML = "$?.??"; + new_calculated_17.innerHTML = json.calc_2; new_provided_calculation_2.appendChild(new_17_p); @@ -190,7 +190,7 @@ function generateNewForm(delete_container){ let new_calculated_15 = document.createElement("p"); new_calculated_15.setAttribute("id", "15%_value"); - new_calculated_15.innerHTML = "$?.??"; + new_calculated_15.innerHTML = json.calc_3; new_provided_calculation_3.appendChild(new_15_p); new_provided_calculation_3.appendChild(new_calculated_15); @@ -213,7 +213,7 @@ function generateNewForm(delete_container){ let new_amount_due = document.createElement("p"); new_amount_due.setAttribute("id", "given_amount"); - new_amount_due.innerHTML = "$200.00"; + new_amount_due.innerHTML = json.amount_due; new_form_amount_due.appendChild(new_amount_due); new_saved_container.appendChild(new_form_amount_due); @@ -223,7 +223,7 @@ function generateNewForm(delete_container){ let new_tip_label = document.createElement("label"); new_tip_label.setAttribute("id","tip"); - new_tip_label.innerHTML = "+ Tip :"; + new_tip_label.innerHTML = `+ Tip ${json.tip_percentage}`; new_saved_container.appendChild(new_tip_label); @@ -235,7 +235,7 @@ function generateNewForm(delete_container){ new_form_tip.setAttribute("class", "form_container"); let new_tip = document.createElement("p"); - new_tip.innerHTML = "$20.00"; + new_tip.innerHTML = json.tip; new_form_tip.appendChild(new_tip); new_saved_container.appendChild(new_form_tip); @@ -250,7 +250,7 @@ function generateNewForm(delete_container){ let new_total_cost = document.createElement("p"); new_total_cost.setAttribute("id", "final_calculation"); - new_total_cost.innerHTML = "$?.??"; + new_total_cost.innerHTML = json.price_per_person; new_saved_container.appendChild(new_footer); new_saved_container.appendChild(new_total_cost); @@ -259,12 +259,9 @@ function generateNewForm(delete_container){ //Adds everything to the webpage document.body.insertBefore(new_saved_container, previously_saved_form); - // console.log(delete_container); + if(delete_container !== undefined){ delete_container.remove(); - // console.log("removing"); - - } return new_saved_container; @@ -291,8 +288,6 @@ function delete_form(delete_button){ function edit_mode(button){ - - // console.log(button); let container = button.parentElement; @@ -309,34 +304,23 @@ function edit_mode(button){ previous_time_stamp.remove(); - // container.setAttribute("class", "container"); - // console.log(calculation); - - // console.log(people_form); - // console.log(amount_form); - // console.log(tip_form); - let people_input = people_form.children[0]; let amount_input = amount_form.children[0]; let tip_input = tip_form.children[0]; - // console.log(people_input); - // console.log(amount_input); - // console.log(tip_input); - // console.log("people_input.innerHTML", people_input.innerHTML); + + let num_of_people = people_input.innerHTML; let amount_due = amount_input.innerHTML; let tip = tip_input.innerHTML; - // console.log(num_of_people); - // console.log(amount_due); - // console.log("tip value = ", tip); + amount_input.remove(); tip_input.remove(); - // people_input.innerHTML = " people"; + let new_people_input = document.createElement("input"); @@ -412,9 +396,6 @@ function edit_mode(button){ } let saved_time = "Saved on " + month + " " + date + ", " + year + " at " + hours + ":" + minutes + tod; - - // console.log(saved_time); - } button.innerHTML = "delete"; @@ -456,7 +437,6 @@ function formatCurrency(input, blur) { let input_val; -// console.log("input", input.value); //If there is no input value, the placeholder value will showup again if(input.value !== ''){ @@ -521,7 +501,6 @@ function formatCurrency(input, blur) { // Updates the value that is inside of the form -// console.log("at the end:", input_val); input.value = input_val; } @@ -584,11 +563,6 @@ function calculate_tip_percentage(input, parent_container){ // Lets get the value the user actually gave for the tip let input_val = input.value; - console.log("parent_container.children", parent_container.children); - console.log("parent_container.children", parent_container.children.length); - console.log("input", input); - console.log("parent_container", parent_container); - let num_of_elements = parent_container.children.length; //This is the element that writes out to the user "+ Tip" @@ -659,65 +633,101 @@ function calculate_tip_percentage(input, parent_container){ } } + + function submit(calculate_button) { - let container = calculate_button.parentElement; + // This is the big white box/form being worked on + let parent_container = calculate_button.parentElement; + + + - // console.log(calculate_button); - if(container.className === "container"){ - // console.log("main form"); - new_saved_container = generateNewForm(); + // // console.log(calculate_button); + // if(container.className === "container"){ + // // console.log("main form"); + // new_saved_container = generateNewForm(); - } - else{ - // console.log("sub form"); - new_saved_container = generateNewForm(container); - } + // } + // else{ + // // console.log("sub form"); + // new_saved_container = generateNewForm(container); + // } - // //prevents the default form action from being executed - // event.preventDefault() - // console.log("total_cost_input", new_saved_container.querySelector('#given_amount')); - const total_cost_input = new_saved_container.querySelector('#given_amount'), - total_cost_json = { given_amount: total_cost_input.value }, - total_cost_body = JSON.stringify(total_cost_json) - - // console.log(total_cost_json); - // console.log(total_cost_body); - const tip_input = container.querySelector('#tip_amount'), - tip_json = { tip_amount: tip_input.value }, - tip_body = JSON.stringify(tip_json) + let people_input = parent_container.children[0].children[0]; + let calc_1 = parent_container.children[1].children[1]; + let calc_2 = parent_container.children[2].children[1]; + let calc_3 = parent_container.children[3].children[1]; + let amount_due_input = parent_container.children[5].children[0]; + let tip_percentage = parent_container.children[6]; + let tip_input = parent_container.children[7].children[0]; - // console.log(tip_input); - // console.log(tip_json); - // console.log(tip_body); + if(parent_container.children.length === 10){ + people_input = parent_container.children[1].children[0]; + calc_1 = parent_container.children[2].children[1]; + calc_2 = parent_container.children[3].children[1]; + calc_3 = parent_container.children[4].children[1]; + amount_due_input = parent_container.children[6].children[0]; + tip_percentage = parent_container.children[7]; + tip_input = parent_container.children[8].children[0]; + } - const people_input = container.querySelector('#people_input'), - people_json = { people_input: people_input.value }, - people_body = JSON.stringify(tip_json) + console.log("tip_percentage", tip_percentage); + + // console.log("calc_1.value = ", calc_1.value); + let values = { + "num_of_people": people_input.value, + "amount_due": amount_due_input.value, + "tip": tip_input.value, + "calc_1": calc_1.innerHTML, + "calc_2": calc_2.innerHTML, + "calc_3": calc_3.innerHTML, + "tip_percentage": tip_percentage.innerHTML.substring(6) + }; + + appdata.push(values); - // console.log(people_input); - // console.log(people_json); - // console.log(people_body); + let data = JSON.stringify(appdata); + // create array + // stringify array fetch('/submit', { method: 'POST', - "body": total_cost_body // Same thing as: "body" : body + "body": data // Same thing as: "body" : body }) .then(function( response ){ //do something with the response - // console.log( response ) + return response.json() + }) + .then(function(json) { + //json is the array returned by the server + console.log("json", json); + appdata = json; + + generateNewForm(undefined, json[json.length - 1].id); + + }) return false } +function getAppropriateJSON(id){ + for( i = 0; i < appdata.length; i++){ + let json = appdata[i]; + if(json.id === id){ + return json; + } + } + return; +} - +let appdata = []; diff --git a/server.improved.js b/server.improved.js index d87f4f04..2bf56f72 100644 --- a/server.improved.js +++ b/server.improved.js @@ -1,3 +1,5 @@ +let count = 0; + const http = require( 'http' ), fs = require( 'fs' ), // IMPORTANT: you must run `npm install` in the directory for this assignment @@ -6,11 +8,6 @@ const http = require( 'http' ), dir = 'public/', port = 3000 -const appdata = [ - { 'model': 'toyota', 'year': 1999, 'mpg': 23 }, - { 'model': 'honda', 'year': 2004, 'mpg': 30 }, - { 'model': 'ford', 'year': 1987, 'mpg': 14} -] const server = http.createServer( function( request,response ) { if( request.method === 'GET' ) { @@ -38,17 +35,32 @@ const handlePost = function( request, response ) { }) request.on( 'end', function() { - console.log( JSON.parse( dataString ) ) + + count = count + 1; const json = JSON.parse(dataString); - // ... do something with the data here!!! + // Here, we add the calculated price per person and add it to the json element to + // be sent back to the client + + let last_json_item = json[json.length - 1]; + + let num_of_people = parseFloat(last_json_item.num_of_people.replace(",", "")); + let amount_due = parseFloat(last_json_item.amount_due.replace("$","").replace(",", "")); + let tip = parseFloat(last_json_item.tip.replace("$","").replace(",", "")); + + let price_per_person = (amount_due + tip) / num_of_people; + + json[json.length - 1]['price_per_person'] = price_per_person.toString(); + json[json.length - 1]['id'] = count.toString(); response.writeHead( 200, "OK", {'Content-Type': 'text/plain' }) response.end(JSON.stringify(json)) }) } + + const sendFile = function( response, filename ) { const type = mime.getType( filename ) From a97e6cafbad423fa91f13966d6ca9de8b08073d0 Mon Sep 17 00:00:00 2001 From: aburke921 Date: Thu, 9 Sep 2021 03:09:10 -0400 Subject: [PATCH 5/8] all functionality only addition I would feel compelled to make is fixing the calculate button so you can't click it if there are not values inside of Amount Due and +Tip. --- public/css/style.css | 3 +++ public/index.html | 60 ++------------------------------------------ public/js/scripts.js | 38 ++++++++++++++++++++++------ server.improved.js | 2 +- 4 files changed, 37 insertions(+), 66 deletions(-) diff --git a/public/css/style.css b/public/css/style.css index 89f98bfd..fa99bdd3 100644 --- a/public/css/style.css +++ b/public/css/style.css @@ -182,6 +182,9 @@ input { } +.calculation:hover { + cursor: not-allowed; +} p { width: fit-content; diff --git a/public/index.html b/public/index.html index ea0e9bcc..d9de4455 100644 --- a/public/index.html +++ b/public/index.html @@ -6,7 +6,7 @@ - + @@ -16,7 +16,7 @@

Tip

Calculator

-
+
@@ -67,63 +67,7 @@

Calculator

- - -
- - - - - - - - -
- -

Saved on September 8, 2021 at 11:19am

- - - edit - -
- - -
- -
-

20%

-

$_.__

-
- -
-

17.5%

-

$_.__

-
- -
-

15%

-

$_.__

-
- - - - -
-

$100.00

-
- - - -
-

$20.00

-
- - - -

$0.00

-
- diff --git a/public/js/scripts.js b/public/js/scripts.js index 0c214aa2..b7c2edb1 100644 --- a/public/js/scripts.js +++ b/public/js/scripts.js @@ -72,7 +72,7 @@ function handle_tip(input, blur){ } } -function generateNewForm(delete_container, id){ +function generateNewForm(id){ @@ -259,11 +259,6 @@ function generateNewForm(delete_container, id){ //Adds everything to the webpage document.body.insertBefore(new_saved_container, previously_saved_form); - - if(delete_container !== undefined){ - delete_container.remove(); - } - return new_saved_container; @@ -280,6 +275,14 @@ function generateNewForm(delete_container, id){ function delete_form(delete_button){ let container = delete_button.parentElement; + + let id = container.id; + + let json = getAppropriateJSON(id); + + let index = appdata.indexOf(json); + + appdata.pop(index); container.remove(); } @@ -709,7 +712,14 @@ function submit(calculate_button) { console.log("json", json); appdata = json; - generateNewForm(undefined, json[json.length - 1].id); + generateNewForm(json[json.length - 1].id); + if(parent_container.id === "0"){ + refresh_form(); + } + else{ + parent_container.remove(); + } + // generateNewForm(undefined, json[json.length - 1].id); }) @@ -717,6 +727,20 @@ function submit(calculate_button) { return false } +function refresh_form(){ + let container = document.getElementById("0"); + + container.children[0].children[0].value = 1; + container.children[1].children[1].innerHTML = "$_.__"; + container.children[2].children[1].innerHTML = "$_.__"; + container.children[3].children[1].innerHTML = "$_.__"; + container.children[5].children[0].value = ""; + container.children[6].innerHTML = "+ Tip :"; + container.children[7].children[0].value = ""; + // container.children[3].children[1].innerHTML = "$_.__"; + +} + function getAppropriateJSON(id){ for( i = 0; i < appdata.length; i++){ diff --git a/server.improved.js b/server.improved.js index 2bf56f72..084cb2af 100644 --- a/server.improved.js +++ b/server.improved.js @@ -51,7 +51,7 @@ const handlePost = function( request, response ) { let price_per_person = (amount_due + tip) / num_of_people; - json[json.length - 1]['price_per_person'] = price_per_person.toString(); + json[json.length - 1]['price_per_person'] = "$" + price_per_person.toFixed(2).toString(); json[json.length - 1]['id'] = count.toString(); response.writeHead( 200, "OK", {'Content-Type': 'text/plain' }) From b8a0f1fde621093db09cc96c4ca57ced92046562 Mon Sep 17 00:00:00 2001 From: aburke921 Date: Thu, 9 Sep 2021 03:46:06 -0400 Subject: [PATCH 6/8] got rid of the action="" attribute for forms the html validator was telling me not to. --- public/index.html | 6 +++--- public/js/scripts.js | 3 --- 2 files changed, 3 insertions(+), 6 deletions(-) diff --git a/public/index.html b/public/index.html index d9de4455..2080c590 100644 --- a/public/index.html +++ b/public/index.html @@ -19,7 +19,7 @@

Calculator

-
+
@@ -42,7 +42,7 @@

Calculator

-
+ Calculator - + Date: Thu, 9 Sep 2021 13:32:28 -0400 Subject: [PATCH 7/8] updated readme --- README.md | 101 +++++------------------------------------------------- 1 file changed, 8 insertions(+), 93 deletions(-) diff --git a/README.md b/README.md index 996cf12d..a420d524 100644 --- a/README.md +++ b/README.md @@ -1,97 +1,12 @@ -Assignment 2 - Short Stack: Basic Two-tier Web Application using HTML/CSS/JS and Node.js -=== - -Due: September 9th, by 11:59 AM. - -This assignment aims to introduce you to creating a prototype two-tiered web application. -Your application will include the use of HTML, CSS, JavaScript, and Node.js functionality, with active communication between the client and the server over the life of a user session. - -Baseline Requirements ---- - -There is a large range of application areas and possibilities that meet these baseline requirements. -Try to make your application do something useful! A todo list, storing / retrieving high scores for a very simple game... have a little fun with it. - -Your application is required to implement the following functionalities: - -- a `Server` which not only serves files, but also maintains a tabular dataset with 3 or more fields related to your application -- a `Results` functionality which shows the entire dataset residing in the server's memory -- a `Form/Entry` functionality which allows a user to add, modify, or delete data items residing in the server's memory -- a `Server Logic` which, upon receiving new or modified "incoming" data, includes and uses a function that adds at least one additional derived field to this incoming data before integrating it with the existing dataset -- the `Derived field` for a new row of data must be computed based on fields already existing in the row. -For example, a `todo` dataset with `task`, `priority`, and `creation_date` may generate a new field `deadline` by looking at `creation_date` and `priority` - -Your application is required to demonstrate the use of the following concepts: - -HTML: -- One or more [HTML Forms](https://developer.mozilla.org/en-US/docs/Learn/HTML/Forms), with any combination of form tags appropriate for the user input portion of the application -- A results page displaying all data currently available on the server. You will most likely use a `` tag for this, but `
    ` or `
      ` could also work and might be simpler to work with. -- All pages should [validate](https://validator.w3.org) - -CSS: -- CSS styling of the primary visual elements in the application -- Various CSS Selector functionality must be demonstrated: - - Element selectors - - ID selectors - - Class selectors -- CSS positioning and styling of the primary visual elements in the application: - - Use of either a CSS grid or flexbox for layout - - Rules defining fonts for all text used; no default fonts! Be sure to use a web safe font or a font from a web service like [Google Fonts](http://fonts.google.com/) - -- CSS defined in a maintainable, readable form, in external stylesheets - -JavaScript: -- At minimum, a small amount of front-end JavaScript to get / fetch data from the server; a sample is provided in this repository. - -Node.js: -- An HTTP Server that delivers all necessary files and data for the application, and also creates the required `Derived Fields` in your data. -A starting point is provided in this repository. - -Deliverables ---- - -Do the following to complete this assignment and acheive a base grade of 85%: - -1. Fork the starting project code (make sure to fork the 2021 repo!). This repo contains some starter code that may be used or discarded as needed. -2. Implement your project with the above requirements. -3. Test your project to make sure that when someone goes to your main page, it displays correctly. -4. Deploy your project to Glitch, and fill in the appropriate fields in your package.json file. -5. Ensure that your project has the proper naming scheme `a2-yourGithubUsername` so we can find it. -6. Modify the README to the specifications below, and delete all of the instructions originally found in this README. -7. Create and submit a Pull Request to the original repo. Label the pull request as follows: a2-gitusername-firstname-lastname - -Acheivements ---- - -Below are suggested technical and design achievements. You can use these to help boost your grade up to an A and customize the assignment to your personal interests. These are recommended acheivements, but feel free to create/implement your own... just make sure you thoroughly describe what you did in your README and why it was challenging. ALL ACHIEVEMENTS MUST BE DESCRIBED IN YOUR README IN ORDER TO GET CREDIT FOR THEM. - -*Technical* -- (10 points) Create a single-page app that both provides a form for users to submit data and always shows the current state of the server-side data. To put it another way, when the user submits data, the server should respond sending back the updated data (including the derived field calculated on the server) and the client should then update its data display. - -*Design/UX* -- (5 points per person, with a max of 10 points) Test your user interface with other students in the class. Define a specific task for them to complete (ideally something short that takes <10 minutes), and then use the [think-aloud protocol](https://en.wikipedia.org/wiki/Think_aloud_protocol) to obtain feedback on your design (talk-aloud is also find). Important considerations when designing your study: - -1. Make sure you start the study by clearly stating the task that you expect your user to accomplish. -2. You shouldn't provide any verbal instructions on how to use your interface / accomplish the task you give them. Make sure that your interface is clear enough that users can figure it out without any instruction, or provide text instructions from within the interface itself. -3. If users get stuck to the point where they give up, you can then provde instruction so that the study can continue, but make sure to discuss this in your README. You won't lose any points for this... all feedback is good feedback! - -You'll need to use sometype of collaborative software that will enable you both to see the test subject's screen and listen to their voice as they describe their thoughts. After completing each study, briefly (one to two sentences for each question) address the following in your README: - -1. Provide the last name of each student you conduct the evaluation with. -2. What problems did the user have with your design? -3. What comments did they make that surprised you? -4. What would you change about the interface based on their feedback? - -*You do not need to actually make changes based on their feedback*. This acheivement is designed to help gain experience testing user interfaces. If you run two user studies, you should answer two sets of questions. - -Sample Readme (delete the above when you're ready to submit, and modify the below so with your links and descriptions) ---- - -## Your Web Application Title -Include a very brief summary of your project here. Be sure to include the CSS positioning technique you used, and any required instructions to use your application. +## Tip Calculator +The idea of this web application is if a group (or single person) goes out to dinner and needs to divide the bill evenly amongst it's group members. The user may give in the webpage, the number of people that the bill should be divided by, the total amount due for the bill and the amount of money they would like to give as a tip. Once the user gives the amount due, some auto generated tip values are shown to make it easy for the user to determine what type of tip they should give. After the user hits the calculate button, the form will be submitted and a saved version will show up beneath the original form. The user has the ability to edit this form where they can either delete it entirely or edit the values they originally gave. ## Technical Achievements -- **Tech Achievement 1**: Using a combination of... +- **Tech Achievement 1**: The webpage always show the current state of the server-side data. This is done by creating additional "tip receipts" that list at at the bottom of the form. +- **User can edit server data**: The user can edit any submitted form which will then also update the values in the server. +- **User can delete data**: Additionally if the user goes into edit mode and then clicks the delete button in the upper right hand corner of the form, the form will delete from the screen and the data will delete from the server. ### Design/Evaluation Achievements -- **Design Achievement 1**: +- **Design Achievement 1**: After giving Stephano Jordhani the chance to work with my webpage, I learnt that it was not as clear on how to use as I thought it was. Stephano thought that at the very beginning he was supposed to do something with the auto generated tips and give it a value. While this surprised me, I guess it did make some sense since. After receiving his feedback, I changed the webpage so that when the user hovers over the auto generated tips, their cursor becomes "not allowed" indicating they don't need to do anything. + +- **Design Achievement 1**: I also received feedback about my webpage from Yihong Xu. Yihong. The only negative feedback Yihong had after using my webpage was to make the input field required to be filled out in order to hit the calculated/submit button. I was also not surprised by this and would have liked to fix this if there was more time with the assignment. This however can be fixed by disabling the button until both the amount due and the tip is given. \ No newline at end of file From 24e4a01fcf367cd09b8fa81f90cbe520fabd99c2 Mon Sep 17 00:00:00 2001 From: aburke921 <81346244+aburke921@users.noreply.github.com> Date: Thu, 9 Sep 2021 13:37:10 -0400 Subject: [PATCH 8/8] fixed link --- README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index a420d524..dfacdca1 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,4 @@ -## Tip Calculator +## Tip Calculator The idea of this web application is if a group (or single person) goes out to dinner and needs to divide the bill evenly amongst it's group members. The user may give in the webpage, the number of people that the bill should be divided by, the total amount due for the bill and the amount of money they would like to give as a tip. Once the user gives the amount due, some auto generated tip values are shown to make it easy for the user to determine what type of tip they should give. After the user hits the calculate button, the form will be submitted and a saved version will show up beneath the original form. The user has the ability to edit this form where they can either delete it entirely or edit the values they originally gave. ## Technical Achievements @@ -9,4 +9,4 @@ The idea of this web application is if a group (or single person) goes out to di ### Design/Evaluation Achievements - **Design Achievement 1**: After giving Stephano Jordhani the chance to work with my webpage, I learnt that it was not as clear on how to use as I thought it was. Stephano thought that at the very beginning he was supposed to do something with the auto generated tips and give it a value. While this surprised me, I guess it did make some sense since. After receiving his feedback, I changed the webpage so that when the user hovers over the auto generated tips, their cursor becomes "not allowed" indicating they don't need to do anything. -- **Design Achievement 1**: I also received feedback about my webpage from Yihong Xu. Yihong. The only negative feedback Yihong had after using my webpage was to make the input field required to be filled out in order to hit the calculated/submit button. I was also not surprised by this and would have liked to fix this if there was more time with the assignment. This however can be fixed by disabling the button until both the amount due and the tip is given. \ No newline at end of file +- **Design Achievement 1**: I also received feedback about my webpage from Yihong Xu. Yihong. The only negative feedback Yihong had after using my webpage was to make the input field required to be filled out in order to hit the calculated/submit button. I was also not surprised by this and would have liked to fix this if there was more time with the assignment. This however can be fixed by disabling the button until both the amount due and the tip is given.