mirror of
https://github.com/amark/gun.git
synced 2025-03-30 15:08:33 +00:00
get rid of tmp
This commit is contained in:
parent
04c731cfe7
commit
c61ab82569
@ -1,50 +0,0 @@
|
||||
<h1>User</h1>
|
||||
|
||||
<form id="sign">
|
||||
<input id="alias" placeholder="username">
|
||||
<input id="pass" type="password" placeholder="passphrase">
|
||||
<input id="in" type="submit" value="sign in">
|
||||
<input id="up" type="button" value="sign up">
|
||||
</form>
|
||||
|
||||
<ul></ul>
|
||||
|
||||
<form id="said">
|
||||
<input id="say">
|
||||
<input id="speak" type="button" value="speak">
|
||||
</form>
|
||||
|
||||
<script src="../../examples/jquery.js"></script>
|
||||
<script src="../../gun.js"></script>
|
||||
<script src="../../sea.js"></script>
|
||||
|
||||
<script>
|
||||
var gun = Gun();
|
||||
var user = gun.user();
|
||||
|
||||
$('#up').on('click', function(e){
|
||||
user.create($('#alias').val(), $('#pass').val());
|
||||
});
|
||||
|
||||
$('#sign').on('submit', function(e){
|
||||
e.preventDefault();
|
||||
user.auth($('#alias').val(), $('#pass').val());
|
||||
});
|
||||
|
||||
gun.on('auth', function(){
|
||||
$('#sign').hide();
|
||||
user.get('said').map().val(UI);
|
||||
});
|
||||
|
||||
$('#said').on('submit', function(e){
|
||||
e.preventDefault();
|
||||
if(!user.is){ return }
|
||||
user.get('said').set($('#say').val());
|
||||
$('#say').val("");
|
||||
});
|
||||
|
||||
function UI(say, id){
|
||||
var li = $('#' + id).get(0) || $('<li>').attr('id', id).appendTo('ul');
|
||||
$(li).text(say);
|
||||
};
|
||||
</script>
|
@ -1,17 +1,25 @@
|
||||
var Gun = require('../../');
|
||||
|
||||
var data = require('fs').readFileSync('/Users/mark/Downloads/raddataformat.txt');
|
||||
/*var data = '';
|
||||
var a = [], b = Gun.text.random(1000 * 1000 * 10), c;
|
||||
for(var i = 0; i <= 7; i++){
|
||||
data += b;
|
||||
}
|
||||
*/
|
||||
data = 1;
|
||||
|
||||
data = data.toString();
|
||||
data += data + data;
|
||||
|
||||
console.log(data.length);
|
||||
|
||||
var gun = Gun('http://localhost:8080/gun');
|
||||
var gun = Gun('http://localhost:8765/gun');
|
||||
//var gun = Gun();
|
||||
|
||||
setTimeout(function(){
|
||||
|
||||
/*console.log("READ!");
|
||||
gun.get('bigsync').get('raw').on(function(a,b){
|
||||
console.log('yay!', b, (a && a.slice && a.slice(0,20)) || a, a.length);
|
||||
});
|
||||
return;*/
|
||||
console.log("SEND!");
|
||||
gun.get('bigsync').get('raw').put(data);
|
||||
gun.get('bigsync').get('raw').put(data, function(ack){console.log(ack)});
|
||||
|
||||
/*var req = require('http').request({
|
||||
host: 'localhost'
|
||||
|
@ -1,101 +0,0 @@
|
||||
<h1>notabug</h1>
|
||||
|
||||
<script src="https://cdn.jsdelivr.net/npm/gun/examples/jquery.js"></script>
|
||||
<script src="https://cdn.jsdelivr.net/npm/gun@0.9.9992/gun.js"></script>
|
||||
<script src="https://cdn.jsdelivr.net/npm/gun@0.9.9992/sea.js"></script>
|
||||
|
||||
<span id='info'></span>
|
||||
|
||||
<h2>homepage</h2>
|
||||
<ul>
|
||||
</ul>
|
||||
|
||||
<div class="model" style="display: none;">
|
||||
<li id="submission">
|
||||
<a href=""></a>
|
||||
<i></i>
|
||||
</li>
|
||||
</div>
|
||||
|
||||
<script>
|
||||
// utilities jacked from NAB
|
||||
var getDayStr = function (timestamp) {
|
||||
var d = new Date(timestamp || new Date().getTime());
|
||||
var year = d.getUTCFullYear();
|
||||
var month = d.getUTCMonth() + 1;
|
||||
var dayNum = d.getUTCDate();
|
||||
return year + "/" + month + "/" + dayNum;
|
||||
}
|
||||
|
||||
function lastDays(days){ --days;
|
||||
var oneDay = (1000*60*60*24);
|
||||
var start = (new Date()).getTime() - oneDay * parseInt(days, 10);
|
||||
dayStrings = [];
|
||||
for (let i = 0; i <= (days + 1); i++) {
|
||||
dayStrings.push(getDayStr(start + (i * oneDay)));
|
||||
}
|
||||
return dayStrings.reverse();
|
||||
}
|
||||
</script>
|
||||
|
||||
<script>
|
||||
Gun.on('create', function(root){
|
||||
var route = {}, rpc = 'homepage', link = Gun.val.link.is;
|
||||
root.on('get', function(msg){
|
||||
var eve = this, get = msg.get, soul = get['#'], ack, tmp;
|
||||
if(soul !== rpc){
|
||||
return eve.to.next(msg);
|
||||
}
|
||||
console.log('get', msg, route);
|
||||
if(tmp = route[rpc]){
|
||||
console.log("do something!", tmp);
|
||||
ack = true;
|
||||
//return;
|
||||
}
|
||||
var graph = root.graph, index = route[rpc] = {};
|
||||
var days = lastDays(2), pre = 'nab/topics/all/days/';
|
||||
days.forEach(function(day){
|
||||
root.$.get(pre + day).map().get('data').once(function(){});
|
||||
if(!(tmp = graph[pre + day])){ return }
|
||||
index[pre + day] = tmp;
|
||||
});
|
||||
Gun.graph.is(index, null, function(val, key){
|
||||
if(!(key = link(val))){ return }
|
||||
console.log("???", key, val);
|
||||
root.$.get(key).once(function(){});
|
||||
if(!(val = graph[key])){ return }
|
||||
index[key] = val;
|
||||
});
|
||||
});
|
||||
})
|
||||
</script>
|
||||
|
||||
<script>;(function(){
|
||||
//localStorage.clear();
|
||||
// benchmark logic
|
||||
var check = {};
|
||||
//var gun = Gun('https://notabug.io/gun');
|
||||
var gun = Gun();
|
||||
window.gun = gun;
|
||||
|
||||
// 'nab/topics/all/days/2018/6/26';
|
||||
var pre = 'nab/topics/all/days/';
|
||||
|
||||
var days = lastDays(2);
|
||||
var start = (+new Date);
|
||||
|
||||
gun.get('homepage').on(function(){});
|
||||
|
||||
days.forEach(function(day){
|
||||
check[pre + day] = true;
|
||||
gun.get(pre + day).map().get('data').once(function(data, key){
|
||||
if(!data || !data.title){ return }
|
||||
$(info).text("loaded in... " + (((+new Date)-start)/1000) +'s.');
|
||||
//console.log('...', key, data);
|
||||
var $li = $(submission).clone(true).attr('id','').appendTo('ul');
|
||||
$li.find('a').attr('src', data.url).text(data.title);
|
||||
$li.find('i').text(data.topic);
|
||||
});
|
||||
});
|
||||
|
||||
}());</script>
|
Loading…
x
Reference in New Issue
Block a user