Skip to content

Commit

Permalink
improved list of invited contacts #1
Browse files Browse the repository at this point in the history
  • Loading branch information
Kravalg committed Dec 30, 2016
1 parent d44c8d9 commit 3d0c967
Show file tree
Hide file tree
Showing 14 changed files with 348 additions and 59 deletions.
5 changes: 4 additions & 1 deletion _locales/en/messages.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,17 @@
"message": "Add new contacts"
},
"add_contacts": {
"message": "Add contacts:"
"message": "Add contacts"
},
"results": {
"message": "Results"
},
"page": {
"message": "page"
},
"total_invited": {
"message": "Total invited:"
},
"visit_special": {
"message": "Visit the special"
},
Expand Down
5 changes: 4 additions & 1 deletion _locales/ru/messages.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,17 @@
"message": "Добавьте новые контакты"
},
"add_contacts": {
"message": "Добавить контакты:"
"message": "Добавить контакты"
},
"results": {
"message": "Результаты"
},
"page": {
"message": "страницу"
},
"total_invited": {
"message": "Всего приглашено:"
},
"visit_special": {
"message": "Посетите специальную"
},
Expand Down
2 changes: 1 addition & 1 deletion bower.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
],
"dependencies": {
"jquery": "^2.2.4",
"bootstrap-material-design": "^4.0.2",
"bootstrap": "^3.3.7",
"components-font-awesome": "^4.7.0",
"jssocials": "^1.4.0"
},
Expand Down
2 changes: 2 additions & 0 deletions components/css/bootstrap-material-design.min.css

Large diffs are not rendered by default.

92 changes: 84 additions & 8 deletions components/css/popup.css
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
.hide {
body {
background-color: #fff;
}

.hide-block {
display: none;
}

Expand All @@ -17,19 +21,19 @@
}

header {
padding: 20px 0 5px 0;
margin-bottom: 5px;
padding: 10px 0 5px 0;
margin-bottom: 10px;
border-bottom: 1px solid rgba(128, 128, 128, 0.2);
}

.app-name {
line-height: 60px;
margin-left: 55px;
line-height: 25px;
margin-left: 50px;
margin-right: 15px;
}

footer {
margin-top: 5px;
margin-top: 10px;
border-top: 1px solid rgba(128, 128, 128, 0.2);
padding-top: 10px;
padding-bottom: 10px;
Expand All @@ -42,8 +46,80 @@ footer {

footer > div {
font-size: 12px;
color: grey;
text-align: center;
}

.jssocials-share-link { border-radius: 50%; }
.text-grey {
color: grey;
}

.text-bold {
font-weight: bold;
}

.jssocials-share-link { border-radius: 50%; }

/* Boostrap 3 panels */

.panel-heading, .panel-footer {
padding: 5px 15px;
}

.dropup.caret {
content: "";
border-top: 0;
border-bottom: 4px dashed;
}

.caret {
margin-left: 10px;
}

.list-group .list-group-item .list-group-item-heading {
font-size: 14px;
line-height: 14px;
}

.list-group-item-text {
margin-bottom: 0;
line-height: 1;
font-size: 12px;
}

#results .list-group-item {
border-bottom: 1px solid rgba(0, 0, 0, .1);
padding-bottom: 10px;
margin-bottom: 10px;
}

#results .list-group .list-group-item .row-picture {
float: left;
}

#results .list-group .list-group-item .row-content {
float: left;
min-height: unset;
height: auto;
}

.vertical-scroll {
overflow: auto;
height: auto;
max-height: 260px;
}

.list-group {
margin-bottom: 0;
}

#number_invited_now {
margin-left: 5px;
}

#number_invited_now:before {
content: '(';
}

#number_invited_now:after {
content: ')';
}
2 changes: 2 additions & 0 deletions components/css/ripples.min.css

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

