-
-
Notifications
You must be signed in to change notification settings - Fork 30
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
base: master
Are you sure you want to change the base?
Conversation
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'] |
There was a problem hiding this comment.
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. |
There was a problem hiding this comment.
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) ; |
There was a problem hiding this comment.
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) |
There was a problem hiding this comment.
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) ; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Revert.
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.