Commit Graph

7 Commits

Author SHA1 Message Date
Javi Martín
9e74ebccb6 Store texts data in the element using them
This way we can have a generic function we can apply in other places.
2019-10-31 15:07:08 +01:00
Javi Martín
e314701d49 Extract method to pluralize text in JavaScript
This way we can reuse it in other places.
2019-10-31 15:03:57 +01:00
Javi Martín
b15ae77ddc Simplify Javascript to pluralize translations
We can pass the whole translation hash instead of passing descriptions
individually, and we can replace `%{count}` so we don't need any <span>
tags.
2019-10-31 14:49:46 +01:00
Javi Martín
7f1bfc6bd7 Avoid using html() to set languages description
The jQuery html() function does not filter <script> tags, so if somehow
an attacker introduced a <script> in the translation, we would be
vulnerable to a XSS attack.

Note using $.parseHTML wouldn't solve the problem, since it doesn't
filter attributes in image tags.

Since changing the text of the part which doesn't have the count wasn't
very clean, I've added another <span> tag for the part with the
description, and so we can use jQuery's text() function to replace it.
2019-10-21 20:24:50 +02:00
Javi Martín
5211f47842 Add and apply ESLint spacing rules
For now we're only adding rules related to spacing and double quotes,
following the same rules we use in Ruby, which are the same rules
CoffeeScript followed when compiling these files.

We're also using the recommended ESLint rules, which will warn us about
many JavaScript common pitfalls, the `strict` rule which enforces using
strict mode, and the `no-console` rule, which will prevent us from
shipping code meant for debugging.

Although it's arguably more common to use the JSON format to define
these rules, I've chosen YAML because it's the format we use in all our
linters.
2019-09-11 14:03:24 +02:00
Javi Martín
ec5af1f1bc Remove unnecessary return statements
These statements were automatically added by CoffeeScript.

I'm only removing the obvious cases; there might be more cases where the
`return` statement isn't necessary.
2019-09-11 14:03:24 +02:00
Javi Martín
d93a029ce5 Convert CofeeScript to JavaScript
Compiled using `coffee -c` with CoffeeScript 1.12.6.
2019-09-11 14:03:24 +02:00