Changeset - 951ef08ce4ad
[Not reviewed]
default
0 1 0
drewp@bigasterisk.com - 9 years ago 2016-06-11 21:13:01
drewp@bigasterisk.com
don't save zeros in effects. put each fx in its own n3 file
Ignore-this: a2b27986c2aacd3f48fd9110b6d673a0
1 file changed with 11 insertions and 5 deletions:
0 comments (0 inline, 0 general)
light9/web/live/live.coffee
Show inline comments
 
@@ -47,31 +47,37 @@ Polymer
 
    ]
 
  ready: ->
 
    @currentSettings = {}
 
    @effectPreview = JSON.stringify({})
 
    window.gather = (sent) =>
 
      [dev, devAttr, value] = sent[0]
 
      return if value == 0
 
      @currentSettings[dev + " " + devAttr] = [dev, devAttr, value]
 
      key = dev + " " + devAttr
 
      if value == 0 or value == '#000000'
 
        delete @currentSettings[key]
 
      else
 
        @currentSettings[key] = [dev, devAttr, value]
 
      @effectPreview = JSON.stringify(v for k,v of @currentSettings)
 
  saveNewEffect: ->
 
    return if not @newEffectName.length
 
    uriName = @newEffectName.replace(/[^a-zA-Z0-9_]/g, '')
 
    return if not uriName.length
 

	
 
    U = (x) -> @graph.Uri(x)
 

	
 
    effectUri = U(":effect") + "/#{@newEffectName}"
 
    ctx = U('http://light9.bigasterisk.com/show/dance2016/effect')
 
    effectUri = U(":effect") + "/#{uriName}"
 
    ctx = U("http://light9.bigasterisk.com/show/dance2016/effect/#{uriName}")
 
    quad = (s, p, o) => {subject: s, predicate: p, object: o, graph: ctx}
 

	
 
    addQuads = [
 
      quad(effectUri, U('rdf:type'), U(':Effect'))
 
      quad(effectUri, U('rdfs:label'), @graph.Literal(@newEffectName))
 
      quad(effectUri, U(':publishAttr'), U(':strength'))
 
      ]
 
    settings = @graph.nextNumberedResources(effectUri + '_set', Object.keys(@currentSettings).length)
 
    for _, row of @currentSettings
 
      if row[2] == 0 or row[2] == '#000000'
 
        continue
 
      setting = settings.shift()
 
      addQuads.push(quad(effectUri, U(':setting'), setting))
 
      addQuads.push(quad(setting, U(':device'), row[0]))
 
      addQuads.push(quad(setting, U(':deviceAttr'), row[1]))
 
      scaledAttributeTypes = [U(':color'), U(':brightness'), U(':uv')]
 
      value = if typeof(row[2]) == 'number'
0 comments (0 inline, 0 general)