Merge branch 'staging' into remove-angular
Conflicts: server/boot/user.js server/views/account/show.jade
This commit is contained in:
@@ -1,3 +1,32 @@
|
||||
var mapShareKey = 'map-shares';
|
||||
var lastCompleted = typeof lastCompleted !== 'undefined' ?
|
||||
lastCompleted :
|
||||
'';
|
||||
|
||||
function getMapShares() {
|
||||
var alreadyShared = JSON.parse(localStorage.getItem(mapShareKey) || '[]');
|
||||
if (!alreadyShared || !Array.isArray(alreadyShared)) {
|
||||
localStorage.setItem(mapShareKey, JSON.stringify([]));
|
||||
alreadyShared = [];
|
||||
}
|
||||
return alreadyShared;
|
||||
}
|
||||
|
||||
function setMapShare(id) {
|
||||
var alreadyShared = getMapShares();
|
||||
var found = false;
|
||||
alreadyShared.forEach(function(_id) {
|
||||
if (_id === id) {
|
||||
found = true;
|
||||
}
|
||||
});
|
||||
if (!found) {
|
||||
alreadyShared.push(id);
|
||||
}
|
||||
localStorage.setItem(mapShareKey, JSON.stringify(alreadyShared));
|
||||
return alreadyShared;
|
||||
}
|
||||
|
||||
$(document).ready(function() {
|
||||
|
||||
var challengeName = typeof challengeName !== 'undefined' ?
|
||||
@@ -381,6 +410,40 @@ $(document).ready(function() {
|
||||
}
|
||||
}, false);
|
||||
}
|
||||
|
||||
|
||||
// map sharing
|
||||
var alreadyShared = getMapShares();
|
||||
|
||||
if (lastCompleted && alreadyShared.indexOf(lastCompleted) === -1) {
|
||||
$('div[id="' + lastCompleted + '"]')
|
||||
.parent()
|
||||
.parent()
|
||||
.removeClass('hidden');
|
||||
}
|
||||
|
||||
// on map view
|
||||
$('.map-challenge-block-share').on('click', function(e) {
|
||||
e.preventDefault();
|
||||
var challengeBlockName = $(this).children().attr('id');
|
||||
var challengeBlockEscapedName = challengeBlockName.replace(/\s/, '%20');
|
||||
var username = typeof window.username !== 'undefined' ?
|
||||
window.username :
|
||||
'';
|
||||
|
||||
var link = 'https://www.facebook.com/dialog/feed?' +
|
||||
'app_id=1644598365767721' +
|
||||
'&display=page&' +
|
||||
'caption=I%20just%20completed%20the%20' +
|
||||
challengeBlockEscapedName +
|
||||
'%20section%20on%20Free%20Code%20Camp%2E' +
|
||||
'&link=http%3A%2F%2Ffreecodecamp%2Ecom%2F' +
|
||||
username +
|
||||
'&redirect_uri=http%3A%2F%2Ffreecodecamp%2Ecom%2Fmap';
|
||||
|
||||
setMapShare(challengeBlockName);
|
||||
window.location.href = link;
|
||||
});
|
||||
});
|
||||
|
||||
function defCheck(a){
|
||||
|
Reference in New Issue
Block a user