chesstok-lookup/gpt_prompt.txt
2023-11-25 11:44:31 -07:00

30 lines
2.2 KiB
Plaintext

I want to write a simple web app that has the following characteristics and functionality:
1. There is a text box with a submit/download button
2. the user inputs a valid username and presses submit/download
3. The pressing of this button triggers the downloading of a .pgn file to their local machine
There are three main files for the app to work:
1. the .html file
2. the main javascript file
3. the userAgents.js file which holds a list of user agents that will be called in the main javascript file
The following is a simple outline of how the web app should work:
There are 4 main functions:
1. a function that makes a single call one time to one endpoint, `https://api.chess.com/pub/player/${username from the text box}/games/archives`, to retreive a list of urls links used in the following function 2.
2. a function that asynchronously makes get requests using that list of download links returned from function 1.
3. a function that concatenates the results of the responses (chess games) of those requests (in .pgn format)
4. a function that triggers the download to save the concatenated results of function 3. the user's local machine.
Note that:
- you can use as many functions as required to accomplish the what the above functions accomplish and fulfill the characteristics and functionality of the web app.
- all functions that make get requests implement JSONp
- No api key is required at any point
- random user agents selected from the userAgents.js file must be applied to each get request
- each url in the list of urls returned from the request to the endpoint "https://api.chess.com/pub/player/${username from the text box}/games/archives", must have a "/.pgn" appended to it prior to making subsequent asynchronous requests. For example, if the list of games returned from a get request to "https://api.chess.com/pub/player/${username from the text box}/games/archives" returns a list of urls, ["https://api.chess.com/pub/player/hippodrunkimus/games/2023/03", "https://api.chess.com/pub/player/hippodrunkimus/games/2023/04"], then the url, "https://api.chess.com/pub/player/hippodrunkimus/games/2023/03" should look like "https://api.chess.com/pub/player/hippodrunkimus/games/2023/03/.pgn?callback=myExampleJavascriptFunction".