"
27 | }
28 |
--------------------------------------------------------------------------------
/static/css/contacts.css:
--------------------------------------------------------------------------------
1 | .contact {
2 | margin: 15px 0;
3 | padding: 10px;
4 | border: 1px solid #DDD;
5 | background: #F0F0F0;
6 | }
7 |
8 | .contact .avatar {
9 | max-width: 80px;
10 | border: 1px solid #CCC;
11 | background: white;
12 | }
13 |
14 | .contact a.edit-link, .contact a.delete-link {
15 | text-align: center;
16 | margin: 10px 0;
17 | }
18 |
19 | .contact .name {
20 | font-size: 18px;
21 | font-weight: bold;
22 | }
23 |
24 | .contact .email-wrap {
25 | display: inline-block;
26 | width: 100%;
27 | white-space: nowrap;
28 | overflow: hidden;
29 | text-overflow: ellipsis;
30 | }
31 |
32 | .contact p {
33 | margin-left: 90px;
34 | }
35 |
36 | .contact:first-of-type, .contact:last-child { margin-bottom: 0; }
37 |
--------------------------------------------------------------------------------
/static/js/contacts.js:
--------------------------------------------------------------------------------
1 | function createNotification(type, message) {
2 | var alert = $('')
3 | .addClass('fade in alert alert-dismissable alert-' + type)
4 | .html('' + message);
5 | $('.notifications').append(alert);
6 | window.setTimeout(function() {
7 | alert.alert('close');
8 | }, 1500);
9 | }
10 |
11 | $(document).on('ready', function () {
12 | var socket = io.connect(document.origin);
13 | socket.on('notification', function(data) {
14 | createNotification(data.type, data.message);
15 | });
16 |
17 | socket.on('contacts', function (contacts) {
18 | contacts.forEach(function (contact) {
19 | var element = $('.sample-contact').clone();
20 | element.removeClass('sample-contact hidden').addClass('col-sm-4');
21 | element.find('.avatar').attr('src', contact.avatarUrl);
22 | element.find('.edit-link').attr('href', "/contacts/" + contact._id + "/edit");
23 | element.find('form').attr('action', "/contacts/" + contact._id);
24 | element.find('.firstName').text(contact.firstName);
25 | element.find('.lastName').text(contact.lastName);
26 | element.find('.twitter-link').attr('href', "https://twitter.com/" + contact.twitter);
27 | element.find('.twitter').text(contact.twitter);
28 | element.find('.streetAddress').text(contact.streetAddress);
29 | element.find('.countryCode').text(contact.countryCode);
30 | element.find('.zipCode').text(contact.zipCode);
31 | element.find('.city').text(contact.city);
32 | element.find('.phone').text(contact.city);
33 | element.find('.email').text(contact.email);
34 |
35 | $('.contacts').prepend(element);
36 | });
37 |
38 | $('.contacts .col-sm-12').remove();
39 | });
40 |
41 | $('#generate-samples').on('click', function (e) {
42 | e.preventDefault();
43 |
44 | createNotification('info', 'Your request has been dispatched');
45 |
46 | socket.emit('generateContacts');
47 | })
48 | });
49 |
--------------------------------------------------------------------------------