Vanilla 1 is no longer supported or maintained. If you need a copy, you can get it here.
HackerOne users: Testing against this community violates our program's Terms of Service and will result in your bounty being denied.
Options

Remaining characters in comment / discussion

edited March 2008 in Vanilla 1.0 Help
It seems like it doesn't tell you you've gone over the character limit until it's too late and you've clicked 'start your discussion', or 'add your comments'.

http://lussumo.com/community/discussion/7833/offlimits-number-caracter-in-discussions/#Item_8

someone should make an extension that has the # of remaining chars toward the bottom right corner of the textbox.

Comments

  • Options
    edited March 2008
    I figured out a way by using some javascript and modifying the comment_form and discussion_form php files. I made an extension to load the javascript. Then the form php files were modified to add onkeyup to the textarea to call the javascript function. Creating a Nugget for the header works fine. No new extension is needed.

    It still doesn't prohibit the user from clicking on the Submit button. But, at least the user is warned that he has exceeded the maximum. I'm still looking into how to control the Submit button.

    If you want to try it, whisper me your email and I'll send it to you.
  • Options
    I did come up with a way to hide the Submit comment button when the maximum characters is exceeded. So, now you can't mistakenly submit a comment or discussion that won't post. If anyone else would like it, please let me know.
  • Options
    Seems like a worthwhile extension, you could avoid editing the PHP files by having the javascript attach the event listener onload. It should also be possible to pass the javascript the maximum character count since it is variable.
  • Options
    Thanks for the idea. I do pass the max character setting to the javascript now. However, with most of the extensions I start, I usually get so far and then stop because I don't have enough skills to complete them. In this case, an example would really help as I don't completely understand "attach the event listener".
  • Options
    Ah ok, well that's just some javascript. I'm not really sure if this will be cross-compatible because I usually work with the Mootools framework which handles all that for me:
    Window.onload = function() { document.getElementById('CommentBox').onkeyup = function(event) { // Code for comment counter goes here }; };
  • Options
    I say let Fyorl continue where jimw left off... (using mootools)
  • Options
    edited March 2008
    Nah, he's still active on it, there's no need for anyone to pick it up. Also, I think Mootools would be a bit heavy for something like this although it might be worth ripping a few functions from it like addEvent.
  • Options
    or you could do what you did with a few other extensions, and provide a 'backup' script that doesn't use mootools; but if the forum in question has it, then I say go ahead and use it.
  • Options
    I am not having any success in making this an extension. Sorry. So, anyone, please feel free to pick it up.
  • Options
    I have been successful in developing this as an extension. I need help on one item. How can I read the max_comment_length value in the javascript?
  • Options
    can't you do something with php to fetch it from the sql db (or is it in conf/settings?) and then pass it over to js

    i'm not fluent in php OR js, but this might work
  • Options
    I solved the problem and will be uploading the extension today.
  • Options
    Ah I'm glad you worked it out, I can check this off the (ever-increasing) todo list.
This discussion has been closed.