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

Add comms to config page and small code refactor #153

Merged
merged 3 commits into from
Sep 24, 2024
Merged

Conversation

CameronRP
Copy link
Contributor

No description provided.

@CameronRP CameronRP requested a review from Zainrax September 24, 2024 21:26
html/config.html Outdated
</tr>

<tr>
<td>Bluetooth Enablued</td>
Copy link
Contributor

Choose a reason for hiding this comment

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

*Bluetooth Enabled
though kind of funny to leave as EnaBLUEd

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Haha, should probably fix it..

Copy link
Contributor

@Zainrax Zainrax left a comment

Choose a reason for hiding this comment

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

Very minor things to fix, have approved 👍

html/config.html Outdated
<td><input type="text" id="input-comms-protect-species"></td>
</tr>
<tr>
<td>Protect Species</td>
Copy link
Contributor

Choose a reason for hiding this comment

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

*Protect Duration

"bluetooth": document.querySelector("#input-comms-bluetooth").checked,
"power-output": document.querySelector("#input-comms-power-output").value || undefined,
"power-up-duration": document.querySelector("#input-comms-power-up-duration").value || undefined,
"trap-species": JSON.parse(document.querySelector("#input-comms-trap-species").value) || undefined,
Copy link
Contributor

Choose a reason for hiding this comment

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

Should be fine, but careful of parsing JSON as it will throw instead of defaulting to undefined if it's invalid

try {
    protectSpecies = JSON.parse(document.querySelector("#input-comms-protect-species").value);
} catch (e) {
    console.error("Invalid JSON for Protect Species:", e);
    protectSpecies = undefined;
    alert("Please enter valid JSON for Protect Species.");
}

@CameronRP CameronRP merged commit b2566a9 into tc2 Sep 24, 2024
2 checks passed
@CameronRP CameronRP deleted the add-comms-config branch September 24, 2024 22:51
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.

2 participants