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

40 retrieve config files from GitHub to display as default #46

Conversation

vulongphan
Copy link
Collaborator

This PR retrieves config files in this repo using Github API. The option for users to upload their own config file is preserved.

@vulongphan vulongphan linked an issue Apr 6, 2023 that may be closed by this pull request
main.js Outdated
}
}
}
else return; // no config file selected

if (!alreadyReadConfigFiles.includes(file)) {
Copy link
Collaborator

Choose a reason for hiding this comment

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

can you add a comment explaining what this does?

Copy link
Collaborator Author

@vulongphan vulongphan Apr 7, 2023

Choose a reason for hiding this comment

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

The condition check if (!alreadyReadConfigFiles.includes(file)){} is from the original code. I guess the purpose is to only read each config file once. However, this does not seem necessary at the moment since we can only read maximum of 1 config file in the upload screen before going to the edit screen. When we want to go back to upload screen again to upload another config file, the window reloads and alreadyReadConfigFiles array is reset to empty.

Copy link
Collaborator

Choose a reason for hiding this comment

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

I mean add a comment in the code, so that when someone wants to go over the code, instead of unpacking code blocks, they read comments.

viewtree.html Outdated
@@ -150,6 +154,74 @@
<script src="scripts/saveSvgAsPng.js"></script>
<script src="scripts/underscore-min.js"></script>
<script src="scripts/cycle.js"></script>
<script>
var defaultConfigFiles = [];
Copy link
Collaborator

Choose a reason for hiding this comment

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

Please move this to a JS file (preferably a new file).

viewtree.html Outdated
var defaultConfigFiles = [];

function populateConfigFileSelectorHelper(files) {
let option;
Copy link
Collaborator

Choose a reason for hiding this comment

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

Can you add comments explaining what each of these functions does?

<option>Choose File</option>
<option>Upload your config file</option>
</select>
<input style="float:left; display:none" type="file" name="configFile" id="configFile"/>
Copy link
Collaborator

Choose a reason for hiding this comment

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

When defining IDs sometimes camel case is used, while other times snake case is used. Please be consistent.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I will consistently define ids in camel case (as is with the original code)

@muhammed-abuodeh muhammed-abuodeh merged commit 913418b into master Apr 10, 2023
@muhammed-abuodeh muhammed-abuodeh deleted the 40-retrieve-config-files-from-github-to-display-as-default branch April 10, 2023 02:03
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.

Retrieve config files from Github to display as default
2 participants