Skip to content

fix: reinfo.php shows no test results even if test results are available#815

Closed
boomzero wants to merge 3 commits intodevfrom
boomzero/reinfo
Closed

fix: reinfo.php shows no test results even if test results are available#815
boomzero wants to merge 3 commits intodevfrom
boomzero/reinfo

Conversation

@boomzero
Copy link
Member

@boomzero boomzero commented Jul 6, 2025

What does this PR aim to accomplish?:

fix: reinfo.php shows no test results even if test results are available
Refer to https://support.xmoj-bbs.me/tickets/XS-16/5Zyo5pl55yL5rWL6KV54K56YCa6LH5oOF5Ya15pe25peg5rOV5pi56S65q2j56Gu5oOF5Ya1

How does this PR accomplish the above?:

Improvements to test point information handling:

  • Modified the conditional check in the /reinfo.php path to ensure proper handling when test point information is available. The code now iterates over elements only if they exist, improving reliability.

Enhancements to error message display:

  • Added a replacement mechanism in the /downloads.php path to replace the error message <pre id="errtxt" class="alert alert-error">sorry , not available (,,,1)</pre> with a more user-friendly message, "没有测试点信息."

By submitting this pull request, I confirm the following:

  1. I have read and understood the contributor's guide, as well as this entire template. I understand which branch to base my commits and Pull Requests against.
  2. I have commented on my proposed changes within the code and I have tested my changes.
  3. I am willing to help maintain this change if there are issues with it later.
  4. It is compatible with the GNU General Public License v3.0
  5. I have squashed any insignificant commits. (git rebase)
  6. I have checked that another pull request for this purpose does not exist.
  7. I have considered and confirmed that this submission will be valuable to others.
  8. I accept that this submission may not be used, and the pull request can be closed at the will of the maintainer.
  9. I give this submission freely and claim no ownership to its content.

  • I have read the above and my PR is ready for review. Check this box to confirm

@hendragon-bot hendragon-bot bot added the user-script This issue or pull request is related to the main user script label Jul 6, 2025
@boomzero boomzero requested a review from Copilot July 6, 2025 15:07
@pull-request-size pull-request-size bot added size/S and removed size/XS labels Jul 6, 2025
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This PR ensures test point information is displayed correctly on /reinfo.php and replaces a raw error block with a user-friendly message on /downloads.php.

  • Refactored the existence check for test results in reinfo.php to only iterate when results exist.
  • Added a replacement for the default error <pre> in downloads.php to show “没有测试点信息.”

if (document.querySelector("#results > div") == undefined) {
document.querySelector("#results").parentElement.innerHTML = "没有测试点信息";
} else {
if (document.querySelector("#results > div") != undefined) {
Copy link

Copilot AI Jul 6, 2025

Choose a reason for hiding this comment

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

The fallback message for when no test results are available was removed. Reintroduce an else branch to display “没有测试点信息” when document.querySelector("#results > div") returns undefined.

Copilot uses AI. Check for mistakes.
Comment on lines +3358 to 3360
if (document.querySelector("#results > div") != undefined) {
for (let i = 0; i < document.querySelector("#results > div").children.length; i++) {
let CurrentElement = document.querySelector("#results > div").children[i].children[0].children[0].children[0];
Copy link

Copilot AI Jul 6, 2025

Choose a reason for hiding this comment

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

Cache the result of document.querySelector("#results > div") into a variable before the loop to avoid repeated DOM queries and improve readability.

Suggested change
if (document.querySelector("#results > div") != undefined) {
for (let i = 0; i < document.querySelector("#results > div").children.length; i++) {
let CurrentElement = document.querySelector("#results > div").children[i].children[0].children[0].children[0];
const resultsDiv = document.querySelector("#results > div");
if (resultsDiv != undefined) {
for (let i = 0; i < resultsDiv.children.length; i++) {
let CurrentElement = resultsDiv.children[i].children[0].children[0].children[0];

Copilot uses AI. Check for mistakes.
});
}
}
document.body.innerHTML = String(document.body.innerHTML).replaceAll("<pre id=\"errtxt\" class=\"alert alert-error\">sorry , not available (,,,1)</pre>", "没有测试点信息");
Copy link

Copilot AI Jul 6, 2025

Choose a reason for hiding this comment

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

Replacing the entire body.innerHTML can break event listeners and is fragile. Instead, target the specific <pre id="errtxt"> element (e.g., via getElementById) and update its textContent.

Suggested change
document.body.innerHTML = String(document.body.innerHTML).replaceAll("<pre id=\"errtxt\" class=\"alert alert-error\">sorry , not available (,,,1)</pre>", "没有测试点信息");
let errorTextElement = document.getElementById("errtxt");
if (errorTextElement) {
errorTextElement.textContent = "没有测试点信息";
}

Copilot uses AI. Check for mistakes.
Copy link
Member

@PythonSmall-Q PythonSmall-Q left a comment

Choose a reason for hiding this comment

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

申请数据不工作

@boomzero
Copy link
Member Author

boomzero commented Jul 9, 2025

#817

@boomzero boomzero closed this Jul 9, 2025
@boomzero boomzero deleted the boomzero/reinfo branch August 24, 2025 03:19
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

size/S user-script This issue or pull request is related to the main user script

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants