tweak notes

This commit is contained in:
Thibault Duplessis 2014-12-09 19:07:16 +01:00
parent a68f0d652f
commit ff15ea4f28
4 changed files with 10 additions and 7 deletions

View file

@ -137,7 +137,7 @@ object Round extends LilaController with TheftPrevention {
implicit val req = ctx.body
Form(single("text" -> text)).bindFromRequest.fold(
err => fuccess(BadRequest),
text => Env.round.noteApi.set(gameId, me.id, text take 10000))
text => Env.round.noteApi.set(gameId, me.id, text.trim take 10000))
}
private def side(pov: Pov, isPlayer: Boolean)(implicit ctx: Context) =

View file

@ -23,7 +23,7 @@
</div>
@if(withNotes) {
<div class="notes">
<textarea placeholder="Type notes here."></textarea>
<textarea placeholder="Type private notes here"></textarea>
</div>
}
</div>

View file

@ -11,10 +11,13 @@ final class NoteApi(coll: Coll) {
_ flatMap (_.getAs[String]("t")) getOrElse ""
}
def set(gameId: String, userId: String, text: String) = coll.update(
BSONDocument("_id" -> makeId(gameId, userId)),
BSONDocument("$set" -> BSONDocument("t" -> text)),
upsert = true).void
def set(gameId: String, userId: String, text: String) = {
if (text.isEmpty) coll.remove(BSONDocument("_id" -> makeId(gameId, userId)))
else coll.update(
BSONDocument("_id" -> makeId(gameId, userId)),
BSONDocument("$set" -> BSONDocument("t" -> text)),
upsert = true)
}.void
private def makeId(gameId: String, userId: String) = s"$gameId$userId"
}

View file

@ -974,7 +974,7 @@ var storage = {
// Toggle Notes/Chat display
$panels = self.element.find('div.chat_panels > div');
$parent.on('click', 'a', function() {
$parent.find('.chat_menu').on('click', 'a', function() {
var panel = $(this).data('panel');
$(this).siblings('.active').removeClass('active').end().addClass('active');
$panels.removeClass('active').filter('.' + panel).addClass('active');