Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7505819
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 29, 20262026-05-29T22:02:42+00:00 2026-05-29T22:02:42+00:00

The following snippet is from an opensource poker client written in JQuery. It displays

  • 0

The following snippet is from an opensource poker client written in JQuery. It displays a poker table that has been previously spawned by the poker server. The table is displayed within a div on the page after the page is loaded.

//
// featured table
//
jpoker.plugins.featuredTable = function(url, options) {

    var opts = $.extend({}, jpoker.plugins.featuredTable.defaults, options);
    var server = jpoker.url2server({ url: url });

server.registerUpdate(function(server, what, packet) {
    if (packet && packet.type == 'PacketPokerTableList') {
        if (packet.packets.length === 0) {
        var updated = function(server, what, packet) {
            if(packet && packet.type == 'PacketPokerTableList') {
            var found = null;
            for(var i = packet.packets.length - 1; i >= 0 ; i--) {
                var subpacket = packet.packets[i];
                if(opts.compare(found, subpacket) >= 0) {
                found = subpacket;
                }
            }
            if(found) {
                found.game_id = found.id;
                server.setTimeout(function() { server.tableJoin(found.game_id); }, 1);
            }
            return false;
            } else {
            return true;
            }
        };
        server.registerUpdate(updated, null, 'featuredTable ' + url);
        server.selectTables(opts.string);
        }
        return false;
    } else {
        return true;
    }
    }, null, 'featuredTable ' + url);
    server.selectTables('my');
    return this;
};

jpoker.plugins.featuredTable.defaults = {
    string: '',
    compare: function(a, b) { return a && b && b.players - a.players; }
};

The code references the following complex dynamic object.

{"players":3,"type":"PacketPokerTableList","packets":[{"observers":1,"name":"sitngo417","waiting":0,"percent_flop":0,"average_pot":10852,"skin":"default","variant":"holdem","hands_per_hour":120,"betting_structure":"level-15-30-no-limit","currency_serial":0,"muck_timeout":5,"players":2,"reason":"TableList","tourney_serial":58151,"seats":2,"player_timeout":60,"type":"PacketPokerTable","id":97},{"observers":0,"name":"sitngo418","waiting":0,"percent_flop":100,"average_pot":97700,"skin":"default","variant":"holdem","hands_per_hour":100,"betting_structure":"level-15-30-no-limit","currency_serial":0,"muck_timeout":5,"players":1,"reason":"TableList","tourney_serial":58151,"seats":2,"player_timeout":60,"type":"PacketPokerTable","id":98}],"tables":2,"time__":1329073257148}

Essentially, there are nested objects within an object or arrays within arrays if you prefer. The main object is named “packet” with a type of “PacketPokerTableList” and the nested objects are named “packets” with each sub packet within packets having a type of “PacketPokerTable”. There can be any number of sub packets within packets and they vary depending on the number of tables that are in a given tournament. Each subpacket of type “PacketPokerTable” contains a number of elements that have a given value that is representative for each table in the tournament. The for loop in the above code only looks at the first subpacket in packets and retrieves the value of “id”, which in this case is 97 and then displays the table by calling server.tableJoin().

I wish to modify this default behaviour so that the “for loop” cycles through all of the sub packets of type “PacketPokerTable” within packet type “PacketPokerTableList” and retrieve the value of “id” from each of the sub packets.
Then instead of automatically displaying the table in a div of the current page; I want, for each table “id”, to display its related table in a new browser window with the window.open() method.

The first obstical that I haven’t been able to overcome is how to loop through the this complex object and retrieve all the values of “id”. Not sure if it is possible or not. Everything that I have researched on the web mostly relate to “for loops” with very basic arrays; of which none have been helpfull. The second obstacle is how to pass this variable along with a function that executes in the child windows.

It seems that solving this own my own is way above my station, I would greatly appreciate any input on how to accomplish this task.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-29T22:02:44+00:00Added an answer on May 29, 2026 at 10:02 pm

    I’m not entirely sure how server.tableJoin() works, but if it returns html for the table, then this will do the trick. If not, you’ll need to do whatever you do to create the html for the new table and put it in it’s place.

    //make sure the object has the necessary info       
    if(packet && packet.type == 'PacketPokerTableList' && packet.packets && packet.packets.length > 0) {
            //go through each packet.packets
            for (var i=0;i < packet.packets.length;i++){
                if(packet.packets[i].type == 'PacketPokerTable'){
                    var id = packet.packets[i].id;
                    //open window
                    var newWin = window.open('_blank',id);
                    //write new content in the new window
                    newWin.document.write(server.tableJoin(id));
                }
            }
        }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

The following snippet from RuntimeUtil.java from jlibs guarantees GC that garbage collection is done.
I have the following code snippet from my PowerShell script that... Loops through a
The following is a snippet from a script I have that tries to tar
I extracted the following snippet from Profiler (from a statement that fails due to
I have the following source snippet from a book that I'm reading now. So
has anyone experienced such a strange reading from Java Calendar? The following snippet is
I have the following snippet below from my script that's using a WebRequest to
I have the following snippet from my code: switch ($extention) { case gif: $src
Given the following code snippet from inside a method; NSBezierPath * tempPath = [NSBezierPath
The following code snippet is from The Official GNOME 2 Developer's Guide : GMemChunk

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.