© Copyright 2018 – 2024 FIRECRACKER SPORTS. All Rights Reserved.​ TERMS OF USE  |  PRIVACY POLICY

Northeast Premier Baseball League (9U-14U)

03/29/2025 - 06/19/2025
Providence , Rhode Island

INFORMATION

  • Age groups:
    6 Divisions 9U 10U 11U 12U 13U 14U
  • Pool Play:
    Saturday, March 29th through Wednesday, June 18th, 2025
  • Price:
    9U - $199.0010U - $299.0011U - $299.0012U - $299.0013U - $299.0014U - $299.00
  • Playoffs/Championships:
    Thursday, June 19th, 2025

For more clarification on "Sub-Divisions" click here

  • Registration Fee: Free until December 31st, 2024. Starting January 1st, 2025 the registration fee will be $299.00 per team.
  • Pre-season and in season monthly meetings with coaches and program directors.
  • Teams are required to have a home field but teams will have equal amount of home and away games, weather permitting.
  • Firecracker Sports will provide matchups for teams to schedule games at their home venues. Once a game has been scheduled between two teams, the home team is required to report this to Firecracker Sports, by emailing operations@firecrackersports.com, for the game to be posted on the League website and verify umpires are scheduled.
  • Teams will be scheduled for matchups against teams in their "geographical area" within their age division, including their "sub-division."
  • All League games will be scored using GameChanger. Teams are required to score their games using the app and must report the final score to Firecracker Sports by filling out the Game Report form here. Teams also will send in a player of the game, for each game played on this form. Players will then be selected to be Player of the Week, for each age division on social media. This must be submitted by end of that game's date.

  • The league will provide all field costs, umpire costs, balls and trophy ceremonies with social media exposure on site for each championship game of each division.
    • 13U and 14U Divisions will play their “Best of 3” Championship(s) at collegiate venues!
  • After the 2025 season, the top 2 teams of the "Champions Division" will be promoted, and the bottom 2 teams of the "Premier Division" will be relegated...allowing true competition and divisions that are based on merit, league play and consistency in building rosters. This will be an annual promotion for those teams to ascend or be demoted based on performance.
  • Enhanced Social Media Presence...Weekly coverage including pitcher/player of the week, players to watch, games of the week and much more!
  • Want more, we got you covered! Player profiles for every player in the league including stats, scores, demographics for free to every family, college coach evaluations at playoff games such as semifinals and championships. Players will have more of an opportunity to gain evaluation for Fire55 and Jr. Fire55, the premier showcase of the summer at Dunkin Park, home of the Hartford Yard Goats. Jr. Fire55 is for those 13U - 14U as well. Options for Trackman and team analytic days during the season.
  • More coming shortly...All Star Games, Skills Competitions, HR Derby, All League, MVP Trophies plus more more!
  • Save the best for last...The top organization of the league, dictated by overall points system, will qualify for the “Grand Slam level of our loyalty program” for their program, starting Fall 2025 and through the Summer of 2026. Program benefits are listed on the "Discounts" button on this page

Registration

  • DIVISION:
    • 9U
    • 10U
    • 11U
    • 12U
    • 13U
    • 14U
    • OPEN
    • OPEN
    • Champions
    • OPEN
    • Champions
    • OPEN
    • Champions
    • OPEN
    • Champions
    • OPEN
    • Champions
    109 Teams Registered
    COST: $199.00 - $299.00

College Coaches Attending

Teams

(7 teams) - OPEN
(7 teams) - OPEN
(5 teams) - Champions
(2 teams) - Premier
(3 teams) - OPEN
(4 teams) - Premier
(1 teams) - Champions
(5 teams) - OPEN
(5 teams) - Premier
(9 teams) - Champions
(5 teams) - OPEN
(11 teams) - Champions
(7 teams) - Premier
(7 teams) - OPEN
(4 teams) - Premier
(8 teams) - Champions

Locations

Richardson Field

60;70;80 Harpin Street

Bellingham massachusetts , United States

Get Directions
VENUE DIVISIONS
  • 14U
