changeset 1781:e46907e9e053

sort numbers within uris numerically Ignore-this: bf3ffb36469c1ddf62fab0bd92c80dd5
author Drew Perttula <drewp@bigasterisk.com>
date Tue, 05 Jun 2018 06:05:58 +0000
parents fbc94316c048
children e6eb97a87117
files light9/effect/sequencer.html light9/web/graph.coffee light9/web/live/live.coffee light9/web/timeline/timeline.coffee
diffstat 4 files changed, 20 insertions(+), 5 deletions(-) [+]
line wrap: on
line diff
--- a/light9/effect/sequencer.html	Mon Jun 04 08:23:05 2018 +0000
+++ b/light9/effect/sequencer.html	Tue Jun 05 06:05:58 2018 +0000
@@ -115,9 +115,15 @@
                  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) => {
--- a/light9/web/graph.coffee	Mon Jun 04 08:23:05 2018 +0000
+++ b/light9/web/graph.coffee	Tue Jun 05 06:05:58 2018 +0000
@@ -371,3 +371,12 @@
       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('')
+      
\ No newline at end of file
--- a/light9/web/live/live.coffee	Mon Jun 04 08:23:05 2018 +0000
+++ b/light9/web/live/live.coffee	Tue Jun 05 06:05:58 2018 +0000
@@ -59,7 +59,7 @@
     @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
@@ -71,7 +71,7 @@
 
       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
@@ -191,8 +191,8 @@
     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
--- a/light9/web/timeline/timeline.coffee	Mon Jun 04 08:23:05 2018 +0000
+++ b/light9/web/timeline/timeline.coffee	Tue Jun 05 06:05:58 2018 +0000
@@ -355,7 +355,7 @@
 
     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)