+ firstFetch: function() {
+ // Fetch most recent problems from server, for both lists
+ this.fetchProblems("others", "bacwkard");
+ this.fetchProblems("mine", "bacwkard");
+ this.listsInitialized = true;
+ },
+ showProblem: function(num) {
+ const pid = num || this.pbNum;
+ location.hash = "#" + pid;
+ const pIdx = this.singletons.findIndex(p => p.id == pid);
+ if (pIdx >= 0)
+ curProb = this.singletons[pIdx];
+ else
+ {
+ // Cannot find problem in current set; get from server, and add to singletons.
+ ajax(
+ "/problems/" + variant.name + "/" + pid, //TODO: use variant._id ?
+ "GET",
+ response => {
+ if (!!response.problem)
+ {
+ this.singletons.push(response.problem);
+ this.curProb = response.problem;
+ }
+ else
+ this.noMoreProblems("Sorry, problem " + pid + " does not exist");
+ }
+ );
+ }