Changeset - e46907e9e053
[Not reviewed]
default
0 4 0
Drew Perttula - 7 years ago 2018-06-05 06:05:58
drewp@bigasterisk.com
sort numbers within uris numerically
Ignore-this: bf3ffb36469c1ddf62fab0bd92c80dd5
4 files changed with 19 insertions and 5 deletions:
0 comments (0 inline, 0 general)
light9/effect/sequencer.html
Show inline comments
 
@@ -112,15 +112,21 @@
 
               report.roundT = Math.floor((report.t || 0) * 1000) / 1000;
 
               report.recentFps = Math.floor((report.recentFps || 0) * 10) / 10;
 
               report.recentDeltasStyle = (report.recentDeltas || []).map((dt) => {
 
                 const height = Math.min(40, dt / 0.025 * 20);
 
                 return `height: ${height}px;`
 
               });
 

	
 
               const fakeUris = (report.songNotes || []).map((obj) => { return {value: obj.note, orig: obj} });
 
               const s = this.graph.sortedUris(fakeUris);
 
               report.songNotes = s.map((u) => { return u.orig; });
 
               
 
               (report.songNotes || []).forEach((note) => {
 
                 note.rowClass = note.nonZero ? 'active' : 'inactive';
 
                 note.effectSettingsPairs = [];
 

	
 
                 const attrs = Object.keys(note.effectSettings);
 
                 attrs.sort();
 
                 attrs.forEach((attr) => {
 
                   note.effectSettingsPairs.push(
 
                     {effectAttr: attr, value: note.effectSettings[attr]});
 
                 });
light9/web/graph.coffee
Show inline comments
 
@@ -368,6 +368,14 @@ class window.SyncedGraph
 
    @_autoDeps.askedFor(s, p, o, null)
 
    ctxs = []
 
    for q in @graph.getQuads(s, p, o)
 
      ctxs.push(q.graph)
 
    return _.unique(ctxs)
 

	
 
  sortedUris: (uris) ->
 
    _.sortBy uris, (u) ->
 
      parts = u.value.split(/([0-9]+)/)
 
      expanded = parts.map (p) ->
 
        f = parseInt(p)
 
        return p if isNaN(f)
 
        return p.padStart(8, '0')
 
      return expanded.join('')
light9/web/live/live.coffee
Show inline comments
 
@@ -56,25 +56,25 @@ coffeeElementSetup(class Light9LiveDevic
 
  update: ->
 
    U = (x) => @graph.Uri(x)
 
    
 
    @deviceClass = @graph.uriValue(@uri, U('rdf:type'))
 
    
 
    @deviceAttrs = []
 
    for da in _.unique(_.sortBy(@graph.objects(@deviceClass, U(':deviceAttr'))))
 
    for da in _.unique(@graph.sortedUris(@graph.objects(@deviceClass, U(':deviceAttr'))))
 
      dataType = @graph.uriValue(da, U(':dataType'))
 
      daRow = {
 
        uri: da
 
        dataType: dataType
 
        showColorPicker: dataType.equals(U(':color'))
 
        }
 
      if dataType.equals(U(':color'))
 
        daRow.useColor = true
 

	
 
      else if dataType.equals(U(':choice'))
 
        daRow.useChoice = true
 
        choiceUris = _.sortBy(@graph.objects(da, U(':choice')))
 
        choiceUris = @graph.sortedUris(@graph.objects(da, U(':choice')))
 
        daRow.choices = ({uri: x, label: @graph.labelOrTail(x)} for x in choiceUris)
 
        daRow.choiceSize = Math.min(choiceUris.length + 1, 10)
 
      else
 
        daRow.useSlider = true
 
        daRow.max = 1
 
        if dataType.equals(U(':angle'))
 
@@ -188,14 +188,14 @@ coffeeElementSetup(class Light9LiveContr
 
      llc.clear()
 
    
 
  update: ->
 
    U = (x) => @graph.Uri(x)
 

	
 
    @set('devices', [])
 
    for dc in _.sortBy(@graph.subjects(U('rdf:type'), U(':DeviceClass')))
 
      for dev in _.sortBy(@graph.subjects(U('rdf:type'), dc))
 
    for dc in @graph.sortedUris(@graph.subjects(U('rdf:type'), U(':DeviceClass')))
 
      for dev in @graph.sortedUris(@graph.subjects(U('rdf:type'), dc))
 
        @push('devices', {uri: dev})
 

	
 
    return
 

	
 
    # Tried css columns- big slowdown from relayout as I'm scrolling.
 
    # Tried isotope- seems to only scroll to the right.
light9/web/timeline/timeline.coffee
Show inline comments
 
@@ -352,13 +352,13 @@ coffeeElementSetup(class TimeZoomed exte
 
    U = (x) => @graph.Uri(x)
 
    return unless @song?
 
    songNotes = @graph.objects(U(@song), U(':note'))
 

	
 
    toRemove = new Set(@noteByUriStr.keys())
 
    
 
    for uri in _.sortBy(songNotes, 'id')
 
    for uri in @graph.sortedUris(songNotes)
 
      had = toRemove.delete(uri.value)
 
      if not had
 
        @_addNote(uri)
 

	
 
    toRemove.forEach @_delNote.bind(@)
 

	
0 comments (0 inline, 0 general)