aboutsummaryrefslogtreecommitdiffstats
path: root/OLD/csci4131/hw5/strap012_hw5
diff options
context:
space:
mode:
Diffstat (limited to 'OLD/csci4131/hw5/strap012_hw5')
-rw-r--r--OLD/csci4131/hw5/strap012_hw5/client/addContact.html113
-rw-r--r--OLD/csci4131/hw5/strap012_hw5/client/contacts.html73
-rw-r--r--OLD/csci4131/hw5/strap012_hw5/client/index.html27
-rw-r--r--OLD/csci4131/hw5/strap012_hw5/client/stock.html123
-rw-r--r--OLD/csci4131/hw5/strap012_hw5/contacts.json22
-rw-r--r--OLD/csci4131/hw5/strap012_hw5/createServer.js90
-rw-r--r--OLD/csci4131/hw5/strap012_hw5/package.json11
7 files changed, 0 insertions, 459 deletions
diff --git a/OLD/csci4131/hw5/strap012_hw5/client/addContact.html b/OLD/csci4131/hw5/strap012_hw5/client/addContact.html
deleted file mode 100644
index 12bfaa2..0000000
--- a/OLD/csci4131/hw5/strap012_hw5/client/addContact.html
+++ /dev/null
@@ -1,113 +0,0 @@
-<!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="index.html"><b>Home</b></a></li>
- <li><a href="contacts.html"><b>Contacts</b></a></li>
- <li><a href="addContact.html"><b>Add Contact</b></a></li>
- <li><a href="stock.html"><b>Stock Page</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="/postContactEntry">
- <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="text" class="form-control" name="website_name" required maxlength="100">
- </div>
- </td>
- </tr>
- <tr>
- <td class="col-md-6">Website URL</td>
- <td class="col-md-6">
- <div class="form-group">
- <input type="url" class="form-control" name="website_url" required maxlength="200">
- </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/OLD/csci4131/hw5/strap012_hw5/client/contacts.html b/OLD/csci4131/hw5/strap012_hw5/client/contacts.html
deleted file mode 100644
index 15e4032..0000000
--- a/OLD/csci4131/hw5/strap012_hw5/client/contacts.html
+++ /dev/null
@@ -1,73 +0,0 @@
-<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 = "contacts.json";
- 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.contacts;
- for (let i = 0; i < contacts.length; i++) {
- var contact = contacts[i];
- var row = table.insertRow();
- for (var j in contact) {
- if (j != "website_url") {
- var value = row.insertCell();
- value.innerHTML = contact[j];
- } else {
- var url = row.insertCell();
- url.innerHTML = "<a href =" + contact[j] + ">" + contact[j] + "</a>";
- }
- }
- }
- }
-
- </script>
- </head>
- <body>
- <nav class="navbar navbar-default">
- <div class="container-fluid">
- <ul class="nav navbar-nav">
- <li><a href="index.html"><b>Home</b></a></li>
- <li><a href="contacts.html"><b>Contacts</b></a></li>
- <li><a href="addContact.html"><b>Add Contact</b></a></li>
- <li><a href="stock.html"><b>Stock Page</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/OLD/csci4131/hw5/strap012_hw5/client/index.html b/OLD/csci4131/hw5/strap012_hw5/client/index.html
deleted file mode 100644
index 44c5d0f..0000000
--- a/OLD/csci4131/hw5/strap012_hw5/client/index.html
+++ /dev/null
@@ -1,27 +0,0 @@
-<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>
-</head>
- <body>
- <nav class="navbar navbar-default">
- <div class="container-fluid">
- <ul class="nav navbar-nav">
- <li><a href="index.html"><b>Home</b></a></li>
- <li><a href="contacts.html"><b>Contacts</b></a></li>
- <li><a href="addContact.html"><b>Add Contact</b></a></li>
- <li><a href="stock.html"><b>Stock Page</b></a></li>
- </ul>
- </div>
- </nav>
- <br><br><br>
- <div class="container">
- <div class="panel panel-default">
- <div class="panel-body"><center>Welcome to Contact Management</center></div>
- </div>
- </div>
-</body>
-</html>
diff --git a/OLD/csci4131/hw5/strap012_hw5/client/stock.html b/OLD/csci4131/hw5/strap012_hw5/client/stock.html
deleted file mode 100644
index b55ffcb..0000000
--- a/OLD/csci4131/hw5/strap012_hw5/client/stock.html
+++ /dev/null
@@ -1,123 +0,0 @@
-<!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="index.html"><b>Home</b></a></li>
- <li><a href="contacts.html"><b>Contacts</b></a></li>
- <li><a href="addContact.html"><b>Add Contact</b></a></li>
- <li><a href="stock.html"><b>Stock Page</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/OLD/csci4131/hw5/strap012_hw5/contacts.json b/OLD/csci4131/hw5/strap012_hw5/contacts.json
deleted file mode 100644
index 54149e8..0000000
--- a/OLD/csci4131/hw5/strap012_hw5/contacts.json
+++ /dev/null
@@ -1,22 +0,0 @@
-{
- "contacts": [
- {
- "name": "President Joan T.A. Gabel",
- "category": "Academic",
- "location": "202 Morrill Hall\r\n100 Church Street SE\r\nMinneapolis, MN 55455",
- "contact": "President of the University of Minnesota System",
- "email": "upres@umn.edu",
- "website_name": "Home Page",
- "website_url": "https://president.umn.edu/"
- },
- {
- "name": "Professor Dan Challou",
- "category": "Academic",
- "location": "383 Shepherd Laboratory\r\n100 Union Street SE\r\nMinneapolis, MN 55455",
- "contact": "Professor of CSCI 4131 - Internet Programming",
- "email": "chal0006@umn.edu",
- "website_name": "Course Home Page",
- "website_url": "https://canvas.umn.edu/courses/217376"
- }
- ]
-}
diff --git a/OLD/csci4131/hw5/strap012_hw5/createServer.js b/OLD/csci4131/hw5/strap012_hw5/createServer.js
deleted file mode 100644
index 9c108cd..0000000
--- a/OLD/csci4131/hw5/strap012_hw5/createServer.js
+++ /dev/null
@@ -1,90 +0,0 @@
-
-const http = require('http');
-const url = require('url');
-const fs = require('fs');
-const qs = require('querystring');
-
-const port = 9001;
-http.createServer(function (req, res) {
- var q = url.parse(req.url, true);
- var filename = "." + q.pathname;
- if(req.url === '/'){
- res.writeHead(301, { 'Location': 'index.html' });
- return res.end("301 Permanent Redirect");
- }
- else if (req.url === '/index.html') {
- indexPage(req, res, '/index.html');
- }
- else if (req.url === '/contacts.html') {
- indexPage(req, res, '/contacts.html');
- }
- else if (req.url === '/addContact.html') {
- indexPage(req, res, '/addContact.html');
- }
- else if (req.url === '/stock.html') {
- indexPage(req, res, '/stock.html');
- }
- else if (req.url === '/contacts.json') {
- jsonSock(req, res, 'contacts.json')
- }
- else if (req.url === "/postContactEntry") {
- POST(req, res);
- res.writeHead(302, { 'Location': 'contacts.html' });
- return res.end("302 Temporary Redirect");
- }
- else{
- res.writeHead(404, {'Content-Type': 'text/html'});
- return res.end("404 Not Found");
- }
-}).listen(port);
-
-function indexPage(req, res, file) {
- fs.readFile('client' + file, function(err, html) {
- if(err) {
- throw err;
- }
- res.statusCode = 200;
- res.setHeader('Content-type', 'text/html');
- res.write(html);
- res.end();
- });
-}
-
-function jsonSock(req, res, file) {
- fs.readFile(file, function (err, json) {
- if (err) {
- throw err;
- }
- res.statusCode = 200;
- res.setHeader('Content-type', 'text/json');
- res.write(json);
- res.end();
- });
-}
-
-function POST(req, res) {
- var reqBody = '';
- // server starts receiving the form data
- req.on('data', function(data) {
- reqBody+= data;
- });// server has received all the form data
- req.on('end', function() {
- var jsonO = {}
- var postObj = qs.parse(reqBody);
- jsonO["name"] = postObj.name;
- jsonO["category"] = postObj.category;
- jsonO["location"] = postObj.location;
- jsonO["contact"] = postObj.contact;
- jsonO["email"] = postObj.email;
- jsonO["website_name"] = postObj.website_name;
- jsonO["website_url"] = postObj.website_url;
- fs.readFile('./contacts.json', 'utf8', function(err, data) {
- var file = JSON.parse(data);
- file.contacts.push(jsonO);
- var string = JSON.stringify(file);
- fs.writeFile('./contacts.json', string, function(err, data) {
- console.log(string);
- }); //Write clojure
- }); //Read clojure
- }); //req clojure
-} \ No newline at end of file
diff --git a/OLD/csci4131/hw5/strap012_hw5/package.json b/OLD/csci4131/hw5/strap012_hw5/package.json
deleted file mode 100644
index 90f2542..0000000
--- a/OLD/csci4131/hw5/strap012_hw5/package.json
+++ /dev/null
@@ -1,11 +0,0 @@
-{
- "name": "strap012_hw5",
- "version": "1.0.0",
- "description": "Assignment 5",
- "main": "createServer.js",
- "scripts": {
- "test": "node createServer.js"
- },
- "author": "strap012",
- "license": "ISC"
-}