cssAudio - Activefile-genericCSS - ActiveGeneric - ActiveHTML - ActiveImage - ActiveJS - ActiveSVG - ActiveText - Activefile-genericVideo - ActiveLovehtmlicon-new-collectionicon-personicon-teamlog-outoctocatpop-outspinnerstartv

Pen Settings

CSS Base

Vendor Prefixing

Add External Stylesheets/Pens

Any URL's added here will be added as <link>s in order, and before the CSS in the editor. If you link to another Pen, it will include the CSS from that Pen. If the preprocessor matches, it will attempt to combine them before processing.

+ add another resource

You're using npm packages, so we've auto-selected Babel for you here, which we require to process imports and make it all work. If you need to use a different JavaScript preprocessor, remove the packages in the npm tab.

Add External Scripts/Pens

Any URL's added here will be added as <script>s in order, and run before the JavaScript in the editor. You can use the URL of any other Pen and it will include the JavaScript from that Pen.

+ add another resource

Use npm Packages

We can make npm packages available for you to use in your JavaScript. We use webpack to prepare them and make them available to import. We'll also process your JavaScript with Babel.

⚠️ This feature can only be used by logged in users.

Code Indentation

     

Save Automatically?

If active, Pens will autosave every 30 seconds after being saved once.

Auto-Updating Preview

If enabled, the preview panel updates automatically as you code. If disabled, use the "Run" button to update.

            
              <html>