61 changes: 41 additions & 20 deletions components/html/popup.html
Original file line number Diff line number Diff line change
Expand Up @@ -3,21 +3,21 @@
<head>
<link rel="stylesheet" type="text/css" href="/components/css/stepper.css">
<link rel="stylesheet" type="text/css" href="/bower_components/bootstrap/dist/css/bootstrap.min.css">
<link rel="stylesheet" type="text/css" href="/bower_components/bootstrap-material-design/dist/bootstrap-material-design.min.css">
<link rel="stylesheet" type="text/css" href="/components/css/bootstrap-material-design.min.css">
<link rel="stylesheet" href="/bower_components/components-font-awesome/css/font-awesome.min.css">
<link rel="stylesheet" type="text/css" href="/bower_components/jssocials/dist/jssocials.css" />
<link rel="stylesheet" type="text/css" href="/bower_components/jssocials/dist/jssocials-theme-flat.css" />
<link rel="stylesheet" type="text/css" href="/components/css/popup.css">
</head>
<body>
<div class="container" style="min-width: 300px">
<div class="container" style="min-width: 320px">
<header>
<h5 class="pull-left app-name">Linkedin <sup class="text-danger">boost</sup></h5>
<h3 class="pull-left app-name">Linkedin <sup class="text-danger">boost</sup></h3>
<img src="/components/img/christmas_tree.png" class="pull-left">
<div class="clearfix"></div>
</header>

<div id="not_linkedin" class="hide">
<div id="not_linkedin" class="hide-block">
<div class="mdl-card mdl-shadow--2dp">
<div class="mdl-card__supporting-text">
<div class="mdl-stepper-horizontal-alternative">
Expand Down Expand Up @@ -58,7 +58,7 @@ <h5 class="pull-left app-name">Linkedin <sup class="text-danger">boost</sup></h5
</div>
</div>

<div id="other_linkedin" class="hide">
<div id="other_linkedin" class="hide-block">
<div class="mdl-card mdl-shadow--2dp">
<div class="mdl-card__supporting-text">
<div class="mdl-stepper-horizontal-alternative">
Expand Down Expand Up @@ -89,27 +89,45 @@ <h5 class="pull-left app-name">Linkedin <sup class="text-danger">boost</sup></h5
</div>
</div>

<div id="add_contacts" class="hide">
<div>
<span data-translation="add_contacts"></span>
<div class="btn-group-gorizontal">
<button data-add-contacts="50" class="btn btn-raised btn-info">50</button>
<button data-add-contacts="100" class="btn btn-raised btn-info">100</button>
<button data-add-contacts="200" class="btn btn-raised btn-info">200</button>
<div id="add_contacts" class="hide-block">
<div class="panel panel-info can-toggle">
<div class="panel-heading pointer">
<span class="pull-left" data-translation="add_contacts"></span>
<span class="pull-right">
<span class="caret"></span>
</span>
<div class="clearfix"></div>
</div>
</div>
<div id="results" class="panel panel-default hide">
<div class="panel-heading" data-translation="results"></div>
<div class="panel-body">
<div class="btn-group-gorizontal">
<button data-add-contacts="50" class="btn btn-raised btn-success">50</button>
<button data-add-contacts="100" class="btn btn-raised btn-success">100</button>
<button data-add-contacts="200" class="btn btn-raised btn-success">200</button>
</div>
</div>
<div class="panel-footer">
<span data-translation="total_invited" class="text-grey"></span>
<span id="total_added_number" class="text-bold"></span>
</div>
</div>
<div id="results" class="panel panel-info hide-block can-toggle">
<div class="panel-heading pointer">
<span class="pull-left" data-translation="results"></span>
<span id="number_invited_now" class="pull-left hide-block">0</span>
<span class="pull-right">
<span class="caret"></span>
</span>
<div class="clearfix"></div>
</div>
<div class="panel-body vertical-scroll">
<div class="list-group">
<div class="list-group-item">
<div class="row-picture">
<img class="circle" src="" alt="icon">
<img width="56px" height="56px" class="circle" src="" alt="icon">
</div>
<div class="row-content">
<h4 class="list-group-item-heading"></h4>

