File tree 2 files changed +22
-5
lines changed
2 files changed +22
-5
lines changed Original file line number Diff line number Diff line change @@ -12,7 +12,7 @@ import {
12
12
displayUnlock ,
13
13
displayHint ,
14
14
} from "./pages/challenge" ;
15
- import { getScoreboard , getScoreboardDetail } from "./pages/scoreboard" ;
15
+ import { getScoreboard , getScoreboardDetail , getBrackets } from "./pages/scoreboard" ;
16
16
import { updateSettings , generateToken , deleteToken } from "./pages/settings" ;
17
17
import { userSolves , userFails , userAwards } from "./pages/users" ;
18
18
import {
@@ -136,6 +136,7 @@ const pages = {
136
136
scoreboard : {
137
137
getScoreboard,
138
138
getScoreboardDetail,
139
+ getBrackets,
139
140
} ,
140
141
settings : {
141
142
updateSettings,
Original file line number Diff line number Diff line change 1
1
import CTFd from "../main" ;
2
2
3
- export async function getScoreboard ( ) {
4
- const response = await CTFd . fetch ( "/api/v1/scoreboard" , {
3
+ export async function getScoreboard ( bracketId = null ) {
4
+ let url = "/api/v1/scoreboard" ;
5
+ if ( bracketId ) {
6
+ url = `${ url } ?bracket_id=${ bracketId } ` ;
7
+ }
8
+ const response = await CTFd . fetch ( url , {
5
9
method : "GET" ,
6
10
} ) ;
7
11
const body = await response . json ( ) ;
8
12
return body [ "data" ] ; // scoreboard data
9
13
}
10
14
11
- export async function getScoreboardDetail ( count ) {
12
- const response = await CTFd . fetch ( `/api/v1/scoreboard/top/${ count } ` , {
15
+ export async function getScoreboardDetail ( count , bracketId = null ) {
16
+ let url = `/api/v1/scoreboard/top/${ count } ` ;
17
+ if ( bracketId ) {
18
+ url = `${ url } ?bracket_id=${ bracketId } ` ;
19
+ }
20
+ const response = await CTFd . fetch ( url , {
13
21
method : "GET" ,
14
22
} ) ;
15
23
const body = await response . json ( ) ;
16
24
return body [ "data" ] ; // scoreboard data
17
25
}
26
+
27
+ export async function getBrackets ( userMode ) {
28
+ const response = await CTFd . fetch ( `/api/v1/brackets?type=${ userMode } ` , {
29
+ method : "GET" ,
30
+ } ) ;
31
+ const body = await response . json ( ) ;
32
+ return body [ "data" ] ;
33
+ }
You can’t perform that action at this time.
0 commit comments