News:

SMF 2.1.4 has been released! Take it for a spin! Read more.

Main Menu

nneonneo's Shoutbox

Started by nneonneo, December 26, 2006, 06:58:11 PM

Previous topic - Next topic

brianjw

Ok, you will have to see when nneonneo gets back. I've seen some nneonneo's shoutboxes scroll perfectly. You may want to use the search and select This Topic, when searcing.
I can help with making some things work but scrolling is one I don't do good at.

brianjw

1. ~Try this
Quote from: nneonneo on January 09, 2007, 09:08:47 PM
For scrollbars, add this code to index.template.php before "#yshout":
#yshout #shouts {
overflow: auto;
height: 100px;
}

Height parameter can be anything you want (in pixels; px must follow). You can also add width, if you so desire, etc. etc.

Spike Saunders

Yeah did that along with his other suggestion after.

Scrolling works fine.

It's the 'auto scroll to latest entry' that doesn't work. It would work if the shoutbox was reverseed with newest on top.

Right now until he is back, im kind of wanting to just reverse it. Any quick fix for that? (Im not at home, so don't have my files to look at, hence asking)

Fallen.One05

Hey guys..

ok.. so i installed this shoutbox.. checked my ftp to make sure all files went through. They did. I even added the required code for a custom theme!  Yet...

...loading shoutbox...



is still showing up... -_-  i installed the package using the package manager... and i've seen through some posts about manually installing it.. but i figured that since the package got uploaded successfully.. that i didn't need to?

Any help would be greatly appreciated...

-Running a custom theme... added in the 2 codes for the custom theme install
-Installed using package manager


comptech

Is there a way to disable History for guests?

nneonneo

#825
@Spike Saunders: The JS modifications was only minimally tested :P

I will test it more thoroughly when I get home (still on vacation)

@ruelnov: Yes, under "history()" function place a check for guests.

Something like "if (!$user['is_logged']) return;" should work.
Check out the AJAX Shoutbox (my one and only mod to date :P)
Do you like SMF? Are you using ProBoards, InvisionFree, ActiveBoards or some other web-hosted forum? I can help you convert to SMF (without having to purchase a DB conversion)...contact me [nneonneo {at} gmail *dot* com], and see this topic
spammers here!

Spike Saunders

Lol thats fine man. Right now im just looking to reorder the chat entries so it's newest at top.. then it's all good till the scroll issue is fixable.

clocktower

hello were do the other php files go

oz_Moses

I've had a go at reversing the display order, and it's working on my board at least.

in /yshout/yshout.php

after
$chatText=preg_replace_callback("/<timeval=(\d+)>/","preg_timeformat",$chatText);

add
$chatText=implode("\n", (array_reverse(explode ( "\n", $chatText ))));

this code takes the $chatText string on it's way to be displayed in the shoutbox, converts it to an array using explode with a \n delimiter, reverses this array, then implodes it back to a string.

bear in mind that I only installed SMF today, don't really know PHP and it's now 1:30am so I'm not really thinking straight. Still, it seems to work for me :)

comptech

Quote from: nneonneo on August 03, 2007, 05:28:01 PM

@ruelnov: Yes, under "history()" function plac a check for guests.

Something like "if (!$user['is_logged']) return;" should work.

Did it, but also the History for logged in members is also rendered blank. Any idea how to to make it blank for Guests only?

Spike Saunders

Quote from: oz_Moses on August 04, 2007, 11:29:08 AM
I've had a go at reversing the display order, and it's working on my board at least.

in /yshout/yshout.php

after
$chatText=preg_replace_callback("/<timeval=(\d+)>/","preg_timeformat",$chatText);

add
$chatText=implode("\n", (array_reverse(explode ( "\n", $chatText ))));

this code takes the $chatText string on it's way to be displayed in the shoutbox, converts it to an array using explode with a \n delimiter, reverses this array, then implodes it back to a string.

bear in mind that I only installed SMF today, don't really know PHP and it's now 1:30am so I'm not really thinking straight. Still, it seems to work for me :)
Sounds good... but returns error on me about

Parse error: syntax error, unexpected '}' in /home/ewnweb/public_html/wth/yshout/yshout.php on line 916

nneonneo

#831
[back from vacation]

@ruelnov: How did you fix auto-collapse? Post that so it can help others :)

The code I posted was correct, but I forgot to note that "$user" must be added to the "global" line in history() for it to work.

Modification: change
global $logDir,$boardurl,$gzipCompression,$defaultEncoding,$txt;
to
global $logDir,$boardurl,$gzipCompression,$defaultEncoding,$txt,$user;
if (!$user['is_logged'])
{
    echo '<h3>Shoutbox history available to logged in users only!</h3>';
    return;
}


