';
$.each([ "#f00", "#ff0", "#0f0", "#0ff", "#00f", "#f0f", "#fff", "#C0C0C0" , "#808080", "#000", "#800000", "#800080" , "#FF7F00", "#008000", "#808000" , "#000080", "#964B00","#C0DCC0","#A6CAF0","#FFFBF0"], function() {
data = data + "
x ";
});
data = data + '
';
data = data + "
";
$.each([1, 3, 5, 10, 15], function() {
data = data + "
" + this + " ";
});
$(".drawtools").append(data + '
');
drawns = 1;
}
$("#colors_sketch").sketch();
});
}
});
$( '.chat[data-id="' + pal + '"] .messageinput').focus(function() {
$(".chat" + pal + " .minichatbtn").addClass("btn-default").removeClass("btn-success");
$('.friendlist .newmsg[data-id="' + pal + '"]').removeClass("newmsg");
$.ajax({type: 'POST',url: "//deittihuone.fi/handler.php",data: 'readed=' + pal});
socket.emit('meta', { room: roomid[pal], user: userid[pal], data: { readed: true } });
if($('.friendlist .newmsg').length == 0)
$('.menubutton').removeClass("btn-success").addClass("btn-default");
});
$( '.chat[data-id="' + pal + '"] .messageinput').bind("paste keydown",function( event ) {
var typid = $(this).data("id");
if(!event.ctrlKey && event.keyCode == 13) {
if($(this).val() != "") {
sendmsg($(this).data("id"));
}
event.preventDefault();
$(this).val("");
$('.chat[data-id="' + typid + '"] textarea').trigger('autosize.resize');
} else {
if(write == 0) {
socket.emit('meta', { room: roomid[typid], user: userid[typid], data: { typing: true } });
write = 1;
setTimeout(function() { write = 0; },1000);
}
}
if($(this).height() != messageheight) {
setTimeout(function() {
messageheight = $(this).height();
textarearesize(typid);
},50);
}
});
}
}
function seemore(pal,timing) {
$.post("//deittihuone.fi/handler.php", {
getmessages : "true",
limit : 20,
from : timing-100,
friend: pal
}).done(function (data) {
if(data != "") {
var arr = JSON.parse(data);
$('.chat-window[data-id="' + pal + '"] .chatdata .seemore').remove();
if(arr.length > 0) {
$.each(arr, function(idx, obj) {
if(obj.user == userid[pal])
who = 1;
else
who = 2;
if(obj.meta != undefined) {
if(obj.meta.type == 6 || obj.meta.type == 3 || obj.meta.type == 4 || obj.meta.type == 5)
obj.meta.type = 0;
if(obj.meta.time != undefined)
newmsg(obj.message,roomid[pal],who,obj.created,0,obj.meta.type,1,1,1);
else
newmsg(obj.message,roomid[pal],who,obj.created,0,obj.meta.type,1,1,1);
} else
newmsg(obj.message,roomid[pal],who,obj.created,0,0,1,1,1);
$(".chat" + pal + " .minichatbtn").addClass("btn-default").removeClass("btn-success");
});
if(arr.length >= 20)
$('.chat-window[data-id="' + pal + '"] .chatdata').prepend('