Changeset - 3c997bc6d380
[Not reviewed]
default
0 11 1
Drew Perttula - 7 years ago 2018-05-24 06:54:58
drewp@bigasterisk.com
fix some coffee lint
Ignore-this: 1a988be1598dda76dd2fefca3b499aa0
8 files changed with 163 insertions and 20 deletions:
0 comments (0 inline, 0 general)
coffeelint.json
Show inline comments
 
new file 100644
 
{
 
  "arrow_spacing": {
 
    "level": "ignore"
 
  },
 
  "braces_spacing": {
 
    "level": "ignore",
 
    "spaces": 0,
 
    "empty_object_spaces": 0
 
  },
 
  "camel_case_classes": {
 
    "level": "error"
 
  },
 
  "coffeescript_error": {
 
    "level": "error"
 
  },
 
  "colon_assignment_spacing": {
 
    "level": "ignore",
 
    "spacing": {
 
      "left": 0,
 
      "right": 0
 
    }
 
  },
 
  "cyclomatic_complexity": {
 
    "level": "ignore",
 
    "value": 10
 
  },
 
  "duplicate_key": {
 
    "level": "error"
 
  },
 
  "empty_constructor_needs_parens": {
 
    "level": "ignore"
 
  },
 
  "ensure_comprehensions": {
 
    "level": "warn"
 
  },
 
  "eol_last": {
 
    "level": "ignore"
 
  },
 
  "indentation": {
 
    "value": 2,
 
    "level": "error"
 
  },
 
  "line_endings": {
 
    "level": "ignore",
 
    "value": "unix"
 
  },
 
  "max_line_length": {
 
    "value": 80,
 
    "level": "error",
 
    "limitComments": true
 
  },
 
  "missing_fat_arrows": {
 
    "level": "ignore",
 
    "is_strict": false
 
  },
 
  "newlines_after_classes": {
 
    "value": 3,
 
    "level": "ignore"
 
  },
 
  "no_backticks": {
 
    "level": "warn"
 
  },
 
  "no_debugger": {
 
    "level": "warn",
 
    "console": false
 
  },
 
  "no_empty_functions": {
 
    "level": "ignore"
 
  },
 
  "no_empty_param_list": {
 
    "level": "ignore"
 
  },
 
  "no_implicit_braces": {
 
    "level": "ignore",
 
    "strict": true
 
  },
 
  "no_implicit_parens": {
 
    "level": "ignore",
 
    "strict": true
 
  },
 
  "no_interpolation_in_single_quotes": {
 
    "level": "ignore"
 
  },
 
  "no_nested_string_interpolation": {
 
    "level": "warn"
 
  },
 
  "no_plusplus": {
 
    "level": "ignore"
 
  },
 
  "no_private_function_fat_arrows": {
 
    "level": "warn"
 
  },
 
  "no_stand_alone_at": {
 
    "level": "ignore"
 
  },
 
  "no_tabs": {
 
    "level": "error"
 
  },
 
  "no_this": {
 
    "level": "ignore"
 
  },
 
  "no_throwing_strings": {
 
    "level": "error"
 
  },
 
  "no_trailing_semicolons": {
 
    "level": "error"
 
  },
 
  "no_trailing_whitespace": {
 
    "level": "error",
 
    "allowed_in_comments": false,
 
    "allowed_in_empty_lines": true
 
  },
 
  "no_unnecessary_double_quotes": {
 
    "level": "ignore"
 
  },
 
  "no_unnecessary_fat_arrows": {
 
    "level": "warn"
 
  },
 
  "non_empty_constructor_needs_parens": {
 
    "level": "ignore"
 
  },
 
  "prefer_english_operator": {
 
    "level": "ignore",
 
    "doubleNotLevel": "ignore"
 
  },
 
  "space_operators": {
 
    "level": "ignore"
 
  },
 
  "spacing_after_comma": {
 
    "level": "ignore"
 
  },
 
  "transform_messes_up_line_numbers": {
 
    "level": "warn"
 
  }
 
}
light9/web/graph.coffee
Show inline comments
 
@@ -19,25 +19,27 @@ patchSizeSummary = (patch) ->
 

	
 
# (sloppily shared to rdfdbclient.coffee too)
 
window.patchSizeSummary = patchSizeSummary
 

	
 
