Ground work for the bill board announcement feature

This commit is contained in:
benmcmahon100
2016-04-12 01:02:17 +01:00
parent 729f966952
commit a27c5ccdd2
5 changed files with 99 additions and 0 deletions

View File

@@ -612,4 +612,38 @@ $(document).ready(function() {
// Repo
window.location = 'https://github.com/freecodecamp/freecodecamp/';
});
function getCurrentBillBoard(cb) {
$.ajax({
url: '/billboard',
method: 'GET',
dataType: 'JSON'
}).done((resp) => {
cb(resp);
});
}
function handleNewBillBoard(message) {
const seen = typeof localStorage.getItem('billboardSeen') !== "undefined" ? localStorage.getItem('billboardSeen') : 'false';
let old = typeof localStorage.getItem('billboard') !== "undefined" ? localStorage.getItem('billboard') : 'false';
if(seen !== 'true') {
old = null;
}
if(message.data !== old) {
if(!message.err) {
$('#billContent').text(message.data);
localStorage.setItem('billboard', message.data)
} else {
console.error(message.err);
}
}
}
getCurrentBillBoard(handleNewBillBoard);
$('#dismissBill').on('click', () => {
console.log("test");
localStorage.setItem('billboardSeen', 'true');
});
});