views:

333

answers:

3

Hi, We are a young start-up launching a unique chat product next week. Our chat is currently based on Jabber (using Openfire as our Jabber server) via BOSH (using Punjab), with jQuery for our client side scripts.

Right now our most critical issue with the current setup is with the site navigation, when navigating between pages in our web-sites the BOSH connection is lost until the new page is loaded and the BOSH connection is authenticated. Due to this issue we have to set a very big timeout (around 1 minute) before logging out users who have left our website without signing out.

We are aware of javascript anchor based navigation solutions, but implementing this would require many changes in our site's markup, CSS and JS scripts and our site's structure is very complicated.

Is there any other solution? I was thinking about frame based navigation, when a page will hold 2 iframes - one is hidden and holds the BOSH connection, and one holds the real page content. the problem with this solution is that it affects the users' feel and the URL in the location bar will always stay the URL of the page that holds the frames.

is there any solution for our problem that will not require a complete rewrite of the site's structure/markup?

Thanks in advance!

+1  A: 

Though this might not be a complete rewrite I'll say it will take some doing. Have the Chat box stay there and ajax in content, i.e. if, like on facebook the bottom has the chat bar, section the rest in an id you ajax you pages into. In other words, take the chat out of your layout, put it separate, and make your links into ajax requests which can be handled via a global link handler and links substituted via a search a replace over all files via sed. (href=" changed to href="javascript:urlhandler( but this will need to account for external links) The other option I can think of is having two iframes on your site. Main and chat. And provide Session cookies for those who navigate from the page, D/C or whatever will happen to them.

Chisum
Thanks for your comment, regarding to the first solution - its pretty much what I was referred to as 'anchor based navigation' - minus the anchors that will indicate which is the current page (similar to the navigation in Facebook/Gmail) - if I'll handle all links via JS code, and stay on the same page 'forever' - I'll still have the problem that I've mentioned before - The URL will always stay the same, and it will result problems when refreshing the page/navigating back-forward/bookmarking an page)... also, this solution will require some serious changes...
jitzo
Regarding to your second solution - which was mentioned in the question - it will require much less changes, but it has the same URL's problem...
jitzo
A quandary good sir, I'll take a closer look, thanks for the info :)
Chisum
+1  A: 

Are you using an implementation of your chat on each page? If so, the answer is to tweak caching for your scripts. Make sure all large JS files are external and that the server registers no changes (e.g.: Last Modified). Combine images into sprites. Run your code through one of the many minifiers that exist. Last but not least, invest in a CDN. Amazon CloudFront is simple and cheap: you'll find that it works wonders for improving performance.

mattbasta
A: 

You can use jquery's history plugin (http://www.mikage.to/jquery/jquery%5Fhistory.html) to handle back and forward navigation and load pages via ajax like you were talking about.

Something like this should work (untested):

Page1.htm:

<html>
<head><title>Page 1</title></head>
<body>
     <div id="content">
         <a href="/page2.htm">Load Page 2</a>
     </div>
    <div id="chat"></div>
</body>
<script>
    $(function(){
        function loadPage(hash){
            if($.browser.msie) {
      hash = encodeURIComponent(hash);
        }
            $.ajax({
                "url":hash,
                "success":function(response){
                     var newPage = $(response);
                     document.title=newPage.find("title").html();
                     $("#content").html(newPage.find("#content").html());
                 }
            });
            return false;
        }
        $.historyInit(loadPage);
        $("a").live("click",function(){
            $.historyload(this.href);
        });
    });
</script>
</html>

Page2.htm:

<html>
<head><title>Page 2</title></head>
<body>
     <div id="content">
         <a href="/page1.htm">Load Page 1</a>
     </div>
    <div id="chat"></div>
</body>
<script>
    $(function(){
        function loadPage(hash){
            if($.browser.msie) {
      hash = encodeURIComponent(hash);
        }
            $.ajax({
                "url":hash,
                "success":function(response){
                     // this is just an example and not too efficient.
                     var newPage = $(response);
                     document.title=newPage.find("title").html();
                     $("#content").html(newPage.find("#content").html());
                 }
            });
            return false;
        }
        $.historyInit(loadPage);
        $("a").live("click",function(){
            $.historyload(this.href);
        });
    });
</script>
</html>

If you would like to outsource the work to me I'd be glad to help. :o)

David Murdoch