<head>
  <meta http-equiv="content-type" content="text/html; charset=UTF-8">
  <title>Frontend Exercise</title>
  <style type="text/css">
    body {
      font-family: arial, sans, sans-serif;
      margin: 0;
    }
    
    #content {
      background: #fff;
    }
    
    #footer {
      background: #f0f0f0;
      border: 1px #ccc solid;
      border-left: 0;
      border-right: 0;
      padding: 13px 10px;
      color: #999;
      height: 1em;
      margin-top: -1px;
    }
    
    #sheettabs {
      margin: 6px 0 0;
      padding: 0 0 5px;
    }
    
    #sheettabs li {
      display: inline;
      list-style-type: none;
      margin: 0;
      padding: 5px 8px;
    }
    
    .active {
      background-color: #fff;
      border: 1px solid #999;
      border-bottom: 0;
      font-weight: bold;
    }
    
    #banner {
      margin: 8px;
      padding: 4px;
      border: 1px solid #fad163;
      background-color: #fae5b0;
      font-weight: bold;
    }
    
    #gaia {
      float: right;
      margin-right: 6px;
    }
    
    .dash {
      padding: 0 6px;
    }
    
    .highlight {
      border: 2px solid #ffa82d;
      background-color: #ffd396;
      padding: 2px;
      margin: 0 4px;
    }
    
    body,
    body td,
    .tblGenFixed,
    .tblGeneric,
    table.waffle {
      font-size: 13px;
    }
    
    .tblGenFixed td.hd,
    .waffle th {
      padding: 0;
      border-right: 0;
      background-color: #c8c8c8;
    }
    
    .tblGenFixed tr.rShim td,
    .tblGenFixed td.rShim {
      padding: 0;
      border-bottom: 0;
    }
    
    .divFrozRowHead .tblGenFixed td.hd,
    .divRowHead .tblGenFixed td.hd,
    .waffle th.row-header {
      background-color: #E8EEF7;
      width: 35px;
      text-align: center;
      vertical-align: middle;
      font-size: 8pt;
      color: #333;
      border-style: solid;
      border-color: #c8c8c8;
      border-width: 0 1px 1px 0;
    }
    
    #tblMain td.hd p,
    .colHeadTable td.hd p {
      margin: 0;
      width: 0;
      overflow: hidden;
      font-size: 0;
    }
    
    td.rShim {
      width: 35px;
      height: 0;
      border-right: 1px #c8c8c8 solid;
    }
    
    .tblGenFixed td {
      padding: 0 3px;
      overflow: hidden;
      white-space: normal;
      letter-spacing: 0;
      word-spacing: 0;
      background-color: #fff;
      z-index: 1;
      border-top: 0px none;
      border-left: 0px none;
      border-bottom: 1px solid #CCC;
      border-right: 1px solid #CCC;
    }
    
    .dn {
      display: none
    }
    
    .tblGenFixed td.s0 {
      background-color: white;
      font-family: arial, sans, sans-serif;
      font-size: 100.0%;
      font-weight: bold;
      font-style: normal;
      color: #000000;
      text-decoration: none;
      text-align: left;
      vertical-align: bottom;
      white-space: normal;
      overflow: hidden;
      text-indent: 0px;
      padding-left: 3px;
      border-top: 1px solid #CCC;
      border-right: 1px solid #CCC;
      border-bottom: 1px solid #CCC;
      border-left: 1px solid #CCC;
    }
    
    .tblGenFixed td.s2 {
      background-color: white;
      font-family: arial, sans, sans-serif;
      font-size: 100.0%;
      font-weight: normal;
      font-style: normal;
      color: #000000;
      text-decoration: none;
      text-align: left;
      vertical-align: bottom;
      white-space: normal;
      overflow: hidden;
      text-indent: 0px;
      padding-left: 3px;
      border-right: 1px solid #CCC;
      border-bottom: 1px solid #CCC;
      border-left: 1px solid #CCC;
    }
    
    .tblGenFixed td.s1 {
      background-color: white;
      font-family: arial, sans, sans-serif;
      font-size: 100.0%;
      font-weight: bold;
      font-style: normal;
      color: #000000;
      text-decoration: none;
      text-align: left;
      vertical-align: bottom;
      white-space: normal;
      overflow: hidden;
      text-indent: 0px;
      padding-left: 3px;
      border-top: 1px solid #CCC;
      border-right: 1px solid #CCC;
      border-bottom: 1px solid #CCC;
    }
    
    .tblGenFixed td.s3 {
      background-color: white;
      font-family: arial, sans, sans-serif;
      font-size: 100.0%;
      font-weight: normal;
      font-style: normal;
      color: #000000;
      text-decoration: none;
      text-align: left;
      vertical-align: bottom;
      white-space: normal;
      overflow: hidden;
      text-indent: 0px;
      padding-left: 3px;
      border-right: 1px solid #CCC;
      border-bottom: 1px solid #CCC;
    }
    
    .tblGenFixed td.s4 {
      background-color: white;
      font-family: arial, sans, sans-serif;
      font-size: 100.0%;
      font-weight: normal;
      font-style: normal;
      color: #000000;
      text-decoration: none;
      text-align: left;
      vertical-align: bottom;
      white-space: normal;
      overflow: hidden;
      text-indent: 0px;
      padding-left: 3px;
      border-right: 1px solid #CCC;
      border-bottom: 1px solid #CCC;
    }
  </style>
  <link rel="alternate" type="application/rss+xml" title="Webdev Exercise - Google Docs" href="https://spreadsheets.google.com/feeds/list/pZYJDq4YnNoSwpd8J_5B5AQ/od6/public/basic">

</head>

