Cleanup Javascript #2185

Closed
Gusted wants to merge 4 commits from Javascript-Cleanup into master
Gusted commented 2021-01-10 17:48:36 +00:00 (Migrated from github.com)
  • Remove sortable.js(not used).
  • Cleanup redirects, I couldn't properly look at it.
  • Made main.js ECMA6 ready.
  • Made event functions into a declaration to ensure compatibility with possible older browser version.
  • Removed useless === true/false.
  • tempSrc uses declaration now.

Description

Resolves: none

For someone who spends a lot of time in Javascript, the javascript at privacytools.io was something to not prefer not look at it. So I've made some changes that should have none to little impact in the end result, It's just some code quality and code inconsistency fixed. You can refer to the Summary what exactly has been done. As the code was already targeting ECMA6 I updated some code that was readable in ECMA6 to make it more consistency. Thereby removed some useless === true/false as JavaScript will automatic evaluate if the return result is true/false. I saw the sortable.js and saw already a security flaw(A variable was reinterpreted as HTML without escaping meta-characters), however fiddling around I saw it has no use-case and not used in production and thereby removed and fixed a little issue with tempSrc to define its a const. Looking at redirect.js, was giving this whole idea to clean it up and moving it to a object and do the window.location just once gives it a better 'maintainability status' to add/modify extra redirects. I've replaced some functions that were passed into events into const x = () => so it will be used as declaration rather then a new function, so in the further if e.g. the removing of this event is needed it will use the declaration and not pass off a new function and gives you some good hours debugging(talking from experience). I didn't really saw a discussion/issue open for this, but I think everyone agrees to have better quality in the code.

Summary:

  • Remove sortable.js(not used).
  • Cleanup redirects, I couldn't properly look at it.
  • Made main.js ECMA6 ready.
  • Made event functions into a declaration to ensure compatibility with possible older browser version.
  • Removed useless === true/false.
  • tempSrc uses declaration now.

Check List

  • I understand that by not opening an issue about a software/service/similar addition/removal, this pull request will be closed without merging.

  • I have read and understand the contributing guidelines.

  • The project is Free Libre and/or Open Source Software

- Remove sortable.js(not used). - Cleanup redirects, I couldn't properly look at it. - Made main.js ECMA6 ready. - Made event functions into a declaration to ensure compatibility with possible older browser version. - Removed useless `=== true/false`. - tempSrc uses declaration now. ## Description Resolves: none For someone who spends a lot of time in Javascript, the javascript at privacytools.io was something to not prefer not look at it. So I've made some changes that should have none to little impact in the end result, It's just some code quality and code inconsistency fixed. You can refer to the Summary what exactly has been done. As the code was already targeting ECMA6 I updated some code that was readable in ECMA6 to make it more consistency. Thereby removed some useless `=== true/false` as JavaScript will automatic evaluate if the return result is true/false. I saw the `sortable.js` and saw already a security flaw(A variable was reinterpreted as HTML without escaping meta-characters), however fiddling around I saw it has no use-case and not used in production and thereby removed and fixed a little issue with `tempSrc` to define its a `const`. Looking at `redirect.js`, was giving this whole idea to clean it up and moving it to a object and do the `window.location` just once gives it a better 'maintainability status' to add/modify extra redirects. I've replaced some functions that were passed into events into `const x = () =>` so it will be used as declaration rather then a new function, so in the further if e.g. the removing of this event is needed it will use the declaration and not pass off a new function and gives you some good hours debugging(talking from experience). I didn't really saw a discussion/issue open for this, but I think everyone agrees to have better quality in the code. Summary: - Remove sortable.js(not used). - Cleanup redirects, I couldn't properly look at it. - Made `main.js` ECMA6 ready. - Made event functions into a declaration to ensure compatibility with possible older browser version. - Removed useless `=== true/false`. - tempSrc uses declaration now. #### Check List <!-- Please add an x in each box below, like so: [x] --> - [x] I understand that by not opening an issue about a software/service/similar addition/removal, this pull request will be closed without merging. - [x] I have read and understand [the contributing guidelines](https://github.com/privacytools/privacytools.io/blob/master/.github/CONTRIBUTING.md). - [x] The project is [Free Libre](https://en.wikipedia.org/wiki/Free_software) and/or [Open Source](https://en.wikipedia.org/wiki/Open-source_software) Software * Netlify preview for the mainly edited page: https://deploy-preview-2185--privacytools-io.netlify.app/

Didn't look at the other changes, but FYI sortable.js is definitely used in production. https://www.privacytools.io/providers/dns/ for example. (I don't think there is any unused code in general but I may be wrong)

Didn't look at the other changes, but FYI sortable.js is definitely used in production. https://www.privacytools.io/providers/dns/ for example. (I don't think there is any unused code in general but I may be wrong)
Gusted commented 2021-01-11 07:51:25 +00:00 (Migrated from github.com)

Didn't look at the other changes, but FYI sortable.js is definitely used in production. https://www.privacytools.io/providers/dns/ for example. (I don't think there is any unused code in general but I may be wrong)

I thought so too, but the problem with this was when I checked at the network request, sortable.js was never requested and doing a quick search in the code doesn't mention any reference. Well the netlify preview on dns provider doesn't show anything wrong with it.

> Didn't look at the other changes, but FYI sortable.js is definitely used in production. https://www.privacytools.io/providers/dns/ for example. (I don't think there is any unused code in general but I may be wrong) I thought so too, but the problem with this was when I checked at the network request, `sortable.js` was never requested and doing a quick search in the code doesn't mention any reference. Well the [netlify preview](https://deploy-preview-2185--privacytools-io.netlify.app/providers/dns/) on dns provider doesn't show anything wrong with it.
This repo is archived. You cannot comment on pull requests.
No reviewers
No Milestone
No Assignees
1 Participants
Due Date
The due date is invalid or out of range. Please use the format 'yyyy-mm-dd'.

No due date set.

Dependencies

No dependencies set.

Reference: privacyguides/privacytools.io#2185
No description provided.