class Handler
 
  # a function and the quad patterns it cared about
 
  constructor: (@func, @label) ->
 
    @patterns = [] # s,p,o,g quads that should trigger the next run
 
    @innerHandlers = [] # Handlers requested while this one was running
 
  
 
class AutoDependencies
 
  constructor: () ->
 
    @handlers = new Handler(null) # tree of all known Handlers (at least those with non-empty patterns). Top node is not a handler.
 
    # tree of all known Handlers (at least those with non-empty
 
    # patterns). Top node is not a handler.
 
    @handlers = new Handler(null)
 
    @handlerStack = [@handlers] # currently running
 
    
 
  runHandler: (func, label) ->
 
    # what if we have this func already? duplicate is safe?
 

	
 
    if not label?
 
      throw new Error("missing label")
 

	
 
    h = new Handler(func, label)
 
    tailChildren = @handlerStack[@handlerStack.length - 1].innerHandlers
 
    matchingLabel = _.filter(tailChildren, ((c) -> c.label == label)).length
 
    # ohno, something depends on some handlers getting run twice :(
 
@@ -142,25 +144,25 @@ class window.SyncedGraph
 
                                 @_clearGraphOnNewConnection.bind(@),
 
                                 @_applyPatch.bind(@),
 
                                 @setStatus)
 
    
 
  clearGraph: ->
 
    # just deletes the statements; watchers are unaffected.
 
    if @graph?
 
      @_applyPatch({addQuads: [], delQuads: @graph.getQuads()})
 

	
 
    # if we had a Store already, this lets N3.Store free all its indices/etc
 
    @graph = N3.Store()
 
    @_addPrefixes(@prefixes)
 
    @cachedFloatValues = new Map();
 
    @cachedFloatValues = new Map()
 

	
 
  _clearGraphOnNewConnection: -> # must not send a patch to the server!
 
    log('graph: clearGraphOnNewConnection')
 
    @clearGraph()
 
    log('graph: clearGraphOnNewConnection done')
 
      
 
  _addPrefixes: (prefixes) ->
 
    for k in (prefixes or {})
 
      @prefixes[k] = prefixes[k]
 
    @prefixFuncs = N3.Util.prefixes(@prefixes)
 
        
 
  Uri: (curie) ->
 
@@ -314,29 +316,31 @@ class window.SyncedGraph
 
  items: (list) ->
 
    out = []
 
    current = list
 
    while true
 
      if current == RDF + 'nil'
 
        break
 
        
 
      @_autoDeps.askedFor(current, null, null, null) # a little loose
 

	
 
      firsts = @graph.getQuads(current, RDF + 'first', null)
 
      rests = @graph.getQuads(current, RDF + 'rest', null)
 
      if firsts.length != 1
 
        throw new Error("list node #{current} has #{firsts.length} rdf:first edges")
 
        throw new Error(
 
          "list node #{current} has #{firsts.length} rdf:first edges")
 
      out.push(firsts[0].object)
 

	
 
      if rests.length != 1
 
        throw new Error("list node #{current} has #{rests.length} rdf:rest edges")
 
        throw new Error(
 
          "list node #{current} has #{rests.length} rdf:rest edges")
 
      current = rests[0].object
 
    
 
    return out
 

	
 
  contains: (s, p, o) ->
 
    @_autoDeps.askedFor(s, p, o, null)
 
    return @graph.getQuads(s, p, o).length > 0
 

	
 
  nextNumberedResources: (base, howMany) ->
 
    # base is NamedNode or string
 
    base = base.id if base.id
 
    results = []
light9/web/rdfdbclient.coffee
Show inline comments
 
@@ -43,25 +43,26 @@ parseJsonPatch = (jsonPatch, cb) ->
 
  parseDels = (cb) =>
 
    parser = N3.Parser()
 
    parser.parse input.patch.deletes, (error, quad, prefixes) =>
 
                  if (quad)
 
                    patch.delQuads.push(quad)
 
                  else
 
                    cb()
 

	
 
  async.parallel([parseAdds, parseDels], ((err) => cb(patch)))
 

	
 