Fields
    Franklin Pierce University

    40 University Drive

    Rindge new hampshire , United States

    Get Directions
    VENUE DIVISIONS
    • 13U
    Fields
      University of Saint Joseph's

      1678 Asylum Avenue Bishop's Corner

      West Hartford connecticut , United States

      Get Directions
      VENUE DIVISIONS
      • 13U
      • 14U
      Fields
        Legion Field

        46 Powder Mill Road

        Southwick massachusetts , United States

        Get Directions
        VENUE DIVISIONS
        • 12U
        Fields
          TBA Playoff Site 4

          Get Directions
          VENUE DIVISIONS
          • 12U
          Fields
            TBA Playoff Site 3

            Get Directions
            VENUE DIVISIONS
            • 12U
            Fields
              TBA Playoff Site 2

              Get Directions
              VENUE DIVISIONS
              • 12U
              Fields
                TBA Playoff Site 1

                Get Directions
                VENUE DIVISIONS
                • 12U
                Fields
                  Blunt Park

                  1780 Roosevelt Avenue

                  Springfield massachusetts , United States

                  Get Directions
                  VENUE DIVISIONS
                  • 12U
                  Fields
                    Thomas J. Hyland Memorial Park and Southwest Recreation Center

                    391 New Britain Avenue Fairfield Avenue Historic District

                    Hartford connecticut , United States

                    Get Directions
                    VENUE DIVISIONS
                    • 12U
                    Fields
                      Beachgrounds Park

                      116 Main Street

                      South Hadley massachusetts , United States

                      Get Directions
                      VENUE DIVISIONS
                      • 13U
                      Fields
                        Quaker Hill Elementary School

                        285 Bloomingdale Road Quaker Hill

                        Waterford connecticut , United States

                        Get Directions
                        VENUE DIVISIONS
                        • 9U
                        Fields
                          Cohanzie Park

                          45 Dayton Road

                          Waterford connecticut , United States

                          Get Directions
                          VENUE DIVISIONS
                          • 9U
                          • 11U
                          Fields
                            Waterford Veterans Memorial Field

                            174, Boston Post Road

                            Waterford connecticut , United States

                            Get Directions
                            VENUE DIVISIONS
                            • 11U
                            Fields
                              Epsom Central School

                              282, Black Hall Road Epsom

                              Epsom new hampshire , United States

                              Get Directions
                              VENUE DIVISIONS
                              • 14U
                              Fields
                                Dr. Kevin M. Hurley Middle School

                                Newman Avenue

                                Seekonk massachusetts , United States

                                Get Directions
                                VENUE DIVISIONS
                                • 14U
                                Fields
                                  Kingswood Oxford School

                                  Kingswood Road

                                  West Hartford connecticut , United States

                                  Get Directions
                                  VENUE DIVISIONS
                                  • 14U
                                  Fields
                                    TBA/Massachusetts

                                    TBA/Massachusetts

                                    TBA massachusetts , USA

                                    Get Directions
                                    VENUE DIVISIONS
                                    • 14U
                                    Fields
                                      Maplewood Park (Stafford Rd)

                                      Stafford Road

                                      Fall River massachusetts , United States

                                      Get Directions
                                      VENUE DIVISIONS
                                      • 14U
                                      Fields
                                        Crandall Park

                                        Cider Mill Road

                                        Tolland connecticut , United States

                                        Get Directions
                                        VENUE DIVISIONS
                                        • 10U
                                        Fields
                                          TBA/Rhode Island

                                          TBA/Rhode Island

                                          TBA rhode island , USA

                                          Get Directions
                                          VENUE DIVISIONS
                                          • 10U
                                          Fields
                                            Lyman Moore Middle School

                                            Auburn Street

                                            Portland maine

                                            Get Directions
                                            VENUE DIVISIONS
                                            • 14U
                                            Fields
                                              Xavier High School

                                              Randolph Road

                                              Middletown connecticut , United States

                                              Get Directions
                                              VENUE DIVISIONS
                                              • 14U
                                              Fields
                                                Kevin DelGobbo Field

                                                Osborn Road

                                                Naugatuck connecticut , United States

                                                Get Directions
                                                VENUE DIVISIONS
                                                • 14U
                                                Fields
                                                  Recreation Park

                                                  25 Maxwell Noble Dr

                                                  Plantsville connecticut , USA

                                                  Get Directions
                                                  VENUE DIVISIONS
                                                  • 13U
                                                  • 14U
                                                  Fields
                                                    Ellington Middle School

                                                    Middle Butcher Road

                                                    Ellington connecticut , United States

                                                    Get Directions
                                                    VENUE DIVISIONS
                                                    • 13U
                                                    Fields
                                                      Wolf Swamp Field

                                                      Wolf Swamp Road

                                                      Longmeadow massachusetts , United States

                                                      Get Directions
                                                      VENUE DIVISIONS
                                                      • 13U
                                                      • 14U
                                                      Fields
                                                        Trombino Sports Complex

                                                        Moorehouse Road

                                                        Westerly rhode island , United States

                                                        Get Directions
                                                        VENUE DIVISIONS
                                                        • 13U
                                                        Fields
                                                          Cromwell Middle School

                                                          Captain James Mann Memorial Drive

                                                          Cromwell connecticut , United States

                                                          Get Directions
                                                          VENUE DIVISIONS
                                                          • 13U
                                                          • 14U
                                                          Fields
                                                            Marshall Roy Field

                                                            El Paso Street

                                                            Springfield massachusetts , United States

                                                            Get Directions
                                                            VENUE DIVISIONS
                                                            • 13U
                                                            Fields
                                                              Tilloston Field

                                                              Crystal Street

                                                              Lenox massachusetts , United States

                                                              Get Directions
                                                              VENUE DIVISIONS
                                                              • 13U
                                                              Fields
                                                                Colt State Park

                                                                Asylum Road

                                                                Bristol rhode island , United States

                                                                Get Directions
                                                                VENUE DIVISIONS
                                                                • 13U
                                                                Fields
                                                                  Minnechaug Regional High School

                                                                  Main Street

                                                                  Wilbraham massachusetts , United States

                                                                  Get Directions
                                                                  VENUE DIVISIONS
                                                                  • 13U
                                                                  Fields
                                                                    Mills Pond Park

                                                                    East Hill Road Canton Valley

                                                                    Canton connecticut , United States

                                                                    Get Directions
                                                                    VENUE DIVISIONS
                                                                    • 13U
                                                                    Fields
                                                                      Hamden Hall Country Day School

                                                                      Skiff Street

                                                                      Hamden connecticut , United States

                                                                      Get Directions
                                                                      VENUE DIVISIONS
                                                                      • 13U
                                                                      Fields
                                                                        Longmeadow DiPippo Park

                                                                        Williams Court

                                                                        Longmeadow massachusetts , United States

                                                                        Get Directions
                                                                        VENUE DIVISIONS
                                                                        • 13U
                                                                        • 14U
                                                                        Fields
                                                                          Northwest Park

                                                                          Tolland Turnpike

                                                                          Manchester connecticut , United States

                                                                          Get Directions
                                                                          VENUE DIVISIONS
                                                                          • 13U
                                                                          Fields
                                                                            Allen Field

                                                                            West Road Ashby

                                                                            Ashby massachusetts , United States

                                                                            Get Directions
                                                                            VENUE DIVISIONS
                                                                            • 13U
                                                                            • 14U
                                                                            Fields
                                                                              TBA/Connecticut

                                                                              TBA/Connecticut

                                                                              TBA connecticut , USA

                                                                              Get Directions
                                                                              VENUE DIVISIONS
                                                                              • 9U
                                                                              Fields
                                                                                Southington Memorial Park

                                                                                Woodruff Street

                                                                                Southington connecticut , United States

                                                                                Get Directions
                                                                                VENUE DIVISIONS
                                                                                • 10U
                                                                                • 12U
                                                                                Fields
                                                                                  Suffield High School

                                                                                  Sheldon Street

                                                                                  Suffield connecticut , United States

                                                                                  Get Directions
                                                                                  VENUE DIVISIONS
                                                                                  • 12U
                                                                                  • 13U
                                                                                  Fields
                                                                                    Turner Park

                                                                                    Williams Street

                                                                                    Longmeadow massachusetts , United States

                                                                                    Get Directions
                                                                                    VENUE DIVISIONS
                                                                                    • 12U
                                                                                    Fields
                                                                                      Montowese Park

                                                                                      Quinnipiac Avenue Montowese

                                                                                      North Haven connecticut , United States

                                                                                      Get Directions
                                                                                      VENUE DIVISIONS
                                                                                      • 12U
                                                                                      Fields
                                                                                        Orchard Park

                                                                                        Orchard Park Street

                                                                                        Boston massachusetts , United States

                                                                                        Get Directions
                                                                                        VENUE DIVISIONS
                                                                                        • 12U
                                                                                        Fields
                                                                                          Miller Richardson Park

                                                                                          Main Street

                                                                                          Coventry connecticut , United States

                                                                                          Get Directions
                                                                                          VENUE DIVISIONS
                                                                                          • 12U
                                                                                          Fields
                                                                                            Southington West LL

                                                                                            Spring Street

                                                                                            Southington connecticut , United States

                                                                                            Get Directions
                                                                                            VENUE DIVISIONS
                                                                                            • 12U
                                                                                            • 13U
                                                                                            • 14U
                                                                                            Fields
                                                                                              Bradley School

                                                                                              David Humphrey Road

                                                                                              Derby connecticut , United States

                                                                                              Get Directions
                                                                                              VENUE DIVISIONS
                                                                                              • 12U
                                                                                              Fields
                                                                                                Whalley Park

                                                                                                Powder Mill Road

                                                                                                Southwick massachusetts , United States

                                                                                                Get Directions
                                                                                                VENUE DIVISIONS
                                                                                                • 12U
                                                                                                • 13U
                                                                                                • 14U
                                                                                                Fields
                                                                                                  Watrous Park

                                                                                                  Geer Street

                                                                                                  Cromwell connecticut , United States

                                                                                                  Get Directions
                                                                                                  VENUE DIVISIONS
                                                                                                  • 12U
                                                                                                  Fields
                                                                                                    Hampden Memorial Park

                                                                                                    495 Main Street

                                                                                                    Hampden massachusetts , US

                                                                                                    Get Directions
                                                                                                    VENUE DIVISIONS
                                                                                                    • 11U
                                                                                                    Fields
                                                                                                      Samoset Middle School

                                                                                                      Decicco Drive

                                                                                                      Leominster massachusetts , United States

                                                                                                      Get Directions
                                                                                                      VENUE DIVISIONS
                                                                                                      • 12U
                                                                                                      Fields
                                                                                                        Newington High School

                                                                                                        Willard Avenue

                                                                                                        Newington connecticut , United States

                                                                                                        Get Directions
                                                                                                        VENUE DIVISIONS
                                                                                                        • 10U
                                                                                                        • 13U
                                                                                                        • 14U
                                                                                                        Fields
                                                                                                          Mansfield Memorial Park

                                                                                                          Church Street

                                                                                                          Mansfield massachusetts , United States

                                                                                                          Get Directions
                                                                                                          VENUE DIVISIONS
                                                                                                          • 10U
                                                                                                          Fields
                                                                                                            Kimberly Ann Rock Memorial Athletic Complex

                                                                                                            220 Ferris Avenue Rumford

                                                                                                            Rumford rhode island , USA

                                                                                                            Get Directions
                                                                                                            VENUE DIVISIONS
                                                                                                            • 10U
                                                                                                            • 12U
                                                                                                            Fields
                                                                                                              Church Hill Park

                                                                                                              Main Street

                                                                                                              Newington connecticut , United States

                                                                                                              Get Directions
                                                                                                              VENUE DIVISIONS
                                                                                                              • 10U
                                                                                                              • 12U
                                                                                                              Fields
                                                                                                                Ricci Field

                                                                                                                Duckworth Street

                                                                                                                Cranston rhode island , United States

                                                                                                                Get Directions
                                                                                                                VENUE DIVISIONS
                                                                                                                • 10U
                                                                                                                Fields
                                                                                                                  North Leominster LL

                                                                                                                  Bernice Avenue

                                                                                                                  Leominster massachusetts , United States

                                                                                                                  Get Directions
                                                                                                                  VENUE DIVISIONS
                                                                                                                  • 10U
                                                                                                                  Fields
                                                                                                                    Daggett Field

                                                                                                                    Daggett Avenue

                                                                                                                    Pawtucket rhode island , United States

                                                                                                                    Get Directions
                                                                                                                    VENUE DIVISIONS
                                                                                                                    • 10U
                                                                                                                    • 13U
                                                                                                                    • 14U
                                                                                                                    Fields
                                                                                                                      Cross Farms Field

                                                                                                                      Rhodes Road

                                                                                                                      Tolland connecticut , United States

                                                                                                                      Get Directions
                                                                                                                      VENUE DIVISIONS
                                                                                                                      • 10U
                                                                                                                      Fields
                                                                                                                        Brooklawn Park

                                                                                                                        Acushnet Avenue

                                                                                                                        New Bedford massachusetts , United States

                                                                                                                        Get Directions
                                                                                                                        VENUE DIVISIONS
                                                                                                                        • 10U
                                                                                                                        Fields
                                                                                                                          TBA/Naugatuck, CT

                                                                                                                          TBA/Naugatuck, CT

                                                                                                                          Naugatuck connecticut , USA

                                                                                                                          Get Directions
                                                                                                                          VENUE DIVISIONS
                                                                                                                          • 10U
                                                                                                                          Fields
                                                                                                                            TBA/Pawtucket, RI

                                                                                                                            TBA/Pawtucket, RI

                                                                                                                            TBA rhode island , USA

                                                                                                                            Get Directions
                                                                                                                            VENUE DIVISIONS
                                                                                                                            • 10U
                                                                                                                            Fields
                                                                                                                              TBA/Southern New Hampshire

                                                                                                                              TBA/Southern New Hampshire

                                                                                                                              TBA new hampshire , USA

                                                                                                                              Get Directions
                                                                                                                              VENUE DIVISIONS
                                                                                                                              • 10U
                                                                                                                              Fields
                                                                                                                                Milton Green Memorial Field

                                                                                                                                13 CT-117, Preston

                                                                                                                                Preston connecticut , USA

                                                                                                                                Get Directions
                                                                                                                                VENUE DIVISIONS
                                                                                                                                • 9U
                                                                                                                                Fields
                                                                                                                                Memorial School

                                                                                                                                Main Street

                                                                                                                                Wilbraham massachusetts

                                                                                                                                Get Directions
                                                                                                                                VENUE DIVISIONS
                                                                                                                                • 9U
                                                                                                                                Fields
                                                                                                                                  • Grass
                                                                                                                                Pope Park

                                                                                                                                Pope Street

                                                                                                                                Acushnet massachusetts

                                                                                                                                Get Directions
                                                                                                                                VENUE DIVISIONS
                                                                                                                                • 9U
                                                                                                                                • 10U
                                                                                                                                • 11U
                                                                                                                                • 12U
                                                                                                                                • 13U
                                                                                                                                Fields
                                                                                                                                • 60/90 Field
                                                                                                                                  • Grass
                                                                                                                                • 50/70 Field
                                                                                                                                  • Grass
                                                                                                                                • 46/60 Field
                                                                                                                                  • Grass
                                                                                                                                Swansea Independent Baseball League (SIBL)

                                                                                                                                Nike Site Road

                                                                                                                                Swansea massachusetts

                                                                                                                                Get Directions
                                                                                                                                VENUE DIVISIONS
                                                                                                                                • 9U
                                                                                                                                • 10U
                                                                                                                                • 12U
                                                                                                                                Fields
                                                                                                                                  • Grass
                                                                                                                                Maplewood Park

                                                                                                                                10, Albert Street

                                                                                                                                Fall River massachusetts , United States

                                                                                                                                Get Directions
                                                                                                                                VENUE DIVISIONS
                                                                                                                                • 9U
                                                                                                                                • 13U
                                                                                                                                Fields
                                                                                                                                Lisa Dedrick Memorial Field and Park

                                                                                                                                45 Dayton Road

                                                                                                                                Waterford connecticut , United States

                                                                                                                                Get Directions
                                                                                                                                VENUE DIVISIONS
                                                                                                                                • 9U
                                                                                                                                Fields
                                                                                                                                Max Read Field

                                                                                                                                544 Pleasant St

                                                                                                                                Pawtucket rhode island

                                                                                                                                Get Directions
                                                                                                                                VENUE DIVISIONS
                                                                                                                                • 13U
                                                                                                                                • 14U
                                                                                                                                Fields
                                                                                                                                  VENUE DETAILS

                                                                                                                                  Max Read Field

                                                                                                                                  Mitchell Woods

                                                                                                                                  701 Montauk Ave

                                                                                                                                  New London

                                                                                                                                  Get Directions
                                                                                                                                  VENUE DIVISIONS
                                                                                                                                  • 10U
                                                                                                                                  Fields
                                                                                                                                    VENUE DETAILS

                                                                                                                                    Mitchell Woods

                                                                                                                                    Alumni Field

                                                                                                                                    168 Alumni Road

                                                                                                                                    Newington connecticut , United States

                                                                                                                                    Get Directions
                                                                                                                                    VENUE DIVISIONS
                                                                                                                                    • 10U
                                                                                                                                    Fields
                                                                                                                                    • Field - 1
                                                                                                                                      • Lights
                                                                                                                                      • Grass
                                                                                                                                    VENUE DETAILS

                                                                                                                                    Alumni Field

                                                                                                                                    Boyd Field

                                                                                                                                    600 Sandy Ln

                                                                                                                                    Warwick rhode island , USA

                                                                                                                                    Get Directions
                                                                                                                                    VENUE DIVISIONS
                                                                                                                                    • 9U
                                                                                                                                    • 10U
                                                                                                                                    Fields
                                                                                                                                    • Boyd Field
                                                                                                                                    Warwick Continental LL Complex

                                                                                                                                    225 Crossings Blvd

                                                                                                                                    Warwick rhode island , USA

                                                                                                                                    Get Directions
                                                                                                                                    VENUE DIVISIONS
                                                                                                                                    • 11U
                                                                                                                                    • 12U
                                                                                                                                    Fields
                                                                                                                                    • D’Abrosca Memorial Field
                                                                                                                                      • Lights
                                                                                                                                      • Grass
                                                                                                                                      • Permanent Bathrooms
                                                                                                                                      • Concession Stand
                                                                                                                                    • Founders Field
                                                                                                                                      • Grass
                                                                                                                                      • Permanent Bathrooms
                                                                                                                                      • Concession Stand
                                                                                                                                    Boys & Girls Club - Pawtucket

                                                                                                                                    1 Moeller Place

                                                                                                                                    Pawtucket rhode island , USA

                                                                                                                                    Get Directions
                                                                                                                                    VENUE DIVISIONS
                                                                                                                                    • 10U
                                                                                                                                    Fields
                                                                                                                                      VENUE DETAILS

                                                                                                                                      Boys & Girls Club - Pawtucket

                                                                                                                                      Martha Hart Park

                                                                                                                                      135 Corbin Ave

                                                                                                                                      New Britain connecticut , USA

                                                                                                                                      Get Directions
                                                                                                                                      VENUE DIVISIONS
                                                                                                                                      • 12U
                                                                                                                                      Fields
                                                                                                                                        VENUE DETAILS

                                                                                                                                        Martha Hart Park

                                                                                                                                        Walnut Hill Park

                                                                                                                                        184 W Main St

                                                                                                                                        New Britain

                                                                                                                                        Get Directions
                                                                                                                                        VENUE DIVISIONS
                                                                                                                                        • 13U
                                                                                                                                        Fields
                                                                                                                                          VENUE DETAILS

                                                                                                                                          Walnut Hill Park

                                                                                                                                          McLaughlin Field - Upper Field

                                                                                                                                          992 Lancaster street

                                                                                                                                          Leominster massachusetts , USA

                                                                                                                                          Get Directions
                                                                                                                                          VENUE DIVISIONS
                                                                                                                                          • 13U
                                                                                                                                          Fields
                                                                                                                                          • Upper Field
                                                                                                                                            • Lights
                                                                                                                                            • Grass
                                                                                                                                            • Portable Bathrooms
                                                                                                                                          Rhode Island College

                                                                                                                                          600 Library Road

                                                                                                                                          Providence

                                                                                                                                          Get Directions
                                                                                                                                          VENUE DIVISIONS
                                                                                                                                          • 13U
                                                                                                                                          • 14U
                                                                                                                                          Fields
                                                                                                                                          • Pontarelli Field
                                                                                                                                            • Grass
                                                                                                                                            • Permanent Bathrooms
                                                                                                                                            • Concession Stand
                                                                                                                                          • Dayna A. Bazar Softball Complex
                                                                                                                                            • Grass
                                                                                                                                            • Permanent Bathrooms
                                                                                                                                            • Concession Stand
                                                                                                                                          VENUE DETAILS

                                                                                                                                          Rhode Island College

                                                                                                                                          Slater Park

                                                                                                                                          401 Newport Ave

                                                                                                                                          Pawtucket rhode island

                                                                                                                                          Get Directions
                                                                                                                                          VENUE DIVISIONS
                                                                                                                                          • 9U
                                                                                                                                          • 10U
                                                                                                                                          • 13U
                                                                                                                                          • 14U
                                                                                                                                          Fields
                                                                                                                                          • McConnon Field
                                                                                                                                            • Lights
                                                                                                                                            • Grass
                                                                                                                                            • Portable Bathrooms
                                                                                                                                          • Dick Cosimini Field
                                                                                                                                            • Grass
                                                                                                                                          Veterans Park

                                                                                                                                          271 Smithfield Ave

                                                                                                                                          Pawtucket rhode island , USA

                                                                                                                                          Get Directions
                                                                                                                                          VENUE DIVISIONS
                                                                                                                                          • 13U
                                                                                                                                          Fields
                                                                                                                                            VENUE DETAILS

                                                                                                                                            Veterans Park

                                                                                                                                            Hank Soar Athletic Complex

                                                                                                                                            470 Prospect St

                                                                                                                                            Pawtucket rhode island

                                                                                                                                            Get Directions
                                                                                                                                            VENUE DIVISIONS
                                                                                                                                            • 11U
                                                                                                                                            • 12U
                                                                                                                                            Fields
                                                                                                                                            • Field #1
                                                                                                                                              • Lights
                                                                                                                                              • Grass
                                                                                                                                              • Permanent Bathrooms
                                                                                                                                            • Field #2
                                                                                                                                              • Lights
                                                                                                                                              • Grass
                                                                                                                                              • Permanent Bathrooms
                                                                                                                                            • Field #3
                                                                                                                                              • Lights
                                                                                                                                              • Grass
                                                                                                                                              • Permanent Bathrooms
                                                                                                                                            University of Rhode Island

                                                                                                                                            3 Keaney Rd

                                                                                                                                            Kingston rhode island , USA

                                                                                                                                            Get Directions
                                                                                                                                            VENUE DIVISIONS
                                                                                                                                            • 14U
                                                                                                                                            Fields
                                                                                                                                            • Bill Beck Field
                                                                                                                                              • Turf
                                                                                                                                              • Portable Bathrooms
                                                                                                                                            VENUE DETAILS

                                                                                                                                            The following items are prohibited at this turf venue…

                                                                                                                                            • Metal Spikes
                                                                                                                                            • Sunflower Seeds
                                                                                                                                            • Gum

                                                                                                                                            schedule

                                                                                                                                            5.12.25 2:00pm

                                                                                                                                            Scores are currently being uploaded from this past weekend, and will be updated with standings shortly.

                                                                                                                                            HOTELS

                                                                                                                                            SCHEDULES & STANDINGS

                                                                                                                                            Standings

                                                                                                                                             TeamWLTRARSRDW%
                                                                                                                                            DateTimeGameDivisionLocationTeamScoreTeamNotes

                                                                                                                                            Brackets

                                                                                                                                            TOP PERFORMERS

                                                                                                                                            RULES

                                                                                                                                            There is no rules.

                                                                                                                                            WEATHER

                                                                                                                                            `);printWindow.document.close(); }); /* function gpe_get_schedules_list() { const event_id = '39771'; let division_filter_drop = $("#division_filter_drop").val(); let pool_filter_drop = $("#pool_filter_drop").val(); let date_filter_drop = $("#date_filter_drop").val();// Show processing indicator (manually trigger it) table.destroy(); // Destroy old DataTable before making new AJAX call $("#schedules_table tbody").html('Loading...'); // Temporary loader row$.ajax({ url: gpe.ajax_url, type: 'post', data: { action: 'gpe_ajax', type: 'gpe_get_schedules_list', event_id: event_id, division_filter_drop: division_filter_drop, pool_filter_drop: pool_filter_drop, date_filter_drop: date_filter_drop }, success: function (response) { // Clear the table body and add new content $("#schedules_table tbody").empty().html(response.data.html);// Reinitialize DataTable with processing enabled table = $("#schedules_table").DataTable({ processing: true, serverSide: false, // Keep it false unless loading data dynamically searching: true, paging: true, autoWidth: false }); } }); } function gpe_get_standing_list() { const event_id = '39771'; let division_filter_drop = $("#division_filter_drop_for_standing").val(); let pool_filter_drop = $("#pool_filter_drop_for_standing").val(); // Show processing indicator (manually trigger it) standings_table.destroy(); // Destroy old DataTable before making new AJAX call $("#standings_table tbody").html('Loading...'); // Temporary loader row $.ajax({ url: gpe.ajax_url, type: 'post', data: { action: 'gpe_ajax', type: 'gpe_get_standing_list', event_id: event_id, division_filter_drop: division_filter_drop, pool_filter_drop: pool_filter_drop }, success: function (response) { // Clear the table body and add new content $("#standings_table tbody").empty().html(response.data.html); // Reinitialize DataTable with processing enabled standings_table = $("#standings_table").DataTable({ processing: true, serverSide: false, // Keep it false unless loading data dynamically searching: true, paging: false }); } }); }*/ $('#shareDropdown').change(function(){ var selectedOption = $(this).val(); if (selectedOption === "copy") { var pageLink = window.location.href; var tempInput = $(""); $("body").append(tempInput); tempInput.val(pageLink).select(); document.execCommand("copy"); tempInput.remove(); Swal.fire({ title:"Success", text:"Copied to clipboard!", icon:'success' }); // Reset dropdown selection $(this).prop('selectedIndex', 0); } }); }); let isSchedulesTableInitialized = false;function gpeCustomeTabsnew(evt, cityName) { var i, tabcontent, tablinks; tabcontent = document.getElementsByClassName("gpe_tabcontent"); for (i = 0; i < tabcontent.length; i++) { tabcontent[i].style.display = "none"; } tablinks = document.getElementsByClassName("gpe_tablinks"); for (i = 0; i < tablinks.length; i++) { tablinks[i].className = tablinks[i].className.replace(" gpe_active", ""); } document.getElementById(cityName).style.display = "block"; evt.currentTarget.className += " gpe_active";if (cityName === "schedules_and_standings") { // ✅ Prevent reinitializing the DataTable if (!isSchedulesTableInitialized) { // Only call once window.gpe_get_schedules_list(); window.gpe_get_standing_list(); isSchedulesTableInitialized = true; } } }function gpeCustomeTabs(evt, cityName) { var i, tabcontent, tablinks; tabcontent = document.getElementsByClassName("gpe_tabcontent"); for (i = 0; i < tabcontent.length; i++) { tabcontent[i].style.display = "none"; } tablinks = document.getElementsByClassName("gpe_tablinks"); for (i = 0; i < tablinks.length; i++) { tablinks[i].className = tablinks[i].className.replace(" gpe_active", ""); } document.getElementById(cityName).style.display = "block"; evt.currentTarget.className += " gpe_active"; // Redraw connectors when Bracket tab is activated if (cityName === "brackets"){ //alert("Bracket"); loadSavedBracket(); } if (cityName === "brackets" && window.globalSerialMap) { // Wait until the browser has painted the visible DOM //requestAnimationFrame(() => { //setTimeout(() => { //waitForLayoutAndDraw(window.globalSerialMap, 20); waitForLayoutAndDrawStable(window.globalSerialMap, 20); //}, 100); //}); } }// Get the element with id="defaultOpen" and click on it document.getElementById("defaultOpen").click(); var acc = document.getElementsByClassName("gpe_accordion"); var i; for (i = 0; i < acc.length; i++) { acc[i].addEventListener("click", function() { this.classList.toggle("active"); var panel = this.nextElementSibling; if (panel.style.maxHeight) { panel.style.maxHeight = null; } else { panel.style.maxHeight = panel.scrollHeight + "px"; } }); }var latitude = document.getElementById("latitude").value; var longitude = document.getElementById("longitude").value;var iframe = document.createElement("iframe"); iframe.src = "https://www.google.com/maps/embed?pb=!1m28!1m12!1m3!1d19797.686238814687!2d-71.3765509!3d41.8633795!2m3!1f0!2f0!3f0!3m2!1i1024!2i768!4f13.1!4m13!3e6!4m5!1s0x89e45a80fc2b13ab%3A0x8f62f2e279889968!2sCurrent%20Location!3m2!1d" + latitude + "!2d" + longitude + "!4m5!1s0x89e45a7a2b41f7f3%3A0x6cb46461e8d0c1b4!2s" + latitude + "%2C" + longitude + "!3m2!1d" + latitude + "!2d" + longitude + "!5e0!3m2!1sen!2sus!4v1644233201036!5m2!1sen!2sus"; iframe.width = "528"; iframe.height = "295"; iframe.style.border = "0"; iframe.allowfullscreen = true;var mapContainer = document.getElementById("mapContainer"); mapContainer.innerHTML = ""; mapContainer.appendChild(iframe); function getPoolsByDivision(divisionId) { return $.ajax({ url: gpe.ajax_url, method: "POST", dataType: "json", data: { action: "gpe_ajax", type: "get_pools_save", division_id: divisionId } }); }function loadSavedBracket() { // Get the division ID from the division select dropdown const divisionId = $("#division_select").val(); // Get the current event ID dynamically from PHP const eventId = '39771';// If division ID is not selected, exit early if (!divisionId) return;// Perform both AJAX requests in parallel $.when( $.ajax({ url: gpe.ajax_url, // URL for the AJAX request type: "POST", // HTTP method dataType: "json", // Expected response type data: { action: "gpe_ajax", // WordPress action hook for AJAX type: "get_saved_bracket", // Custom action to get saved bracket data event_id: eventId, // The current event ID division_id: divisionId // The selected division ID } }), getPoolsByDivision(divisionId) // Function to get pools for the selected division ).done(function (bracketRes, poolsRes) { // Extract bracket data from the first response (bracketRes) const bracketData = bracketRes[0]?.data?.bracket_data || []; // Prepare a map of pool ID to pool title const poolMap = {}; poolsRes[0]?.data?.forEach(pool => { poolMap[pool.id] = pool.title; });// Call renderSavedBracket function to render the bracket renderSavedBracket(bracketData, poolMap); }).fail(function () { // In case of failure, show an error message in the bracket container $("#bracket").html("
                                                                                                                                            Error loading bracket.
                                                                                                                                            "); }); } function renderSavedBracket(bracketData, poolMap) { let bracketWrapper = $(".bracket_wrapper"); if (bracketWrapper.length === 0) { bracketWrapper = $("
                                                                                                                                            ").addClass("bracket_wrapper"); // Append it to the main container if it's missing $("#bracket").replaceWith(bracketWrapper); } else { bracketWrapper.empty(); // Clear existing content if already present } let bracketDiv = $("
                                                                                                                                            ").attr("id", "bracket"); bracketWrapper.append(bracketDiv); if (!bracketData || bracketData.length === 0) { bracketDiv.append(`

                                                                                                                                            Bracket not available, please select a different division from the drop down menu

                                                                                                                                            `); return; } let groups = {}; let serialMap = {}; let matchCounter = 1; bracketData.forEach(match => { if (match.is_important === "1") { if (!groups[match.group_number]) groups[match.group_number] = {}; if (!groups[match.group_number][match.column_number]) groups[match.group_number][match.column_number] = []; groups[match.group_number][match.column_number].push(match); } }); const sortedGroups = Object.keys(groups).sort(); const mainGroup = sortedGroups[0]; let groupScrollWrapper = $("
                                                                                                                                            ").addClass("group-scroll-wrapper"); for (let group of sortedGroups) { let groupSerialCounter = 1; let groupDiv = $("
                                                                                                                                            ").addClass("group").attr("data-group", group); let columnsContainer = $("
                                                                                                                                            ").addClass("columns-container"); let groupMatchesArray = Object.values(groups[group]).flat(); let groupLabel = groupMatchesArray[0]?.group_label ?? `Group ${group}`; let labelDiv = $("
                                                                                                                                            ").addClass("group-label").text(groupLabel); groupDiv.append(labelDiv); let columns = Object.keys(groups[group]).sort((a, b) => a - b); const groupMatches = {}; const allMatches = Object.values(groups[group]).flat(); const matchCount = allMatches.length; const isFiveTeam = allMatches.length === 4 && columns.length === 3; const isSevenTeam = matchCount === 6 && columns.length === 4; const isTenTeam = matchCount === 9 && columns.length === 4; const isNineTeam = matchCount === 8 && columns.length === 4; const isSixTeam = matchCount === 5 && columns.length === 3; const isTwelveTeam = matchCount === 11 && columns.length === 4; // Adjust if using 12 matches if (isTwelveTeam) { allMatches.sort((a, b) => parseInt(a.name) - parseInt(b.name)); const displayOrder = [ allMatches[0], allMatches[1], allMatches[2], allMatches[3], // Round 1 allMatches[4], allMatches[5], allMatches[6], allMatches[7], // Round 2 allMatches[8], allMatches[9], // Semifinals allMatches[10] // Final ];let roundDiv1 = $("
                                                                                                                                            ").addClass("round").attr("data-column", columns[0]); let roundDiv2 = $("
                                                                                                                                            ").addClass("round").attr("data-column", columns[1]); let roundDiv3 = $("
                                                                                                                                            ").addClass("round").attr("data-column", columns[2]); let roundDiv4 = $("
                                                                                                                                            ").addClass("round").attr("data-column", columns[3]);displayOrder.forEach((match, i) => { const serial = groupSerialCounter++; const matchId = `match-serial-${group}-${serial}`; let matchDiv = $("
                                                                                                                                            ") .addClass("match") .attr("id", matchId) .attr("data-match-index", match.name);let score1 = match.team1_score ?? "-"; let score2 = match.team2_score ?? "-"; //let team1 = match.team_name1 ?? "Team 1"; //let team2 = match.team_name2 ?? "Team 2"; let team1 = match.source_label_team1 && match.source_label_team1.trim() !== "" ? match.source_label_team1 : (match.team_name1 ?? "Team 1"); let team2 = match.source_label_team2 && match.source_label_team2.trim() !== "" ? match.source_label_team2 : (match.team_name2 ?? "Team 2");let startTime = formatStartDateTime(match.start_date, match.start_time); let location = match.location || "";matchDiv.html(`
                                                                                                                                            ${match.name}
                                                                                                                                            ${startTime}
                                                                                                                                            ${location}
                                                                                                                                            ${team1} ${score1}
                                                                                                                                            ${team2} ${score2}
                                                                                                                                            `);const matchContainer = $("
                                                                                                                                            ").addClass("match-container").css("margin-bottom", "20px"); matchContainer.append(matchDiv);match.serial = serial; if (!groupMatches[match.column_number]) groupMatches[match.column_number] = []; groupMatches[match.column_number].push(match); serialMap[`${group}-${serial}`] = { ...match, group, column: match.column_number, serial };if (i < 4) roundDiv1.append(matchContainer); // Round 1 else if (i < 8) roundDiv2.append(matchContainer); // Round 2 else if (i < 10) roundDiv3.append(matchContainer); // Semis else roundDiv4.append(matchContainer); // Final });columnsContainer.append(roundDiv1); columnsContainer.append($("
                                                                                                                                            ").addClass("connector-column")); columnsContainer.append(roundDiv2); columnsContainer.append($("
                                                                                                                                            ").addClass("connector-column")); columnsContainer.append(roundDiv3); columnsContainer.append($("
                                                                                                                                            ").addClass("connector-column")); columnsContainer.append(roundDiv4);groupDiv.append(columnsContainer); groupScrollWrapper.append(groupDiv);const groupNumbers = Object.keys(groups); // make sure 'groups' is defined and validconst importantMatchExists = Object.values(groupMatches) .flat() .some(m => m.is_importantlast === "1");setTimeout(() => { if (importantMatchExists) { const currentGroupNumber = group; const currentIndex = groupNumbers.indexOf(currentGroupNumber); const prevGroupNumber = currentIndex > 0 ? groupNumbers[currentIndex - 1] : null; const lastChecked = true;positionMatcheslast(groupMatches, currentGroupNumber, prevGroupNumber, lastChecked); } positionMatches(groupMatches, group); //waitForLayoutAndDraw(serialMap, 20); waitForLayoutAndDrawStable(serialMap, 20);}, 100);continue; }if (isSixTeam) { allMatches.sort((a, b) => parseInt(a.name) - parseInt(b.name));const displayOrder = [ allMatches[0], // Match 1 allMatches[1], // Match 2 allMatches[2], // Match 3 allMatches[3], // Match 4 allMatches[4] // Final ];let roundDiv1 = $("
                                                                                                                                            ").addClass("round").attr("data-column", columns[0]); let roundDiv2 = $("
                                                                                                                                            ").addClass("round").attr("data-column", columns[1]); let roundDiv3 = $("
                                                                                                                                            ").addClass("round").attr("data-column", columns[2]);displayOrder.forEach((match, i) => { const serial = groupSerialCounter++; const matchId = `match-serial-${group}-${serial}`;let matchDiv = $("
                                                                                                                                            ") .addClass("match") .attr("id", matchId) .attr("data-match-index", match.name);let score1 = match.team1_score ?? "-"; let score2 = match.team2_score ?? "-"; //let team1 = match.team_name1 ?? "Team 1"; //let team2 = match.team_name2 ?? "Team 2"; let team1 = match.source_label_team1 && match.source_label_team1.trim() !== "" ? match.source_label_team1 : (match.team_name1 ?? "Team 1"); let team2 = match.source_label_team2 && match.source_label_team2.trim() !== "" ? match.source_label_team2 : (match.team_name2 ?? "Team 2");let startTime = formatStartDateTime(match.start_date, match.start_time); let location = match.location || "";matchDiv.html(`
                                                                                                                                            ${match.name}
                                                                                                                                            ${startTime}
                                                                                                                                            ${location}
                                                                                                                                            ${team1} ${score1}
                                                                                                                                            ${team2} ${score2}
                                                                                                                                            `);const matchContainer = $("
                                                                                                                                            ").addClass("match-container").css("margin-bottom", "20px"); matchContainer.append(matchDiv);match.serial = serial; if (!groupMatches[match.column_number]) groupMatches[match.column_number] = []; groupMatches[match.column_number].push(match);serialMap[`${group}-${serial}`] = { ...match, group, column: match.column_number, serial };if (i < 2) roundDiv1.append(matchContainer); else if (i < 4) roundDiv2.append(matchContainer); else roundDiv3.append(matchContainer); });columnsContainer.append(roundDiv1); columnsContainer.append($("
                                                                                                                                            ").addClass("connector-column")); columnsContainer.append(roundDiv2); columnsContainer.append($("
                                                                                                                                            ").addClass("connector-column")); columnsContainer.append(roundDiv3);groupDiv.append(columnsContainer); groupScrollWrapper.append(groupDiv);const groupNumbers = Object.keys(groups); // make sure 'groups' is defined and validconst importantMatchExists = Object.values(groupMatches) .flat() .some(m => m.is_importantlast === "1");setTimeout(() => { if (importantMatchExists) { const currentGroupNumber = group; const currentIndex = groupNumbers.indexOf(currentGroupNumber); const prevGroupNumber = currentIndex > 0 ? groupNumbers[currentIndex - 1] : null; const lastChecked = true;positionMatcheslast(groupMatches, currentGroupNumber, prevGroupNumber, lastChecked); } positionMatches(groupMatches, group); //waitForLayoutAndDraw(serialMap, 20); waitForLayoutAndDrawStable(serialMap, 20);}, 100);continue; } if (isNineTeam) { allMatches.sort((a, b) => parseInt(a.name) - parseInt(b.name));const displayOrder = [ allMatches[0], // Game 1 - Round 1 allMatches[1], // Game 2 - Round 2 allMatches[2], // Game 3 allMatches[3], // Game 4 allMatches[4], // Game 5 allMatches[5], // Game 6 - Round 3 allMatches[6], // Game 7 allMatches[7] // Game 8 - Round 4 (Final) ];let roundDiv1 = $("
                                                                                                                                            ").addClass("round").attr("data-column", columns[0]); let roundDiv2 = $("
                                                                                                                                            ").addClass("round").attr("data-column", columns[1]); let roundDiv3 = $("
                                                                                                                                            ").addClass("round").attr("data-column", columns[2]); let roundDiv4 = $("
                                                                                                                                            ").addClass("round").attr("data-column", columns[3]);displayOrder.forEach((match, i) => { const serial = groupSerialCounter++; const matchId = `match-serial-${group}-${serial}`;let matchDiv = $("
                                                                                                                                            ") .addClass("match") .attr("id", matchId) .attr("data-match-index", match.name);let score1 = match.team1_score ?? "-"; let score2 = match.team2_score ?? "-"; //let team1 = match.team_name1 ?? "Team 1"; //let team2 = match.team_name2 ?? "Team 2"; let team1 = match.source_label_team1 && match.source_label_team1.trim() !== "" ? match.source_label_team1 : (match.team_name1 ?? "Team 1"); let team2 = match.source_label_team2 && match.source_label_team2.trim() !== "" ? match.source_label_team2 : (match.team_name2 ?? "Team 2");let startTime = formatStartDateTime(match.start_date, match.start_time); let location = match.location || "";matchDiv.html(`
                                                                                                                                            ${match.name}
                                                                                                                                            ${startTime}
                                                                                                                                            ${location}
                                                                                                                                            ${team1} ${score1}
                                                                                                                                            ${team2} ${score2}
                                                                                                                                            `);const matchContainer = $("
                                                                                                                                            ").addClass("match-container").css("margin-bottom", "20px"); matchContainer.append(matchDiv);match.serial = serial; if (!groupMatches[match.column_number]) groupMatches[match.column_number] = []; groupMatches[match.column_number].push(match);serialMap[`${group}-${serial}`] = { ...match, group, column: match.column_number, serial };if (i === 0) roundDiv1.append(matchContainer); else if (i >= 1 && i <= 4) roundDiv2.append(matchContainer); else if (i === 5 || i === 6) roundDiv3.append(matchContainer); else if (i === 7) roundDiv4.append(matchContainer); });columnsContainer.append(roundDiv1); columnsContainer.append($("
                                                                                                                                            ").addClass("connector-column")); columnsContainer.append(roundDiv2); columnsContainer.append($("
                                                                                                                                            ").addClass("connector-column")); columnsContainer.append(roundDiv3); columnsContainer.append($("
                                                                                                                                            ").addClass("connector-column")); columnsContainer.append(roundDiv4);groupDiv.append(columnsContainer); groupScrollWrapper.append(groupDiv);const groupNumbers = Object.keys(groups); // make sure 'groups' is defined and validconst importantMatchExists = Object.values(groupMatches) .flat() .some(m => m.is_importantlast === "1");setTimeout(() => { if (importantMatchExists) { const currentGroupNumber = group; const currentIndex = groupNumbers.indexOf(currentGroupNumber); const prevGroupNumber = currentIndex > 0 ? groupNumbers[currentIndex - 1] : null; const lastChecked = true;positionMatcheslast(groupMatches, currentGroupNumber, prevGroupNumber, lastChecked); } positionMatches(groupMatches, group); //waitForLayoutAndDraw(serialMap, 20); waitForLayoutAndDrawStable(serialMap, 20);}, 100);continue; }if (isTenTeam) { allMatches.sort((a, b) => parseInt(a.name) - parseInt(b.name)); console.log("10-team allMatches:", allMatches.map(m => ({ name: m.name, id: m.id, column: m.column_number })));// Custom display order: Round 2 is visually reordered // Custom display order: Round 2 is visually reordered const displayOrder = [ allMatches[0], allMatches[1], // Round 1: Match 36, 37 allMatches[2], allMatches[3], allMatches[4], allMatches[5], // Round 2: Matches 3, 4, 5, 6 (in order) allMatches[6], allMatches[7], // Round 3: Matches 42–43 allMatches[8] // Final: Match 44 ];let roundDiv1 = $("
                                                                                                                                            ").addClass("round").attr("data-column", columns[0]); let roundDiv2 = $("
                                                                                                                                            ").addClass("round").attr("data-column", columns[1]); let roundDiv3 = $("
                                                                                                                                            ").addClass("round").attr("data-column", columns[2]); let roundDiv4 = $("
                                                                                                                                            ").addClass("round").attr("data-column", columns[3]);displayOrder.forEach((match, i) => { const serial = groupSerialCounter++; const matchId = `match-serial-${group}-${serial}`;let matchDiv = $("
                                                                                                                                            ") .addClass("match") .attr("id", matchId) .attr("data-match-index", match.name);let score1 = match.team1_score ?? "-"; let score2 = match.team2_score ?? "-"; //let team1 = match.team_name1 ?? "Team 1"; //let team2 = match.team_name2 ?? "Team 2"; let team1 = match.source_label_team1 && match.source_label_team1.trim() !== "" ? match.source_label_team1 : (match.team_name1 ?? "Team 1"); let team2 = match.source_label_team2 && match.source_label_team2.trim() !== "" ? match.source_label_team2 : (match.team_name2 ?? "Team 2");let startTime = formatStartDateTime(match.start_date, match.start_time); let location = match.location || "";matchDiv.html(`
                                                                                                                                            ${match.name}
                                                                                                                                            ${startTime}
                                                                                                                                            ${location}
                                                                                                                                            ${team1} ${score1}
                                                                                                                                            ${team2} ${score2}
                                                                                                                                            `);const matchContainer = $("
                                                                                                                                            ") .addClass("match-container") .css("margin-bottom", "20px"); // ← add spacing between matchesmatchContainer.append(matchDiv);match.serial = serial; if (!groupMatches[match.column_number]) groupMatches[match.column_number] = []; groupMatches[match.column_number].push(match);serialMap[`${group}-${serial}`] = { ...match, group, column: match.column_number, serial };if (i < 2) roundDiv1.append(matchContainer); // Round 1 else if (i >= 2 && i <= 5) { // Force desired visual order for Round 2: Matches 38, 39, 40, 41 // Map i to visual index: 2→0, 3→1, 4→2, 5→3 const round2Order = [2, 3, 4, 5]; const targetIndex = round2Order.indexOf(i);if (targetIndex !== -1) { const container = roundDiv2.find(".match-container").eq(targetIndex); if (container.length) { container.before(matchContainer); } else { roundDiv2.append(matchContainer); } } }else if (i < 8) roundDiv3.append(matchContainer); // Round 3 else roundDiv4.append(matchContainer); // Final });columnsContainer.append(roundDiv1); columnsContainer.append($("
                                                                                                                                            ").addClass("connector-column")); columnsContainer.append(roundDiv2); columnsContainer.append($("
                                                                                                                                            ").addClass("connector-column")); columnsContainer.append(roundDiv3); columnsContainer.append($("
                                                                                                                                            ").addClass("connector-column")); columnsContainer.append(roundDiv4);groupDiv.append(columnsContainer); groupScrollWrapper.append(groupDiv);const groupNumbers = Object.keys(groups); // make sure 'groups' is defined and validconst importantMatchExists = Object.values(groupMatches) .flat() .some(m => m.is_importantlast === "1");setTimeout(() => { if (importantMatchExists) { const currentGroupNumber = group; const currentIndex = groupNumbers.indexOf(currentGroupNumber); const prevGroupNumber = currentIndex > 0 ? groupNumbers[currentIndex - 1] : null; const lastChecked = true;positionMatcheslast(groupMatches, currentGroupNumber, prevGroupNumber, lastChecked); } positionMatches(groupMatches, group); //waitForLayoutAndDraw(serialMap, 20); waitForLayoutAndDrawStable(serialMap, 20);}, 100);continue; }if (isFiveTeam) { allMatches.sort((a, b) => parseInt(a.name) - parseInt(b.name)); const displayOrder = [allMatches[0], allMatches[2], allMatches[1], allMatches[3]]; groupMatches[columns[0]] = [allMatches[0]]; groupMatches[columns[1]] = [allMatches[2], allMatches[1]]; groupMatches[columns[2]] = [allMatches[3]]; let roundDiv1 = $("
                                                                                                                                            ").addClass("round").attr("data-column", columns[0]); let roundDiv2 = $("
                                                                                                                                            ").addClass("round").attr("data-column", columns[1]); let roundDiv3 = $("
                                                                                                                                            ").addClass("round").attr("data-column", columns[2]); displayOrder.forEach((match, i) => { const serial = groupSerialCounter++; const matchId = `match-serial-${group}-${serial}`; let matchDiv = $("
                                                                                                                                            ") .addClass("match") .attr("id", matchId) .attr("data-match-index", match.name);let score1 = match.team1_score ?? "-"; let score2 = match.team2_score ?? "-"; //let team1 = match.team_name1 ?? "Team 1"; //let team2 = match.team_name2 ?? "Team 2"; let team1 = match.source_label_team1 && match.source_label_team1.trim() !== "" ? match.source_label_team1 : (match.team_name1 ?? "Team 1"); let team2 = match.source_label_team2 && match.source_label_team2.trim() !== "" ? match.source_label_team2 : (match.team_name2 ?? "Team 2");let startTime = formatStartDateTime(match.start_date, match.start_time); let location = match.location || "";matchDiv.html(`
                                                                                                                                            ${match.name}
                                                                                                                                            ${startTime}
                                                                                                                                            ${location}
                                                                                                                                            ${team1} ${score1}
                                                                                                                                            ${team2} ${score2}
                                                                                                                                            `); const matchContainer = $("
                                                                                                                                            ").addClass("match-container"); matchContainer.append(matchDiv);match.serial = serial; serialMap[`${group}-${serial}`] = { ...match, group, column: match.column_number, serial };if (i === 0) roundDiv1.append(matchContainer); else if (i === 1 || i === 2) roundDiv2.append(matchContainer); else if (i === 3) roundDiv3.append(matchContainer); });columnsContainer.append(roundDiv1); columnsContainer.append($("
                                                                                                                                            ").addClass("connector-column")); columnsContainer.append(roundDiv2); columnsContainer.append($("
                                                                                                                                            ").addClass("connector-column")); columnsContainer.append(roundDiv3);groupDiv.append(columnsContainer); groupScrollWrapper.append(groupDiv);const groupNumbers = Object.keys(groups); // make sure 'groups' is defined and validconst importantMatchExists = Object.values(groupMatches) .flat() .some(m => m.is_importantlast === "1");setTimeout(() => { if (importantMatchExists) { const currentGroupNumber = group; const currentIndex = groupNumbers.indexOf(currentGroupNumber); const prevGroupNumber = currentIndex > 0 ? groupNumbers[currentIndex - 1] : null; const lastChecked = true;positionMatcheslast(groupMatches, currentGroupNumber, prevGroupNumber, lastChecked); } positionMatches(groupMatches, group); //waitForLayoutAndDraw(serialMap, 20); waitForLayoutAndDrawStable(serialMap, 20);}, 100);continue; }if (isSevenTeam) { allMatches.sort((a, b) => parseInt(a.name) - parseInt(b.name));const displayOrder = [ allMatches[0], // Match 1 allMatches[1], // Match 2 allMatches[2], // Match 3 allMatches[3], // Match 4 allMatches[4], // Match 5 allMatches[5] // Match 6 ];// Use only the first 3 columns for layout let roundDiv1 = $("
                                                                                                                                            ").addClass("round").attr("data-column", columns[0]); let roundDiv2 = $("
                                                                                                                                            ").addClass("round").attr("data-column", columns[1]); let roundDiv3 = $("
                                                                                                                                            ").addClass("round").attr("data-column", columns[2]);displayOrder.forEach((match, i) => { const serial = groupSerialCounter++; const matchId = `match-serial-${group}-${serial}`;let matchDiv = $("
                                                                                                                                            ") .addClass("match") .attr("id", matchId) .attr("data-match-index", match.name);let score1 = match.team1_score ?? "-"; let score2 = match.team2_score ?? "-"; //let team1 = match.team_name1 ?? "Team 1"; //let team2 = match.team_name2 ?? "Team 2"; let team1 = match.source_label_team1 && match.source_label_team1.trim() !== "" ? match.source_label_team1 : (match.team_name1 ?? "Team 1"); let team2 = match.source_label_team2 && match.source_label_team2.trim() !== "" ? match.source_label_team2 : (match.team_name2 ?? "Team 2");let startTime = formatStartDateTime(match.start_date, match.start_time); let location = match.location || "";matchDiv.html(`
                                                                                                                                            ${match.name}
                                                                                                                                            ${startTime}
                                                                                                                                            ${location}
                                                                                                                                            ${team1} ${score1}
                                                                                                                                            ${team2} ${score2}
                                                                                                                                            `);const matchContainer = $("
                                                                                                                                            ").addClass("match-container"); matchContainer.append(matchDiv);match.serial = serial; if (!groupMatches["1"]) groupMatches["1"] = []; groupMatches["1"].push(match); serialMap[`${group}-${serial}`] = { ...match, group, column: match.column_number, serial };if (i < 3) { roundDiv1.append(matchContainer); // Matches 0,1,2 } else if (i < 5) { roundDiv2.append(matchContainer); // Matches 3,4 } else { roundDiv3.append(matchContainer); // Match 5 }});columnsContainer.append(roundDiv1); columnsContainer.append($("
                                                                                                                                            ").addClass("connector-column")); columnsContainer.append(roundDiv2); columnsContainer.append($("
                                                                                                                                            ").addClass("connector-column")); columnsContainer.append(roundDiv3);groupDiv.append(columnsContainer); groupScrollWrapper.append(groupDiv);const groupNumbers = Object.keys(groups); // make sure 'groups' is defined and validconst importantMatchExists = Object.values(groupMatches) .flat() .some(m => m.is_importantlast === "1");setTimeout(() => { if (importantMatchExists) { const currentGroupNumber = group; const currentIndex = groupNumbers.indexOf(currentGroupNumber); const prevGroupNumber = currentIndex > 0 ? groupNumbers[currentIndex - 1] : null; const lastChecked = true;positionMatcheslast(groupMatches, currentGroupNumber, prevGroupNumber, lastChecked); } positionMatches(groupMatches, group); //waitForLayoutAndDraw(serialMap, 20); waitForLayoutAndDrawStable(serialMap, 20);}, 100);continue; } columns.forEach((column, columnIndex) => { groups[group][column].sort((a, b) => parseInt(a.name) - parseInt(b.name)); let roundDiv = $("
                                                                                                                                            ").addClass("round").attr("data-column", column); groupMatches[column] = [];groups[group][column].forEach(match => { const serial = groupSerialCounter++; const matchId = `match-serial-${group}-${serial}`;let matchDiv = $("
                                                                                                                                            ") .addClass("match") .attr("id", matchId) .attr("data-match-index", match.name);let score1 = match.team1_score ?? "-"; let score2 = match.team2_score ?? "-"; //let team1 = match.team_name1 ?? "Team 1"; //let team2 = match.team_name2 ?? "Team 2"; let team1 = match.source_label_team1 && match.source_label_team1.trim() !== "" ? match.source_label_team1 : (match.team_name1 ?? "Team 1"); let team2 = match.source_label_team2 && match.source_label_team2.trim() !== "" ? match.source_label_team2 : (match.team_name2 ?? "Team 2"); let startTime = formatStartDateTime(match.start_date, match.start_time); let location = match.location || "";matchDiv.html(`
                                                                                                                                            ${match.name}
                                                                                                                                            ${startTime}
                                                                                                                                            ${location}
                                                                                                                                            ${team1} ${score1}
                                                                                                                                            ${team2} ${score2}
                                                                                                                                            `);const matchContainer = $("
                                                                                                                                            ").addClass("match-container"); matchContainer.append(matchDiv); roundDiv.append(matchContainer);match.serial = serial; serialMap[`${group}-${serial}`] = { ...match, group, column, serial };groupMatches[column].push(match); });columnsContainer.append(roundDiv); if (columnIndex < columns.length - 1) { columnsContainer.append($("
                                                                                                                                            ").addClass("connector-column")); } });groupDiv.append(columnsContainer); groupScrollWrapper.append(groupDiv);const groupNumbers = Object.keys(groups); // make sure 'groups' is defined and validconst importantMatchExists = Object.values(groupMatches) .flat() .some(m => m.is_importantlast === "1");setTimeout(() => { if (importantMatchExists) { const currentGroupNumber = group; const currentIndex = groupNumbers.indexOf(currentGroupNumber); const prevGroupNumber = currentIndex > 0 ? groupNumbers[currentIndex - 1] : null; const lastChecked = true;positionMatcheslast(groupMatches, currentGroupNumber, prevGroupNumber, lastChecked); }positionMatches(groupMatches, group); //waitForLayoutAndDraw(serialMap, 20); waitForLayoutAndDrawStable(serialMap, 20); }, 100);}bracketDiv.append(groupScrollWrapper);const observer = new MutationObserver(() => { const visible = $(".bracket_wrapper:visible").length > 0; if (visible) { setTimeout(() => { //waitForLayoutAndDraw(window._lastSerialMap || {}, 20); waitForLayoutAndDrawStable(window._lastSerialMap || {}, 20);}, 100); } });observer.observe(document.body, { childList: true, subtree: true }); window.globalSerialMap = serialMap; } function isElementVisible(el) { if (!el) return false; const style = window.getComputedStyle(el); const rect = el.getBoundingClientRect();return ( style.display !== 'none' && style.visibility !== 'hidden' && style.opacity !== '0' && rect.width > 0 && rect.height > 0 && document.body.contains(el) ); }function positionMatcheslast(groupMatches, group, prevGroupNumber, isLastCheckboxChecked = false) { if (!isLastCheckboxChecked) { // If checkbox not checked, hide and clear SVG just in case const existingSvg = document.getElementById('global-connector-svg'); if (existingSvg) { existingSvg.style.display = 'none'; while (existingSvg.firstChild) existingSvg.removeChild(existingSvg.firstChild); console.log("❌ Checkbox not checked — hiding SVG and clearing lines."); } return; }const prevGroup = document.querySelector(`.group[data-group="${prevGroupNumber}"]`); const currGroup = document.querySelector(`.group[data-group="${group}"]`);let svg = document.getElementById('global-connector-svg'); if (!svg) { svg = document.createElementNS("http://www.w3.org/2000/svg", "svg"); svg.id = 'global-connector-svg'; svg.style.position = 'absolute'; svg.style.top = '0'; svg.style.left = '0'; svg.style.zIndex = '9999'; svg.style.pointerEvents = 'none'; document.body.appendChild(svg); console.log("📦 Created global SVG container with id='global-connector-svg'"); }// Always update size svg.style.width = document.documentElement.scrollWidth + 'px'; svg.style.height = document.documentElement.scrollHeight + 'px';if (isElementVisible(prevGroup) && isElementVisible(currGroup)) { const prevRect = prevGroup.getBoundingClientRect(); const currRect = currGroup.getBoundingClientRect();const prevPos = { x: prevRect.left + window.scrollX + prevRect.width, y: prevRect.top + window.scrollY + prevRect.height / 2 };const currPos = { x: currRect.left + window.scrollX, y: currRect.top + window.scrollY + currRect.height / 2 };// Clear old lines while (svg.firstChild) { svg.removeChild(svg.firstChild); }// Draw new line const line = document.createElementNS("http://www.w3.org/2000/svg", "line"); line.setAttribute("x1", prevPos.x); line.setAttribute("y1", prevPos.y); line.setAttribute("x2", currPos.x); line.setAttribute("y2", currPos.y); line.setAttribute("stroke", "#999"); line.setAttribute("stroke-width", "2");svg.appendChild(line);svg.style.display = 'block'; // show SVG console.log("✅ Line appended to global SVG and SVG shown"); } else { // No visible groups → clear and hide SVG while (svg.firstChild) { svg.removeChild(svg.firstChild); } svg.style.display = 'none'; console.warn("⚠️ One or both group elements are hidden or missing — hiding SVG"); } }function formatStartDateTime(start_date, start_time) { // Check for null, undefined, or empty values if (!start_date || !start_time || typeof start_time !== 'string' || !start_time.includes(' ')) { return ""; }const timePart = start_time.split(' ')[1]; if (!timePart) return "";const timeObj = new Date(`1970-01-01T${timePart}`); if (isNaN(timeObj.getTime())) { return ""; }// Convert start_date from "YYYY-MM-DD" to "MM/DD/YYYY" const [year, month, day] = start_date.split('-'); if (!year || !month || !day) return "";const formattedDate = `${month}/${day}/${year}`;const timeFormatted = timeObj.toLocaleTimeString('en-US', { hour: '2-digit', minute: '2-digit', hour12: true, // 24-hour format });return `${formattedDate} ${timeFormatted} EST`; }function positionMatches(groupMatches, group) { const levels = Object.keys(groupMatches).sort((a, b) => +a - +b); const matchCenters = {}; const spacing = 200; let bottomMost = 0; const totalMatches = Object.values(groupMatches).flat().length; const isFiveTeamLayout = totalMatches === 4; const isSixTeamLayout = totalMatches === 5; const isSevenTeamLayout = totalMatches === 6; const isTenTeamLayout = totalMatches === 9; const isNineTeamLayout = totalMatches === 8; const isTwelveTeamLayout = totalMatches === 11;if (isTwelveTeamLayout) { const serialPositions = { 1: 200, // Round 1 2: 400, 3: 600, 4: 800, 5: 100, 6: 300, // Quarterfinals 7: 500, 8: 700, 9: 200, 10: 600, // Semifinal 1 11: 400 // Final };// Position matches Object.keys(serialPositions).forEach((serialStr) => { const serial = parseInt(serialStr); const $match = $(`#match-serial-${group}-${serial}`).closest(".match-container"); if ($match.length) { const y = serialPositions[serial]; $match.css({ position: "absolute", top: `${y}px` }); matchCenters[serial] = y + $match.outerHeight() / 2; bottomMost = Math.max(bottomMost, y + $match.outerHeight()); } });// Draw connector lines (you may need to tweak based on actual match setup) drawConnectorLine(group, 1, 5, 'left', 'bottom'); drawConnectorLine(group, 2, 6, 'left', 'bottom'); drawConnectorLine(group, 3, 7, 'left', 'bottom'); drawConnectorLine(group, 4, 8, 'left', 'bottom'); drawConnectorLine(group, 5, 9, 'right', 'top'); drawConnectorLine(group, 6, 9, 'right', 'bottom'); drawConnectorLine(group, 7, 10, 'right', 'top'); drawConnectorLine(group, 8, 10, 'right', 'bottom'); drawConnectorLine(group, 9, 11, 'right', 'top'); drawConnectorLine(group, 10, 11, 'right', 'bottom'); drawChampionLine(group, 11);$(`.group[data-group="${group}"]`).css("height", `${bottomMost + 250}px`); return; }if (isNineTeamLayout) { const serialPositions = { 1: 200, // Game 1 (Round 1) 2: 100, // Game 2 (Round 2) 3: 300, // Game 3 4: 500, // Game 4 5: 700, // Game 5 6: 200, // Game 6 (Round 3) 7: 600, // Game 7 8: 400 // Game 8 (Final) };[1, 2, 3, 4, 5, 6, 7, 8].forEach((serial) => { const $match = $(`#match-serial-${group}-${serial}`).closest(".match-container"); if ($match.length) { const y = serialPositions[serial]; $match.css({ position: "absolute", top: `${y}px` }); matchCenters[serial] = y + $match.outerHeight() / 2; bottomMost = Math.max(bottomMost, y + $match.outerHeight()); } }); // Draw connector lines based on logical flow drawConnectorLine(group, 1, 2); // Game 1 → Game 2 drawConnectorLine(group, 2, 6); // Game 2 → Game 6 drawConnectorLine(group, 3, 6); // Game 3 → Game 6 drawConnectorLine(group, 4, 7); // Game 4 → Game 7 drawConnectorLine(group, 5, 7); // Game 5 → Game 7 drawConnectorLine(group, 6, 8); // Game 6 → Game 8 drawConnectorLine(group, 7, 8); // Game 7 → Game 8 drawChampionLine(group, 8);bottomMost = 0; [1, 2, 3, 4, 5, 6, 7, 8].forEach((serial) => { const $match = $(`#match-serial-${group}-${serial}`).closest(".match-container"); if ($match.length) { const y = serialPositions[serial]; $match.css({ position: "absolute", top: `${y}px` }); matchCenters[serial] = y + $match.outerHeight() / 2; bottomMost = Math.max(bottomMost, y + $match.outerHeight()); } }); drawChampionLine(group, 8); // Apply accurate height to container $(`.group[data-group="${group}"]`).css("height", `${bottomMost + 250}px`); return; }// Ten Team Layout if (isTenTeamLayout) { const serialPositions = { 1: 200, 2: 600, 3: 100, 4: 300, 5: 500, 6: 700, 7: 200, 8: 600, 9: 400 };// Loop through matches 1 to 9 to set positions [1, 2, 3, 4, 5, 6, 7, 8, 9].forEach((serial) => { const $match = $(`#match-serial-${group}-${serial}`).closest(".match-container"); if ($match.length) { const y = serialPositions[serial]; $match.css({ position: "absolute", top: `${y}px` }); matchCenters[serial] = y + $match.outerHeight() / 2; bottomMost = Math.max(bottomMost, y + $match.outerHeight()); } });// Draw connector lines for Round 1, 2, and 3 drawConnectorLine(group, 1, 3, 'left', 'bottom'); drawConnectorLine(group, 2, 5, 'left', 'bottom'); drawConnectorLine(group, 3, 7, 'right', 'top'); drawConnectorLine(group, 4, 7, 'right', 'bottom'); drawConnectorLine(group, 5, 8, 'right', 'top'); drawConnectorLine(group, 6, 8, 'right', 'bottom'); drawConnectorLine(group, 7, 9, 'right', 'top'); drawConnectorLine(group, 8, 9, 'right', 'bottom'); drawChampionLine(group, 9);bottomMost = 0; [1, 2, 3, 4, 5, 6, 7, 8, 9].forEach((serial) => { const $match = $(`#match-serial-${group}-${serial}`).closest(".match-container"); if ($match.length) { const y = serialPositions[serial]; $match.css({ position: "absolute", top: `${y}px` }); matchCenters[serial] = y + $match.outerHeight() / 2; bottomMost = Math.max(bottomMost, y + $match.outerHeight()); } }); drawChampionLine(group, 9); $(`.group[data-group="${group}"]`).css("height", `${bottomMost + 250}px`); return; } if (isSevenTeamLayout) { const matchCenters = {}; let bottomMost = 0;// More generous vertical spacing between 1 → 2 → 3 (adjusted for more matches) const serialPositions = { 1: 0, // Match 1 at the top 2: 180, // Match 2 below Match 1 3: 400, // Match 3 below Match 2 4: 620, // Match 4 below Match 3 (between 1 & 2) 5: 840, // Match 5 below Match 4 (between 2 & 3) 6: 1060, // Match 6 below Match 5 (between 4 & 5) 7: 1280 // Match 7 at the bottom (below Match 6) };// Position Matches 1–7 (Play-ins) [1, 2, 3, 4, 5, 6, 7].forEach((serial) => { const $match = $(`#match-serial-${group}-${serial}`).closest(".match-container"); if ($match.length) { const y = serialPositions[serial]; $match.css({ position: "absolute", top: `${y}px` }); matchCenters[serial] = y + $match.outerHeight() / 2; bottomMost = Math.max(bottomMost, y + $match.outerHeight()); } }); console.log('Height1'+bottomMost); // Adjust positions for the additional matches if necessary: // Match 4: between 1 & 2 (Positioned earlier in `serialPositions`) const $match4 = $(`#match-serial-${group}-4`).closest(".match-container"); if ($match4.length) { const centerY = (matchCenters[1] + matchCenters[2]) / 2 - $match4.outerHeight() / 2; $match4.css({ position: "absolute", top: `${centerY}px` }); matchCenters[4] = centerY + $match4.outerHeight() / 2; bottomMost = Math.max(bottomMost, centerY + $match4.outerHeight()); }// Match 5: between 2 and 3 — center with slight right offset const $match5 = $(`#match-serial-${group}-5`).closest(".match-container"); if ($match5.length && matchCenters[2] && matchCenters[3]) { const centerY = (matchCenters[2] + matchCenters[3]) / 2 - $match5.outerHeight() / 2; const rightOffset = 40; // slight offset to center horizontally $match5.css({ position: "absolute", top: `${centerY}px` }); matchCenters[5] = centerY + $match5.outerHeight() / 2; bottomMost = Math.max(bottomMost, centerY + $match5.outerHeight()); }// Match 6: between match 4 and 5, centered to the right const $match6 = $(`#match-serial-${group}-6`).closest(".match-container"); if ($match6.length && matchCenters[4] && matchCenters[5]) { const centerY = (matchCenters[4] + matchCenters[5]) / 2 - $match6.outerHeight() / 2; const rightOffset = 60; // adjust as needed for proper placement $match6.css({ position: "absolute", top: `${centerY}px` }); matchCenters[6] = centerY + $match6.outerHeight() / 2; bottomMost = Math.max(bottomMost, centerY + $match6.outerHeight()); }// Match 7: below match 6, at the bottom-most position const $match7 = $(`#match-serial-${group}-7`).closest(".match-container"); if ($match7.length && matchCenters[6]) { const centerY = matchCenters[6] + 180; // 180px down from match 6 $match7.css({ position: "absolute", top: `${centerY}px` }); matchCenters[7] = centerY + $match7.outerHeight() / 2; bottomMost = Math.max(bottomMost, centerY + $match7.outerHeight()); }// Draw connector lines between matches drawConnectorLine(group, 1, 4); drawConnectorLine(group, 2, 5); drawConnectorLine(group, 3, 5); drawConnectorLine(group, 4, 6); drawConnectorLine(group, 5, 6); drawConnectorLine(group, 6, 7); // Adding connector line for Match 7 drawChampionLine(group, 7);// Set container height based on the bottom-most position // Recalculate actual bottom-most point after all matches are positioned bottomMost = 0; [1, 2, 3, 4, 5, 6, 7].forEach((serial) => { const $match = $(`#match-serial-${group}-${serial}`).closest(".match-container"); if ($match.length) { const top = parseFloat($match.css("top")) || 0; const height = $match.outerHeight() || 0; bottomMost = Math.max(bottomMost, top + height); } }); // Apply accurate height to container drawChampionLine(group, 6); $(`.group[data-group="${group}"]`).css("height", `${bottomMost + 250}px`); return; } if (isSixTeamLayout) { const serialPositions = { 1: 225, // Game 1 2: 400, // Game 2 3: 100, // Game 3 (Winner G1 vs Team 5) 4: 525, // Game 4 (Winner G2 vs Team 6) 5: 300 // Game 5 (Final) };[1, 2, 3, 4, 5].forEach((serial) => { const $match = $(`#match-serial-${group}-${serial}`).closest(".match-container"); if ($match.length) { const y = serialPositions[serial]; $match.css({ position: "absolute", top: `${y}px` }); matchCenters[serial] = y + $match.outerHeight() / 2; bottomMost = Math.max(bottomMost, y + $match.outerHeight()); } });// Draw correct connector lines //drawConnectorLine(group, 1, 3, 'right', 'top'); //drawConnectorLine(group, 2, 4, 'right', 'bottom'); //drawConnectorLine(group, 3, 5, 'right', 'top'); //drawConnectorLine(group, 4, 5, 'right', 'bottom');// Adjust container height bottomMost = 0; [1, 2, 3, 4, 5].forEach((serial) => { const $match = $(`#match-serial-${group}-${serial}`).closest(".match-container"); if ($match.length) { const top = parseFloat($match.css("top")) || 0; const height = $match.outerHeight() || 0; bottomMost = Math.max(bottomMost, top + height); } }); drawChampionLine(group, 5); $(`.group[data-group="${group}"]`).css("height", `${bottomMost + 250}px`); return; }// Helper function function drawConnectorLine(group, fromSerial, toSerial) { const fromEl = $(`#match-serial-${group}-${fromSerial}`).closest(".match-container"); const toEl = $(`#match-serial-${group}-${toSerial}`).closest(".match-container");if (!fromEl.length || !toEl.length) { console.warn(`Cannot draw line: from ${fromSerial} or to ${toSerial} not found.`); return; }const $group = $(`.group[data-group="${group}"]`); const $svg = $group.find("svg.connector-layer");if (!$svg.length) { console.warn(`Missing SVG layer in group ${group}`); return; }const fromOffset = fromEl.position(); const toOffset = toEl.position();const fromX = fromEl.position().left + fromEl.outerWidth(); const fromY = fromOffset.top + fromEl.outerHeight() / 2; const toX = toEl.position().left; const toY = toOffset.top + toEl.outerHeight() / 2;const line = document.createElementNS("http://www.w3.org/2000/svg", "line"); line.setAttribute("x1", fromX); line.setAttribute("y1", fromY); line.setAttribute("x2", toX); line.setAttribute("y2", toY); line.setAttribute("stroke", "#333"); line.setAttribute("stroke-width", "2");$svg.append(line); }// Positioning for 5-team layout if (isFiveTeamLayout) { const serialPositions = { 1: 200, // First round (Play-in) 3: 80, // Semifinal 1 (top) 2: 320, // Semifinal 2 (bottom) 4: 200 // Final (centered between semi 1 and 2) };Object.entries(groupMatches).forEach(([level, matches]) => { matches.forEach((match) => { const matchId = `match-serial-${group}-${match.serial}`; const $el = $(`#${matchId}`).closest(".match-container");if (!$el.length) return;const y = serialPositions[match.serial] ?? 0; $el.css({ position: "absolute", top: `${y}px` });matchCenters[match.serial] = y + $el.outerHeight() / 2; bottomMost = Math.max(bottomMost, y + $el.outerHeight()); }); }); drawChampionLine(group, 4); $(`.group[data-group="${group}"]`).css("height", bottomMost + 160); return; }// Default layout for other brackets levels.forEach((level, levelIndex) => { const matches = groupMatches[level];matches.forEach((match, i) => { const matchId = `match-serial-${group}-${match.serial}`; const $el = $(`#${matchId}`).closest(".match-container");if (!$el.length) return;if (levelIndex === 0) { const pairIndex = Math.floor(i / 2); const y = i * spacing + pairIndex * 40; $el.css({ position: "absolute", top: `${y}px` }); matchCenters[match.serial] = y + $el.outerHeight() / 2; bottomMost = Math.max(bottomMost, y + $el.outerHeight()); } else { const prevLevel = levels[levelIndex - 1]; const prevMatches = groupMatches[prevLevel]; const prev1 = prevMatches[i * 2]; const prev2 = prevMatches[i * 2 + 1];if (prev1 && prev2) { const center1 = matchCenters[prev1.serial]; const center2 = matchCenters[prev2.serial]; const centerY = (center1 + center2) / 2; const topOffset = centerY - $el.outerHeight() / 2; $el.css({ position: "absolute", top: `${topOffset}px` }); matchCenters[match.serial] = centerY; bottomMost = Math.max(bottomMost, topOffset + $el.outerHeight()); } } }); });$(`.group[data-group="${group}"]`).css("height", bottomMost + 180); const lastLevel = levels[levels.length - 1]; const lastMatch = groupMatches[lastLevel]?.[0]; if (lastMatch) drawChampionLine(group, lastMatch.serial);} function drawChampionLine(group, finalMatchSerial) { console.log(`drawChampionLine called with group=${group}, finalMatchSerial=${finalMatchSerial}`);const finalMatch = $(`#match-serial-${group}-${finalMatchSerial}`).closest(".match-container"); if (!finalMatch.length) { console.warn("Final match element not found"); return; }const $group = $(`.group[data-group="${group}"]`); let $svg = $group.find("svg.connector-layer");if (!$svg.length) { console.warn(`Missing SVG layer in group ${group}, creating one.`); $svg = $(``); $group.append($svg); }const matchOffset = finalMatch.offset(); const svgOffset = $svg.offset();const matchRightX = matchOffset.left - svgOffset.left + finalMatch.outerWidth(); const matchCenterY = matchOffset.top - svgOffset.top + finalMatch.outerHeight() / 2;const $teams = finalMatch.find(".team-row"); let championName = ""; let highScore = -1;$teams.each(function () { const teamName = $(this).find(".team-name").text().trim(); const score = parseInt($(this).find(".score").text().trim(), 10); if (!isNaN(score) && score > 0 && score > highScore) { highScore = score; championName = teamName; } });if (!championName) { console.warn("Could not determine champion team"); return; }const lowerChampionName = championName.toLowerCase(); const skipKeywords = ["winner", "winner of game"]; const shouldSkip = skipKeywords.some(keyword => lowerChampionName.includes(keyword));if (shouldSkip) { console.log(`Skipping champion line: name "${championName}" includes skip keyword.`); return; }console.log(`Champion team: ${championName} with score ${highScore}`);const svgNS = "http://www.w3.org/2000/svg"; const lineLength = 180; const offsetY = 29; // how much to move everything down from matchCenterYconst lineY = matchCenterY + offsetY;// Draw line const line = document.createElementNS(svgNS, "line"); line.setAttribute("x1", matchRightX); line.setAttribute("y1", lineY); line.setAttribute("x2", matchRightX + lineLength); line.setAttribute("y2", lineY); line.setAttribute("stroke", "#ccc"); line.setAttribute("stroke-width", "2"); $svg.append(line);const centerX = matchRightX + lineLength / 2; // Champion name (above the line) const nameText = document.createElementNS(svgNS, "text"); nameText.setAttribute("x", centerX); nameText.setAttribute("y", lineY - 16); // slightly above the line nameText.setAttribute("text-anchor", "middle"); nameText.setAttribute("font-size", "15px"); nameText.setAttribute("font-weight", "bold"); nameText.setAttribute("fill", "#000"); nameText.setAttribute("style", "text-shadow: 1px 1px 2px #ccc;"); nameText.textContent = `${championName}`; $svg.append(nameText);// "Champion" label (below the line) const championText = document.createElementNS(svgNS, "text"); championText.setAttribute("x", centerX); championText.setAttribute("y", lineY + 26); // slightly below the line championText.setAttribute("text-anchor", "middle"); championText.setAttribute("font-size", "14px"); championText.setAttribute("font-style", "italic"); championText.setAttribute("fill", "#000"); championText.setAttribute("style", "text-shadow: 1px 1px 1px #eee;"); championText.textContent = "Champion"; $svg.append(championText);console.log("Champion line and labels drawn."); }function debounce(func, delay) { let timeout; return function (...args) { clearTimeout(timeout); timeout = setTimeout(() => func.apply(this, args), delay); }; } /* function waitForLayoutAndDraw(serialMap, maxTries = 10) { if (window._isDrawingScheduled) return;window._isDrawingScheduled = true; window._lastSerialMap = serialMap;let tries = 0;function tryDraw() { const wrapper = document.querySelector(".bracket_wrapper");if (!wrapper) { if (tries < maxTries) { tries++; requestAnimationFrame(tryDraw); } else { window._isDrawingScheduled = false; // Reset if failed after all tries } return; }const rect = wrapper.getBoundingClientRect(); if (rect.width < 100 || rect.height < 100) { if (tries < maxTries) { tries++; requestAnimationFrame(tryDraw); } else { window._isDrawingScheduled = false; } return; }// ✅ Only draw once per layout session if (!wrapper.dataset.hasDrawn) { drawBracketConnectors(serialMap, true); wrapper.dataset.hasDrawn = "true"; // 🔽 🔽 Add this block here 🔽 🔽 document.querySelectorAll('.group').forEach(group => { const maxHeight = 900; if (group.offsetHeight > maxHeight && !group.classList.contains('group-scroll')) { group.classList.add('group-scroll'); console.log("✅ group-scroll added to:", group); } }); }// 🟢 Reset the flag after a short time (if needed later) setTimeout(() => { window._isDrawingScheduled = false; wrapper.dataset.hasDrawn = ""; // Allow future redraws if needed }, 1000);const scrollTarget = document.querySelector(".group-scroll-wrapper");if (!scrollTarget.dataset.scrollListenerAdded && window.innerWidth <= 768) { console.log("🟢 Mobile scroll listener added");scrollTarget.addEventListener( "scroll", debounce(() => { console.log("🔁 Scrolling (mobile)"); drawBracketConnectors(window._lastSerialMap, true); }, 2) );scrollTarget.dataset.scrollListenerAdded = "true"; }requestAnimationFrame(tryDraw); }*/ function waitForLayoutAndDraw(serialMap, maxTries = 10) { if (window._isDrawingScheduled) return;window._isDrawingScheduled = true; window._lastSerialMap = serialMap;let tries = 0;function tryDraw() { const wrapper = document.querySelector(".bracket_wrapper");if (!wrapper) { if (tries < maxTries) { tries++; requestAnimationFrame(tryDraw); } else { window._isDrawingScheduled = false; } return; }const rect = wrapper.getBoundingClientRect(); if (rect.width < 100 || rect.height < 100) { if (tries < maxTries) { tries++; requestAnimationFrame(tryDraw); } else { window._isDrawingScheduled = false; } return; }// ✅ Draw once per layout if (!wrapper.dataset.hasDrawn) { drawBracketConnectors(serialMap, true); wrapper.dataset.hasDrawn = "true";document.querySelectorAll(".group").forEach(group => { const maxHeight = 900; if (group.offsetHeight > maxHeight && !group.classList.contains("group-scroll")) { group.classList.add("group-scroll"); console.log("✅ group-scroll added to:", group); } }); }// 🟢 Reset draw flag after timeout setTimeout(() => { window._isDrawingScheduled = false; wrapper.dataset.hasDrawn = ""; }, 1000);// ✅ ADD SCROLL LISTENER FOR MOBILE ONLY console.log("Window width:", window.innerWidth); // Inside tryDraw() const scrollTarget = document.querySelector(".group-scroll-wrapper");if (!scrollTarget.dataset.scrollListenerAdded && window.innerWidth <= 768) { console.log("🟢 Mobile scroll listener added");scrollTarget.addEventListener( "scroll", debounce(() => { console.log("🔁 Scrolling (mobile)"); drawBracketConnectors(window._lastSerialMap, true); }, 2) );scrollTarget.dataset.scrollListenerAdded = "true"; }}requestAnimationFrame(tryDraw); }function waitForLayoutAndDrawStable(serialMap, maxTries = 10) { let tries = 0;function attempt() { const wrapper = document.querySelector(".bracket_wrapper"); const groupReady = Array.from(document.querySelectorAll(".group")).every(el => el.offsetHeight > 200);if (!groupReady && tries < maxTries) { tries++; return setTimeout(attempt, 100); // Wait for layout }waitForLayoutAndDraw(serialMap); // ⬅️ Only call once layout is stable }attempt(); } function drawBracketConnectors(serialMap, forceRedraw = false) { console.log("Ketan test"); const svgNS = "http://www.w3.org/2000/svg"; let svg = document.getElementById("bracket-connector-svg"); const wrapper = document.querySelector(".bracket_wrapper");const wrapperRect = wrapper.getBoundingClientRect(); const scrollLeft = wrapper.scrollLeft; const scrollTop = wrapper.scrollTop;if (!svg) { svg = document.createElementNS(svgNS, "svg"); svg.setAttribute("id", "bracket-connector-svg"); svg.style.position = "absolute"; svg.style.top = "0"; svg.style.left = "0"; svg.style.pointerEvents = "none"; wrapper.appendChild(svg); }svg.style.width = wrapper.scrollWidth + "px"; svg.style.height = wrapper.scrollHeight + "px";const layoutHash = JSON.stringify( Object.values(serialMap).map(m => { const el = document.getElementById(`match-serial-${m.group}-${m.serial}`); const rect = el?.getBoundingClientRect(); return { serial: m.serial, group: m.group, column: m.column, rect: rect ? { top: rect.top, left: rect.left, width: rect.width, height: rect.height } : null }; }) );if (!forceRedraw && window._lastLayoutHash === layoutHash) return; window._lastLayoutHash = layoutHash;while (svg.firstChild) svg.removeChild(svg.firstChild);const groupMap = {}; for (const serial in serialMap) { const match = serialMap[serial]; if (!groupMap[match.group]) groupMap[match.group] = []; groupMap[match.group].push(match); }for (const group in groupMap) { const matches = groupMap[group].sort((a, b) => +a.serial - +b.serial); const matchMap = {};matches.forEach(match => { matchMap[match.serial] = match; match.el = document.getElementById(`match-serial-${group}-${match.serial}`); match.rect = match.el?.getBoundingClientRect(); });const isFiveMatch = matches.length === 4; const isThreeTeam = matches.length === 2 && matchMap["1"] && matchMap["2"]; if ( matches.length === 11 && matchMap["1"] && matchMap["2"] && matchMap["3"] && matchMap["4"] && matchMap["5"] && matchMap["6"] && matchMap["7"] && matchMap["8"] && matchMap["9"] && matchMap["10"] && matchMap["11"] ) { const m = matchMap;// Round 1 → Round 2 drawLConnectorCustom(m[1].rect, m[5].rect, "bottom", 40); drawLConnectorCustom(m[2].rect, m[6].rect, "bottom", 40);drawLConnectorCustom(m[3].rect, m[7].rect, "bottom", 40); drawLConnectorCustom(m[4].rect, m[8].rect, "bottom", 40);// Seeds 1-4 with byes go directly to M7–M10 // Assume M5 feeds M7, M6 feeds M8, and so ondrawLConnectorCustom(m[5].rect, m[9].rect, "top", 40); drawLConnectorCustom(m[6].rect, m[9].rect, "bottom", 40);drawLConnectorCustom(m[7].rect, m[10].rect, "top", 40); // adjust if seed logic differs drawLConnectorCustom(m[8].rect, m[10].rect, "bottom", 40);// Round 2 → Semifinal drawLConnectorCustom(m[9].rect, m[11].rect, "top", 40); drawLConnectorCustom(m[10].rect, m[11].rect, "bottom", 40);continue; }if ( matches.length === 9 && matchMap["1"] && matchMap["2"] && matchMap["3"] && matchMap["4"] && matchMap["5"] && matchMap["6"] && matchMap["7"] && matchMap["8"] && matchMap["9"] ) { const m1 = matchMap[1]; const m2 = matchMap[2]; const m3 = matchMap[3]; const m4 = matchMap[4]; const m5 = matchMap[5]; const m6 = matchMap[6]; const m7 = matchMap[7]; const m8 = matchMap[8]; const m9 = matchMap[9];// Round 1 if (m1?.rect && m5?.rect) drawLConnectorCustom(m1.rect, m3.rect, "bottom", 40); if (m2?.rect && m6?.rect) drawLConnectorCustom(m2.rect, m5.rect, "bottom", 40);// Round 2 if (m3?.rect && m7?.rect) drawLConnectorCustom(m3.rect, m7.rect, "top", 40); if (m4?.rect && m7?.rect) drawLConnectorCustom(m4.rect, m7.rect, "bottom", 40); if (m5?.rect && m8?.rect) drawLConnectorCustom(m5.rect, m8.rect, "top", 40); if (m6?.rect && m8?.rect) drawLConnectorCustom(m6.rect, m8.rect, "bottom", 40);// Round 3 (Final) if (m7?.rect && m9?.rect) drawLConnectorCustom(m7.rect, m9.rect, "top", 40); if (m8?.rect && m9?.rect) drawLConnectorCustom(m8.rect, m9.rect, "bottom", 40);continue; } if (matches.length === 5) { // Adjusted for 5 matches console.log("matches.length === 5", matches); // log matches array console.log("matchMap:", matchMap); // log matchMap objectconst m1 = matchMap[1]; const m2 = matchMap[2]; const m3 = matchMap[3]; const m4 = matchMap[4]; const m5 = matchMap[5]; // Remove m6 because it's not available// Round 1 → Round 2 // M1 → M4 (top) if (m1?.rect && m3?.rect) { console.log("Drawing connector for M1 to M3"); drawLConnectorCustom(m1.rect, m3.rect, "top", 40); }// M2 → M5 (top) if (m2?.rect && m4?.rect) { console.log("Drawing connector for M2 to M4"); drawLConnectorCustom(m2.rect, m4.rect, "top", 40); }// M3 → M5 (bottom) if (m3?.rect && m5?.rect) { console.log("Drawing connector for M3 to M5"); drawLConnectorCustom(m3.rect, m5.rect, "bottom", 40); }// Round 2 → Final // M4 → (no M6, adjust logic based on match availability) if (m4?.rect && m5?.rect) { console.log("Drawing connector for M4 to the final match"); // Draw a connector to the final match (if you have a final setup) // You might have a fallback if there's no M6 drawLConnectorCustom(m4.rect,m5.rect, "top", 40); }continue; // use continue, not return — don't break whole function }if (matches.length === 6 && matchMap["1"] && matchMap["2"] && matchMap["3"] && matchMap["4"] && matchMap["5"] && matchMap["6"]) {const m1 = matchMap[1]; const m2 = matchMap[2]; const m3 = matchMap[3]; const m4 = matchMap[4]; const m5 = matchMap[5]; const m6 = matchMap[6];// Round 1 → Round 2 // M1 → M4 (top) if (m1?.rect && m4?.rect) drawLConnectorCustom(m1.rect, m4.rect, "top", 40);// M2 → M5 (top) if (m2?.rect && m5?.rect) drawLConnectorCustom(m2.rect, m5.rect, "top", 40);// M3 → M5 (bottom) if (m3?.rect && m5?.rect) drawLConnectorCustom(m3.rect, m5.rect, "bottom", 40);// Round 2 → Final // M4 → M6 (top) if (m4?.rect && m6?.rect) drawLConnectorCustom(m4.rect, m6.rect, "top", 40);// M5 → M6 (bottom) if (m5?.rect && m6?.rect) drawLConnectorCustom(m5.rect, m6.rect, "bottom", 40);continue; }if (isThreeTeam) { console.log("This is a testing"); const fromMatch = matchMap[1]; const toMatch = matchMap[2];if (fromMatch?.rect && toMatch?.rect) { drawLConnectorCustom(fromMatch.rect, toMatch.rect, "right", 40); }continue; // only skip current group } /*if (matches.length === 5) { const m1 = matchMap[1], m2 = matchMap[2]; const m3 = matchMap[3], m4 = matchMap[4], m5 = matchMap[5];if (m1?.rect && m4?.rect) drawLConnectorCustom(m1.rect, m4.rect, "top", 40); if (m2?.rect && m4?.rect) drawLConnectorCustom(m2.rect, m4.rect, "bottom", 40); if (m3?.rect && m5?.rect) drawLConnectorCustom(m3.rect, m5.rect, "top", 40); if (m4?.rect && m5?.rect) drawLConnectorCustom(m4.rect, m5.rect, "bottom", 40); }*/if (isFiveMatch) { const s1 = matchMap[1], s2 = matchMap[2], s3 = matchMap[3], s4 = matchMap[4];if (s1?.rect && s3?.rect) drawLConnectorCustom(s1.rect, s2.rect, "top"); if (s2?.rect && s4?.rect) drawLConnectorCustom(s2.rect, s4.rect, "top", 40); if (s3?.rect && s4?.rect) drawLConnectorCustom(s3.rect, s4.rect, "bottom", 80);continue; // use continue, not return — don't break whole function }const columns = [...new Set(matches.map(m => +m.column))].sort((a, b) => a - b);for (let colIndex = 1; colIndex < columns.length; colIndex++) { const currentCol = columns[colIndex]; const prevCol = columns[colIndex - 1];const currentMatches = matches.filter(m => +m.column === currentCol); const prevMatches = matches.filter(m => +m.column === prevCol);for (let i = 0; i < currentMatches.length; i++) { const targetMatch = currentMatches[i]; const input1 = prevMatches[i * 2]; const input2 = prevMatches[i * 2 + 1];if (input1?.rect && input2?.rect && targetMatch?.rect) { drawLConnectorCustom(input1.rect, targetMatch.rect, "top", 40); drawLConnectorCustom(input2.rect, targetMatch.rect, "bottom", 40); } else if ((input1?.rect || input2?.rect) && targetMatch?.rect) { const fromRect = input1?.rect || input2?.rect; const direction = input1?.rect ? "top" : "bottom"; drawLConnectorCustom(fromRect, targetMatch.rect, direction, 40); } } }function drawLConnectorCustom(fromRect, toRect, toPoint = "center", elbowOffset = 40) { const startX = fromRect.right - wrapperRect.left + scrollLeft; const startY = fromRect.top + fromRect.height / 2 - wrapperRect.top + scrollTop;let toY; const headerOffset = 48;if (toPoint === "top") { toY = toRect.top + headerOffset + 10 - wrapperRect.top + scrollTop; } else if (toPoint === "bottom") { toY = toRect.bottom - 10 - wrapperRect.top + scrollTop; } else { toY = toRect.top + toRect.height / 2 - wrapperRect.top + scrollTop; }const endX = toRect.left - wrapperRect.left + scrollLeft + 5;const path = document.createElementNS(svgNS, "path"); path.setAttribute("stroke", "#999"); path.setAttribute("stroke-width", "1.5"); path.setAttribute("fill", "none"); path.setAttribute("stroke-linecap", "round");const d = ` M ${startX},${startY} H ${endX} V ${toY} `;path.setAttribute("d", d.trim().replace(/\s+/g, " ")); svg.appendChild(path); }function drawTConnector(fromRect, toRect) { const startX = fromRect.right - wrapperRect.left + scrollLeft; const startY = fromRect.top + fromRect.height / 2 - wrapperRect.top + scrollTop;const endX = toRect.left - wrapperRect.left + scrollLeft; const endY = toRect.top + toRect.height / 2 - wrapperRect.top + scrollTop; const midX = (startX + endX) / 2;const path1 = document.createElementNS(svgNS, "path"); path1.setAttribute("stroke", "#999"); path1.setAttribute("stroke-width", "1.5"); path1.setAttribute("fill", "none"); path1.setAttribute("stroke-linecap", "round"); path1.setAttribute("d", `M ${startX},${startY} H ${midX}`); svg.appendChild(path1);const path2 = document.createElementNS(svgNS, "path"); path2.setAttribute("stroke", "#999"); path2.setAttribute("stroke-width", "1.5"); path2.setAttribute("fill", "none"); path2.setAttribute("stroke-linecap", "round"); path2.setAttribute("d", `M ${endX},${endY} H ${midX}`); svg.appendChild(path2);const verticalLine = document.createElementNS(svgNS, "path"); verticalLine.setAttribute("stroke", "#999"); verticalLine.setAttribute("stroke-width", "1.5"); verticalLine.setAttribute("fill", "none"); verticalLine.setAttribute("stroke-linecap", "round"); verticalLine.setAttribute("d", `M ${midX},${startY} V ${endY}`); svg.appendChild(verticalLine); }function drawHorizontalConnector(fromRect, toRect) { const startX = fromRect.right - wrapperRect.left + scrollLeft; const startY = fromRect.top + fromRect.height / 2 - wrapperRect.top + scrollTop;const endX = toRect.left - wrapperRect.left + scrollLeft;const path = document.createElementNS(svgNS, "path"); path.setAttribute("stroke", "#999"); path.setAttribute("stroke-width", "1.5"); path.setAttribute("fill", "none"); path.setAttribute("stroke-linecap", "round");const d = `M ${startX},${startY} H ${endX}`; path.setAttribute("d", d.trim().replace(/\s+/g, " ")); svg.appendChild(path); }function drawRightThenVertical(fromRect, toRect, align = "top") { const startX = fromRect.right - wrapperRect.left + scrollLeft; const startY = fromRect.top + fromRect.height / 2 - wrapperRect.top + scrollTop; const elbowX = startX + 40;const toY = align === "top" ? toRect.top - wrapperRect.top + scrollTop : toRect.bottom - wrapperRect.top + scrollTop;const toX = toRect.left - wrapperRect.left + scrollLeft;const path = document.createElementNS(svgNS, "path"); path.setAttribute("stroke", "#888"); path.setAttribute("stroke-width", "4"); path.setAttribute("fill", "none"); path.setAttribute("stroke-linejoin", "round"); path.setAttribute("stroke-linecap", "round");const d = ` M ${startX},${startY} H ${elbowX} V ${toY} H ${toX} `; path.setAttribute("d", d.trim().replace(/\s+/g, " ")); svg.appendChild(path); }function drawLine(from, to) { if (!from?.rect || !to?.rect) return;const x1 = from.rect.right + scrollLeft - wrapperRect.left; const y1 = from.rect.top + from.rect.height / 2 + scrollTop - wrapperRect.top;const x2 = to.rect.left + scrollLeft - wrapperRect.left; const y2 = to.rect.top + to.rect.height / 2 + scrollTop - wrapperRect.top;const midX = (x1 + x2) / 2;const path = document.createElementNS(svgNS, "path"); path.setAttribute("stroke", "#999"); path.setAttribute("stroke-width", "2"); path.setAttribute("fill", "none"); path.setAttribute("d", `M ${x1},${y1} H ${midX} V ${y2} H ${x2}`); svg.appendChild(path); }function drawDefaultConnect(input1, input2, targetMatch) { if (!input1?.rect || !input2?.rect || !targetMatch?.rect) return;const x1 = input1.rect.right + scrollLeft - wrapperRect.left; const y1 = input1.rect.top + input1.rect.height / 2 + scrollTop - wrapperRect.top;const x2 = input2.rect.right + scrollLeft - wrapperRect.left; const y2 = input2.rect.top + input2.rect.height / 2 + scrollTop - wrapperRect.top;const toX = targetMatch.rect.left + scrollLeft - wrapperRect.left; const toY = targetMatch.rect.top + targetMatch.rect.height / 2 + scrollTop - wrapperRect.top;const midX = (x1 + toX) / 2; const midY = (y1 + y2) / 2;const path = document.createElementNS(svgNS, "path"); path.setAttribute("stroke", "#999"); path.setAttribute("stroke-width", "2"); path.setAttribute("fill", "none");const d = ` M ${x1},${y1} H ${midX} M ${x2},${y2} H ${midX} M ${midX},${y1} V ${y2} M ${midX},${midY} H ${toX} `; path.setAttribute("d", d.trim().replace(/\s+/g, ' ')); svg.appendChild(path); } } }
                                                                                                                                            ×

                                                                                                                                            Request for More Info