allow adding of multiple stickers

fixes #37
This commit is contained in:
ali asaria 2014-09-02 01:52:54 -04:00
parent 46a80badc7
commit b3e1a40398
5 changed files with 118 additions and 68 deletions

View file

@ -64,6 +64,12 @@
} }
.filler {
margin-right: 34px;
margin-bottom: 42px;
margin-left: 25px;
}
.stickertarget { .stickertarget {
position: absolute; position: absolute;
} }

View file

@ -63,6 +63,13 @@
} }
.filler {
margin-right: 12px;
margin-bottom: 19px;
margin-left: 19px;
}
.xcontent { .xcontent {
overflow: hidden; overflow: hidden;
display: block; display: block;

View file

@ -362,7 +362,7 @@ xopacity: .5;
top: 1px; top: 1px;
} }
.sticker-red { /*.sticker-red {
background-image: url('/images/stickers/sticker-red.png'); background-image: url('/images/stickers/sticker-red.png');
background-repeat: no-repeat; background-repeat: no-repeat;
background-position: right bottom; background-position: right bottom;
@ -432,7 +432,7 @@ xopacity: .5;
background-image: url('/images/stickers/sticker-purple.png'); background-image: url('/images/stickers/sticker-purple.png');
background-repeat: no-repeat; background-repeat: no-repeat;
background-position: right bottom; background-position: right bottom;
} }*/
@ -540,6 +540,10 @@ input:hover {
background-color: rgba(128, 128, 256,0.1) background-color: rgba(128, 128, 256,0.1)
} }
/*img ~ .card-hover-draggable {
-webkit-filter: hue-rotate(180deg);
}*/
.config { .config {
position: fixed; position: fixed;
right: 18px; right: 18px;
@ -557,7 +561,15 @@ input:hover {
.filler {
xwidth: 100%;
xbackground-color: rgba(255,0,0,0.1);
xheight: 100%;
right: 0;
bottom: 0;
position: absolute;
text-align: right;
}

View file

@ -168,7 +168,7 @@ function drawNewCard(id, text, x, y, rot, colour, sticker, animationspeed)
<img src="/images/icons/token/Xion.png" class="card-icon delete-card-icon" />\ <img src="/images/icons/token/Xion.png" class="card-icon delete-card-icon" />\
<img class="card-image" src="/images/' + colour + '-card.png">\ <img class="card-image" src="/images/' + colour + '-card.png">\
<div id="content:' + id + '" class="content stickertarget droppable">' + <div id="content:' + id + '" class="content stickertarget droppable">' +
text + '</div>\ text + '</div><span class="filler"></span>\
</div>'; </div>';
var card = $(h); var card = $(h);
@ -295,7 +295,7 @@ function drawNewCard(id, text, x, y, rot, colour, sticker, animationspeed)
//add applicable sticker //add applicable sticker
if (sticker !== null) if (sticker !== null)
$("#" + id).children('.content').addClass( sticker ); addSticker( id, sticker );
} }
@ -314,21 +314,27 @@ function moveCard(card, position) {
function addSticker ( cardId , stickerId ) function addSticker ( cardId , stickerId )
{ {
cardContent = $('#' + cardId).children('.content'); stickerContainer = $('#' + cardId + ' .filler');
cardContent.removeClass("sticker-red"); if (stickerId === "nosticker")
cardContent.removeClass("sticker-blue"); {
cardContent.removeClass("sticker-green"); stickerContainer.html("");
cardContent.removeClass("sticker-yellow"); return;
cardContent.removeClass("sticker-gold"); }
cardContent.removeClass("sticker-silverstar");
cardContent.removeClass("sticker-bluestar");
cardContent.removeClass("sticker-redstar"); if ( Array.isArray( stickerId ) )
cardContent.removeClass("sticker-orange"); {
cardContent.removeClass("sticker-pink"); for (var i in stickerId)
cardContent.removeClass("sticker-purple"); {
cardContent.removeClass("sticker-lightblue"); stickerContainer.prepend('<img src="images/stickers/' + stickerId[i] + '.png">');
cardContent.addClass( stickerId ); }
}
else
{
if ( stickerContainer.html().indexOf(stickerId) < 0 )
stickerContainer.prepend('<img src="images/stickers/' + stickerId + '.png">');
}
} }

View file

@ -4,6 +4,7 @@ var redis = require("redis"),
redisClient = null; //redis.createClient(); redisClient = null; //redis.createClient();
var async = require("async"); var async = require("async");
var sets = require('simplesets');
// If you want Memory Store instead... // If you want Memory Store instead...
// var MemoryStore = require('connect/middleware/session/memory'); // var MemoryStore = require('connect/middleware/session/memory');
@ -142,9 +143,27 @@ db.prototype = {
redisClient.hget(REDIS_PREFIX + '-room:' + room + '-cards', cardId, function(err, res) { redisClient.hget(REDIS_PREFIX + '-room:' + room + '-cards', cardId, function(err, res) {
var card = JSON.parse(res); var card = JSON.parse(res);
if (card !== null) { if (card !== null) {
card.sticker = stickerId; if (stickerId === "nosticker")
{
card.sticker = null;
redisClient.hset(REDIS_PREFIX + '-room:' + room + '-cards', cardId, JSON.stringify(card)); redisClient.hset(REDIS_PREFIX + '-room:' + room + '-cards', cardId, JSON.stringify(card));
} }
else
{
if (card.sticker !== null)
stickerSet = new sets.Set( card.sticker );
else
stickerSet = new sets.Set();
stickerSet.add(stickerId);
card.sticker = stickerSet.array();
redisClient.hset(REDIS_PREFIX + '-room:' + room + '-cards', cardId, JSON.stringify(card));
}
}
}); });
}, },