[CHAT BUG FIX] word wrap on too long words
Posted: 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):
add this function:
Now search the following (line 136 for me):
and replace it with:
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.
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.