<body>

  <div id="content">
    <table id="tblMain" border="0" cellpadding="0" cellspacing="0">
      <tbody>
        <tr>
          <td>
            <table class="tblGenFixed" id="tblMain_0" border="0" cellpadding="0" cellspacing="0">
              <tbody>
                <tr class="rShim">
                  <td class="rShim" style="width: 0pt;"></td>
                  <td class="rShim" style="width: 97px;"></td>
                  <td class="rShim" style="width: 163px;"></td>
                  <td class="rShim" style="width: 97px;"></td>
                  <td class="rShim" style="width: 146px;"></td>
                  <td class="rShim" style="width: 113px;"></td>
                  <td class="rShim" style="width: 97px;"></td>
                  <td class="rShim" style="width: 97px;"></td>
                  <td class="rShim" style="width: 97px;"></td>
                </tr>
                <tr>
                  <td class="hd">
                    <p style="height: 16px;">.</p>
                  </td>
                  <td class="s0">Name</td>
                  <td class="s1">Email</td>
                  <td class="s1">Phone</td>
                  <td class="s1">Address1</td>
                  <td class="s1">Address2</td>
                  <td class="s1">City</td>
                  <td class="s1">State</td>
                  <td class="s1">Zip</td>
                </tr>
                <tr>
                  <td class="hd">
                    <p style="height: 16px;">.</p>
                  </td>
                  <td class="s2">Amar</td>
                  <td class="s3">amardeep@live.com</td>
                  <td class="s3">408-555-1234</td>
                  <td class="s3">555 Halford Ave.</td>
                  <td class="s3">Apartment #43C</td>
                  <td class="s3">Santa Clara</td>
                  <td class="s3">CA</td>
                  <td class="s4">95051</td>
                </tr>
                <tr>
                  <td class="hd">
                    <p style="height: 16px;">.</p>
                  </td>
                  <td class="s2">Deepa</td>
                  <td class="s3">deepa@yahoo.com</td>
                  <td class="s3">408-555-1234</td>
                  <td class="s3">1234 Montcalm St.</td>
                  <td></td>
                  <td class="s3">Chula Vista</td>
                  <td class="s3">CA</td>
                  <td class="s4">91911</td>
                </tr>
                <tr>
                  <td class="hd">
                    <p style="height: 16px;">.</p>
                  </td>
                  <td class="s2">Eric</td>
                  <td class="s3">eric@ericrules.com</td>
                  <td class="s3">408-555-1234</td>
                  <td class="s3">10 Candyland</td>
                  <td></td>
                  <td class="s3">North Pole</td>
                  <td class="s3">PA</td>
                  <td class="s4">87996</td>
                </tr>
                <tr>
                  <td class="hd">
                    <p style="height: 16px;">.</p>
                  </td>
                  <td class="s2">Gregor</td>
                  <td class="s3">gregor@gmail.com</td>
                  <td class="s3">897-984-3145</td>
                  <td class="s3">Gregor Insurance Co.</td>
                  <td class="s3">1234 Strip St.</td>
                  <td class="s3">New York</td>
                  <td class="s3">NY</td>
                  <td class="s4">45879</td>
                </tr>
                <tr>
                  <td class="hd">
                    <p style="height: 16px;">.</p>
                  </td>
                  <td class="s2">Jeff</td>
                  <td class="s3">jeff@aol.com</td>
                  <td class="s3">408-555-1234</td>
                  <td class="s3">1234 Montcalm St.</td>
                  <td></td>
                  <td class="s3">Chula Vista</td>
                  <td class="s3">CA</td>
                  <td class="s4">91911</td>
                </tr>
                <tr>
                  <td class="hd">
                    <p style="height: 16px;">.</p>
                  </td>
                  <td class="s2">Jen</td>
                  <td class="s3">jen@ebay.com</td>
                  <td class="s3">408-555-1234</td>
                  <td class="s3">1234 Lily St.</td>
                  <td></td>
                  <td class="s3">San Diego</td>
                  <td class="s3">CA</td>
                  <td class="s4">91911</td>
                </tr>
                <tr>
                  <td class="hd">
                    <p style="height: 16px;">.</p>
                  </td>
                  <td class="s2">Katie</td>
                  <td class="s3">katie@ask.com</td>
                  <td class="s3">415-555-1234</td>
                  <td class="s3">949 Thunk Ct.</td>
                  <td></td>
                  <td class="s3">Sacramento</td>
                  <td class="s3">CA</td>
                  <td class="s4">95826</td>
                </tr>
                <tr>
                  <td class="hd">
                    <p style="height: 16px;">.</p>
                  </td>
                  <td class="s2">Vivian</td>
                  <td class="s3">vivian@altavista.com</td>
                  <td class="s3">650-458-1234</td>
                  <td class="s3">949 FooBar St.</td>
                  <td></td>
                  <td class="s3">San Mateo</td>
                  <td class="s3">CA</td>
                  <td class="s4">98745</td>
                </tr>
              </tbody>
            </table>
          </td>
        </tr>
      </tbody>
    </table>
  </div>
  <div id="footer"></div>
</body>

</html>
            
          
!
            
              #content,
#footer {
  display: none;
}

html {
  -webkit-box-sizing: border-box;
  -moz-box-sizing: border-box;
  box-sizing: border-box;
}

*,
*:before,
*:after {
  -webkit-box-sizing: inherit;
  -moz-box-sizing: inherit;
  box-sizing: inherit;
}

