fix a bunch of bug risk eslint warnings

This commit is contained in:
Devin Howard 2016-10-04 23:38:32 +08:00
parent dbc2ff75df
commit 113a5a2530
15 changed files with 59 additions and 40 deletions

View file

@ -1,3 +1,5 @@
/* global $, CanvasLoader */
/* /*
* Metamaps.Erb * Metamaps.Erb
*/ */
@ -43,7 +45,7 @@ const Account = {
var file = $('#user_image')[0].files[0] var file = $('#user_image')[0].files[0]
var reader = new FileReader() var reader = new window.FileReader()
reader.onload = function (e) { reader.onload = function (e) {
var $canvas = $('<canvas>').attr({ var $canvas = $('<canvas>').attr({
@ -51,7 +53,7 @@ const Account = {
height: 84 height: 84
}) })
var context = $canvas[0].getContext('2d') var context = $canvas[0].getContext('2d')
var imageObj = new Image() var imageObj = new window.Image()
imageObj.onload = function () { imageObj.onload = function () {
$('.userImageDiv canvas').remove() $('.userImageDiv canvas').remove()

View file

@ -41,7 +41,7 @@ const Admin = {
var self = Admin var self = Admin
if (self.selectMetacodes.length == 0) { if (self.selectMetacodes.length == 0) {
alert('Would you pretty please select at least one metacode for the set?') window.alert('Would you pretty please select at least one metacode for the set?')
return false return false
} }
} }

View file

@ -63,7 +63,7 @@ const Control = {
return return
} }
var r = confirm(outdent` var r = window.confirm(outdent`
You have ${ntext} and ${etext} selected. Are you sure you want You have ${ntext} and ${etext} selected. Are you sure you want
to permanently delete them all? This will remove them from all to permanently delete them all? This will remove them from all
maps they appear on.`) maps they appear on.`)
@ -456,7 +456,7 @@ const Control = {
var message = nString + ' you can edit updated to ' + metacode.get('name') var message = nString + ' you can edit updated to ' + metacode.get('name')
GlobalUI.notifyUser(message) GlobalUI.notifyUser(message)
Visualize.mGraph.plot() Visualize.mGraph.plot()
}, }
} }
export default Control export default Control

View file

@ -169,15 +169,15 @@ const Create = {
queryTokenizer: Bloodhound.tokenizers.whitespace, queryTokenizer: Bloodhound.tokenizers.whitespace,
remote: { remote: {
url: '/topics/autocomplete_topic?term=%QUERY', url: '/topics/autocomplete_topic?term=%QUERY',
wildcard: '%QUERY', wildcard: '%QUERY'
}, }
}) })
// initialize the autocomplete results for the metacode spinner // initialize the autocomplete results for the metacode spinner
$('#topic_name').typeahead( $('#topic_name').typeahead(
{ {
highlight: true, highlight: true,
minLength: 2, minLength: 2
}, },
[{ [{
name: 'topic_autocomplete', name: 'topic_autocomplete',
@ -186,7 +186,7 @@ const Create = {
templates: { templates: {
suggestion: function (s) { suggestion: function (s) {
return Hogan.compile($('#topicAutocompleteTemplate').html()).render(s) return Hogan.compile($('#topicAutocompleteTemplate').html()).render(s)
}, }
}, },
source: topicBloodhound, source: topicBloodhound,
}] }]

View file

@ -143,7 +143,7 @@ const Import = {
// FALL THROUGH - if we're not sure what to do, pretend // FALL THROUGH - if we're not sure what to do, pretend
// we're on the TOPICS_NEED_HEADERS state and parse some headers // we're on the TOPICS_NEED_HEADERS state and parse some headers
case STATES.TOPICS_NEED_HEADERS: // eslint-disable-line case STATES.TOPICS_NEED_HEADERS: // eslint-disable-line no-fallthrough
if (noblanks.length < 2) { if (noblanks.length < 2) {
self.abort('Not enough topic headers on line ' + index) self.abort('Not enough topic headers on line ' + index)
state = STATES.ABORT state = STATES.ABORT
@ -207,8 +207,8 @@ const Import = {
} }
break break
case STATES.ABORT: case STATES.ABORT:
// FALL THROUGH
default: default: // eslint-disable-line no-fallthrough
self.abort('Invalid state while parsing import data. Check code.') self.abort('Invalid state while parsing import data. Check code.')
state = STATES.ABORT state = STATES.ABORT
} }

View file

@ -1,6 +1,7 @@
/* global Metamaps, $, Image, CanvasLoader */ /* global Metamaps, $, Image, CanvasLoader */
import _ from 'lodash' import _ from 'lodash'
import outdent from 'outdent'
import $jit from '../patched/JIT' import $jit from '../patched/JIT'
@ -1323,16 +1324,26 @@ const JIT = {
if (Active.Topic) { if (Active.Topic) {
menustring += '<li class="rc-center"><div class="rc-icon"></div>Center this topic<div class="rc-keyboard">Alt+E</div></li>' menustring += '<li class="rc-center"><div class="rc-icon"></div>Center this topic<div class="rc-keyboard">Alt+E</div></li>'
} }
menustring += '<li class="rc-popout"><div class="rc-icon"></div>Open in new tab</li>' menustring += '<li class="rc-popout"><div class="rc-icon"></div>Open in new tab</li>'
if (Active.Mapper) { if (Active.Mapper) {
var options = '<ul><li class="changeP toCommons"><div class="rc-perm-icon"></div>commons</li> \ var options = outdent`
<li class="changeP toPublic"><div class="rc-perm-icon"></div>public</li> \ <ul>
<li class="changeP toPrivate"><div class="rc-perm-icon"></div>private</li> \ <li class="changeP toCommons"><div class="rc-perm-icon"></div>commons</li>
</ul>' <li class="changeP toPublic"><div class="rc-perm-icon"></div>public</li>
<li class="changeP toPrivate"><div class="rc-perm-icon"></div>private</li>
</ul>`
menustring += '<li class="rc-spacer"></li>' menustring += '<li class="rc-spacer"></li>'
menustring += '<li class="rc-permission"><div class="rc-icon"></div>Change permissions' + options + '<div class="expandLi"></div></li>' menustring += outdent`
<li class="rc-permission">
<div class="rc-icon"></div>
Change permissions
${options}
<div class="expandLi"></div>
</li>`
var metacodeOptions = $('#metacodeOptions').html() var metacodeOptions = $('#metacodeOptions').html()
@ -1345,10 +1356,11 @@ const JIT = {
// set up the get sibling menu as a "lazy load" // set up the get sibling menu as a "lazy load"
// only fill in the submenu when they hover over the get siblings list item // only fill in the submenu when they hover over the get siblings list item
var siblingMenu = '<ul id="fetchSiblingList"> \ var siblingMenu = outdent`
<li class="fetchAll">All<div class="rc-keyboard">Alt+R</div></li> \ <ul id="fetchSiblingList">
<li id="loadingSiblings"></li> \ <li class="fetchAll">All<div class="rc-keyboard">Alt+R</div></li>
</ul>' <li id="loadingSiblings"></li>
</ul>`
menustring += '<li class="rc-siblings"><div class="rc-icon"></div>Reveal siblings' + siblingMenu + '<div class="expandLi"></div></li>' menustring += '<li class="rc-siblings"><div class="rc-icon"></div>Reveal siblings' + siblingMenu + '<div class="expandLi"></div></li>'
} }
@ -1571,10 +1583,12 @@ const JIT = {
if (Active.Map && Active.Mapper) menustring += '<li class="rc-spacer"></li>' if (Active.Map && Active.Mapper) menustring += '<li class="rc-spacer"></li>'
if (Active.Mapper) { if (Active.Mapper) {
var permOptions = '<ul><li class="changeP toCommons"><div class="rc-perm-icon"></div>commons</li> \ var permOptions = outdent`
<li class="changeP toPublic"><div class="rc-perm-icon"></div>public</li> \ <ul>
<li class="changeP toPrivate"><div class="rc-perm-icon"></div>private</li> \ <li class="changeP toCommons"><div class="rc-perm-icon"></div>commons</li>
</ul>' <li class="changeP toPublic"><div class="rc-perm-icon"></div>public</li> \
<li class="changeP toPrivate"><div class="rc-perm-icon"></div>private</li> \
</ul>`
menustring += '<li class="rc-permission"><div class="rc-icon"></div>Change permissions' + permOptions + '<div class="expandLi"></div></li>' menustring += '<li class="rc-permission"><div class="rc-icon"></div>Change permissions' + permOptions + '<div class="expandLi"></div></li>'
} }

View file

@ -1,3 +1,5 @@
/* global $ */
const CheatSheet = { const CheatSheet = {
init: function () { init: function () {
// tab the cheatsheet // tab the cheatsheet

View file

@ -343,7 +343,7 @@ const InfoBox = {
permission: permission permission: permission
}) })
Active.Map.updateMapWrapper() Active.Map.updateMapWrapper()
shareable = permission === 'private' ? '' : 'shareable' const shareable = permission === 'private' ? '' : 'shareable'
$('.mapPermission').removeClass('commons public private minimize').addClass(permission) $('.mapPermission').removeClass('commons public private minimize').addClass(permission)
$('.mapPermission .permissionSelect').remove() $('.mapPermission .permissionSelect').remove()
$('.mapInfoBox').removeClass('shareable').addClass(shareable) $('.mapInfoBox').removeClass('shareable').addClass(shareable)
@ -369,7 +369,7 @@ const InfoBox = {
GlobalUI.notifyUser('Map eliminated!') GlobalUI.notifyUser('Map eliminated!')
} }
else if (!authorized) { else if (!authorized) {
alert("Hey now. We can't just go around willy nilly deleting other people's maps now can we? Run off and find something constructive to do, eh?") window.alert("Hey now. We can't just go around willy nilly deleting other people's maps now can we? Run off and find something constructive to do, eh?")
} }
} }
} }

