diff --git a/examples/docs.html b/examples/docs.html index 73389007..87412a8a 100644 --- a/examples/docs.html +++ b/examples/docs.html @@ -27,11 +27,13 @@

Docs

-

The contemporary tendency in our society is to base our distribution on scarcity, which has vanished, and to compress our abundance into the overfed mouths of the middle and upper classes until they gag with superfluity. If democracy is to have breadth of meaning, it is necessary to adjust this inequity. It is not only moral, but it is also intelligent. We are wasting and degrading human life by clinging to archaic thinking.

+

The contemporary tendency in our society is to base our distribution on scarcity, which has vanished, and to compress our abundance into the overfed mouths of the middle and upper classes until they gag with superfluity. If democracy is to have breadth of meaning, it is necessary to adjust this inequity. It is not only moral, but it is also intelligent. We are wasting and degrading human life by clinging to archaic thinking.

+ + - - - - diff --git a/examples/stats.html b/examples/stats.html index b6dfe27d..8d1d72df 100644 --- a/examples/stats.html +++ b/examples/stats.html @@ -2,161 +2,93 @@ - + - -
0 peers 0 min 0 nodes 0 hours
-
-
+ + +
-
-
-
+
+
-
-
-
-
-
- -
-
-
- -
-
-
- - + \ No newline at end of file diff --git a/lib/meta.js b/lib/meta.js index b067f868..6cb610ac 100644 --- a/lib/meta.js +++ b/lib/meta.js @@ -16,133 +16,131 @@ if(typeof module !== "undefined"){ var common = module } ;USE(function(module){ - var noop = function(){}, u; - $.fn.or = function(s){ return this.length ? this : $(s||'body') }; - var m = window.meta = {edit:[]}; - var k = m.key = {}; - k.meta = {17:17, 91:17, 93:17, 224:17}; - k.down = function(eve){ - if(eve.repeat){ return } - var key = (k.eve = m.eve = eve).which = eve.which || eve.fake || eve.keyCode; - if(!eve.fake && key === k.last){ return } k.last = key; - if(!eve.fake && $(eve.target).closest('input, textarea, [contenteditable=true]').length){ - if(k.meta[key]){ k.down.meta = key = -1 } - if(!k.down.meta){ return } - } - (k.combo || (k.combo = [])).push(key); - m.check('on', key, k.at || (k.at = m.edit)); - if(k.meta[key]){ - m.list(k.at.back || m.edit); - if(k.at && !k.at.back){ m.flip() } - } + var noop = function(){}, u; + $.fn.or = function(s){ return this.length ? this : $(s||'body') }; + var m = window.meta = {edit:[]}; + var k = m.key = {}; + k.meta = {17:17, 91:17, 93:17, 224:17}; + k.down = function(eve){ + if(eve.repeat){ return } + var key = (k.eve = m.eve = eve).which = eve.which || eve.fake || eve.keyCode; + if(!eve.fake && key === k.last){ return } k.last = key; + if(!eve.fake && $(eve.target).closest('input, textarea, [contenteditable=true]').length){ + if(k.meta[key]){ k.down.meta = key = -1 } + if(!k.down.meta){ return } } - k.up = function(eve){ var tmp; - var key = (k.eve = m.eve = eve).which = eve.which || eve.fake || eve.keyCode; - if(!eve.fake && $(eve.target).closest('input, textarea, [contenteditable=true]').length){ + (k.combo || (k.combo = [])).push(key); + m.check('on', key, k.at || (k.at = m.edit)); if(k.meta[key]){ - k.down.meta = null; - key = -1; - } else - if(!k.down.meta){ return } - } - k.last = null; - if($(':focus').closest('#meta').length){ return } - m.check('up', key); - if(-1 === key || 27 === eve.which){ k.wipe() } - } - m.flip = function(tmp){ - var board = $('#meta .meta-menu'); - ((tmp === false) || (!tmp && board.is(':visible')))? - board.addClass('meta-none') - : board.removeClass('meta-none'); - } - m.flip.is = function(){ - return $('#meta .meta-menu').is(':visible'); - } - m.flip.wait = 500; - m.check = function(how, key, at){ - at = k.at || m.edit; - var edit = at[key]; - if(!edit){ return } - var tmp = k.eve || noop; - if(tmp.preventDefault){ tmp.preventDefault() } - if(edit[how]){ - if(tmp.fake && !edit.fake){ - m.tap.edit = edit; - } else { - edit[how](m.eve); - /*if(k.at !== m.edit && 'up' === how){ - if(k.down.meta){ m.list(k.at = m.edit) } - else { k.wipe() } - }*/ + m.list(k.at.back || m.edit); + if(k.at && !k.at.back){ m.flip() } } } - if('up' != how){ return } - if(at != edit){ edit.back = at } - m.list(edit, true); + k.up = function(eve){ var tmp; + var key = (k.eve = m.eve = eve).which = eve.which || eve.fake || eve.keyCode; + if(!eve.fake && $(eve.target).closest('input, textarea, [contenteditable=true]').length){ + if(k.meta[key]){ + k.down.meta = null; + key = -1; + } else + if(!k.down.meta){ return } } - m.list = function(at, opt){ - if(!at){ return m.flip(false) } - var l = []; - $.each(at, function(i,k){ 'back' != i && k.combo && k.name && l.push(k) }); - if(!l.length){ return } - k.at = at; - l = l.sort(function(a,b){ - a = a.combo.slice(-1)[0] || 0; - if(a.length){ a = a.toUpperCase().charCodeAt(0) } - b = b.combo.slice(-1)[0] || 0; - if(b.length){ b = b.toUpperCase().charCodeAt(0) } - return (a < b)? -1 : 1; - }); - var $ul = $('#meta .meta-menu ul') - $ul.children('li').addClass('meta-none').hide(); setTimeout(function(){ $ul.children('.meta-none').remove() },250); // necessary fix for weird bug glitch - $.each(l, function(i, k){ - $ul.append($('
  • ').text(k.name)); - }); - if(opt){ m.flip(true) } - $ul.append($('
  • ').html('←').one('click', function(){ - m.list(k.at = at.back); - })); + k.last = null; + if($(':focus').closest('#meta').length){ return } + m.check('up', key); + if(-1 === key || 27 === eve.which){ k.wipe() } + } + m.flip = function(tmp){ + var board = $('#meta .meta-menu'); + ((tmp === false) || (!tmp && board.is(':visible')))? + board.addClass('meta-none') + : board.removeClass('meta-none'); + } + m.flip.is = function(){ + return $('#meta .meta-menu').is(':visible'); + } + m.flip.wait = 500; + m.check = function(how, key, at){ + at = k.at || m.edit; + var edit = at[key]; + if(!edit){ return } + var tmp = k.eve || noop; + if(tmp.preventDefault){ tmp.preventDefault() } + if(edit[how]){ + //if(tmp.fake && !edit.fake){ + //m.tap.edit = edit; + //} else { + edit[how](m.eve); + /*if(k.at !== m.edit && 'up' === how){ + if(k.down.meta){ m.list(k.at = m.edit) } + else { k.wipe() } + }*/ + //} } - m.ask = function(help, cb){ - var $ul = $('#meta .meta-menu ul').empty(); - var $put = $('').attr('id', 'meta-ask').attr('placeholder', help); - var $form = $('
    ').append($put).on('submit', function(eve){ - eve.preventDefault(); - cb($put.val()); - $li.remove(); - k.wipe(); - }); - var $li = $('
  • ').append($form); - $ul.append($li); - m.flip(true); - $put.focus(); - } - k.wipe = function(opt){ - k.down.meta = false; - k.combo = []; - if(!opt){ m.flip(false) } - m.list(k.at = m.edit); - }; - m.tap = function(){ - var on = $('.meta-on') - .or($($(document.querySelectorAll(':hover')).get().reverse()).first()) - .or($(document.elementFromPoint(meta.tap.x, meta.tap.y))); - return on; - } - meta.edit = function(edit){ - var tmp = edit.combow = []; - $.each(edit.combo || (edit.combo = []), function(i,k){ - if(!k || !k.length){ if('number' == typeof k){ tmp.push(k) } return } - tmp.push(k.toUpperCase().charCodeAt(0)); - }); - var at = meta.edit, l = edit.combo.length; - $.each(tmp, function(i,k){ at = at[k] = (++i >= l)? edit : at[k] || {} }); - edit.combow = edit.combow.join(','); - m.list(meta.edit); - } - - + if('up' != how){ return } + if(at != edit){ edit.back = at } + m.list(edit, true); + } + m.list = function(at, opt){ + if(!at){ return m.flip(false) } + var l = []; + $.each(at, function(i,k){ 'back' != i && k.combo && k.name && l.push(k) }); + if(!l.length){ return } + k.at = at; + l = l.sort(function(a,b){ + a = a.combo.slice(-1)[0] || 0; + if(a.length){ a = a.toUpperCase().charCodeAt(0) } + b = b.combo.slice(-1)[0] || 0; + if(b.length){ b = b.toUpperCase().charCodeAt(0) } + return (a < b)? -1 : 1; + }); + var $ul = $('#meta .meta-menu ul') + $ul.children('li').addClass('meta-none').hide(); setTimeout(function(){ $ul.children('.meta-none').remove() },250); // necessary fix for weird bug glitch + $.each(l, function(i, k){ + $ul.append($('
  • ').text(k.name).data(k)); + }); + if(opt){ m.flip(true) } + $ul.append($('
  • ').html('←').one('click', function(){ + m.list(k.at = at.back); + })); + } + m.ask = function(help, cb){ + var $ul = $('#meta .meta-menu ul').empty(); + var $put = $('').attr('id', 'meta-ask').attr('placeholder', help); + var $form = $('').append($put).on('submit', function(eve){ + eve.preventDefault(); + cb($put.val()); + $li.remove(); + k.wipe(); + }); + var $li = $('
  • ').append($form); + $ul.append($li); + m.flip(true); + $put.focus(); + } + k.wipe = function(opt){ + k.down.meta = false; + k.combo = []; + if(!opt){ m.flip(false) } + m.list(k.at = m.edit); + }; + m.tap = function(){ + var on = $('.meta-on') + .or($($(document.querySelectorAll(':hover')).get().reverse()).first()) + .or($(document.elementFromPoint(meta.tap.x, meta.tap.y))); + return on; + } + meta.edit = function(edit){ + var tmp = edit.combow = []; + $.each(edit.combo || (edit.combo = []), function(i,k){ + if(!k || !k.length){ if('number' == typeof k){ tmp.push(k) } return } + tmp.push(k.toUpperCase().charCodeAt(0)); + }); + var at = meta.edit, l = edit.combo.length; + $.each(tmp, function(i,k){ at = at[k] = (++i >= l)? edit : at[k] || {} }); + edit.combow = edit.combow.join(','); + m.list(meta.edit); + } })(USE, './metaCore'); ;USE(function(module){ try{ @@ -235,8 +233,7 @@ tag.innerHTML = tmp; document.body.appendChild(tag); } - }catch(e){} - + }catch(e){} })(USE, './metaUI'); ;USE(function(module){ // include basic text editing by default. @@ -380,8 +377,6 @@ on: function(eve){ meta.text.editor('fontSize', 7) }, up: function(){} }); - - })(USE, './metaText'); ;USE(function(module){ var m = meta, k = m.key; @@ -399,6 +394,11 @@ }); $(document).on('touchstart', '#meta .meta-start', function(eve){ m.tap.stun = true }); $(document).on('click', '#meta .meta-menu li', function(eve){ + eve.fake = eve.which = $(this).data().combo.slice(-1)[0].charCodeAt(0); + eve.tap = true; + k.down(eve); + //k.up(eve); + return; if(m.tap.stun){ return m.tap.stun = false } if(!(eve.fake = eve.which = (($(this).text().match(/[A-Z]/)||{})[0]||'').toUpperCase().charCodeAt(0))){ return } eve.tap = true; @@ -407,7 +407,5 @@ }); $(document).on('keydown', k.down).on('keyup', k.up); $(document).on('select contextmenu keyup mouseup', '[contenteditable=true]', m.text.on); - - })(USE, './metaEvents'); }()); diff --git a/sea.js b/sea.js index ee2fbf8f..f42db5d0 100644 --- a/sea.js +++ b/sea.js @@ -964,6 +964,7 @@ } // If authenticated user wants to delete his/her account, let's support it! User.prototype.delete = async function(alias, pass, cb){ + console.log("user.delete() IS DEPRECATED AND WILL BE MOVED TO A MODULE!!!"); var gun = this, root = gun.back(-1), user = gun.back('user'); try { user.auth(alias, pass, function(ack){ @@ -1005,6 +1006,7 @@ return gun; } User.prototype.alive = async function(){ + console.log("user.alive() IS DEPRECATED!!!"); const gunRoot = this.back(-1) try { // All is good. Should we do something more with actual recalled data? @@ -1024,25 +1026,32 @@ console.log(ctx, ev) }) } + user.get('trust').get(path).put(theirPubkey); + + // do a lookup on this gun chain directly (that gets bob's copy of the data) + // do a lookup on the metadata trust table for this path (that gets all the pubkeys allowed to write on this path) + // do a lookup on each of those pubKeys ON the path (to get the collab data "layers") + // THEN you perform Jachen's mix operation + // and return the result of that to... } User.prototype.grant = function(to, cb){ console.log("`.grant` API MAY BE DELETED OR CHANGED OR RENAMED, DO NOT USE!"); - var gun = this, user = gun.back(-1).user(), pair = user.pair(), path = ''; + var gun = this, user = gun.back(-1).user(), pair = user._.sea, path = ''; gun.back(function(at){ if(at.is){ return } path += (at.get||'') }); (async function(){ - var enc, sec = await user.get('trust').get(pair.pub).get(path).then(); + var enc, sec = await user.get('grant').get(pair.pub).get(path).then(); sec = await SEA.decrypt(sec, pair); if(!sec){ sec = SEA.random(16).toString(); enc = await SEA.encrypt(sec, pair); - user.get('trust').get(pair.pub).get(path).put(enc); + user.get('grant').get(pair.pub).get(path).put(enc); } var pub = to.get('pub').then(); var epub = to.get('epub').then(); pub = await pub; epub = await epub; var dh = await SEA.secret(epub, pair); enc = await SEA.encrypt(sec, dh); - user.get('trust').get(pub).get(path).put(enc, cb); + user.get('grant').get(pub).get(path).put(enc, cb); }()); return gun; }