@Fallen.One05: Not sure what could be the problem. Anything in the server error log?

@clocktower: What php files? There is only one: yshout.php (goes in /path/to/forum/yshout/yshout.php)

@oz_Moses: That's actually a very nice solution -- handy to remember.

@Spike Saunders:
Updated guide to scroll code:

This code is adapted from http://radio.javaranch.com/pascarello/2006/08/17/1155837038219.html.
In yshout/js/yshout.js:
Find
// Set off the AJAX call to load the chat form into the empty yShout div
Add BEFORE
var chatscroll = new Object();

chatscroll.Pane = function(scrollContainerId){
this.bottomThreshold = 20;
this.scrollContainerId = scrollContainerId;
this._lastScrollPosition = 100000000;
}

chatscroll.Pane.prototype.activeScroll = function(){

var _ref = this;
var scrollDiv = document.getElementById(this.scrollContainerId);
var currentHeight = 0;

var _getElementHeight = function(){
var intHt = 0;
if(scrollDiv.style.pixelHeight)intHt = scrollDiv.style.pixelHeight;
else intHt = scrollDiv.offsetHeight;
return parseInt(intHt);
}

var _hasUserScrolled = function(){
if(_ref._lastScrollPosition == scrollDiv.scrollTop || _ref._lastScrollPosition == null){
return false;
}
return true;
}

var _scrollIfInZone = function(){
if( !_hasUserScrolled() ||
(currentHeight - scrollDiv.scrollTop - _getElementHeight() <= _ref.bottomThreshold)){
scrollDiv.scrollTop = currentHeight;
_ref._isUserActive = false;
}
}


if (scrollDiv.scrollHeight > 0)currentHeight = scrollDiv.scrollHeight;
else if(scrollDiv.offsetHeight > 0)currentHeight = scrollDiv.offsetHeight;

_scrollIfInZone();

_ref = null;
scrollDiv = null;

}
var divScroll;


Find
function setupChat() {
Add AFTER
divScroll = new chatscroll.Pane('shouts');
objDiv = document.getElementById('shouts');
objDiv.scrollTop = objDiv.scrollHeight;


Find
function startRefresh() {
if (!refreshSet) {
setTimeout("doRefresh()", refreshTime);
refreshSet = true;
}
}

function schedRefresh() {
if (refreshSet) {
setTimeout("doRefresh()", refreshTime);
}
}

Replace with
function startRefresh() {
if (!refreshSet) {
refreshSet = true;
schedRefresh();
}
}

function schedRefresh() {
if (refreshSet) {
setTimeout("divScroll.activeScroll()", 5);
setTimeout("doRefresh()", refreshTime);
}
}


This *has* been tested (not extensively though), but requires that you use the CSS
#yshout #shouts {
height: 100px;
overflow: auto;
}

so that only the shout div gets a scrollbar, not the whole shoutbox. It should appear like this in index.template.php:
#yshout p {
line-height: 1;
margin-top: 0;
}
#yshout {
overflow: hidden;
}
#yshout #shouts {
height: 100px;
overflow: auto;
}
#yshout .shout-timestamp {
font-weight: normal;
color: #000;
}
Check out the AJAX Shoutbox (my one and only mod to date :P)
Do you like SMF? Are you using ProBoards, InvisionFree, ActiveBoards or some other web-hosted forum? I can help you convert to SMF (without having to purchase a DB conversion)...contact me [nneonneo {at} gmail *dot* com], and see this topic
spammers here!

oz_Moses

#832
Cheers nneonneo, I appreciate the hack.

@Spike Saunders it seems strange to get an error on line 916, as my mod was on line 660.. also there weren't any } in my line of code. Any chance you can upload the original yshout/yshout.php and make the change again?

Spike Saunders

@oz_Moses  Likely... lol not sure  where the error came from even tho all i did was add your code lol.

@nneonneo  Awesome. I'll have a check of it... eventaully. My site was hacked today. Everthing's gone on the file tree/directory. Yet the entire Database still remains. My server admin should have a backup of my domain tho so hopefully it'll be fixed shorttly.. otherwise ill just reinstall SMf and it's mods... and not worry about the 4 years of hsitory on the domain that are now gone heh. - oh and welcome back.

comptech

#834
Quote from: nneonneo on August 04, 2007, 07:30:18 PM
[back from vacation]

@ruelnov: How did you fix auto-collapse? Post that so it can help others :)

The code I posted was correct, but I forgot to note that "$user" must be added to the "global" line in history() for it to work.

