contactsPane.js
function (book, name, callbackFunction) {
        var gix = kb.any(book, ns.vcard('groupIndex'))

        var x = book.uri.split('#')[0]
        var gname = name.replace(' ', '_')
        var doc = kb.sym(x.slice(0, x.lastIndexOf('/') + 1) + 'Group/' + gname + '.ttl')
        var group = kb.sym(doc.uri + '#this')
        console.log(' New group will be: ' + group + '\n')

        UI.store.fetcher.nowOrWhenFetched(gix, function (ok, message) {
          if (ok) {
            console.log(' Group index must be loaded\n')

            var insertTriples = [
              $rdf.st(book, ns.vcard('includesGroup'), group, gix),
              $rdf.st(group, ns.rdf('type'), ns.vcard('Group'), gix),
              $rdf.st(group, ns.vcard('fn'), name, gix)
            ]
            updater.update([], insertTriples, function (uri, success, body) {
              if (ok) {
                var triples = [
                  $rdf.st(book, ns.vcard('includesGroup'), group, gix), // Pointer back to book
                  $rdf.st(group, ns.rdf('type'), ns.vcard('Group'), doc),
                  $rdf.st(group, ns.vcard('fn'), name, doc)
                ]
                updater.put(doc, triples, 'text/turtle', function (uri, ok, body) {
                  callbackFunction(ok, ok ? group : "Can't save new group file " + doc + body)
                })
              } else {
                callbackFunction(ok, 'Could not update group index ' + body) // fail
              }
            })
          } else {
            console.log('Error loading people index!' + gix.uri + ': ' + message)
            callbackFunction(false, 'Error loading people index!' + gix.uri + ': ' + message + '\n')
          }
        })
      }
function (book, name, callbackFunction) {
        var gix = kb.any(book, ns.vcard('groupIndex'))

        var x = book.uri.split('#')[0]
        var gname = name.replace(' ', '_')
        var doc = kb.sym(x.slice(0, x.lastIndexOf('/') + 1) + 'Group/' + gname + '.ttl')
        var group = kb.sym(doc.uri + '#this')
        console.log(' New group will be: ' + group + '\n')

        UI.store.fetcher.nowOrWhenFetched(gix, function (ok, message) {
          if (ok) {
            console.log(' Group index must be loaded\n')

            var insertTriples = [
              $rdf.st(book, ns.vcard('includesGroup'), group, gix),
              $rdf.st(group, ns.rdf('type'), ns.vcard('Group'), gix),
              $rdf.st(group, ns.vcard('fn'), name, gix)
            ]
            updater.update([], insertTriples, function (uri, success, body) {
              if (ok) {
                var triples = [
                  $rdf.st(book, ns.vcard('includesGroup'), group, gix), // Pointer back to book
                  $rdf.st(group, ns.rdf('type'), ns.vcard('Group'), doc),
                  $rdf.st(group, ns.vcard('fn'), name, doc)
                ]
                updater.put(doc, triples, 'text/turtle', function (uri, ok, body) {
                  callbackFunction(ok, ok ? group : "Can't save new group file " + doc + body)
                })
              } else {
                callbackFunction(ok, 'Could not update group index ' + body) // fail
              }
            })
          } else {
            console.log('Error loading people index!' + gix.uri + ': ' + message)
            callbackFunction(false, 'Error loading people index!' + gix.uri + ': ' + message + '\n')
          }
        })
      }
function ( book , name , callbackFunction ) { var gix = kb . any ( book , ns . vcard ( 'groupIndex' ) ) var x = book . uri . split ( '#' ) [ 0 ] var gname = name . replace ( ' ' , '_' ) var doc = kb . sym ( x . slice ( 0 , x . lastIndexOf ( '/' ) + 1 ) + 'Group/' + gname + '.ttl' ) var group = kb . sym ( doc . uri + '#this' ) console . log ( ' New group will be: ' + group + '\n' ) UI . store . fetcher . nowOrWhenFetched ( gix , function ( ok , message ) { if ( ok ) { console . log ( ' Group index must be loaded\n' ) var insertTriples = [ $rdf . st ( book , ns . vcard ( 'includesGroup' ) , group , gix ) , $rdf . st ( group , ns . rdf ( 'type' ) , ns . vcard ( 'Group' ) , gix ) , $rdf . st ( group , ns . vcard ( 'fn' ) , name , gix ) ] updater . update ( [ ] , insertTriples , function ( uri , success , body ) { if ( ok ) { var triples = [ $rdf . st ( book , ns . vcard ( 'includesGroup' ) , group , gix ) , // Pointer back to book $rdf . st ( group , ns . rdf ( 'type' ) , ns . vcard ( 'Group' ) , doc ) , $rdf . st ( group , ns . vcard ( 'fn' ) , name , doc ) ] updater . put ( doc , triples , 'text/turtle' , function ( uri , ok , body ) { callbackFunction ( ok , ok ? group : "Can't save new group file " + doc + body ) } ) } else { callbackFunction ( ok , 'Could not update group index ' + body ) // fail } } ) } else { console . log ( 'Error loading people index!' + gix . uri + ': ' + message ) callbackFunction ( false , 'Error loading people index!' + gix . uri + ': ' + message + '\n' ) } } ) }
Write new group to web Creates an empty new group file and adds it to the index
Write new group to web Creates an empty new group file and adds it to the index