Merge pull request #8076 from FreeCodeCamp/feature/billBoard
Announcement feature
This commit is contained in:
@ -124,6 +124,30 @@ main = (function(main, global) {
|
|||||||
Mousetrap.bind('g c', toggleMainChat);
|
Mousetrap.bind('g c', toggleMainChat);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
function localStorageIO(item = '', input = null) {
|
||||||
|
if (input) {
|
||||||
|
try {
|
||||||
|
input = typeof input === 'string' ? input : JSON.stringify(input);
|
||||||
|
} catch (e) {
|
||||||
|
// Do Nothing
|
||||||
|
}
|
||||||
|
localStorage.setItem(item, input);
|
||||||
|
return input;
|
||||||
|
} else {
|
||||||
|
let data = typeof localStorage.getItem(item)
|
||||||
|
!== 'undefined' && localStorage.getItem(item)
|
||||||
|
!== null ? localStorage.getItem(item) : '';
|
||||||
|
try {
|
||||||
|
data = JSON.parse(data);
|
||||||
|
} catch (e) {
|
||||||
|
// Do Nothing
|
||||||
|
}
|
||||||
|
return data;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
main.localStorageIO = localStorageIO;
|
||||||
|
|
||||||
return main;
|
return main;
|
||||||
}(main, window));
|
}(main, window));
|
||||||
|
|
||||||
@ -612,4 +636,49 @@ $(document).ready(function() {
|
|||||||
// Repo
|
// Repo
|
||||||
window.location = 'https://github.com/freecodecamp/freecodecamp/';
|
window.location = 'https://github.com/freecodecamp/freecodecamp/';
|
||||||
});
|
});
|
||||||
|
|
||||||
|
function getCurrentBillBoard(cb) {
|
||||||
|
$.ajax({
|
||||||
|
url: '/api/flyers/findOne?'
|
||||||
|
+ 'filter=%7B%22order%22%3A%20%20%22id%20DESC%22%7D',
|
||||||
|
method: 'GET',
|
||||||
|
dataType: 'JSON',
|
||||||
|
data: {'order': 'id DESC'}
|
||||||
|
}).done((resp) => {
|
||||||
|
cb(resp);
|
||||||
|
});
|
||||||
|
$('#dismissBill').on('click', (e) => {
|
||||||
|
const elemData
|
||||||
|
= e.target.parentNode.parentNode.children;
|
||||||
|
|
||||||
|
const res
|
||||||
|
= elemData[Object.keys(elemData).filter((key)=> {
|
||||||
|
return elemData[key].id === 'billContent';
|
||||||
|
|
||||||
|
})[0]].innerHTML;
|
||||||
|
|
||||||
|
main.localStorageIO('lastBillBoardSeen', res);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
function handleNewBillBoard(resp) {
|
||||||
|
const data = typeof main.localStorageIO('lastBillBoardSeen')
|
||||||
|
!== 'undefined' && main.localStorageIO('lastBillBoardSeen')
|
||||||
|
!== null ? main.localStorageIO('lastBillBoardSeen') : '';
|
||||||
|
if (
|
||||||
|
data.replace(/\s*/gi, '')
|
||||||
|
.replace(/\&\w*\;/gi, '')
|
||||||
|
.replace(/(\<|\/|\>)/gi, '')
|
||||||
|
!== resp.message
|
||||||
|
.replace(/\s*/gi, '')
|
||||||
|
.replace(/\&\w*\;/gi, '')
|
||||||
|
.replace(/(\<|\/|\>)/gi, '')
|
||||||
|
&& resp.active
|
||||||
|
) {
|
||||||
|
$('#billContent').html(resp.message);
|
||||||
|
$('#billBoard').fadeIn();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
getCurrentBillBoard(handleNewBillBoard);
|
||||||
});
|
});
|
||||||
|
34
common/models/flyer.json
Normal file
34
common/models/flyer.json
Normal file
@ -0,0 +1,34 @@
|
|||||||
|
{
|
||||||
|
"name": "flyer",
|
||||||
|
"base": "PersistedModel",
|
||||||
|
"idInjection": true,
|
||||||
|
"trackChanges": false,
|
||||||
|
"properties": {
|
||||||
|
"message": {
|
||||||
|
"type": "string"
|
||||||
|
},
|
||||||
|
"active": {
|
||||||
|
"type": "boolean",
|
||||||
|
"default": false
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"validations": [],
|
||||||
|
"relations": {
|
||||||
|
|
||||||
|
},
|
||||||
|
"acls": [
|
||||||
|
{
|
||||||
|
"accessType": "*",
|
||||||
|
"principalType": "ROLE",
|
||||||
|
"principalId": "$everyone",
|
||||||
|
"permission": "DENY"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"accessType": "READ",
|
||||||
|
"principalType": "ROLE",
|
||||||
|
"principalId": "$everyone",
|
||||||
|
"permission": "ALLOW"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"methods": []
|
||||||
|
}
|
@ -66,5 +66,9 @@
|
|||||||
"userIdentity": {
|
"userIdentity": {
|
||||||
"dataSource": "db",
|
"dataSource": "db",
|
||||||
"public": true
|
"public": true
|
||||||
|
},
|
||||||
|
"flyer": {
|
||||||
|
"dataSource": "db",
|
||||||
|
"public": true
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
extends ../layout
|
extends ../layout
|
||||||
block content
|
block content
|
||||||
|
include ../partials/flyer
|
||||||
script(src="/bower_components/cal-heatmap/cal-heatmap.min.js")
|
script(src="/bower_components/cal-heatmap/cal-heatmap.min.js")
|
||||||
script.
|
script.
|
||||||
var challengeName = 'Profile View';
|
var challengeName = 'Profile View';
|
||||||
|
@ -4,6 +4,7 @@ block content
|
|||||||
link(rel='stylesheet', href='/bower_components/CodeMirror/addon/lint/lint.css')
|
link(rel='stylesheet', href='/bower_components/CodeMirror/addon/lint/lint.css')
|
||||||
link(rel='stylesheet', href='/bower_components/CodeMirror/theme/monokai.css')
|
link(rel='stylesheet', href='/bower_components/CodeMirror/theme/monokai.css')
|
||||||
link(rel='stylesheet', href='/css/ubuntu.css')
|
link(rel='stylesheet', href='/css/ubuntu.css')
|
||||||
|
include ../partials/flyer
|
||||||
.row
|
.row
|
||||||
.col-md-4.col-lg-3
|
.col-md-4.col-lg-3
|
||||||
.scroll-locker(id = "scroll-locker")
|
.scroll-locker(id = "scroll-locker")
|
||||||
|
@ -4,6 +4,7 @@ block content
|
|||||||
link(rel='stylesheet', href='/bower_components/CodeMirror/addon/lint/lint.css')
|
link(rel='stylesheet', href='/bower_components/CodeMirror/addon/lint/lint.css')
|
||||||
link(rel='stylesheet', href='/bower_components/CodeMirror/theme/monokai.css')
|
link(rel='stylesheet', href='/bower_components/CodeMirror/theme/monokai.css')
|
||||||
link(rel='stylesheet', href='/css/ubuntu.css')
|
link(rel='stylesheet', href='/css/ubuntu.css')
|
||||||
|
include ../partials/flyer
|
||||||
.row
|
.row
|
||||||
.col-md-3.col-lg-3
|
.col-md-3.col-lg-3
|
||||||
.scroll-locker(id = "scroll-locker")
|
.scroll-locker(id = "scroll-locker")
|
||||||
|
@ -4,6 +4,7 @@ block content
|
|||||||
link(rel='stylesheet', href='/bower_components/CodeMirror/addon/lint/lint.css')
|
link(rel='stylesheet', href='/bower_components/CodeMirror/addon/lint/lint.css')
|
||||||
link(rel='stylesheet', href='/bower_components/CodeMirror/theme/monokai.css')
|
link(rel='stylesheet', href='/bower_components/CodeMirror/theme/monokai.css')
|
||||||
link(rel='stylesheet', href='/css/ubuntu.css')
|
link(rel='stylesheet', href='/css/ubuntu.css')
|
||||||
|
include ../partials/flyer
|
||||||
.row
|
.row
|
||||||
.col-md-4.col-lg-3
|
.col-md-4.col-lg-3
|
||||||
.scroll-locker(id = "scroll-locker")
|
.scroll-locker(id = "scroll-locker")
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
extends ../layout-wide
|
extends ../layout-wide
|
||||||
block content
|
block content
|
||||||
|
include ../partials/flyer
|
||||||
.row
|
.row
|
||||||
.col-md-8.col-md-offset-2
|
.col-md-8.col-md-offset-2
|
||||||
for step, index in description
|
for step, index in description
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
extends ../layout-wide
|
extends ../layout-wide
|
||||||
block content
|
block content
|
||||||
|
include ../partials/flyer
|
||||||
.row
|
.row
|
||||||
.col-xs-12.col-sm-12.col-md-4
|
.col-xs-12.col-sm-12.col-md-4
|
||||||
h4.text-center.challenge-instructions-title= name
|
h4.text-center.challenge-instructions-title= name
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
extends ../layout-wide
|
extends ../layout-wide
|
||||||
block content
|
block content
|
||||||
|
include ../partials/flyer
|
||||||
.row
|
.row
|
||||||
.col-md-4
|
.col-md-4
|
||||||
h4.text-center.challenge-instructions-title= name
|
h4.text-center.challenge-instructions-title= name
|
||||||
|
@ -6,7 +6,7 @@ html(lang='en')
|
|||||||
body.top-and-bottom-margins
|
body.top-and-bottom-margins
|
||||||
include partials/scripts
|
include partials/scripts
|
||||||
include partials/navbar
|
include partials/navbar
|
||||||
.container
|
|
||||||
include partials/flash
|
include partials/flash
|
||||||
|
.container
|
||||||
block content
|
block content
|
||||||
include partials/footer
|
include partials/footer
|
||||||
|
@ -1,4 +1,5 @@
|
|||||||
.row.flashMessage
|
.container
|
||||||
|
.row.flashMessage.negative-30
|
||||||
.col-xs-12
|
.col-xs-12
|
||||||
if (messages.errors || messages.error)
|
if (messages.errors || messages.error)
|
||||||
.alert.alert-danger.fade.in
|
.alert.alert-danger.fade.in
|
||||||
|
8
server/views/partials/flyer.jade
Normal file
8
server/views/partials/flyer.jade
Normal file
@ -0,0 +1,8 @@
|
|||||||
|
if (user && user.points > 5)
|
||||||
|
.container
|
||||||
|
.row.flashMessage.negative-30
|
||||||
|
.col-xs-12
|
||||||
|
#billBoard.alert.alert-info.fade.in(style="display: none;")
|
||||||
|
button.close(type='button', data-dismiss='alert')
|
||||||
|
span.ion-close-circled#dismissBill
|
||||||
|
#billContent
|
Reference in New Issue
Block a user