Modification: change
global $logDir,$boardurl,$gzipCompression,$defaultEncoding,$txt;
to
global $logDir,$boardurl,$gzipCompression,$defaultEncoding,$txt,$user;
if (!$user['is_logged'])
{
    echo '<h3>Shoutbox history available to logged in users only!</h3>';
    return;
}



Thanks for that correction, nneonneo. Shout Box history now turned OFF for Guests only.

Auto-collapse was fixed after I changed $updateTimeout=20; TO $updateTimeout=10; in yshout.php.


Also, how do I change the Shout Box title found just above the History command?

Lastly, what changes have to be done to the code below so that another instance of Shout Box will work just above the QUICK REPLY Box when a user is viewing a topic?
// YSHOUT HERE
      echo '
                     <br /><b>Shout Box</b><br /><br />
                     <div id="yshout">',$txt['yshout_loading'],'<br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /></div>';
      // YSHOUT END

I have placed above code at the correct location in Display.Template.php, but all I get is "...loading shoutbox....", but the 1st instance of shoutbox (default location) works fine. 

Spike Saunders

@nneonneo

Awesme man. It worked. Had to reedit everything after the backup, but it's all good. Thanks. Lovely modification.

nneonneo

@ruelnov: To change "Shout Box" title, change $txt['yshout_shoutbox'] in Themes/default/languages/Modifications.<language>.php.
Second problem is a bit thornier. It requires changes to the Javascript to recognize multiple instances.

Right now I don't have the time to work out the details, but a fair bit of JS must be changed. The main issue is that the Javascript was only ever designed to support one instance. It can be hacked to support two, though.
Check out the AJAX Shoutbox (my one and only mod to date :P)
Do you like SMF? Are you using ProBoards, InvisionFree, ActiveBoards or some other web-hosted forum? I can help you convert to SMF (without having to purchase a DB conversion)...contact me [nneonneo {at} gmail *dot* com], and see this topic
spammers here!

comptech

#837
Quote from: nneonneo on August 05, 2007, 01:49:58 PM
@ruelnov: To change "Shout Box" title, change $txt['yshout_shoutbox'] in Themes/default/languages/Modifications.<language>.php.
Second problem is a bit thornier. It requires changes to the Javascript to recognize multiple instances.

Right now I don't have the time to work out the details, but a fair bit of JS must be changed. The main issue is that the Javascript was only ever designed to support one instance. It can be hacked to support two, though.

@nneonneo: ShoutBox title not changed by doing above hint. Did this before also before asking you this question. Only the Shout Box word in title of History Page is changed. Any other approach?

And would a second instance mod be in your next version? But how soon? It would be great indeed if members wouldn't have to scroll to the top anymore to continue chatting with other members.

Also, I've noticed a bug when the shoutbox is enabled for Guests. Registered members can still continue shouting after logging out, but with the admin's username! Makes me worried, indeed, that they could access the Admin Panel, so I disabled it for guests at the moment.


nneonneo

Argh...looks like I forgot to use $txt there.

In // YSHOUT HERE
      echo '
                     <br /><b>Shout Box</b><br /><br />
                     <div id="yshout">',$txt['yshout_loading'],'<br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /></div>';
      // YSHOUT END

--> change the words Shout Box (between <b> tags).


Quote from: ruelnov on August 05, 2007, 03:20:28 PMAlso, I've noticed a bug when the shoutbox is enabled for Guests. Registered members can still continue shouting after logging out, but with the admin's username! Makes me worried, indeed, that they could access the Admin Panel, so I disabled it for guests at the moment.
Sure they can shout with an admin's username, because they can set their own usernames as guests. However, they show up as black text (not red like admins). You can set "$autoGuestName" in yshout.php to prevent them from picking their own usernames as guests.
Check out the AJAX Shoutbox (my one and only mod to date :P)
Do you like SMF? Are you using ProBoards, InvisionFree, ActiveBoards or some other web-hosted forum? I can help you convert to SMF (without having to purchase a DB conversion)...contact me [nneonneo {at} gmail *dot* com], and see this topic
spammers here!

comptech

Quote from: nneonneo on August 05, 2007, 05:09:44 PM
Argh...looks like I forgot to use $txt there.

In // YSHOUT HERE
      echo '
                     <br /><b>Shout Box</b><br /><br />
                     <div id="yshout">',$txt['yshout_loading'],'<br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /></div>';
      // YSHOUT END

--> change the words Shout Box (between <b> tags).

@nneonneo: Thanks, it worked now.

And how do I move the shoutbox up 1 line closer to the Shout Box title? Need to save some space.

Advertisement: