aboutsummaryrefslogtreecommitdiffstats
path: root/csci4131/hw7/public
diff options
context:
space:
mode:
authorMatthew Strapp <msattr@gmail.com>2021-04-29 12:08:29 -0500
committerMatthew Strapp <msattr@gmail.com>2021-04-29 12:08:29 -0500
commitcb0d7de098f482ba667029f266dd286eab1795b6 (patch)
treed267c42f6ce9bb9461a53104185c5e32043f548d /csci4131/hw7/public
parentFix styling (diff)
downloadhomework-cb0d7de098f482ba667029f266dd286eab1795b6.tar
homework-cb0d7de098f482ba667029f266dd286eab1795b6.tar.gz
homework-cb0d7de098f482ba667029f266dd286eab1795b6.tar.bz2
homework-cb0d7de098f482ba667029f266dd286eab1795b6.tar.lz
homework-cb0d7de098f482ba667029f266dd286eab1795b6.tar.xz
homework-cb0d7de098f482ba667029f266dd286eab1795b6.tar.zst
homework-cb0d7de098f482ba667029f266dd286eab1795b6.zip
Add HW6 files
Diffstat (limited to '')
-rw-r--r--csci4131/hw7/public/addContact.html106
-rw-r--r--csci4131/hw7/public/contacts.html78
-rw-r--r--csci4131/hw7/public/stock.html124
-rw-r--r--csci4131/hw7/public/welcome.html53
4 files changed, 361 insertions, 0 deletions
diff --git a/csci4131/hw7/public/addContact.html b/csci4131/hw7/public/addContact.html
new file mode 100644
index 0000000..629f9b2
--- /dev/null
+++ b/csci4131/hw7/public/addContact.html
@@ -0,0 +1,106 @@
+<!doctype html>
+<html lang="en">
+
+ <head>
+ <meta charset="utf-8">
+ <meta name="viewport" content="width=device-width, initial-scale=1">
+ <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css">
+ <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.1.1/jquery.min.js"></script>
+ <script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js"></script>
+ </head>
+
+ <body>
+ <nav class="navbar navbar-default">
+ <div class="container-fluid">
+ <ul class="nav navbar-nav">
+ <li><a href="/"><b>Home</b></a></li>
+ <li><a href="contacts"><b>Contacts</b></a></li>
+ <li><a href="addContact"><b>Add Contact</b></a></li>
+ <li><a href="stock"><b>Stock Page</b></a></li>
+ <li><a href="logout"><b>Logout</b></a></li>
+ </ul>
+ </div>
+ </nav>
+ <br><br>
+
+ <div class="container">
+ <div class="row">
+ <p><br /></p>
+ </div>
+
+ <div class="row">
+ <div class="col-md-4"></div>
+ <div class="col-md-4">
+ <div class="panel panel-default">
+ <form name="addContact" method="post" action="/api/addContact">
+ <p></p>
+ <table class="table table-bordered table-hover">
+ <tbody>
+ <tr>
+ <td class="col-md-6">Name</td>
+ <td class="col-md-6">
+ <div class="form-group">
+ <input type="text" class="form-control" name="name" required>
+ </div>
+ </td>
+ </tr>
+ <tr>
+ <td class="col-md-6">Category</td>
+ <td class="col-md-6">
+ <div class="form-group">
+ <select class="form-control" name="category">
+ <option>Personal</option>
+ <option>Academic</option>
+ <option>Industry</option>
+ </select>
+ </div>
+ </td>
+ </tr>
+ <tr>
+ <td class="col-md-6">Location</td>
+ <td class="col-md-6">
+ <div class="form-group">
+ <input type="text" class="form-control" name="location" required>
+ </div>
+ </td>
+ </tr>
+ <tr>
+ <td class="col-md-6">Contact Information</td>
+ <td class="col-md-6">
+ <div class="form-group">
+ <input type="text" class="form-control" name="contact" required>
+ </div>
+ </td>
+ </tr>
+ <tr>
+ <td class="col-md-6">Email</td>
+ <td class="col-md-6">
+ <div class="form-group">
+ <input type="email" class="form-control" name="email" required>
+ </div>
+ </td>
+ </tr>
+ <tr>
+ <td class="col-md-6">Website Name</td>
+ <td class="col-md-6">
+ <div class="form-group">
+ <input type="url" class="form-control" name="website_name" required maxlength="100">
+ </div>
+ </td>
+ </tr>
+ <tr>
+ <td class="col-md-6"></td>
+ <td class="col-md-6">
+ <input type="submit" value="Submit">
+ </td>
+ </tr>
+ </tbody>
+ </table>
+ </form>
+ </div>
+ </div>
+ <div class="col-md-4"></div>
+ </div>
+ </div>
+ </body>
+</html>
diff --git a/csci4131/hw7/public/contacts.html b/csci4131/hw7/public/contacts.html
new file mode 100644
index 0000000..5cd2907
--- /dev/null
+++ b/csci4131/hw7/public/contacts.html
@@ -0,0 +1,78 @@
+<html>
+ <head>
+ <meta charset="utf-8">
+ <meta name="viewport" content="width=device-width, initial-scale=1">
+ <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css">
+ <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.1.1/jquery.min.js"></script>
+ <script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js"></script>
+ <script type="text/javascript" defer>
+ //Get JSON
+ var xmlhttp = new XMLHttpRequest();
+ var url = "api/contacts";
+ xmlhttp.onreadystatechange = function () {
+ if (xmlhttp.readyState == 4 && xmlhttp.status == 200) {
+ var parse = JSON.parse(xmlhttp.responseText);
+ process(parse);
+ }
+ }
+ xmlhttp.open("GET", url, true);
+ xmlhttp.send();
+
+ function process(a) {
+ var table = document.getElementsByTagName("tbody")[0];
+ var contacts = a;
+ for (let i = 0; i < contacts.length; i++) {
+ var contact = contacts[i];
+ var row = table.insertRow();
+ for (var j in contact) {
+ if (j === "contact_id") continue;
+ if (j === "website_url") {
+ var url = row.insertCell();
+ url.innerHTML = "<a href =" + contact[j] + ">" + contact[j] + "</a>";
+ } else if (j === "email") {
+ var email = row.insertCell();
+ email.innerHTML = "<a href =mailto://" + contact[j] + ">" + contact[j] + "</a>";
+ } else {
+ var value = row.insertCell();
+ value.innerHTML = contact[j];
+ }
+ }
+ }
+ }
+
+ </script>
+ </head>
+ <body>
+ <nav class="navbar navbar-default">
+ <div class="container-fluid">
+ <ul class="nav navbar-nav">
+ <li><a href="/"><b>Home</b></a></li>
+ <li><a href="contacts"><b>Contacts</b></a></li>
+ <li><a href="addContact"><b>Add Contact</b></a></li>
+ <li><a href="stock"><b>Stock Page</b></a></li>
+ <li><a href="logout"><b>Logout</b></a></li>
+ </ul>
+ </div>
+ </nav>
+ <br><br>
+
+ <div class="container">
+ <table class="table" id="contactsTable">
+ <thead>
+ <tr>
+ <th scope="col">Name</th>
+ <th scope="col">Category</th>
+ <th scope="col">Location</th>
+ <th scope="col">Contact Information</th>
+ <th scope="col">Email</th>
+ <th scope="col">Website <br> (URL) </th>
+ </tr>
+ </thead>
+ <tbody></tbody>
+ </table>
+ </div>
+ <script type="text/javascript">
+
+ </script>
+ </body>
+</html>
diff --git a/csci4131/hw7/public/stock.html b/csci4131/hw7/public/stock.html
new file mode 100644
index 0000000..d63b233
--- /dev/null
+++ b/csci4131/hw7/public/stock.html
@@ -0,0 +1,124 @@
+<!DOCTYPE html>
+<html>
+<head>
+ <meta charset="utf-8">
+ <meta name="viewport" content="width=device-width, initial-scale=1">
+ <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css">
+ <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.1.1/jquery.min.js"></script>
+ <script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js"></script>
+ <style>
+ pre {
+ max-height: 12em;
+ }
+ textarea {
+ width: 100%;
+ min-height: 30rem;
+ background-color: black;
+ font-family: "Lucida Console", Monaco, monospace;
+ font-size: 0.75 rem;
+ line-height: 1.2;
+ color: #fff;
+ }
+ </style>
+</head>
+
+<body>
+ <nav class="navbar navbar-default">
+ <div class="container-fluid">
+ <ul class="nav navbar-nav">
+ <li><a href="/"><b>Home</b></a></li>
+ <li><a href="contacts"><b>Contacts</b></a></li>
+ <li><a href="addContact"><b>Add Contact</b></a></li>
+ <li><a href="stock"><b>Stock Page</b></a></li>
+ <li><a href="logout"><b>Logout</b></a></li>
+ </ul>
+ </div>
+ </nav>
+ <br><br>
+
+ <div class="container">
+ <div class="panel panel-default">
+ <div class="panel-body"><center>Welcome to Stock Page</center></div>
+ </div>
+ </div>
+
+ <div class="container">
+ <div class="row">
+ <div class="col">
+ <table class="table table-bordered table-hover">
+ <tbody>
+ <tr>
+ <td class="col-md-6">Company</td>
+ <td class="col-md-6">
+ <div class="form-group">
+ <select id="Company" name="Company">
+ <option value="GME">Gamestop</option>
+ <option value="MSFT">Microsoft</option>
+ <option value="BA">Boeing Company</option>
+ <option value="AAPL">Apple Inc</option>
+ <option value="AMZN">Amazon</option>
+ <option value="NVDA">NVIDIA Corporation</option>
+ </select>
+ </div>
+ </td>
+ </tr>
+ <tr>
+ <td colspan="2">
+ <button type="button" onclick="Click()">Get Data</button>
+ </td>
+ </tr>
+ </tbody>
+ </table>
+ </div>
+ </div>
+ </div>
+
+ <div class="container">
+ <div id="chartContainer"></div>
+ </div>
+
+ <div class="container">
+ <table class="table" id="StockData">
+ <thead>
+ <tr>
+ <th scope="col" id="meta">Company-MetaData</th>
+ <th scope="col" id="Time">Stock-Info</th>
+ </tr>
+ </thead>
+ <pre>
+ <tbody></tbody>
+ </pre>
+ </table>
+ </div>
+
+ <script>
+ function Click() {
+ var comp = document.getElementById("Company").value;
+ var xmlhttp = new XMLHttpRequest();
+ var url = "https://www.alphavantage.co/query?function=TIME_SERIES_DAILY&symbol=" + comp + "&apikey=8MWSNPDWKH0BTBH2";
+ xmlhttp.onreadystatechange = function () {
+ if (xmlhttp.readyState == 4 && xmlhttp.status == 200) {
+ var parse = JSON.parse(xmlhttp.responseText);
+ var table = document.getElementById("StockData").getElementsByTagName("tbody")[0];
+ var row = table.insertRow();
+ for (var i in parse) {
+ var cell = row.insertCell();
+ cell.innerHTML = "<pre>" + JSON.stringify(parse[i], undefined, 2) + "</pre>";
+ }
+ }
+ }
+ xmlhttp.open("GET", url, true);
+ xmlhttp.send();
+
+ }
+ /* TODO:
+ / Bonus 1. Request the TIME_SERIES_DAILY endpoint of alphavantage API
+ / for the company selected in the dropdown. Display the JSON
+ / in the result according to the write up.
+ / Bonus 2. Take the JSON from the alphavantage API and chart it to a
+ / line chart using Chart.js to the chartContainer div. Ensure
+ / the chart meets all requirements from the HW writeup.
+ /*/
+ </script>
+</body>
+</html>
diff --git a/csci4131/hw7/public/welcome.html b/csci4131/hw7/public/welcome.html
new file mode 100644
index 0000000..095023e
--- /dev/null
+++ b/csci4131/hw7/public/welcome.html
@@ -0,0 +1,53 @@
+<!doctype html>
+<html lang="en">
+<head>
+ <meta charset="utf-8">
+ <meta name="viewport" content="width=device-width, initial-scale=1">
+ <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css">
+ <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.1.1/jquery.min.js"></script>
+ <script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js"></script>
+ <title>Welcome to Node.js</title>
+ <style type="text/css">
+ .jumbotron {
+ text-align: center;
+ }
+ </style>
+</head>
+
+<body>
+<div class="jumbotron" style="background: DarkSeaGreen !important">
+ <h1>Welcome to Express (Node.js)</h1>
+ <p>The objective of this assignment is to develop a basic website with:</p>
+ <p><b>Express</b> which is a Node.js web application framework.</p>
+ <br/>
+ <p>Following are some useful resources:</p>
+
+ <ul style="list-style-type:none">
+ <li><a href="https://expressjs.com/">Express website</a></li>
+ <li><a href="https://expressjs.com/en/starter/installing.html">Express installation</a></li>
+ <li><a href="https://expressjs.com/en/starter/hello-world.html">Hello world example</a></li>
+ <li><a href="https://expressjs.com/en/starter/basic-routing.html">Basic routing</a></li>
+ <li><a href="https://expressjs.com/en/starter/static-files.html">Serving static files in Express</a></li>
+ <li><a href="https://expressjs.com/en/starter/faq.html">FAQ</a></li>
+ <li><a href="https://expressjs.com/en/guide/routing.html">Routing</a></li>
+ <li><a href="https://expressjs.com/en/4x/api.html">API Reference</a></li>
+ <li><a href="https://expressjs.com/en/resources/books-blogs.html">Books and blogs</a></li>
+ <li><a href="https://docs.npmjs.com/getting-started/what-is-npm">NPM introduction</a></li>
+ </ul>
+
+ <br/>
+ <br/>
+
+</div>
+
+<div class="row">
+ <div class="col-md-1"></div>
+ <div class="col-md-10">
+ <button id="myButton" type="button" class="btn btn-primary btn-block" onclick="location.href ='/login'">
+ Navigate to website
+ </button>
+ </div>
+ <div class="col-md-1"></div>
+</div>
+</body>
+</html>