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

@ -1,20 +1,20 @@
.card { .card {
width: 230px; width: 230px;
height: 152px; height: 152px;
xpadding: 5px; float: left; xpadding: 5px; float: left;
xmargin: 0 10px 10px 0; xmargin: 0 10px 10px 0;
font-size: .9em; font-size: .9em;
overflow: hidden; overflow: hidden;
position: absolute; position: absolute;
z-index: 10; z-index: 10;
top: 460px; top: 460px;
left: 0px; left: 0px;
display: block; display: block;
} }
@ -40,30 +40,36 @@
z-index: -1000; z-index: -1000;
} }
.content { .content {
overflow: hidden; overflow: hidden;
display: block; display: block;
width: 158px; width: 158px;
height: 88px; height: 88px;
margin: 5px 23px 0px 34px; margin: 5px 23px 0px 34px;
font-family: 'Covered By Your Grace',"Arial Rounded MT Bold", arial, serif; font-family: 'Covered By Your Grace',"Arial Rounded MT Bold", arial, serif;
font-size: 18px; font-size: 18px;
letter-spacing: 0px; letter-spacing: 0px;
xtext-shadow: 0px 0px 1px #444; xtext-shadow: 0px 0px 1px #444;
opacity: 1; opacity: 1;
color: black; color: black;
text-align: center; text-align: center;
padding-top: 18px; padding-top: 18px;
xline-height: 16px; xline-height: 16px;
xopacity: .8; xopacity: .8;
}
.filler {
margin-right: 34px;
margin-bottom: 42px;
margin-left: 25px;
} }
.stickertarget { .stickertarget {
position: absolute; position: absolute;
} }

View file

@ -1,20 +1,20 @@
.card { .card {
width: 115px; width: 115px;
height: 76px; height: 76px;
xpadding: 5px; float: left; xpadding: 5px; float: left;
xmargin: 0 10px 10px 0; xmargin: 0 10px 10px 0;
font-size: .9em; font-size: .9em;
overflow: hidden; overflow: hidden;
position: absolute; position: absolute;
z-index: 10; z-index: 10;
top: 460px; top: 460px;
left: 0px; left: 0px;
display: block; display: block;
} }
@ -41,45 +41,52 @@
z-index: -1000; z-index: -1000;
} }
.content { .content {
overflow: hidden; overflow: hidden;
display: block; display: block;
width: 79px; width: 79px;
height: 45px; height: 45px;
margin: 1px 10px 0px 19px; margin: 1px 10px 0px 19px;
font-family: "Arial Rounded MT Bold" , arial, serif; font-family: "Arial Rounded MT Bold" , arial, serif;
font-size: 10px; font-size: 10px;
letter-spacing: 0px; letter-spacing: 0px;
line-height: 9px; line-height: 9px;
xtext-shadow: 0px 0px 1px #444; xtext-shadow: 0px 0px 1px #444;
opacity: 1; opacity: 1;
color: #333; color: #333;
text-align: center; text-align: center;
padding-top: 8px; padding-top: 8px;
} }
.xcontent { .filler {
margin-right: 12px;
margin-bottom: 19px;
margin-left: 19px;
}
.xcontent {
overflow: hidden; overflow: hidden;
display: block; display: block;
width: 79px; width: 79px;
height: 45px; height: 45px;
margin: 0px 10px 0px 19px; margin: 0px 10px 0px 19px;
font-family: "Arial Rounded MT Bold", "Arial" , arial, serif; font-family: "Arial Rounded MT Bold", "Arial" , arial, serif;
xfont-size: 10px; xfont-size: 10px;
letter-spacing: 0px; letter-spacing: 0px;
line-height: 8px; line-height: 8px;
xtext-shadow: 0px 0px 1px #444; xtext-shadow: 0px 0px 1px #444;
opacity: 1; opacity: 1;
color: #333; color: #333;
text-align: center; text-align: center;
padding-top: 8px; padding-top: 8px;
} }

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');
@ -14,16 +15,16 @@ var REDIS_PREFIX = '#scrumblr#';
//For Redis Debugging //For Redis Debugging
var db = function(callback) { var db = function(callback) {
redisClient = redis.createClient(); redisClient = redis.createClient();
redisClient.on("connect", function (err) { redisClient.on("connect", function (err) {
callback(); callback();
}); });
redisClient.on("error", function (err) { redisClient.on("error", function (err) {
console.log("Redis error: " + err); console.log("Redis error: " + err);
}); });
} }
db.prototype = { db.prototype = {
@ -48,7 +49,7 @@ db.prototype = {
// Column commands // Column commands
createColumn: function(room, name, callback) { createColumn: function(room, name, callback) {
redisClient.rpush(REDIS_PREFIX + '-room:' + room + '-columns', name, redisClient.rpush(REDIS_PREFIX + '-room:' + room + '-columns', name,
function (err, res) { function (err, res) {
if (typeof callback != "undefined" && callback !== null) callback(); if (typeof callback != "undefined" && callback !== null) callback();
} }
@ -72,8 +73,8 @@ db.prototype = {
async.forEachSeries( async.forEachSeries(
columns, columns,
function( item, callback ) { function( item, callback ) {
//console.log('rpush: ' + REDIS_PREFIX + '-room:' + room + '-columns' + ' -- ' + item); //console.log('rpush: ' + REDIS_PREFIX + '-room:' + room + '-columns' + ' -- ' + item);
redisClient.rpush(REDIS_PREFIX + '-room:' + room + '-columns', item, redisClient.rpush(REDIS_PREFIX + '-room:' + room + '-columns', item,
function (err, res) { function (err, res) {
callback(); callback();
} }
@ -98,14 +99,14 @@ db.prototype = {
getAllCards: function(room, callback) { getAllCards: function(room, callback) {
redisClient.hgetall(REDIS_PREFIX + '-room:' + room + '-cards', function (err, res) { redisClient.hgetall(REDIS_PREFIX + '-room:' + room + '-cards', function (err, res) {
var cards = []; var cards = [];
for (i in res) { for (i in res) {
cards.push( JSON.parse(res[i]) ); cards.push( JSON.parse(res[i]) );
} }
//console.dir(cards); //console.dir(cards);
callback(cards); callback(cards);
}); });
}, },
@ -142,21 +143,39 @@ 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")
redisClient.hset(REDIS_PREFIX + '-room:' + room + '-cards', cardId, JSON.stringify(card)); {
card.sticker = null;
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));
}
} }
}); });
}, },
setBoardSize: function(room, size) { setBoardSize: function(room, size) {
redisClient.set(REDIS_PREFIX + '-room:' + room + '-size', JSON.stringify(size)); redisClient.set(REDIS_PREFIX + '-room:' + room + '-size', JSON.stringify(size));
}, },
getBoardSize: function(room, callback) { getBoardSize: function(room, callback) {
redisClient.get(REDIS_PREFIX + '-room:' + room + '-size', function (err, res) { redisClient.get(REDIS_PREFIX + '-room:' + room + '-size', function (err, res) {
callback(JSON.parse(res)); callback(JSON.parse(res));
}); });
} }
}; };
exports.db = db; exports.db = db;