Give proper error message for too long annotations
authorMagnus Hagander <magnus@hagander.net>
Sat, 14 Mar 2015 12:57:02 +0000 (13:57 +0100)
committerMagnus Hagander <magnus@hagander.net>
Sat, 14 Mar 2015 12:57:02 +0000 (13:57 +0100)
pgcommitfest/commitfest/static/commitfest/js/commitfest.js

index be143f92f6e896c920257211ade7a28527b788a2..ce0df910bc7a804485475deb12d52f994449dc7b 100644 (file)
@@ -143,12 +143,17 @@ function addAnnotation(threadid) {
     updateAnnotationMessages(threadid);
     $('#doAnnotateMessageButton').unbind('click');
     $('#doAnnotateMessageButton').click(function() {
+       var msg = $('#annotateMessage').val();
+       if (msg.length >= 500) {
+           alert('Maximum length for an annotation is 500 characters.\nYou should probably post an actual message in the thread!');
+           return;
+       }
        $('#doAnnotateMessageButton').addClass('disabled');
        $('#annotateMessageBody').addClass('loading');
        $.post('/ajax/annotateMessage/', {
            't': threadid,
            'msgid': $.trim($('#annotateMsgId').val()),
-           'msg': $('#annotateMessage').val()
+           'msg': msg
        }).success(function(data) {
            if (data != 'OK') {
                alert(data);