<p class="list-group-item-text"></p>
<h6 class="list-group-item-heading text-bold"></h6>
<p class="list-group-item-text text-grey"></p>
</div>
</div>
</div>
Expand All @@ -118,12 +136,15 @@ <h4 class="list-group-item-heading"></h4>
</div>

<footer>
<div data-translation="share_friends"></div>
<div data-translation="share_friends" class="text-grey"></div>
<div id="share_friends"></div>
</footer>
</div>

<script src="/bower_components/jquery/dist/jquery.min.js"></script>
<script src="/bower_components/bootstrap/dist/js/bootstrap.min.js"></script>
<script src="/components/js/material.min.js"></script>
<script src="/components/js/class.localstorage.js"></script>
<script src="/components/js/popup.js"></script>
<script src="/bower_components/jssocials/dist/jssocials.min.js"></script>
</body>
Expand Down
25 changes: 25 additions & 0 deletions components/js/background.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
chrome.runtime.onMessage.addListener( function (request, sender, sendResponse) {
if (request.action === 'added_contacts') {

var totalAdded = parseInt(request.message.totalAdded);

if (Number.isInteger(totalAdded) && totalAdded > 0) {
chrome.storage.local.get('totalAdded', function(result) {
if (result.totalAdded === undefined) {
result.totalAdded = 0;
}

chrome.storage.local.set({
totalAdded: result.totalAdded + totalAdded
});

request.message.allAdded = result.totalAdded + totalAdded;

chrome.runtime.sendMessage({
action: 'added_contact_to_content',
data: request.message
});
});
}
}
});
35 changes: 35 additions & 0 deletions components/js/class.localstorage.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
function set (result) {
for (var key in result) {
LocalStorage.app[key] = result[key];
}
}

var LocalStorage = function LocalStorage () {

this.app = {
totalAdded: 0
};

this.set = function (obj) {
chrome.storage.local.set(obj);
};

this.get = function (key, callback) {
chrome.storage.local.get(key, function(result) {
callback(result);
});
};

this.init = function () {
this.updateAppData(set);
};

this.updateAppData = function (callback) {
for (var key in this.app) {
this.get(key, function (result) {
callback(result);
});
}
};

};
23 changes: 15 additions & 8 deletions components/js/content.js
Original file line number Diff line number Diff line change
@@ -1,11 +1,15 @@
const contactsNumOnOnePage = 15;

function sendMessageToBackground (obj) {
chrome.runtime.sendMessage(obj);
}

function addContacts(height, countOfPagesScrolled) {
setTimeout(function () {
if (countOfPagesScrolled > 0 && height != document.body.clientHeight) {
scrollDown(document.body.clientHeight, --countOfPagesScrolled);
} else {
console.log(sendRequest());
sendRequest();
}
}, 1500);
}
Expand All @@ -27,15 +31,20 @@ function sendRequest(){
jQuery(this).click();
addedContacts[contactsNum] = {
initials: jQuery(this).parents('.card-wrapper').find('.picture img').attr('alt'),
img: jQuery(this).parents('.card-wrapper').find('.picture img').attr('src')
title: jQuery(this).parents('.card-wrapper').find('.headline > span').attr('title'),
img: jQuery(this).parents('.card-wrapper').find('.picture img').attr('src'),
link: jQuery(this).parents('.card-wrapper').find('.picture a').attr('href')
};
contactsNum++;
});

return {
countAdded: contactsNum,
addedContacts: addedContacts
};
sendMessageToBackground({
action: 'added_contacts',
message: {
totalAdded: contactsNum,
addedContacts: addedContacts
}
});
}

function onRequest(request, sender, sendResponse) {
Expand All @@ -46,8 +55,6 @@ function onRequest(request, sender, sendResponse) {
}

scrollDown(document.body.clientHeight, getNumPages(request.contactsNumber));

sendResponse({result: true});
}

}
Expand Down
Loading

0 comments on commit 3d0c967

Please sign in to comment.