[CHAT BUG FIX] word wrap on too long words

Third-party modifications and add-ons, Apps and Clients

Moderator: moderators

[CHAT BUG FIX] word wrap on too long words

Postby Zougi » Sat Oct 22, 2011 12:25 pm

Hey!

As you certainly know, when someone post a long string on the chat like "fooooooooooooooooooooooooooooooooo", a horizontal scroll bar appears and the chat becomes nearly unreadable and ugly.

To prevent this, my solution is to cut the word and add a '-', the new line character and another '-':
e.g:
"foooooooooooooooooooooooo-
-ooooooooo"

Here is the fix:
Open the file [install_directory]/subsonic/jetty/xxxx/webapp/WEB-INF/jsp/right.jsp
After the below tags (line 79 for me):
Code: Select all
<c:if test="${model.showChat}">
    <script type="text/javascript">

add this function:
Code: Select all
            function split_long_word(text, limit)
            {
                var t = '';
                var j = 0;
                for (var i = 0; i < text.length; i++)
                {
                        if (text[i] == ' ')
                        {
                                j = i;
                        }
                        if (i > j + limit)
                        {
                                t += "-\n-";
                                j = i;
                        }
                        t += text[i];
                }
                return t;
            }


Now search the following (line 136 for me):
Code: Select all
dwr.util.setValue("content" + id, message.content);

and replace it with:
Code: Select all
dwr.util.setValue("content" + id, split_long_word(message.content, 25));

25 means it will split the word on the 25th character, obviously you can modify this number if you want.

I hope Sindre Mehus, the developer of subsonic, will maybe see my post and correct this bug.

Zougi.
Zougi
 
Posts: 1
Joined: Sat Oct 22, 2011 11:57 am

Re: [CHAT BUG FIX] word wrap on too long words

Postby neodawg » Sun Jun 17, 2012 3:54 am

This seems to work well, I do have one suggestion and that is dont put in any "-" because if someone puts in a hyperlink and it adds in the hyphens it breaks the link if they do a direct copy-paste.


Thanks,
neodawg
Music Collection--
2,890 artists
8,253 albums
103,492 songs
640.11 GB
7,023 hours
neodawg
 
Posts: 51
Joined: Fri Feb 12, 2010 2:51 pm


Return to Mods, Apps and Clients

Who is online

Users browsing this forum: No registered users and 2 guests