teijo / jquery-bracket

jQuery Bracket library for organizing single and double elimination tournaments
http://aropupu.fi/bracket/
MIT License
482 stars 253 forks source link

How do I know I've already finished a tournament? #115

Open LuisBarcenas14 opened 7 years ago

LuisBarcenas14 commented 7 years ago

I working with your api for my scholar project and I do not find the way to close automatically a tourney

teijo commented 7 years ago

Unfortunately I don't think there is any straightforward way of knowing that. Depending on the settings and number of participants, the number of matches can change. Quite a nasty hack would be to see if the DOM has the HTML element indicating the winner (the "1st" arrow next to the result box).

You could fork the library and add your own way for indicating the completeness too.

noiwid commented 6 years ago

Hi, Maybe it's a bit late for your project, but I found a way to achieve this that I can share :

1/ In jquery.bracket.min.js, I forced BYE items (empty) to have a specific class: Add this code just before : return void t.append("BYE"); $(t).parent().addClass("byeempty");

2/ In my saveFN function, I add a test fired after every edit that check if all steps are completed, if yes, it do an action (in my case, show a button that allow to record results) var numItems = $('.team').not('.byeempty').not('.lose').not('.win').length; if(numItems==0) $('#saveResults').show(); else $('#saveResults').hide();

Thanks to @teijo for this nice project ! I didn't found the JS unminified, if this is public and you accept to share it, it would be wonderfull!!! :)