.contact-list {
  position:absolute;
  top: 20%;
  left: 40%;
}

.container {
  top: 100px;
  width: 320px;
  border-radius: 0.5em;
  border: solid #809BCA 0.12em;
  margin-bottom: 1em;
  font-family: sans-serif;
}

.header,
.footer {
  background-color: #E6ECF8;
}

h3 {
  margin: 0;
}

.header {
  padding: 0.3em;
  border-radius: 0.5em 0.5em 0 0;
  border-bottom: solid #CFD4DE 0.1em;
}

.contact {
  padding: 0.5em 0.5em 0 0.5em;
  width: 100%;
  font-size: 12px;
  position: relative;
}

.contact:hover > .contactInfo {
  vertical-align: top;
  display: inline-block;
  position: absolute;
  z-index: 1;
  border-right: solid #AAAAAA 0.1em;
  border-bottom: solid #AAAAAA 0.1em;
  /* IE7 hack */
  
  zoom: 1;
  *display: inline;
}

.contact:hover > .contactEmail,
.contact:hover > .contactPhone {
  display: none !important;
}

.contact:hover > .contactImg {
  padding-left: 14em;
  display: inline-block;
  vertical-align: top;
}

.contact:hover > .contactImg img {
  position: absolute;
  z-index: 1;
}

.contactInfo {
  display: none;
  width: 71.5%;
  padding: 0 0.3em 0.3em 0.3em;
}

.contactInfo p {
  margin: 0;
  padding: 0 0.1em 0.1em 0.1em;
}

.contactName {
  vertical-align: top;
  width: 28%;
  display: inline-block;
  /* IE7 hack */
  
  zoom: 1;
  *display: inline;
}

.contact:hover,
.contact:hover .contactInfo {
  background-color: #EFEFEF;
}

.contact:hover {
  border: solid #AAAAAA 0.1em;
  box-sizing: border-box;
}

.footer {
  margin-top: 1em;
  text-align: right;
  padding: 0.3em 0.3em 0.3em 0;
  border-radius: 0 0 0.5em 0.5em;
}

.view-option {
  display: inline-block;
  /* IE7 hack */
  
  zoom: 1;
  *display: inline;
}

.contactPhone,
.contactEmail {
  padding-left: 0.3em;
}

.contactPhone,
.contactImg {
  display: none;
}

.hidden {
  display: none;
}

