Skip to content

Commit

Permalink
Apply Standard 12.x code style to JavaScript files
Browse files Browse the repository at this point in the history
  • Loading branch information
bkimminich committed Aug 29, 2018
1 parent 37c83d9 commit 9467e4a
Show file tree
Hide file tree
Showing 105 changed files with 578 additions and 578 deletions.
4 changes: 2 additions & 2 deletions app/js/controllers/BasketController.js
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ angular.module('juiceShop').controller('BasketController', [
$scope.applyCoupon = function () {
basketService.applyCoupon($window.sessionStorage.bid, encodeURIComponent($scope.coupon)).then(function (data) {
$scope.coupon = undefined
$translate('DISCOUNT_APPLIED', {discount: data}).then(function (discountApplied) {
$translate('DISCOUNT_APPLIED', { discount: data }).then(function (discountApplied) {
$scope.confirmation = discountApplied
}, function (translationId) {
$scope.confirmation = translationId
Expand Down Expand Up @@ -82,7 +82,7 @@ angular.module('juiceShop').controller('BasketController', [
function addToQuantity (id, value) {
basketService.get(id).then(function (basketItem) {
var newQuantity = basketItem.quantity + value
basketService.put(id, {quantity: newQuantity < 1 ? 1 : newQuantity}).then(function () {
basketService.put(id, { quantity: newQuantity < 1 ? 1 : newQuantity }).then(function () {
load()
}).catch(function (err) {
console.log(err)
Expand Down
2 changes: 1 addition & 1 deletion app/js/controllers/ChangePasswordController.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ angular.module('juiceShop').controller('ChangePasswordController', [
'use strict'

$scope.changePassword = function () {
userService.changePassword({current: $scope.currentPassword, new: $scope.newPassword, repeat: $scope.newPasswordRepeat}).then(function () {
userService.changePassword({ current: $scope.currentPassword, new: $scope.newPassword, repeat: $scope.newPasswordRepeat }).then(function () {
$scope.error = undefined
$scope.confirmation = 'Your password was successfully changed.'
resetForm()
Expand Down
2 changes: 1 addition & 1 deletion app/js/controllers/ComplaintController.js
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ angular.module('juiceShop').controller('ComplaintController', [
$scope.upload = function (file) {
Upload.upload({
url: '/file-upload',
data: {file: file}
data: { file: file }
}).then(function (req) {
$scope.complaint.file = req.config.data.file.name
saveComplaint()
Expand Down
2 changes: 1 addition & 1 deletion app/js/controllers/ForgotPasswordController.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ angular.module('juiceShop').controller('ForgotPasswordController', [
}

$scope.resetPassword = function () {
userService.resetPassword({email: $scope.email, answer: $scope.securityAnswer, new: $scope.newPassword, repeat: $scope.newPasswordRepeat}).then(function () {
userService.resetPassword({ email: $scope.email, answer: $scope.securityAnswer, new: $scope.newPassword, repeat: $scope.newPasswordRepeat }).then(function () {
$scope.error = undefined
$scope.confirmation = 'Your password was successfully changed.'
resetForm()
Expand Down
60 changes: 30 additions & 30 deletions app/js/controllers/LanguageController.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,34 +18,34 @@ angular.module('juiceShop').controller('LanguageController', [
}])

var languages = [
{key: 'ar_SA', icon: 'ae', lang: 'عربى'},
{key: 'cs_CZ', icon: 'cz', lang: 'Česky', isFlask: true},
{key: 'da_DK', icon: 'dk', lang: 'Dansk', isFlask: true},
{key: 'de_DE', icon: 'de', lang: 'Deutsch'},
{key: 'el_GR', icon: 'gr', lang: 'Ελληνικά', isFlask: true},
{key: 'es_ES', icon: 'es', lang: 'Español', isFlask: true},
{key: 'et_EE', icon: 'ee', lang: 'Eesti'},
{key: 'fi_FI', icon: 'fi', lang: 'Suomalainen', isFlask: true},
{key: 'fr_FR', icon: 'fr', lang: 'Français'},
{key: 'he_IL', icon: 'il', lang: 'עברי'},
{key: 'hi_IN', icon: 'in', lang: 'हिंदी'},
{key: 'hu_HU', icon: 'hu', lang: 'Magyar', isFlask: true},
{key: 'id_ID', icon: 'id', lang: 'Bahasa Indonesia'},
{key: 'it_IT', icon: 'it', lang: 'Italiano'},
{key: 'ja_JP', icon: 'jp', lang: '日本の'},
{key: 'lt_LT', icon: 'lt', lang: 'Lietuviešu', isFlask: true},
{key: 'lv_LV', icon: 'lv', lang: 'Latvijas', isFlask: true},
{key: 'my_MM', icon: 'mm', lang: 'ျမန္မာ', isFlask: true},
{key: 'nl_NL', icon: 'nl', lang: 'Nederlands'},
{key: 'no_NO', icon: 'no', lang: 'Norsk'},
{key: 'pl_PL', icon: 'pl', lang: 'Język Polski'},
{key: 'pt_PT', icon: 'pt', lang: 'Português', isFlask: true},
{key: 'pt_BR', icon: 'br', lang: 'Português (Brasil)'},
{key: 'ro_RO', icon: 'ro', lang: 'Românesc'},
{key: 'ru_RU', icon: 'ru', lang: 'Pусский', isFlask: true},
{key: 'sv_SE', icon: 'se', lang: 'Svenska'},
{key: 'tr_TR', icon: 'tr', lang: 'Türkçe'},
{key: 'ur_PK', icon: 'pk', lang: 'اردو'},
{key: 'zh_CN', icon: 'cn', lang: '中国'},
{key: 'zh_HK', icon: 'hk', lang: '繁體中文'}
{ key: 'ar_SA', icon: 'ae', lang: 'عربى' },
{ key: 'cs_CZ', icon: 'cz', lang: 'Česky', isFlask: true },
{ key: 'da_DK', icon: 'dk', lang: 'Dansk', isFlask: true },
{ key: 'de_DE', icon: 'de', lang: 'Deutsch' },
{ key: 'el_GR', icon: 'gr', lang: 'Ελληνικά', isFlask: true },
{ key: 'es_ES', icon: 'es', lang: 'Español', isFlask: true },
{ key: 'et_EE', icon: 'ee', lang: 'Eesti' },
{ key: 'fi_FI', icon: 'fi', lang: 'Suomalainen', isFlask: true },
{ key: 'fr_FR', icon: 'fr', lang: 'Français' },
{ key: 'he_IL', icon: 'il', lang: 'עברי' },
{ key: 'hi_IN', icon: 'in', lang: 'हिंदी' },
{ key: 'hu_HU', icon: 'hu', lang: 'Magyar', isFlask: true },
{ key: 'id_ID', icon: 'id', lang: 'Bahasa Indonesia' },
{ key: 'it_IT', icon: 'it', lang: 'Italiano' },
{ key: 'ja_JP', icon: 'jp', lang: '日本の' },
{ key: 'lt_LT', icon: 'lt', lang: 'Lietuviešu', isFlask: true },
{ key: 'lv_LV', icon: 'lv', lang: 'Latvijas', isFlask: true },
{ key: 'my_MM', icon: 'mm', lang: 'ျမန္မာ', isFlask: true },
{ key: 'nl_NL', icon: 'nl', lang: 'Nederlands' },
{ key: 'no_NO', icon: 'no', lang: 'Norsk' },
{ key: 'pl_PL', icon: 'pl', lang: 'Język Polski' },
{ key: 'pt_PT', icon: 'pt', lang: 'Português', isFlask: true },
{ key: 'pt_BR', icon: 'br', lang: 'Português (Brasil)' },
{ key: 'ro_RO', icon: 'ro', lang: 'Românesc' },
{ key: 'ru_RU', icon: 'ru', lang: 'Pусский', isFlask: true },
{ key: 'sv_SE', icon: 'se', lang: 'Svenska' },
{ key: 'tr_TR', icon: 'tr', lang: 'Türkçe' },
{ key: 'ur_PK', icon: 'pk', lang: 'اردو' },
{ key: 'zh_CN', icon: 'cn', lang: '中国' },
{ key: 'zh_HK', icon: 'hk', lang: '繁體中文' }
]
2 changes: 1 addition & 1 deletion app/js/controllers/OAuthController.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ angular.module('juiceShop').controller('OAuthController', [
'use strict'

userService.oauthLogin(parseRedirectUrlParams()['access_token']).then(function (profile) {
userService.save({email: profile.email, password: $base64.encode(profile.email)}).then(function () {
userService.save({ email: profile.email, password: $base64.encode(profile.email) }).then(function () {
login(profile)
}).catch(function () { // eslint-disable-line handle-callback-err
login(profile)
Expand Down
2 changes: 1 addition & 1 deletion app/js/controllers/ProductReviewEditController.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ angular.module('juiceShop').controller('ProductReviewEditController', [
$scope.message = review.message

$scope.editReview = function () {
productReviewService.patch({id: $scope.id, message: $scope.message}).then(function () {
productReviewService.patch({ id: $scope.id, message: $scope.message }).then(function () {
$uibModalInstance.close($scope.message)
}).catch(function (err) {
console.log(err)
Expand Down
2 changes: 1 addition & 1 deletion app/js/controllers/RegisterController.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ angular.module('juiceShop').controller('RegisterController', [

$scope.save = function () {
userService.save($scope.user).then(function (user) {
securityAnswerService.save({UserId: user.id, answer: $scope.user.securityAnswer, SecurityQuestionId: $scope.user.securityQuestion.id}).then(function () {
securityAnswerService.save({ UserId: user.id, answer: $scope.user.securityAnswer, SecurityQuestionId: $scope.user.securityQuestion.id }).then(function () {
$scope.user = {}
$location.path('/login')
})
Expand Down
2 changes: 1 addition & 1 deletion app/js/controllers/SearchController.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,6 @@ angular.module('juiceShop').controller('SearchController', [
'use strict'

$scope.search = function () {
$location.path('/search').search({q: $scope.searchQuery || ''})
$location.path('/search').search({ q: $scope.searchQuery || '' })
}
}])
8 changes: 4 additions & 4 deletions app/js/controllers/SearchResultController.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,9 +32,9 @@ angular.module('juiceShop').controller('SearchResultController', [
found = true
basketService.get(productsInBasket[i].BasketItem.id).then(function (existingBasketItem) {
var newQuantity = existingBasketItem.quantity + 1
basketService.put(existingBasketItem.id, {quantity: newQuantity}).then(function (updatedBasketItem) {
basketService.put(existingBasketItem.id, { quantity: newQuantity }).then(function (updatedBasketItem) {
productService.get(updatedBasketItem.ProductId).then(function (product) {
$translate('BASKET_ADD_SAME_PRODUCT', {product: product.name}).then(function (basketAddSameProduct) {
$translate('BASKET_ADD_SAME_PRODUCT', { product: product.name }).then(function (basketAddSameProduct) {
$scope.confirmation = basketAddSameProduct
}, function (translationId) {
$scope.confirmation = translationId
Expand All @@ -52,9 +52,9 @@ angular.module('juiceShop').controller('SearchResultController', [
}
}
if (!found) {
basketService.save({ProductId: id, BasketId: $window.sessionStorage.bid, quantity: 1}).then(function (newBasketItem) {
basketService.save({ ProductId: id, BasketId: $window.sessionStorage.bid, quantity: 1 }).then(function (newBasketItem) {
productService.get(newBasketItem.ProductId).then(function (product) {
$translate('BASKET_ADD_PRODUCT', {product: product.name}).then(function (basketAddProduct) {
$translate('BASKET_ADD_PRODUCT', { product: product.name }).then(function (basketAddProduct) {
$scope.confirmation = basketAddProduct
}, function (translationId) {
$scope.confirmation = translationId
Expand Down
2 changes: 1 addition & 1 deletion app/js/controllers/TrackOrderController.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,6 @@ angular.module('juiceShop').controller('TrackOrderController', [
'use strict'

$scope.save = function () {
$location.path('/track-result').search({id: encodeURIComponent($scope.orderId) || ''})
$location.path('/track-result').search({ id: encodeURIComponent($scope.orderId) || '' })
}
}])
12 changes: 6 additions & 6 deletions app/js/routes.js
Original file line number Diff line number Diff line change
Expand Up @@ -88,12 +88,12 @@ angular.module('juiceShop').config(['$routeProvider', function ($routeProvider)
return String.fromCharCode(C - D - 45 - A)
}).join('')
})(25, 184, 174, 179, 182, 186) + (36669).toString(36).toLowerCase() + (function () {
var T = Array.prototype.slice.call(arguments)
var M = T.shift()
return T.reverse().map(function (m, H) {
return String.fromCharCode(m - M - 24 - H)
}).join('')
})(13, 144, 87, 152, 139, 144, 83, 138) + (10).toString(36).toLowerCase(), {
var T = Array.prototype.slice.call(arguments)
var M = T.shift()
return T.reverse().map(function (m, H) {
return String.fromCharCode(m - M - 24 - H)
}).join('')
})(13, 144, 87, 152, 139, 144, 83, 138) + (10).toString(36).toLowerCase(), {
templateUrl: '\x76\x69\x65\x77\x73\x2F\x54\x6F\x6B\x65\x6E\x53\x61\x6C\x65\x2E\x68\x74\x6D\x6C',
controller: '\x54\x6F\x6B\x65\x6E\x53\x61\x6C\x65\x43\x6F\x6E\x74\x72\x6F\x6C\x6C\x65\x72'
})
Expand Down
2 changes: 1 addition & 1 deletion app/js/services/ProductReviewService.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ angular.module('juiceShop').factory('ProductReviewService', ['$http', '$q', func

function like (_id) {
var updatedReview = $q.defer()
var id = {id: _id}
var id = { id: _id }
$http.post(host + '/reviews', id).then(function (response) {
updatedReview.resolve(response.data.data)
}).catch(function (response) {
Expand Down
2 changes: 1 addition & 1 deletion data/datacreator.js
Original file line number Diff line number Diff line change
Expand Up @@ -416,7 +416,7 @@ function createOrders () {
]

return Promise.all(
orders.map(({orderId, email, totalPrice, products, eta}) =>
orders.map(({ orderId, email, totalPrice, products, eta }) =>
mongodb.orders.insert({
orderId: orderId,
email: email,
Expand Down
8 changes: 4 additions & 4 deletions lib/insecurity.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,8 @@ exports.cutOffPoisonNullByte = str => {
return str
}

exports.isAuthorized = () => expressJwt({secret: this.publicKey})
exports.denyAll = () => expressJwt({secret: '' + Math.random()})
exports.isAuthorized = () => expressJwt({ secret: this.publicKey })
exports.denyAll = () => expressJwt({ secret: '' + Math.random() })
exports.authorize = (user = {}) => jwt.sign(user, privateKey, { expiresIn: 3600 * 5, algorithm: 'RS256' })

exports.sanitizeHtml = html => sanitizeHtml(html)
Expand All @@ -47,7 +47,7 @@ exports.authenticatedUsers = {
}
}

exports.userEmailFrom = ({headers}) => {
exports.userEmailFrom = ({ headers }) => {
return headers ? headers['x-user-email'] : undefined
}

Expand Down Expand Up @@ -95,7 +95,7 @@ exports.isRedirectAllowed = url => {
}

exports.verifyCaptcha = () => (req, res, next) => {
models.Captcha.findOne({ where: {captchaId: req.body.captchaId} }).then(captcha => {
models.Captcha.findOne({ where: { captchaId: req.body.captchaId } }).then(captcha => {
if (req.body.captcha === captcha.dataValues.answer) {
next()
} else {
Expand Down
2 changes: 1 addition & 1 deletion lib/startup/registerWebsocketEvents.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ const registerWebsocketEvents = (server) => {
})

socket.on('notification received', data => {
const i = notifications.findIndex(({flag}) => flag === data)
const i = notifications.findIndex(({ flag }) => flag === data)
if (i > -1) {
notifications.splice(i, 1)
}
Expand Down
4 changes: 2 additions & 2 deletions lib/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,7 @@ exports.downloadToFile = (url, dest) => {
})
}

exports.jwtFrom = ({headers}) => {
exports.jwtFrom = ({ headers }) => {
if (headers && headers.authorization) {
const parts = headers.authorization.split(' ')
if (parts.length === 2) {
Expand All @@ -170,7 +170,7 @@ exports.parseJsonCustom = (jsonString) => {
const parser = clarinet.parser()
const result = []
parser.onkey = parser.onopenobject = k => {
result.push({key: k, value: null})
result.push({ key: k, value: null })
}
parser.onvalue = v => {
result[result.length - 1].value = v
Expand Down
4 changes: 2 additions & 2 deletions models/basket.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
/* jslint node: true */
module.exports = (sequelize, {STRING}) => {
module.exports = (sequelize, { STRING }) => {
const Basket = sequelize.define('Basket', {
coupon: STRING
})

Basket.associate = ({User, Product, BasketItem}) => {
Basket.associate = ({ User, Product, BasketItem }) => {
Basket.belongsTo(User, { constraints: true, foreignKeyConstraint: true })
Basket.belongsToMany(Product, { through: BasketItem })
}
Expand Down
2 changes: 1 addition & 1 deletion models/basketitem.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/* jslint node: true */
module.exports = (sequelize, {INTEGER}) => {
module.exports = (sequelize, { INTEGER }) => {
const BasketItem = sequelize.define('BasketItem', {
id: {
type: INTEGER,
Expand Down
2 changes: 1 addition & 1 deletion models/captcha.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
module.exports = (sequelize, {INTEGER, STRING}) => {
module.exports = (sequelize, { INTEGER, STRING }) => {
const Challenge = sequelize.define('Captcha', {
captchaId: INTEGER,
captcha: STRING,
Expand Down
2 changes: 1 addition & 1 deletion models/challenge.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/* jslint node: true */
module.exports = (sequelize, {STRING, INTEGER, BOOLEAN}) => {
module.exports = (sequelize, { STRING, INTEGER, BOOLEAN }) => {
const Challenge = sequelize.define('Challenge', {
key: STRING,
name: STRING,
Expand Down
4 changes: 2 additions & 2 deletions models/complaint.js
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
/* jslint node: true */
module.exports = (sequelize, {STRING}) => {
module.exports = (sequelize, { STRING }) => {
const Complaint = sequelize.define('Complaint', {
message: STRING,
file: STRING
})

Complaint.associate = ({User}) => {
Complaint.associate = ({ User }) => {
Complaint.belongsTo(User, { constraints: true, foreignKeyConstraint: true })
}

Expand Down
4 changes: 2 additions & 2 deletions models/feedback.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ const insecurity = require('../lib/insecurity')
const utils = require('../lib/utils')
const challenges = require('../data/datacache').challenges

module.exports = (sequelize, {STRING, INTEGER}) => {
module.exports = (sequelize, { STRING, INTEGER }) => {
const Feedback = sequelize.define('Feedback', {
comment: {
type: STRING,
Expand All @@ -27,7 +27,7 @@ module.exports = (sequelize, {STRING, INTEGER}) => {
}
})

Feedback.associate = ({User}) => {
Feedback.associate = ({ User }) => {
Feedback.belongsTo(User) // no FK constraint to allow anonymous feedback posts
}

Expand Down
4 changes: 2 additions & 2 deletions models/product.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
const utils = require('../lib/utils')
const challenges = require('../data/datacache').challenges

module.exports = (sequelize, {STRING, DECIMAL}) => {
module.exports = (sequelize, { STRING, DECIMAL }) => {
const Product = sequelize.define('Product', {
name: STRING,
description: {
Expand All @@ -18,7 +18,7 @@ module.exports = (sequelize, {STRING, DECIMAL}) => {
image: STRING
}, { paranoid: true })

Product.associate = ({Basket, BasketItem}) => {
Product.associate = ({ Basket, BasketItem }) => {
Product.belongsToMany(Basket, { through: BasketItem })
}

Expand Down
4 changes: 2 additions & 2 deletions models/recycle.js
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
/* jslint node: true */
module.exports = (sequelize, {INTEGER, STRING, BOOLEAN, DATE}) => {
module.exports = (sequelize, { INTEGER, STRING, BOOLEAN, DATE }) => {
const Recycle = sequelize.define('Recycle', {
quantity: INTEGER,
address: STRING,
isPickup: { type: BOOLEAN, defaultValue: false },
date: DATE
})

Recycle.associate = ({User}) => {
Recycle.associate = ({ User }) => {
Recycle.belongsTo(User, { constraints: true, foreignKeyConstraint: true })
}

Expand Down
4 changes: 2 additions & 2 deletions models/securityAnswer.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/* jslint node: true */
const insecurity = require('../lib/insecurity')

module.exports = (sequelize, {STRING, INTEGER}) => {
module.exports = (sequelize, { STRING, INTEGER }) => {
const SecurityAnswer = sequelize.define('SecurityAnswer', {
answer: {
type: STRING,
Expand All @@ -12,7 +12,7 @@ module.exports = (sequelize, {STRING, INTEGER}) => {
UserId: { type: INTEGER, unique: true }
})

SecurityAnswer.associate = ({User, SecurityQuestion}) => {
SecurityAnswer.associate = ({ User, SecurityQuestion }) => {
SecurityAnswer.belongsTo(User)
SecurityAnswer.belongsTo(SecurityQuestion, { constraints: true, foreignKeyConstraint: true })
}
Expand Down
2 changes: 1 addition & 1 deletion models/securityQuestion.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/* jslint node: true */
module.exports = (sequelize, {STRING}) => {
module.exports = (sequelize, { STRING }) => {
const SecurityQuestion = sequelize.define('SecurityQuestion', {
question: STRING
}
Expand Down
Loading

0 comments on commit 9467e4a

Please sign in to comment.