YAFLogo

Posted by: slikvik - Monday, 14 June 2010 17:26:43
I've done the stored procedure no problem. The problem I'm having is getting the scroll bar to remember where it last was (e.g at the bottom) I've tried all sorts of changes to div.scrollTop etc but nothing is working? Any ideas?

Posted by: bbobb - Tuesday, 15 June 2010 17:59:10
You can do it in procedures.sql In sp shoutbox_getmessages: Replace ORDER BY Date DESC for ORDER BY Date Save it and launch update.

Posted by: slikvik - Tuesday, 15 June 2010 20:06:30
Hi bbobb! Thanks for the prompt reply but as I said in my original post I've manage to do the stored procedure no problem. My issue is with the div box scroll behaviour. Everytime you make a post the scroll bar defaults to the top. Obviously the new messages are now at the bottom :wink: so you don't see them. I need a way for the scroll bar to be positioned at the bottom after a post. I've seen many solutions on the net that supposedly not only handle Ajax but also Repeater objects that the Shoutbox use, such as setting the div elements scrollTop property to 0, but none seem to work! What am I missing about the shoutbox that could be stopping this? I've have noticed that onload it runs a JS scroll behavior method which I thought might be overriding it but I've remmed that out and it made no difference. I've had at least 15 people on my board ask for this change as they use it like a chatroom and its scroll the opposite way to how they (and I) expect. :cheesy: Thanks

Posted by: bbobb - Wednesday, 16 June 2010 10:04:32
I've looked into it and I'm a bit of sceptic too now. Really, I don't have time now to investigate the complex problem. If you come up with some solution, please let us know:)