View file

@ -230,7 +230,7 @@ const Map = {
canEditNow: function () { canEditNow: function () {
var confirmString = "You've been granted permission to edit this map. " var confirmString = "You've been granted permission to edit this map. "
confirmString += 'Do you want to reload and enable realtime collaboration?' confirmString += 'Do you want to reload and enable realtime collaboration?'
var c = confirm(confirmString) var c = window.confirm(confirmString)
if (c) { if (c) {
Router.maps(Active.Map.id) Router.maps(Active.Map.id)
} }
@ -256,10 +256,11 @@ const Map = {
canvas.getSize = function () { canvas.getSize = function () {
if (this.size) return this.size if (this.size) return this.size
var canvas = this.canvas var canvas = this.canvas
return this.size = { this.size = {
width: canvas.width, width: canvas.width,
height: canvas.height height: canvas.height
} }
return this.size
} }
canvas.scale = function (x, y) { canvas.scale = function (x, y) {
var px = this.scaleOffsetX * x, var px = this.scaleOffsetX * x,

View file

@ -1,5 +1,3 @@
/* global $ */
import _ from 'lodash' import _ from 'lodash'
import $jit from '../patched/JIT' import $jit from '../patched/JIT'
@ -44,7 +42,7 @@ const Organize = {
var column = floor(width / cellWidth) var column = floor(width / cellWidth)
var totalCells = row * column var totalCells = row * column
if (totalCells) if (totalCells) {
Visualize.mGraph.graph.eachNode(function (n) { Visualize.mGraph.graph.eachNode(function (n) {
if (column == numColumns) { if (column == numColumns) {
column = 0 column = 0
@ -56,6 +54,7 @@ const Organize = {
n.setPos(newPos, 'end') n.setPos(newPos, 'end')
column += 1 column += 1
}) })
}
Visualize.mGraph.animate(JIT.ForceDirected.animateSavedLayout) Visualize.mGraph.animate(JIT.ForceDirected.animateSavedLayout)
} else if (layout == 'radial') { } else if (layout == 'radial') {
var centerX = centerNode.getPos().x var centerX = centerNode.getPos().x
@ -112,7 +111,7 @@ const Organize = {
console.log(lowX, lowY, highX, highY) console.log(lowX, lowY, highX, highY)
var newOriginX = (lowX + highX) / 2 var newOriginX = (lowX + highX) / 2
var newOriginY = (lowY + highY) / 2 var newOriginY = (lowY + highY) / 2
} else alert('please call function with a valid layout dammit!') } else window.alert('please call function with a valid layout dammit!')
} }
} }

View file

@ -13,16 +13,16 @@ const PasteInput = {
// intercept dragged files // intercept dragged files
// see http://stackoverflow.com/questions/6756583 // see http://stackoverflow.com/questions/6756583
window.addEventListener("dragover", function(e) { window.addEventListener("dragover", function(e) {
e = e || event; e = e || window.event;
e.preventDefault(); e.preventDefault();
}, false); }, false);
window.addEventListener("drop", function(e) { window.addEventListener("drop", function(e) {
e = e || event; e = e || window.event;
e.preventDefault(); e.preventDefault();
var coords = Util.pixelsToCoords({ x: e.clientX, y: e.clientY }) var coords = Util.pixelsToCoords({ x: e.clientX, y: e.clientY })
if (e.dataTransfer.files.length > 0) { if (e.dataTransfer.files.length > 0) {
var fileReader = new FileReader() var fileReader = new window.FileReader()
var text = fileReader.readAsText(e.dataTransfer.files[0]) fileReader.readAsText(e.dataTransfer.files[0])
fileReader.onload = function(e) { fileReader.onload = function(e) {
var text = e.currentTarget.result var text = e.currentTarget.result
if (text.substring(0,5) === '<?xml') { if (text.substring(0,5) === '<?xml') {

View file

@ -8,6 +8,7 @@ import GlobalUI from './GlobalUI'
import JIT from './JIT' import JIT from './JIT'
import Map from './Map' import Map from './Map'
import Mapper from './Mapper' import Mapper from './Mapper'
import Synapse from './Synapse'
import Topic from './Topic' import Topic from './Topic'
import Util from './Util' import Util from './Util'
import Views from './Views' import Views from './Views'

View file

@ -1,6 +1,6 @@
const Selected = { const Selected = {
reset: function () { reset: function () {
var self = Metamaps.Selected var self = Selected
self.Nodes = [] self.Nodes = []
self.Edges = [] self.Edges = []
}, },

View file

@ -15,7 +15,7 @@ const Settings = {
background: '#18202E', background: '#18202E',
text: '#DDD' text: '#DDD'
} }
}, }
} }
export default Settings export default Settings

View file

@ -1,4 +1,4 @@
/* global Metamaps, $ */ /* global Metamaps, $, CanvasLoader, Countable, Hogan, embedly */
import Active from './Active' import Active from './Active'
import GlobalUI from './GlobalUI' import GlobalUI from './GlobalUI'