Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Changed api request #48

Open
wants to merge 3 commits into
base: master
Choose a base branch
from

Conversation

jeroenflvr
Copy link

Changed api request from get to post with json body.
Required for to ie. generate worksheets for all characters per HSK level in 1 go.
Limited to 200 characters by default.

@lucivpav
Copy link
Owner

Thank you for the PR. How can one generate a worksheet for a HSK level in 1 go with this change? It is limited by 200 characters, which is not enough for the entire HSK level.

def update_words_file(working_directory, request_args):
def update_words_file(working_directory, request_body):
try:
words_definitions = request_body['words']
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If words parameter is not provided, no words should be generated (to match current logic). Also, this method now throws, if the number of words in words_definitions does not match the number of words in WORDS_FILE. Again, to match the current logic, we should use an empty array at words_definitions[i], for which we do not have the data in words_definitions.

req.open("POST", url, true);
req.setRequestHeader("Content-Type", "application/json");

req.onreadystatechange = function () { //Call a function when the state changes.
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please remove the unnecessary comment.

req.onerror = function (e) {
document.getElementById("infos_loading").style.display = "none";
showError("infos_error", GENERATOR_UNAVAILABLE_MSG);
showError("sheet_error", GENERATOR_UNAVAILABLE_MSG + ": " + e) ;
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why sheet_error? Also, I don't think we want to show to a user message like:

Error: Generator is unavailable. Please try again later.: [object ProgressEvent]

@@ -70,14 +73,15 @@ function onInfosGenerated(response)
createWordsTable(response["words"]);
document.getElementById("confirm").style.display = "inline";
id = response["id"];
// console.log("id: " + id)
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Remove it.

}
req.onerror = function (e) {
document.getElementById("sheet_loading").style.display = "none";
showError("sheet_error", GENERATOR_UNAVAILABLE_MSG);
showError("sheet_error", GENERATOR_UNAVAILABLE_MSG) ;
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Revert.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants