keep words from getting cut off when character limit invoked

Hi. I added a little JavaScript (not my own, honestly, just a bit I have been using) that keeps words from getting cutoff in the middle by the '...'. I tried to comment well. I hope this is useful.