summaryrefslogtreecommitdiff
path: root/js
diff options
context:
space:
mode:
Diffstat (limited to 'js')
-rw-r--r--js/util.js21
1 files changed, 21 insertions, 0 deletions
diff --git a/js/util.js b/js/util.js
new file mode 100644
index 000000000..59a489170
--- /dev/null
+++ b/js/util.js
@@ -0,0 +1,21 @@
+$(document).ready(function(){
+ // count character on keyup
+ function counter(){
+ var maxLength = 140;
+ var currentLength = $("#status_textarea").val().length;
+ var remaining = 140 - currentLength;
+ $("#counter").text(remaining);
+
+ if(remaining <= 0) {
+ $("#counter").attr("class", "toomuch");
+ } else {
+ $("#counter").attr("class", "");
+ }
+ }
+
+ if ($("#status_textarea").length) {
+ $("#status_textarea").bind("keyup", counter);
+ }
+
+});
+