2008-06-24 18:46:13 +01:00
|
|
|
$(document).ready(function(){
|
|
|
|
// count character on keyup
|
2008-07-01 19:30:16 +01:00
|
|
|
function counter(){
|
|
|
|
var maxLength = 140;
|
2008-07-08 10:04:18 +01:00
|
|
|
var currentLength = $("#status_textarea").val()
|
|
|
|
.replace(/[\uD800-\uDBFF][\uDC00-\uDFFF]/g, "drry")
|
|
|
|
.replace(/[\u0800-\uFFFF]/g, "drr")
|
|
|
|
.replace(/[\u0080-\u07FF]/g, "dr")
|
|
|
|
.length;
|
|
|
|
var remaining = maxLength - currentLength;
|
|
|
|
var counter = $("#counter");
|
2008-06-25 13:58:47 +01:00
|
|
|
counter.text(remaining);
|
2008-06-24 18:46:13 +01:00
|
|
|
|
2008-07-08 10:04:18 +01:00
|
|
|
if (remaining <= 0) {
|
2008-06-25 13:58:47 +01:00
|
|
|
counter.attr("class", "toomuch");
|
2008-07-08 10:04:18 +01:00
|
|
|
} else {
|
2008-06-25 13:58:47 +01:00
|
|
|
counter.attr("class", "");
|
2008-07-08 10:04:18 +01:00
|
|
|
}
|
2008-06-24 18:46:13 +01:00
|
|
|
}
|
2008-07-09 08:14:39 +01:00
|
|
|
|
2008-06-24 18:46:13 +01:00
|
|
|
if ($("#status_textarea").length) {
|
|
|
|
$("#status_textarea").bind("keyup", counter);
|
2008-07-01 19:30:16 +01:00
|
|
|
// run once in case there's something in there
|
2008-07-08 10:04:18 +01:00
|
|
|
counter();
|
2008-06-24 18:46:13 +01:00
|
|
|
}
|
|
|
|
});
|
|
|
|
|
2008-07-09 08:14:39 +01:00
|
|
|
function doreply(nick) {
|
|
|
|
rgx_username = /^[0-9a-zA-Z\-_.]*$/;
|
|
|
|
if (nick.match(rgx_username)) {
|
|
|
|
replyto = "@" + nick + " ";
|
|
|
|
if ($("#status_textarea")) {
|
2008-07-09 08:24:29 +01:00
|
|
|
$("#status_textarea").val(replyto);
|
2008-07-09 08:14:39 +01:00
|
|
|
$("#status_textarea").focus();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|