2008-08-27 02:38:35 +01:00
|
|
|
/*
|
|
|
|
* Laconica - a distributed open-source microblogging tool
|
|
|
|
* Copyright (C) 2008, Controlez-Vous, Inc.
|
|
|
|
*
|
|
|
|
* This program is free software: you can redistribute it and/or modify
|
|
|
|
* it under the terms of the GNU Affero General Public License as published by
|
|
|
|
* the Free Software Foundation, either version 3 of the License, or
|
|
|
|
* (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU Affero General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU Affero General Public License
|
|
|
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
*/
|
|
|
|
|
2008-06-24 18:46:13 +01:00
|
|
|
$(document).ready(function(){
|
|
|
|
// count character on keyup
|
2008-09-05 05:54:15 +01:00
|
|
|
function counter(event){
|
2008-07-01 19:30:16 +01:00
|
|
|
var maxLength = 140;
|
2008-08-17 16:31:43 +01:00
|
|
|
var currentLength = $("#status_textarea").val().length;
|
2008-07-08 10:04:18 +01:00
|
|
|
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-09-05 05:57:36 +01:00
|
|
|
function submitonreturn(event) {
|
|
|
|
if (event.keyCode == 13) {
|
|
|
|
$("#status_form").submit();
|
2008-09-05 06:03:56 +01:00
|
|
|
event.preventDefault();
|
|
|
|
event.stopPropagation();
|
|
|
|
return false;
|
2008-09-05 05:57:36 +01:00
|
|
|
}
|
2008-09-05 06:03:56 +01:00
|
|
|
return true;
|
2008-09-05 05:57:36 +01:00
|
|
|
}
|
2008-09-05 05:54:15 +01:00
|
|
|
|
2008-06-24 18:46:13 +01:00
|
|
|
if ($("#status_textarea").length) {
|
2008-09-05 05:57:36 +01:00
|
|
|
$("#status_textarea").bind("keyup", counter);
|
|
|
|
$("#status_textarea").bind("keydown", submitonreturn);
|
|
|
|
|
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-09-05 06:08:24 +01:00
|
|
|
|
|
|
|
// set the focus
|
|
|
|
$("#status_textarea").focus();
|
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 + " ";
|
2008-09-05 10:08:48 +01:00
|
|
|
if ($("#status_textarea").length) {
|
2008-07-09 08:24:29 +01:00
|
|
|
$("#status_textarea").val(replyto);
|
2008-07-09 08:14:39 +01:00
|
|
|
$("#status_textarea").focus();
|
2008-08-27 02:50:10 +01:00
|
|
|
return false;
|
|
|
|
}
|
2008-07-09 08:14:39 +01:00
|
|
|
}
|
2008-08-27 02:50:10 +01:00
|
|
|
return true;
|
2008-07-09 08:14:39 +01:00
|
|
|
}
|
|
|
|
|