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.

Javascript error on 'Go back to discussions'

edited February 2006 in Vanilla 1.0 Help
I dunno how easy this would be or how resource intensive (or whether you even think it's a good idea or core-worthy) but i just thought it might be nifty to have a javascript (or other) popup when the 'back to discussions' link was clicked at the bottom of the page *if* there was any text in the enter comments box incase some idiot (ok, just me) clicked it instead of 'add comments' or whatever.
Thoughts?

Comments

  • i don't know how to make it as an extension yet, but the code would look something like:
    function confirmGoBack() { var cb = document.getElementById('CommentBox') if (cb.value.length > 0) { if (confirm('You have not submitted your comments. Really go back?')) { window.location = 'http://wherever/'; } else { cb.focus(); } } }

    and i'd add onClick='confirmGoBack()' in the Back to Discussions link.
  • Hmm. Interesting, maybe i'll take a look at extensionising it later.
  • lechlech Chicagoland
    Yeah, ithcy's little JS snippet there could prove core worthy if implimented nicely. I'd say let this be a user toggleable feature for those who want or need it. It's a pretty nifty idea, mini.
  • Hmm. Seems the Back to Discussions link is hardcoded into the theme in the comments_foot file. Does that mean it's not possible to do this as an extension?
  • it could be written into the link from an extension via JS as well...
  • Um. Clues how? :D
  • let me see if i can hack it out and fix it up as an extension, and i'll report back.
  • okay. i got it to work. phew. that was alot of vanilla learnin' but i'm glad i did it, because i've got other extensions i've been wanting to write. you can download it from http://htmlephant.com/ConfirmGoBack.zip (unzip into your extensions folder, of course) there is a dictionary element in there for anyone with a non-english forum - you can replace the confirmation prompt (You have not submitted your comments. Really go back?) with the correct text in your language. take a look at default.php in that zip, there are some simple instructions. let me know if it doesn't work for you.
  • oh and it'll only work with 0.9.3 >= revision 196, i believe - whatever the SVN revision where mark cleaned up the extensions system a few days ago.
  • Ahh. Yeah i dont know jack about JS so i guess i couldnt have worked that out. Interesting though.
  • the js was the easy part, believe me
  • After digging through various bits of code i really do (i'm sure its good code but since i aint ever used OOP stuff it does boggle me a little. I guess the fact i can just about follow it is a compliment really). But as i say i know even less JS than php so i'd never have known how to insert that bit of validation into the 'a' html tag with the defined link.
This discussion has been closed.