Skip to content

Commit

Permalink
eslint frontend folder (#923)
Browse files Browse the repository at this point in the history
  • Loading branch information
devvmh committed Nov 7, 2016
1 parent 9df974a commit a176cdf
Show file tree
Hide file tree
Showing 61 changed files with 1,702 additions and 1,788 deletions.
1 change: 1 addition & 0 deletions .eslintrc.js
Expand Up @@ -20,6 +20,7 @@ module.exports = {
"rules": {
"react/jsx-uses-react": [2],
"react/jsx-uses-vars": [2],
"space-before-function-paren": [2, "never"],
"yoda": [2, "never", { "exceptRange": true }]
}
}
26 changes: 13 additions & 13 deletions frontend/src/Metamaps/Account.js
@@ -1,33 +1,33 @@
/* global $, CanvasLoader */

const Account = {
init: function (serverData) {
init: function(serverData) {
Account.userIconUrl = serverData['user.png']
},
listenersInitialized: false,
userIconUrl: null,
initListeners: function () {
initListeners: function() {
var self = Account

$('#user_image').change(self.showImagePreview)
self.listenersInitialized = true
},
toggleChangePicture: function () {
toggleChangePicture: function() {
var self = Account

$('.userImageMenu').toggle()
if (!self.listenersInitialized) self.initListeners()
},
openChangePicture: function () {
openChangePicture: function() {
var self = Account

$('.userImageMenu').show()
if (!self.listenersInitialized) self.initListeners()
},
closeChangePicture: function () {
closeChangePicture: function() {
$('.userImageMenu').hide()
},
showLoading: function () {
showLoading: function() {
var loader = new CanvasLoader('accountPageLoading')
loader.setColor('#4FC059') // default is '#000000'
loader.setDiameter(28) // default is 40
Expand All @@ -36,20 +36,20 @@ const Account = {
loader.show() // Hidden by default
$('#accountPageLoading').show()
},
showImagePreview: function () {
showImagePreview: function() {
var file = $('#user_image')[0].files[0]

var reader = new window.FileReader()

reader.onload = function (e) {
reader.onload = function(e) {
var $canvas = $('<canvas>').attr({
width: 84,
height: 84
})
var context = $canvas[0].getContext('2d')
var imageObj = new window.Image()

imageObj.onload = function () {
imageObj.onload = function() {
$('.userImageDiv canvas').remove()
$('.userImageDiv img').hide()

Expand Down Expand Up @@ -80,7 +80,7 @@ const Account = {
$('#remove_image').val('0')
}
},
removePicture: function () {
removePicture: function() {
var self = Account

$('.userImageDiv canvas').remove()
Expand All @@ -91,15 +91,15 @@ const Account = {
input.replaceWith(input.val('').clone(true))
$('#remove_image').val('1')
},
changeName: function () {
changeName: function() {
$('.accountName').hide()
$('.changeName').show()
},
showPass: function () {
showPass: function() {
$('.toHide').show()
$('.changePass').hide()
},
hidePass: function () {
hidePass: function() {
$('.toHide').hide()
$('.changePass').show()

Expand Down
21 changes: 10 additions & 11 deletions frontend/src/Metamaps/Admin.js
Expand Up @@ -3,44 +3,43 @@
const Admin = {
selectMetacodes: [],
allMetacodes: [],
init: function () {
init: function() {
var self = Admin

$('#metacodes_value').val(self.selectMetacodes.toString())
},
selectAll: function () {
selectAll: function() {
var self = Admin

$('.editMetacodes li').removeClass('toggledOff')
self.selectMetacodes = self.allMetacodes.slice(0)
$('#metacodes_value').val(self.selectMetacodes.toString())
},
deselectAll: function () {
deselectAll: function() {
var self = Admin

$('.editMetacodes li').addClass('toggledOff')
self.selectMetacodes = []
$('#metacodes_value').val(0)
},
liClickHandler: function () {
liClickHandler: function() {
var self = Admin

if ($(this).attr('class') != 'toggledOff') {
if ($(this).attr('class') !== 'toggledOff') {
$(this).addClass('toggledOff')
var value_to_remove = $(this).attr('id')
self.selectMetacodes.splice(self.selectMetacodes.indexOf(value_to_remove), 1)
const valueToRemove = $(this).attr('id')
self.selectMetacodes.splice(self.selectMetacodes.indexOf(valueToRemove), 1)
$('#metacodes_value').val(self.selectMetacodes.toString())
}
else if ($(this).attr('class') == 'toggledOff') {
} else if ($(this).attr('class') === 'toggledOff') {
$(this).removeClass('toggledOff')
self.selectMetacodes.push($(this).attr('id'))
$('#metacodes_value').val(self.selectMetacodes.toString())
}
},
validate: function () {
validate: function() {
var self = Admin

if (self.selectMetacodes.length == 0) {
if (self.selectMetacodes.length === 0) {
window.alert('Would you pretty please select at least one metacode for the set?')
return false
}
Expand Down
23 changes: 10 additions & 13 deletions frontend/src/Metamaps/AutoLayout.js
Expand Up @@ -7,7 +7,7 @@ const AutoLayout = {
nextYshift: 0,
timeToTurn: 0,

getNextCoord: function (opts = {}) {
getNextCoord: function(opts = {}) {
var self = AutoLayout
var nextX = self.nextX
var nextY = self.nextY
Expand All @@ -28,22 +28,19 @@ const AutoLayout = {
self.timeToTurn = 0

// going right? turn down
if (self.nextXshift == 1 && self.nextYshift == 0) {
if (self.nextXshift === 1 && self.nextYshift === 0) {
self.nextXshift = 0
self.nextYshift = 1
}
// going down? turn left
else if (self.nextXshift == 0 && self.nextYshift == 1) {
} else if (self.nextXshift === 0 && self.nextYshift === 1) {
// going down? turn left
self.nextXshift = -1
self.nextYshift = 0
}
// going left? turn up
else if (self.nextXshift == -1 && self.nextYshift == 0) {
} else if (self.nextXshift === -1 && self.nextYshift === 0) {
// going left? turn up
self.nextXshift = 0
self.nextYshift = -1
}
// going up? turn right
else if (self.nextXshift == 0 && self.nextYshift == -1) {
} else if (self.nextXshift === 0 && self.nextYshift === -1) {
// going up? turn right
self.nextXshift = 1
self.nextYshift = 0
}
Expand All @@ -59,14 +56,14 @@ const AutoLayout = {
}
}
},
coordsTaken: function (x, y, mappings) {
coordsTaken: function(x, y, mappings) {
if (mappings.findWhere({ xloc: x, yloc: y })) {
return true
} else {
return false
}
},
resetSpiral: function () {
resetSpiral: function() {
var self = AutoLayout
self.nextX = 0
self.nextY = 0
Expand Down

0 comments on commit a176cdf

Please sign in to comment.