Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

switch status string based on active count #365

Open
wants to merge 5 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 16 additions & 6 deletions lib/assets/client.js
Original file line number Diff line number Diff line change
Expand Up @@ -66,14 +66,24 @@ socket.on('data', function (users){
for (var i in users) update(i, users[i])
})
socket.on('total', function (n){ update('total', n) })
socket.on('active', function (n){ update('active', n) })
socket.on('active', function (n){
if (n > 0) {
document.querySelector('.statusActive').className = 'statusActive'
document.querySelector('.statusInactive').className = 'statusInactive hide'
} else {
document.querySelector('.statusActive').className = 'statusActive hide'
document.querySelector('.statusInactive').className = 'statusInactive'
}
update('active', n)
})

function update (val, n, noanim){
var el = document.querySelector('.' + val)
if (n != el.innerHTML) {
el.innerHTML = n
anim(el, val)
}
document.querySelectorAll('.' + val).forEach(function(el) {
if (n != el.innerHTML) {
el.innerHTML = n
anim(el, val)
}
})
}

function anim (el, c){
Expand Down
23 changes: 15 additions & 8 deletions lib/splash.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,17 @@ export default function splash ({ path, name, org, coc, logo, active, total, cha
' on Slack.'
),
dom('p.status',
active
? [
dom('span.' + (active ? 'statusActive' : 'statusActive.hide'),
[
dom('b.active', active), ' users online now of ',
dom('b.total', total), ' registered.'
]
: [dom('b.total', total), ' users are registered so far.']
),
dom('span.' + (active ? 'statusInactive.hide' : 'statusInactive'),
[
dom('b.total', total), ' users are registered so far.'
]
)
),
dom('form id=invite',
channels && (
Expand Down Expand Up @@ -81,6 +86,10 @@ function style ({ logo, active, large, iframe } = {}){
'font-family': '"Helvetica Neue", Helvetica, Arial'
})

css.add('.hide', {
'display': 'none'
})

if (iframe) {
css.add('body, html', {
'margin': '0',
Expand Down Expand Up @@ -300,11 +309,9 @@ function style ({ logo, active, large, iframe } = {}){
'outline': '0'
})

if (active) {
css.add('.active', {
'color': pink
})
}
css.add('.active', {
'color': pink
})

css.add('p.signin', {
'padding': '1rem 0 1rem',
Expand Down