]> git.mxchange.org Git - quix0rs-gnu-social.git/blob - js/util.js
Locate examples in config
[quix0rs-gnu-social.git] / js / util.js
1 $(document).ready(function(){
2         // count character on keyup
3         function counter(){
4             var maxLength     = 140;
5             var currentLength = $("#status_textarea").val()
6                                                      .replace(/[\uD800-\uDBFF][\uDC00-\uDFFF]/g, "drry")
7                                                      .replace(/[\u0800-\uFFFF]/g, "drr")
8                                                      .replace(/[\u0080-\u07FF]/g, "dr")
9                                                      .length;
10             var remaining = maxLength - currentLength;
11             var counter   = $("#counter");
12             counter.text(remaining);
13
14             if (remaining <= 0) {
15                 counter.attr("class", "toomuch");
16             } else {
17                 counter.attr("class", "");
18             }
19         }
20      
21         if ($("#status_textarea").length) {
22             $("#status_textarea").bind("keyup", counter);
23             // run once in case there's something in there
24             counter();
25         }
26 });
27
28 function doreply(nick) {
29      rgx_username = /^[0-9a-zA-Z\-_.]*$/;
30      if (nick.match(rgx_username)) {
31           replyto = "@" + nick + " ";
32           if ($("#status_textarea")) {
33                $("#status_textarea").val(replyto);
34                $("#status_textarea").focus();
35           }
36      }
37      return false;
38 }
39