Skip to content
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
2 changes: 1 addition & 1 deletion callins.html
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ <h1>Answer call-in queue</h1>
<td><div class="answer">{{answer}}</div>{{#if backsolve}}(backsolve){{/if}}{{#if provided}}(provided){{/if}}</td>
<td>{{pretty_ts this.created}}</td>
<td>{{#with lastAttempt type target}}{{pretty_ts timestamp}} <small>({{pretty_ts timestamp=timestamp style="brief duration"}})</small>{{else}}-{{/with}}</td>
{{#if sessionNick}}
{{#if mynick}}
<td><input type="checkbox" class="bb-submitted-to-hq" checked={{submitted_to_hq}}></td>
<td class="btn-group">
<button class="btn btn-success bb-callin-correct">Correct</button>
Expand Down
2 changes: 1 addition & 1 deletion chat.html
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@
</template>

<template name="messages_input">
{{#if hasNick}}
{{#if mynick}}
<form id="messageForm" class="navbar-form">
<textarea id="messageInput" class="input-block-level" rows="1"
placeholder="Type your message and press enter..."
Expand Down
74 changes: 37 additions & 37 deletions client/blackboard.coffee
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
'use strict'

import { reactiveLocalStorage } from './imports/storage.coffee'

model = share.model # import
settings = share.settings # import

Expand All @@ -22,7 +25,7 @@ Meteor.startup ->
return unless doc.target? # 'no recent puzzle was solved'
return if doc.target is oldDoc.target # answer changed, not really new
console.log 'that was easy', doc, oldDoc
unless Session.get 'mute'
if 'true' isnt reactiveLocalStorage.getItem 'mute'
blackboard.newAnswerSound?.play?()
# see if we've got native emoji support, and add the 'has-emojis' class
# if so; inspired by
Expand Down Expand Up @@ -64,18 +67,16 @@ okCancelEvents = share.okCancelEvents = (selector, callbacks) ->
events

######### general properties of the blackboard page ###########
['sortReverse','hideSolved','hideRoundsSolvedMeta','hideStatus','compactMode'].forEach (name) ->
Session.setDefault name, $.cookie(name)
compactMode = ->
editing = (Session.get 'nick') and (Session.get 'canEdit')
(Session.get 'compactMode') and not editing
editing = (reactiveLocalStorage.getItem 'nick') and (Session.get 'canEdit')
('true' is reactiveLocalStorage.getItem 'compactMode') and not editing
nCols = -> if compactMode() then 2 else \
(if ((Session.get 'nick') and (Session.get 'canEdit')) then 3 else 5)
(if ((reactiveLocalStorage.getItem 'nick') and (Session.get 'canEdit')) then 3 else 5)
Template.blackboard.helpers
sortReverse: -> Session.get 'sortReverse'
hideSolved: -> Session.get 'hideSolved'
hideRoundsSolvedMeta: -> Session.get 'hideRoundsSolvedMeta'
hideStatus: -> Session.get 'hideStatus'
sortReverse: -> 'true' is reactiveLocalStorage.getItem 'sortReverse'
hideSolved: -> 'true' is reactiveLocalStorage.getItem 'hideSolved'
hideRoundsSolvedMeta: -> 'true' is reactiveLocalStorage.getItem 'hideRoundsSolvedMeta'
hideStatus: -> 'true' is reactiveLocalStorage.getItem 'hideStatus'
compactMode: compactMode
nCols: nCols

Expand Down Expand Up @@ -122,7 +123,7 @@ Template.blackboard.events
############## groups, rounds, and puzzles ####################
Template.blackboard.helpers
roundgroups: ->
dir = if Session.get 'sortReverse' then 'desc' else 'asc'
dir = if 'true' is reactiveLocalStorage.getItem 'sortReverse' then 'desc' else 'asc'
model.RoundGroups.find {}, sort: [["created", dir]]
# the following is a map() instead of a direct find() to preserve order
rounds: ->
Expand All @@ -135,13 +136,13 @@ Template.blackboard.helpers
num_solved: (p for p in (model.Rounds.findOne(id)?.puzzles or []) when \
model.Puzzles.findOne(p)?.solved?).length
} for id, index in this.rounds)
r.reverse() if Session.get 'sortReverse'
r.reverse() if 'true' is reactiveLocalStorage.getItem 'sortReverse'
return r
stuck: share.model.isStuck

Template.blackboard_status_grid.helpers
roundgroups: ->
dir = if Session.get 'sortReverse' then 'desc' else 'asc'
dir = if 'true' is reactiveLocalStorage.getItem 'sortReverse' then 'desc' else 'asc'
model.RoundGroups.find {}, sort: [["created", dir]]
# the following is a map() instead of a direct find() to preserve order
rounds: ->
Expand Down Expand Up @@ -192,8 +193,7 @@ Template.blackboard.onRendered ->
# see the global 'updateScrollSpy' helper for details on how
# we update scrollspy when the rounds list changes
doBoolean = (name, newVal) ->
Session.set name, newVal
$.cookie name, (newVal or ''), {expires: 365, path: '/'}
reactiveLocalStorage.setItem name, newVal
Template.blackboard.events
"click .bb-sort-order button": (event, template) ->
reverse = $(event.currentTarget).attr('data-sortReverse') is 'true'
Expand All @@ -205,40 +205,40 @@ Template.blackboard.events
"change .bb-compact-mode input": (event, template) ->
doBoolean 'compactMode', event.target.checked
"click .bb-hide-status": (event, template) ->
doBoolean 'hideStatus', !(Session.get 'hideStatus')
doBoolean 'hideStatus', ('true' isnt reactiveLocalStorage.getItem 'hideStatus')
"click .bb-add-round-group": (event, template) ->
alertify.prompt "Name of new round group:", (e,str) ->
return unless e # bail if cancelled
Meteor.call 'newRoundGroup', { name: str, who: Session.get('nick') }
Meteor.call 'newRoundGroup', { name: str, who: reactiveLocalStorage.getItem 'nick' }
"click .bb-roundgroup-buttons .bb-add-round": (event, template) ->
[type, id, rest...] = share.find_bbedit(event)
who = Session.get('nick')
who = reactiveLocalStorage.getItem 'nick'
alertify.prompt "Name of new round:", (e,str) ->
return unless e # bail if cancelled
Meteor.call 'newRound', { name: str, who: who }, (error,r)->
throw error if error
Meteor.call 'addRoundToGroup', {round: r._id, group: id, who: who}
"click .bb-round-buttons .bb-add-puzzle": (event, template) ->
[type, id, rest...] = share.find_bbedit(event)
who = Session.get('nick')
who = reactiveLocalStorage.getItem 'nick'
alertify.prompt "Name of new puzzle:", (e,str) ->
return unless e # bail if cancelled
Meteor.call 'newPuzzle', { name: str, who: who }, (error,p)->
throw error if error
Meteor.call 'addPuzzleToRound', {puzzle: p._id, round: id, who: who}
"click .bb-add-tag": (event, template) ->
[type, id, rest...] = share.find_bbedit(event)
who = Session.get('nick')
who = reactiveLocalStorage.getItem 'nick'
alertify.prompt "Name of new tag:", (e,str) ->
return unless e # bail if cancelled
Meteor.call 'setTag', {type:type, object:id, name:str, value:'', who:who}
"click .bb-move-up, click .bb-move-down": (event, template) ->
[type, id, rest...] = share.find_bbedit(event)
up = event.currentTarget.classList.contains('bb-move-up')
# flip direction if sort order is inverted
up = (!up) if (Session.get 'sortReverse') and type isnt 'puzzles'
up = (!up) if ('true' is reactiveLocalStorage.getItem 'sortReverse') and type isnt 'puzzles'
method = if up then 'moveUp' else 'moveDown'
Meteor.call method, {type:type, id:id, who:Session.get('nick')}
Meteor.call method, {type:type, id:id, who:reactiveLocalStorage.getItem 'nick'}
"click .bb-canEdit .bb-delete-icon": (event, template) ->
event.stopPropagation() # keep .bb-editable from being processed!
[type, id, rest...] = share.find_bbedit(event)
Expand Down Expand Up @@ -281,21 +281,21 @@ processBlackboardEdit =
processBlackboardEdit["roundgroups_#{field}"]?(text, id)
puzzles_title: (text, id) ->
if text is null # delete puzzle
Meteor.call 'deletePuzzle', {id:id, who:Session.get('nick')}
Meteor.call 'deletePuzzle', {id:id, who:reactiveLocalStorage.getItem 'nick'}
else
Meteor.call 'renamePuzzle', {id:id, name:text, who:Session.get('nick')}
Meteor.call 'renamePuzzle', {id:id, name:text, who:reactiveLocalStorage.getItem 'nick'}
rounds_title: (text, id) ->
if text is null # delete round
Meteor.call 'deleteRound', {id:id, who:Session.get('nick')}
Meteor.call 'deleteRound', {id:id, who:reactiveLocalStorage.getItem 'nick'}
else
Meteor.call 'renameRound', {id:id, name:text, who:Session.get('nick')}
Meteor.call 'renameRound', {id:id, name:text, who:reactiveLocalStorage.getItem 'nick'}
roundgroups_title: (text, id) ->
if text is null # delete roundgroup
Meteor.call 'deleteRoundGroup', {id:id, who:Session.get('nick')}
Meteor.call 'deleteRoundGroup', {id:id, who:reactiveLocalStorage.getItem 'nick'}
else
Meteor.call 'renameRoundGroup', {id:id,name:text,who:Session.get('nick')}
Meteor.call 'renameRoundGroup', {id:id,name:text,who:reactiveLocalStorage.getItem 'nick'}
tags_name: (text, id, canon) ->
who = Session.get('nick')
who = reactiveLocalStorage.getItem 'nick'
n = model.Names.findOne(id)
if text is null # delete tag
return Meteor.call 'deleteTag', {type:n.type, object:id, name:canon, who:who}
Expand All @@ -316,23 +316,23 @@ processBlackboardEdit =
canon: model.canonical(special)
value: ''
# set tag (overwriting previous value)
Meteor.call 'setTag', {type:n.type, object:id, name:t.name, value:text, who:Session.get('nick')}
Meteor.call 'setTag', {type:n.type, object:id, name:t.name, value:text, who:reactiveLocalStorage.getItem 'nick'}
link: (text, id) ->
n = model.Names.findOne(id)
Meteor.call 'setField',
type: n.type
object: id
who: Session.get 'nick'
who: reactiveLocalStorage.getItem 'nick'
fields: link: text

Template.blackboard_round.helpers
hasPuzzles: -> (this.round?.puzzles?.length > 0)
showRound: ->
return false if (Session.get 'hideRoundsSolvedMeta') and (this.round?.solved?)
return (!Session.get 'hideSolved') or (!this.round?.solved?) or
return false if ('true' is reactiveLocalStorage.getItem 'hideRoundsSolvedMeta') and (this.round?.solved?)
return ('true' isnt reactiveLocalStorage.getItem 'hideSolved') or (!this.round?.solved?) or
((model.Puzzles.findOne(id) for id, index in this.round?.puzzles ? []).
filter (p) -> !p?.solved?).length > 0
showMeta: -> (!Session.get 'hideSolved') or (!this.round?.solved?)
showMeta: -> ('true' isnt reactiveLocalStorage.getItem 'hideSolved') or (!this.round?.solved?)
# the following is a map() instead of a direct find() to preserve order
puzzles: ->
p = ({
Expand All @@ -341,8 +341,8 @@ Template.blackboard_round.helpers
puzzle: model.Puzzles.findOne(id) or { _id: id }
rXpY: "r#{this.round_num}p#{1+index}"
} for id, index in this.round.puzzles)
editing = (Session.get 'nick') and (Session.get 'canEdit')
hideSolved = Session.get 'hideSolved'
editing = (reactiveLocalStorage.getItem 'nick') and (Session.get 'canEdit')
hideSolved = 'true' is reactiveLocalStorage.getItem 'hideSolved'
return p if editing or !hideSolved
p.filter (pp) -> !pp.puzzle.solved?
tag: (name) ->
Expand Down Expand Up @@ -400,4 +400,4 @@ Template.blackboard.onCreated -> this.autorun =>
Meteor.startup ->
Meteor.setInterval ->
Session.set "currentTime", model.UTCNow()
, 60*1000
, 60*1000
16 changes: 7 additions & 9 deletions client/callins.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -41,31 +41,29 @@ Template.callins.helpers

Template.callins.onRendered ->
$("title").text("Answer queue")
share.ensureNick()

Template.callins.events
"click .bb-addquip-btn": (event, template) ->
share.Router.goTo "quips", "new"
"click .bb-quip-next": (event, template) ->
Meteor.call 'useQuip',
id: template.get_quip_id(event)
who: Session.get('nick')
who: reactiveLocalStorage.getItem 'nick'
"click .bb-quip-punt": (event, template) ->
Meteor.call 'useQuip',
id: template.get_quip_id(event)
who: Session.get('nick')
who: reactiveLocalStorage.getItem 'nick'
punted: true
"click .bb-quip-remove": (event, template) ->
Meteor.call 'removeQuip',
id: template.get_quip_id(event)
who: Session.get('nick')
who: reactiveLocalStorage.getItem 'nick'

Template.callin_row.onCreated ->
this.get_callin_id = (event) ->
$(event.currentTarget).closest('*[data-bbedit]').attr('data-bbedit')

Template.callin_row.helpers
sessionNick: -> Session.get 'nick'
lastAttempt: (type, target) ->
p = if target then model.collection(type).findOne(target)
return null unless p? and p.incorrectAnswers?.length > 0
Expand All @@ -80,22 +78,22 @@ Template.callin_row.events
"click .bb-callin-correct": (event, template) ->
Meteor.call 'correctCallIn',
id: template.get_callin_id(event)
who: Session.get('nick')
who: reactiveLocalStorage.getItem 'nick'

"click .bb-callin-incorrect": (event, template) ->
Meteor.call 'incorrectCallIn',
id: template.get_callin_id(event)
who: Session.get('nick')
who: reactiveLocalStorage.getItem 'nick'

"click .bb-callin-cancel": (event, template) ->
Meteor.call 'cancelCallIn',
id: template.get_callin_id(event)
who: Session.get('nick')
who: reactiveLocalStorage.getItem 'nick'

"change .bb-submitted-to-hq": (event, template) ->
checked = !!event.currentTarget.checked
Meteor.call 'setField',
type: 'callins'
object: template.get_callin_id(event)
fields: submitted_to_hq: checked
who: Session.get('nick')
who: reactiveLocalStorage.getItem 'nick'
Loading