class window.RdfDbClient
 
  # Send and receive patches from rdfdb
 
  constructor: (@patchSenderUrl, @clearGraphOnNewConnection, @applyPatch, @setStatus) ->
 
  constructor: (@patchSenderUrl, @clearGraphOnNewConnection, @applyPatch,
 
                @setStatus) ->
 
    @_patchesToSend = []
 
    @_lastPingMs = -1
 
    @_patchesReceived = 0
 
    @_patchesSent = 0
 

	
 
    @_reconnectionTimeout = null
 
    @_newConnection()
 

	
 
  _updateStatus: ->
 
    ws = (if not @ws? then 'no' else switch @ws.readyState
 
      when @ws.CONNECTING then 'connecting'
 
      when @ws.OPEN then 'open'
light9/web/timeline/adjustable.coffee
Show inline comments
 
@@ -101,25 +101,26 @@ class window.AdjustableFloatObject exten
 
  constructor: (@config) ->
 
    # config also has:
 
    #   graph
 
    #   subj
 
    #   pred
 
    #   ctx
 
    #   getTargetPosForValue(value) -> getTarget result for value
 
    #   getValueForPos
 
    super()
 
    @ctor2()
 
    if not @config.ctx?
 
      throw new Error("missing ctx")
 
    @config.graph.runHandler(@_syncValue.bind(@), "adj sync #{@config.subj.value}")
 
    @config.graph.runHandler(@_syncValue.bind(@),
 
                             "adj sync #{@config.subj.value}")
 

	
 
  _syncValue: () ->
 
    @_currentValue = @config.graph.floatValue(@config.subj, @config.pred)
 
    @_onChange() if @_onChange
 
    
 
  _getValue: () ->
 
    # this is a big speedup- callers use _getValue about 4x as much as
 
    # the graph changes and graph.floatValue is slow
 
    @_currentValue
 

	
 
  getTarget: () ->
 
    @config.getTargetPosForValue(@_getValue())
 
@@ -151,25 +152,25 @@ class window.AdjustableFade extends Adju
 
  getTarget: ->
 
    mid = @note.worldPts[@i0].x(.5).add(@note.worldPts[@i1].x(.5))
 
    $V([@note.zoomInX(mid.e(1)), @yForV(mid.e(2))])
 

	
 
  _getValue: ->
 
    mid = @note.worldPts[@i0].x(.5).add(@note.worldPts[@i1].x(.5))
 
    mid.e(1)
 

	
 
   continueDrag: (pos) ->
 
    # pos is vec2 of pixels relative to the drag start
 
    super(pos)
 
    graph = @note.graph
 
    U = (x) => graph.Uri(x)
 
    U = (x) -> graph.Uri(x)
 

	
 
    goalCenterSec = @note.zoomInX.invert(@initialTarget.e(1) + pos.e(1))
 

	
 
    diamSec = @note.worldPts[@i1].e(1) - @note.worldPts[@i0].e(1)
 
    newSec0 = goalCenterSec - diamSec / 2
 
    newSec1 = goalCenterSec + diamSec / 2
 

	
 
    originSec = graph.floatValue(@note.uri, U(':originTime'))
 

	
 
    p0 = @_makePatch(graph, @i0, newSec0, originSec, @config.ctx)
 
    p1 = @_makePatch(graph, @i1, newSec1, originSec, @config.ctx)
 

	
light9/web/timeline/adjusters.coffee
Show inline comments
 
@@ -31,25 +31,26 @@ coffeeElementSetup(class AdjustersCanvas
 
    if ev.buttons == 1
 
      start = $V([ev.x, ev.y])
 
      adj = @_adjAtPoint(start)
 
      if adj
 
        ev.stopPropagation()
 
        @currentDrag = {start: start, adj: adj}
 
        adj.startDrag()
 

	
 
  onMove: (ev) ->
 
    pos = $V([ev.x, ev.y])
 
    if @currentDrag
 
      @currentDrag.cur = pos
 
      @currentDrag.adj.continueDrag(@currentDrag.cur.subtract(@currentDrag.start))
 
      @currentDrag.adj.continueDrag(
 
        @currentDrag.cur.subtract(@currentDrag.start))
 

	
 
  onUp: (ev) ->
 
    return unless @currentDrag
 
    @currentDrag.adj.endDrag()
 
    @currentDrag = null
 
    
 
  _setAdjuster: (adjId, makeAdjustable) ->
 
    # callers register/unregister the Adjustables they want us to make
 
    # adjuster elements for. Caller invents adjId.  makeAdjustable is
 
    # a function returning the Adjustable or it is null to clear any
 
    # adjusters with this id.
 
    if not @adjs[adjId] or not makeAdjustable?
light9/web/timeline/drawing.coffee
Show inline comments
 
@@ -13,23 +13,23 @@ window.Drawing.svgPathFromPoints = (pts)
 
    return
 
  out
 

	
 
window.Drawing.line = (ctx, p1, p2) ->
 
  ctx.moveTo(p1.e(1), p1.e(2))
 
  ctx.lineTo(p2.e(1), p2.e(2))
 

	
 
# http://stackoverflow.com/a/4959890
 
window.Drawing.roundRect = (ctx, sx,sy,ex,ey,r) ->
 
    d2r = Math.PI/180
 
    r = ( ( ex - sx ) / 2 ) if ( ex - sx ) - ( 2 * r ) < 0 # ensure that the radius isn't too large for x
 
    r = ( ( ey - sy ) / 2 ) if ( ey - sy ) - ( 2 * r ) < 0 # ensure that the radius isn't too large for y
 
    ctx.beginPath();
 
    ctx.moveTo(sx+r,sy);
 
    ctx.lineTo(ex-r,sy);
 
    ctx.arc(ex-r,sy+r,r,d2r*270,d2r*360,false);
 
    ctx.lineTo(ex,ey-r);
 
    ctx.arc(ex-r,ey-r,r,d2r*0,d2r*90,false);
 
    ctx.lineTo(sx+r,ey);
 
    ctx.arc(sx+r,ey-r,r,d2r*90,d2r*180,false);
 
    ctx.lineTo(sx,sy+r);
 
    ctx.arc(sx+r,sy+r,r,d2r*180,d2r*270,false);
 
    ctx.closePath();
 
  ctx.beginPath()
 
  ctx.moveTo(sx+r,sy)
 
  ctx.lineTo(ex-r,sy)
 
  ctx.arc(ex-r,sy+r,r,d2r*270,d2r*360,false)
 
  ctx.lineTo(ex,ey-r)
 
  ctx.arc(ex-r,ey-r,r,d2r*0,d2r*90,false)
 
  ctx.lineTo(sx+r,ey)
 
  ctx.arc(sx+r,ey-r,r,d2r*90,d2r*180,false)
 
  ctx.lineTo(sx,sy+r)
 
  ctx.arc(sx+r,sy+r,r,d2r*180,d2r*270,false)
 
  ctx.closePath()
light9/web/timeline/timeline.coffee
Show inline comments
 
@@ -632,13 +632,13 @@ class Note
 
    else        
 
      hash = 0
 
      for i in [(effect.length-10)...effect.length]
 
        hash += effect.charCodeAt(i)
 
      hue = (hash * 8) % 360
 
      sat = 40 + (hash % 20) # don't conceal colorscale too much
 

	
 
    return parseInt(tinycolor.fromRatio({h: hue / 360, s: sat / 100, l: .58}).toHex(), 16)
 

	
 
    #elem = @getOrCreateElem(uri+'/label', 'noteLabels', 'text', {style: "font-size:13px;line-height:125%;font-family:'Verana Sans';text-align:start;text-anchor:start;fill:#000000;"})
 
    #elem.setAttribute('x', curvePts[0].e(1)+20)
 
    #elem.setAttribute('y', curvePts[0].e(2)-10)
 
    #elem.innerHTML = effectLabel;
 
    #elem.innerHTML = effectLabel
package.json
Show inline comments
 
@@ -5,24 +5,25 @@
 
  "license": "MIT",
 
  "description": "Mini instructions:",
 
  "main": "index.js",
 
  "directories": {
 
    "test": "test"
 
  },
 
  "dependencies": {
 
    "@webcomponents/shadycss": "^1.1.3",
 
    "@webcomponents/webcomponentsjs": "^1.2.0",
 
    "bower": "^1.8.4",
 
    "browserify": "^16.2.0",
 
    "chai": "^3.5.0",
 
    "coffeelint": "^2.1.0",
 
    "coffeescript": "^2.3.0",
 
    "d3": "^5.1.0",
 
    "mocha": "^2.5.3",
 
    "n3": "^1.0.0-alpha",
 
    "pixi.js": "^4.7.3",
 
    "tinycolor2": "^1.4.1"
 
  },
 
  "devDependencies": {
 
    "mocha": "^2.5.3"
 
  },
 
  "scripts": {
 
    "test": "mocha"
0 comments (0 inline, 0 general)