Posted by: logan - Thursday, 17 June 2010 01:50:37
This seems to work in all newer version browsers. HTH ShoutBox Reversed Scroll 1. Reverse the message list. In Install/mssql/procedures.sql Modify line 6992 - Removing the DESC [code=sql]ORDER BY Date [/code] 2. Set the ID of the ShoutBox
In Controls/Shoutbox.ascx add the id to the div that wraps the messages approx. line48 [code=c#]
[/code] 3. Set the scrollbar to the bottom of box when the Timer fires. In YAF Project find: Classes/Utilities/JavaScriptBlocks.cs Add the endrequest section and function [code=c#] public static string DisablePageManagerScrollJs { get { return @" var prm = Sys.WebForms.PageRequestManager.getInstance(); prm.add_beginRequest(beginRequest); prm.add_endRequest(endRequest); //ADDED function beginRequest() { prm._scrollPosition = null; } //ADDED function endRequest(){ var div = document.getElementById('divShoutBox'); if(div) div.scrollTop = 10000 }//END ADD "; } }[/code] OR this can be added as in step 5. So you don't modify the source project. [code=c#][/code] 4. Add pause to the Shoutbox , Hover the mouse over the chatbox message area to pause the timer. In Controls/Shoutbox.ascx add the onmouseover and onmouseout section after the new id you gave the
[code=c#]
[/code] 5. Add Functions for onmouseover and onmouseout In the [/code] 6. Set Scrollbar to bottom on pageload. In Default.aspx add the onload to body tag and [/code] [code=c#][/code] Rebuild the YAF Project to update the YAF.dll. Update all files changed on Host and rerun install to update the SP. Should be good to go.[wink] [biggrin] I like it this way [thumbup]

Posted by: slikvik - Monday, 21 June 2010 11:51:23
Haha, thanks. I've actually got it working exactly the way you have over the weekend and was just to about to proudly post the solution! You beat me to it. BUT.... there is a small problem with the stored procedure. Simply changing the date order only works until you've reach the set ROWCOUNT!! At that point it just shows the oldest messages, albiet in the right order. Looking at it now, but if you find anything please let me know. Ta

Posted by: slikvik - Monday, 21 June 2010 11:59:48
OK fixed it. You need to change the query to something like this... [code]USE [YAFF] GO /****** Object: StoredProcedure [dbo].[yaf_shoutbox_getmessages] Script Date: 06/21/2010 09:43:52 ******/ SET ANSI_NULLS ON GO SET QUOTED_IDENTIFIER ON GO /***************************************************************************************************** // Original code by: DLESKTECH at http://www.dlesktech.com/support.aspx // Modifications by: KASL Technologies at www.kasltechnologies.com // Modifications for integration into YAF/Conventions by Jaben Cargman *****************************************************************************************************/ ALTER PROCEDURE [dbo].[yaf_shoutbox_getmessages] ( @NumberOfMessages int, @StyledNicks bit = 0 ) AS BEGIN SET ROWCOUNT @NumberOfMessages SELECT t1.Username, t1.UserID, t1.Message, t1.[Date], Style = case(@StyledNicks) when 1 then [dbo].[yaf_get_userstyle](UserID) else '' end FROM (SELECT TOP 30 t2.* FROM [dbo].[yaf_ShoutboxMessage] t2 ORDER BY t2.[Date] DESC) t1 ORDER BY t1.[Date] SET ROWCOUNT 0 END[/code] There might be a better way but it was all I could come up with in 5 minutes. Regards Vic

Posted by: logan - Tuesday, 22 June 2010 00:37:36
Thanks Vic works Great[biggrin]

Posted by: slikvik - Tuesday, 22 June 2010 12:23:39
Just to let you know that I've been playing with alternate scripts too. One small issue with pausing the timer on mouseover is that people are finding messages appearing a bit more quirky. :wink: So i tried the following: [code] Sys.WebForms.PageRequestManager.getInstance().add_endRequest(EndRequestHandler); Sys.WebForms.PageRequestManager.getInstance().add_beginRequest(BeginRequestHandler); var scrollPos; function BeginRequestHandler(sender, args) { var elem = document.getElementById('shoutScroll'); scrollPos = elem.scrollTop; if (scrollPos == elem.scrollHeight) { scrollPos = 10000; } //alert(scrollPos);"+ } function EndRequestHandler(sender, args) { var elem = document.getElementById('shoutScroll'); elem.scrollTop = scrollPos; //alert(scrollPos); }[/code] This stores the position before a request and then restores it after. This allows messages to continue to flow and the user can leave the scroll bar where they choose to leave it. It also removes the need for the two mouseover scripts. Unfortunately this has its own quirk too. Say the BeginHandler captures scrollPos at 50 and then you start moving, when EndHandler runs it moves your scrollbar back to 50. Not a big issue but still not perfect. [confused]

Posted by: Zero2Cool - Thursday, 5 October 2017 22:12:37
I modified the stored procedure below and the ShoutBox control (forum\controls\ShoutBox.ascx) to get the order changed. [b]User Control[/b] change Added this below "" [code=javascript][/code] [b]Stored Procedure[/b] change [code=sql] Alter PROCEDURE [dbo].[yaf_shoutbox_getmessages] ( @BoardId int, @NumberOfMessages int, @StyledNicks bit = 0 ) AS BEGIN --SELECT TOP(@NumberOfMessages) -- sh.[ShoutBoxMessageID], -- sh.UserName, -- sh.UserID, -- sh.[Message], -- sh.[Date], -- Style= case(@StyledNicks) -- when 1 then usr.UserStyle -- else '' end --FROM -- [dbo].[yaf_ShoutboxMessage] sh -- JOIN [dbo].[yaf_User] usr on usr.UserID = sh.UserID --WHERE -- sh.BoardId = @BoardId --ORDER BY sh.Date DESC DECLARE @maxid int SET @maxid = (SELECT MAX(ShoutBoxMessageID) FROM [dbo].[yaf_ShoutboxMessage]); SELECT TOP(@NumberOfMessages) sh.[ShoutBoxMessageID], sh.UserName, sh.UserID, sh.[Message], sh.[Date], Style= case(@StyledNicks) when 1 then usr.UserStyle else '' end FROM [dbo].[yaf_ShoutboxMessage] sh JOIN [dbo].[yaf_User] usr on usr.UserID = sh.UserID WHERE sh.BoardId = @BoardId AND sh.ShoutBoxMessageID >= (@maxid - @NumberOfMessages + 1) ORDER BY sh.ShoutBoxMessageID ASC, sh.Date ASC END[/code]