Skip to content

Commit

Permalink
Ranking: Retain selected teams/contestants upon page refresh
Browse files Browse the repository at this point in the history
  • Loading branch information
ranaldmiao authored and fushar committed Aug 31, 2022
1 parent 8cba28d commit e494acd
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 7 deletions.
8 changes: 3 additions & 5 deletions cmsranking/static/DataStore.js
Original file line number Diff line number Diff line change
Expand Up @@ -722,7 +722,7 @@ var DataStore = new function () {
});

self.create_event_source();
self.init_selections();
self.init_callback();
};

self.update_rank = function (u_id, user) {
Expand Down Expand Up @@ -786,8 +786,8 @@ var DataStore = new function () {
- they also start an AJAX request and process its data
- when BOTH requests finish init_scores() is called
- it does again an AJAX request and processes its data
- at the end it calls init_ranks() which calls init_selections() which,
in turn, calls init_callback()
- at the end it calls init_ranks() which calls init_callback()
- Subsequently, when TeamStore is initialized, we call init_selections().
*/

self.init = function (callback) {
Expand Down Expand Up @@ -1157,8 +1157,6 @@ var DataStore = new function () {
}
}
});

self.init_callback();
};

self.set_selected = function (u_id, flag, color_idx) {
Expand Down
4 changes: 3 additions & 1 deletion cmsranking/static/Ranking.js
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,9 @@ $(document).ready(function() {
HistoryStore.init();
UserDetail.init();
TimeView.init();
TeamSearch.init();
TeamSearch.init(function() {
DataStore.init_selections();
});
Overview.init();
Scoreboard.init();
});
Expand Down
3 changes: 2 additions & 1 deletion cmsranking/static/TeamSearch.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
var TeamSearch = new function () {
var self = this;

self.init = function () {
self.init = function (callback) {
$("#TeamSearch_input").focus(function () {
self.show();
});
Expand Down Expand Up @@ -98,6 +98,7 @@ var TeamSearch = new function () {
self.update();

DataStore.select_events.add(self.select_handler);
callback();
};

self.generate = function () {
Expand Down

0 comments on commit e494acd

Please sign in to comment.