Massive JavaScript cleanup

- Use JSX for templates
- Docblock/comment everything
- Mostly passes ESLint (still some work to do)
- Lots of renaming, refactoring, etc.

CSS hasn't been updated yet.
This commit is contained in:
Toby Zerner
2015-07-15 14:00:11 +09:30
parent 4480e0a83f
commit ab6c03c0cc
220 changed files with 9785 additions and 5919 deletions

View File

@ -1,13 +1,28 @@
/**
* The `punctuate` helper formats a list of strings (e.g. names) to read
* fluently in the application's locale.
*
* @example
* punctuate(['Toby', 'Franz', 'Dominion'])
* // Toby, Franz, and Dominion
*
* @param {Array} items
* @return {Array}
*/
export default function punctuate(items) {
var newItems = [];
const punctuated = [];
// FIXME: update to use translation
items.forEach((item, i) => {
newItems.push(item);
punctuated.push(item);
if (i <= items.length - 2) {
newItems.push((items.length > 2 ? ', ' : '')+(i === items.length - 2 ? ' and ' : ''));
// If this item is not the last one, then we will follow it with some
// punctuation. If the list is more than 2 items long, we'll add a comma.
// And if this is the second-to-last item, we'll add 'and'.
if (i < items.length - 1) {
punctuated.push((items.length > 2 ? ', ' : '') + (i === items.length - 2 ? ' and ' : ''));
}
});
return newItems;
return punctuated;
};