.inline {
  display: inline;
}
            
          
!
            
              (function() {
  // Polyfills for browser compatibility
  var Node = Node || {
    ELEMENT_NODE: 1,
    ATTRIBUTE_NODE: 2,
    TEXT_NODE: 3
  };
  // Polyfill for querySelector/querySelectorAll
  if (!document.querySelectorAll) {
    document.querySelectorAll = function(selectors) {
      var style = document.createElement('style'),
        elements = [],
        element;
      document.documentElement.firstChild.appendChild(style);
      document._qsa = [];

      style.styleSheet.cssText = selectors + '{x-qsa:expression(document._qsa && document._qsa.push(this))}';
      window.scrollBy(0, 0);
      style.parentNode.removeChild(style);

      while (document._qsa.length) {
        element = document._qsa.shift();
        element.style.removeAttribute('x-qsa');
        elements.push(element);
      }
      document._qsa = null;
      return elements;
    };
  }

  if (!document.querySelector) {
    document.querySelector = function(selectors) {
      var elements = document.querySelectorAll(selectors);
      return (elements.length) ? elements[0] : null;
    };
  }

  // Polyfill for bind
  if (!Function.prototype.bind) {
    Function.prototype.bind = function(oThis) {
      if (typeof this !== 'function') {
        // closest thing possible to the ECMAScript 5
        // internal IsCallable function
        throw new TypeError('Function.prototype.bind - what is trying to be bound is not callable');
      }

      var aArgs = Array.prototype.slice.call(arguments, 1),
        fToBind = this,
        fNOP = function() {},
        fBound = function() {
          return fToBind.apply(this instanceof fNOP && oThis ? this : oThis,
            aArgs.concat(Array.prototype.slice.call(arguments)));
        };

      fNOP.prototype = this.prototype;
      fBound.prototype = new fNOP();

      return fBound;
    };
  }

  // Polyfill for trim
  if (!String.prototype.trim) {
    String.prototype.trim = function() {
      return this.replace(/^[\s\uFEFF\xA0]+|[\s\uFEFF\xA0]+$/g, '');
    };
  }

  // Define a constructor
  this.ContactListWidget = function() {

    // Create global element references
    this.widget = null;
    this.select = null;

    // Define option defaults
    var defaults = {
      select: true
    };

    // Create options by extending defaults with the passed in arguments
    this.options = extendDefaults(defaults, arguments[0]);
  };

  // Public methods
  ContactListWidget.prototype.build = function() {
    init.call(this);
    initializeEvents.call(this);
  };

  // Private methods
  function init() {
    // Instantiate main elements of the widget
    var docFrag,
      contentHolder,
      header,
      footer;

    // Create a DocumentFragment to build with
    docFrag = document.createDocumentFragment();

    // Create widget element
    this.widget = document.createElement("div");
    this.widget.className = "contact-list";

    // Create content area
    contentHolder = document.createElement("div");
    contentHolder.className = "container";
    header = document.createElement("div");
    header.className = "header";
    var contactsHeader = document.createElement("h3");
    contactsHeader.textContent = contactsHeader.innerText = "Contacts";
    header.appendChild(contactsHeader);
    contentHolder.appendChild(header);

    // Get HTML table of contacts
    var table = document.querySelectorAll('table.tblGenFixed tr');
    var contactFieldRow = table[1].childNodes;

    // Utility method to populate an array of contact fields from the table headers
    var contactFields = [];
    for (var i = 0; i < contactFieldRow.length; i++) {
      var contactField = contactFieldRow[i].innerText || contactFieldRow[i].textContent;
      // Certain browsers will register whitespace between tags as textNodes, we only want nodes with contact field information
      if (contactFieldRow[i].nodeType === Node.ELEMENT_NODE && contactField.trim() !== ".")
        contactFields.push(contactField);
    }

    // Create array of contact objects
    var contacts = [];
    for (var k = 2; k < table.length; k++) {
      var contactRow = table[k].childNodes;
      var contactObj = {};
      var fieldCount = 0;
      // Build contact object info using contact fields array as properties
      for (var j = 0; j < contactRow.length; j++) {
        var field = contactRow[j].innerText || contactRow[j].textContent;
        // Certain browsers will register whitespace between tags as textNodes, we only want nodes with contact field information
        if (contactRow[j].nodeType === Node.ELEMENT_NODE && field.trim() !== ".") {
          contactObj[contactFields[fieldCount]] = field;
          fieldCount++;
        }
      }
      contacts.push(contactObj);
    }

    // Create contact list elements from contacts array
    for (var m = 0; m < contacts.length; m++) {
      var contactInfoObj = contacts[m];
      // Create contact div
      var contact = document.createElement("div");
      contact.className = "contact";
      // Add contact name to contact div
      var contactName = document.createElement("a");
      contactName.className = "contactName";
      contactName.innerText = contactName.textContent = contactInfoObj[contactFields[0]];
      contact.appendChild(contactName);
      // Create contactInfo div that will show on hover
      var contactInfo = document.createElement("div");
      contactInfo.className = "contactInfo";

      var pEmail = document.createElement("p");
      var emailLink = document.createElement("a");
      var mailToLink = "mailto:" + contactInfoObj[contactFields[1]];
      emailLink.href = mailToLink;
      emailLink.innerText = emailLink.textContent = contactInfoObj[contactFields[1]];
      pEmail.appendChild(emailLink);
      contactInfo.appendChild(pEmail);

      var pPhone = document.createElement("p");
      pPhone.innerText = pPhone.textContent = contactInfoObj[contactFields[2]];
      contactInfo.appendChild(pPhone);

      var pAddress1 = document.createElement("p");
      var address1 = contactInfoObj[contactFields[3]];
      pAddress1.innerText = pAddress1.textContent = address1 + " - ";

      var pAddress2 = document.createElement("p");
      var address2 = contactInfoObj[contactFields[4]];

      if (address2 !== "" && address2 != undefined) {
        pAddress2.innerText = pAddress2.textContent =
          address2;
      }

      var pCityStateZip = document.createElement("p");
      var cityStateZip = contactInfoObj[contactFields[5]] +
        ", " +
        contactInfoObj[contactFields[6]] +
        " " +
        contactInfoObj[contactFields[7]];
      pCityStateZip.innerText =
        pCityStateZip.textContent = cityStateZip;

      var address = address1;
      if (address2 !== "" && address2 != undefined) {
        address = address + ", " + address2;
      }
      address += ", " + cityStateZip;
      var mapLink = document.createElement("a");
      mapLink.href = "https://www.google.com/maps/search/" + address;
      mapLink.innerText = mapLink.textContent = "map";

      pAddress1.appendChild(mapLink);
      contactInfo.appendChild(pAddress1);
      contactInfo.appendChild(pAddress2);
      contactInfo.appendChild(pCityStateZip);

      var pChatsEmails = document.createElement("p");
      pChatsEmails.innerText = pChatsEmails.textContent = "Chats - Emails";
      contactInfo.appendChild(pChatsEmails);

      contact.appendChild(contactInfo);

      var imageDiv = document.createElement("div");
      imageDiv.className = "contactImg";
      var img = document.createElement("img");
      img.src = "https://s17.postimg.org/ytlrgs957/amar.gif";
      imageDiv.appendChild(img);

      contact.appendChild(imageDiv);

      // Add inline contact email and phone divs
      var contactEmailSpan = document.createElement("span");
      contactEmailSpan.className = "contactEmail";
      var emailLink2 = document.createElement("a");
      emailLink2.href = mailToLink;
      emailLink2.innerText = emailLink2.textContent = contactInfoObj[contactFields[1]];
      contactEmailSpan.appendChild(emailLink2);

      contact.appendChild(contactEmailSpan);

      var contactPhoneSpan = document.createElement("span");
      contactPhoneSpan.className = "contactPhone";
      contactPhoneSpan.innerText = contactPhoneSpan.textContent = contactInfoObj[contactFields[2]];
      contact.appendChild(contactPhoneSpan);

      contentHolder.appendChild(contact);
    }

    footer = document.createElement("div");
    footer.className = "footer";

    // If select option is true, add it
    if (this.options.select) {
      this.select = document.createElement("select");
      this.select.className = "view-option";
      var filters = ["Email address", "Phone number"];
      for (var i = 0; i < filters.length; i++) {
        var option = new Option(filters[i], filters[i]);

        // Fix for Firefox 3.5 add() that must have a second argument
        try {
          this.select.add(option);
        } catch (e) {
          this.select.add(option, null);
        }
      }
      footer.appendChild(this.select);
    }

    contentHolder.appendChild(footer);

    this.widget.appendChild(contentHolder);
    // Append widget to Document Fragment
    docFrag.appendChild(this.widget);

    // Append Document Fragment to body
    document.body.appendChild(docFrag);
  }

  function initializeEvents() {
    if (this.select) {
      this.select.onchange = changeDisplay.bind(this);
      this.select.onclick = changeDisplay.bind(this);
    }
  }

  // Changes the display info next to contact name based on selection
  function changeDisplay() {
    var selectValue = this.select.options[this.select.selectedIndex].value;
    var email = document.querySelectorAll(".contactEmail");
    var phone = document.querySelectorAll(".contactPhone");
    if (selectValue === 'Email address') {
      for (var i = 0; i < email.length; i++) {
        email[i].className = "contactEmail inline";
        phone[i].className = "contactPhone hidden";
      }
    } else {
      for (var i = 0; i < email.length; i++) {
        email[i].className = "contactEmail hidden";
        phone[i].className = "contactPhone inline";
      }
    }
  }

  // Utility method to extend defaults with user options
  function extendDefaults(source, properties) {
    var property;
    for (property in properties) {
      if (properties.hasOwnProperty(property)) {
        source[property] = properties[property];
      }
    }
    return source;
  }

  window.onload = function() {
    var myWidget = new ContactListWidget();
    myWidget.build();
  };

}());
            
          
!
999px
🕑 One or more of the npm packages you are using needs to be built. You're the first person to ever need it! We're building it right now and your preview will start updating again when it's ready.
Loading ..................

Console