-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add getBrackets function to CTFd.pages.scoreboard and add bracketId a…
…rgument to scoreboard functions
- Loading branch information
Showing
2 changed files
with
22 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,17 +1,33 @@ | ||
import CTFd from "../main"; | ||
|
||
export async function getScoreboard() { | ||
const response = await CTFd.fetch("/api/v1/scoreboard", { | ||
export async function getScoreboard(bracketId = null) { | ||
let url = "/api/v1/scoreboard"; | ||
if (bracketId) { | ||
url = `${url}&bracket_id=${bracketId}`; | ||
} | ||
const response = await CTFd.fetch(url, { | ||
method: "GET", | ||
}); | ||
const body = await response.json(); | ||
return body["data"]; // scoreboard data | ||
} | ||
|
||
export async function getScoreboardDetail(count) { | ||
const response = await CTFd.fetch(`/api/v1/scoreboard/top/${count}`, { | ||
export async function getScoreboardDetail(count, bracketId = null) { | ||
let url = `/api/v1/scoreboard/top/${count}`; | ||
if (bracketId) { | ||
url = `${url}&bracket_id=${bracketId}`; | ||
} | ||
const response = await CTFd.fetch(url, { | ||
method: "GET", | ||
}); | ||
const body = await response.json(); | ||
return body["data"]; // scoreboard data | ||
} | ||
|
||
export async function getBrackets(userMode) { | ||
const response = await CTFd.fetch(`/api/v1/brackets?type=${userMode}`, { | ||
method: "GET", | ||
}); | ||
const body = await response.json(); | ||
return body["data"]; | ||
} |