2008-08-26 21:38:35 -04: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 13:46:13 -04:00
|
|
|
$(document).ready(function(){
|
|
|
|
// count character on keyup
|
2008-09-05 00:54:15 -04:00
|
|
|
function counter(event){
|
2008-07-01 14:30:16 -04:00
|
|
|
var maxLength = 140;
|
2008-08-17 11:31:43 -04:00
|
|
|
var currentLength = $("#status_textarea").val().length;
|
2008-07-08 05:04:18 -04:00
|
|
|
var remaining = maxLength - currentLength;
|
|
|
|
var counter = $("#counter");
|
2008-06-25 08:58:47 -04:00
|
|
|
counter.text(remaining);
|
2008-06-24 13:46:13 -04:00
|
|
|
|
2008-07-08 05:04:18 -04:00
|
|
|
if (remaining <= 0) {
|
2008-06-25 08:58:47 -04:00
|
|
|
counter.attr("class", "toomuch");
|
2008-07-08 05:04:18 -04:00
|
|
|
} else {
|
2008-06-25 08:58:47 -04:00
|
|
|
counter.attr("class", "");
|
2008-07-08 05:04:18 -04:00
|
|
|
}
|
2008-06-24 13:46:13 -04:00
|
|
|
}
|
2008-07-09 03:14:39 -04:00
|
|
|
|
2008-09-05 00:57:36 -04:00
|
|
|
function submitonreturn(event) {
|
|
|
|
if (event.keyCode == 13) {
|
|
|
|
$("#status_form").submit();
|
2008-09-05 01:03:56 -04:00
|
|
|
event.preventDefault();
|
|
|
|
event.stopPropagation();
|
|
|
|
return false;
|
2008-09-05 00:57:36 -04:00
|
|
|
}
|
2008-09-05 01:03:56 -04:00
|
|
|
return true;
|
2008-09-05 00:57:36 -04:00
|
|
|
}
|
2008-09-05 00:54:15 -04:00
|
|
|
|
2008-06-24 13:46:13 -04:00
|
|
|
if ($("#status_textarea").length) {
|
2008-09-05 00:57:36 -04:00
|
|
|
$("#status_textarea").bind("keyup", counter);
|
|
|
|
$("#status_textarea").bind("keydown", submitonreturn);
|
|
|
|
|
2008-07-01 14:30:16 -04:00
|
|
|
// run once in case there's something in there
|
2008-07-08 05:04:18 -04:00
|
|
|
counter();
|
2008-09-05 01:08:24 -04:00
|
|
|
|
|
|
|
// set the focus
|
|
|
|
$("#status_textarea").focus();
|
2008-06-24 13:46:13 -04:00
|
|
|
}
|
2008-09-08 17:16:10 -04:00
|
|
|
|
|
|
|
var options = {dataType: 'xml',
|
|
|
|
success: function(xml) {
|
|
|
|
// replace the form with what's returned
|
2008-09-08 17:16:56 -04:00
|
|
|
}};
|
2008-09-08 17:16:10 -04:00
|
|
|
|
|
|
|
$("form.favor").ajaxForm(options);
|
|
|
|
$("form.disfavor").ajaxForm(options);
|
2008-06-24 13:46:13 -04:00
|
|
|
});
|
|
|
|
|
2008-07-09 03:14:39 -04:00
|
|
|
function doreply(nick) {
|
|
|
|
rgx_username = /^[0-9a-zA-Z\-_.]*$/;
|
|
|
|
if (nick.match(rgx_username)) {
|
|
|
|
replyto = "@" + nick + " ";
|
2008-09-05 05:08:48 -04:00
|
|
|
if ($("#status_textarea").length) {
|
2008-07-09 03:24:29 -04:00
|
|
|
$("#status_textarea").val(replyto);
|
2008-07-09 03:14:39 -04:00
|
|
|
$("#status_textarea").focus();
|
2008-08-26 21:50:10 -04:00
|
|
|
return false;
|
|
|
|
}
|
2008-07-09 03:14:39 -04:00
|
|
|
}
|
2008-08-26 21:50:10 -04:00
|
|
|
return true;
|
2008-07-09 03:14:39 -04:00
|
|
|
}
|
|
|
|
|