aboutsummaryrefslogtreecommitdiffstats
path: root/csci4131/hw5/strap012_hw5/client/contacts.html
blob: 2e4bf6540216cddf29159a9674fe56e34b866fbe (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
<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(-1);
              var nam = row.insertCell(0);
              nam.innerHTML = contact.name;
              var cat = row.insertCell(1);
              cat.innerHTML = contact.category;
              var loc = row.insertCell(2);
              loc.innerHTML = contact.location;
              var con = row.insertCell(3);
              con.innerHTML = contact.contact;
              var ema = row.insertCell(4);
              ema.innerHTML = contact.email;
              var url = row.insertCell(5);
              url.innerHTML = "<a href =" + contact.website_url + ">" + contact.website_url + "</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>