Oh no! Where's the JavaScript?
Your Web browser does not have JavaScript enabled or does not support JavaScript. Please enable JavaScript on your Web browser to properly view this Web site, or upgrade to a Web browser that does support JavaScript.
Not a member yet? Click here to register.
Forgot Password?

Shoutbox width

Asked Modified Viewed 2,158 times
D
dfmurphy
D
  • Member, joined since
  • Contributed 84 posts on the community forums.
  • Started 19 threads in the forums
  • Started this discussions
asked
Member

If someone enters a bunch of smilies into the shoutbox without putting spaces in between them, they can screw up the width of the entire right panel.

The shoutbox_panel.php module truncates things at 25 characters, but the smilies are wider than standard characters. I just tried it on this site, and it happens here too.

To see it in action, shout this:

Quote

Testing ... smilesmilesmilesmilesmilesmilesmilesmilesmilesmilesmilesmilesmilesmilesmilesmile


I only noticed this because some kids did it on my site. While it's not nice behavior, this is something that needs to be anticipated and prevented.

Possible solutions: disable smilies in the shoutbox ... put a cap on the number of smileys in a shout message (for example, anything over five isn't parsed) ... write an algorithm that calculates the length of shout message before displaying it and branches to an appropriate display routine ... something else?
0 replies

8 posts

D
dfmurphy
D
  • Member, joined since
  • Contributed 84 posts on the community forums.
  • Started 19 threads in the forums
  • Started this discussions
answered
Member

Someone pointed out that this issue has been hashed about on beta.

If you want more info on this, go to:
http://beta.phpfusion-mods.com/forum/...#post_6374

Also, I figured out to determine left/right panel status. My mod takes that into account and the updated version is on the beta site.
Edited by dfmurphy on 03-02-2007 21:24,
0 replies
D
dfmurphy
D
  • Member, joined since
  • Contributed 84 posts on the community forums.
  • Started 19 threads in the forums
  • Started this discussions
answered
Member

OK ... I'm back again, and I just discovered the three $theme_width variables.

My proposed solution (see above) uses a hardcoded value to set the width of the shoutbox, but this is unneccesary if you know the side panel width. Just subtract 15 or so, and you're in business.

Looking at the shoutbox_panel.php, there are two other places that use a hardcoded width value. This could break certain themes. Also, its sloppy to assume all shoutboxes are in the right panel and that the panels are always equal width ... so I've got a question:

How do you know which side panel your code is in?

$shoutbox_width=( (test for panel) ? $theme_width_r : $theme_width_l) -15;


What expression needs to go into the "test for panel" example above?
Edited by dfmurphy on 01-02-2007 08:19,
0 replies
D
dfmurphy
D
  • Member, joined since
  • Contributed 84 posts on the community forums.
  • Started 19 threads in the forums
  • Started this discussions
answered
Member

Ok ... before I posted the above suggestion, I tried it in IE7 and FF2. It worked fine in both cases.

When I tried it in Opera9.10, it did not work at all. So, I did a little more digging and I found a way to make Opera behave as well:

echo "<br>\n<span class='shoutbox' style='display: block; width:160px; word-wrap: break-word;'>".parsesmileys($data['shout_message'])."</span><br>\n";


The only difference is the addition of a 'display: block;' to the style statement.

So, this works better than the post above. Anybody care to test this out on other systems/browsers?
0 replies
D
dfmurphy
D
  • Member, joined since
  • Contributed 84 posts on the community forums.
  • Started 19 threads in the forums
  • Started this discussions
answered
Member

Ken, I thought you were being funny ... I didn't mean to come off all snarky. My bad.

Here's my potential solution:

From shoutbox_panel.php:

I removed this line (actually just commented it out):
$shout_message = preg_replace("/([^\s]{25})/", "$1\n", $shout_message);


I changed the following line:
echo "<br>\n<span class='shoutbox'>".parsesmileys($data['shout_message'])."</span><br>\n";


to:
echo "<br>\n<span class='shoutbox' style='width:160px; word-wrap: break-word'>".parsesmileys($data['shout_message'])."</span><br>\n";



Basically, I removed the line that originally inserted \n at 25 chars and went with a style-sheet solution to the problem. After all, why code it if the browser can do it? My only change was adding a style statement that set width and word-wrap.

My particular installation hardcodes the textarea input box at 140px, so I arbitrairily used 160px as the word-wrap width. It seems to work just fine for me, but it is not rigorously tested. I don't how consistently word-wrap is applied on various browsers.

Comments?
Edited by dfmurphy on 25-01-2007 02:54,
0 replies
K
Ken
K
Ken 10
No Support by PM. Please use the forum.
  • Senior Member, joined since
  • Contributed 713 posts on the community forums.
  • Started 43 threads in the forums
answered
Senior Member

Well, sorry for trying to be funny. I just feel that sometimes things can be to stiff if we tighten up everything. If you can find a solution for this, it is ofcourse great, but then again I can't see this as a very big case. I'm sorry about that. If someone is just out for trouble I guess they will find another way to mess around. Kids are kids... If someone messes up my site I just delete the mess. If that doesn't help I ban the user for a day or two until they learn to behave and respect my sites. Maybe I'm to hard, but I feel it works.

Just my two cents.
0 replies
D
dfmurphy
D
  • Member, joined since
  • Contributed 84 posts on the community forums.
  • Started 19 threads in the forums
  • Started this discussions
answered
Member

Some of the comments here and a few more that showed in the shoutbox are (I hope) attempts at funny.

Spank offending users. Have clear rules. Tighten up truncation. Turn it off altogether.

Now of these are real solutions. User interfaces are supposed to be bullet-proof. Anyone can screw up this very site (or every other shoutbox enabled fusion site) by posting specific things into the shoutbox. I'll take a stab at fixing it myself, and I'll post my efforts here for others to examine, but a solution from someone is absolutely necessary.

Truncation doesn't really work because it only takes 7 or 8 smilies on this site to trigger the margin bug. Setting the wrap that low isn't acceptable. I'm using images that are about 70% the size of these images, but I can still do it on my site too.
Edited by dfmurphy on 24-01-2007 23:41,
0 replies
S
Sveinungs
S
  • Veteran Member, joined since
  • Contributed 935 posts on the community forums.
  • Started 3 threads in the forums
answered
Veteran Member

...if you could get your hands on them that is :D

But you found the solution your self:

Quote

The shoutbox_panel.php module truncates things at 25 characters, but the smiles are wider than standard characters.


You can edit "shoutbox_panel.php" and have it wrap at say 20 instead of 25 right, in case those naughty kids comes back again...:)
0 replies
K
Ken
K
Ken 10
No Support by PM. Please use the forum.
  • Senior Member, joined since
  • Contributed 713 posts on the community forums.
  • Started 43 threads in the forums
answered
Senior Member

I would simply give those kids a spank www.world-of-smilies.com/html/images/smilies/gewalt/d066.gif

Problem solved smiles2k.net/smiles/big_smiles/super_smilies007.gif
0 replies

Category Forum

Bugs and Errors - 6

Labels

None yet

Statistics

  • Views 0 views
  • Posts 8 posts
  • Votes 0 votes
  • Topic users 3 members

0 participants

Notifications

Track thread

You are not receiving notifications from this thread.

Related Questions

Not yet