mirror of
https://github.com/amark/gun.git
synced 2026-03-13 20:05:24 +00:00
ONE BIG MASSIVE UPDATE
This commit is contained in:
@@ -53,10 +53,10 @@
|
||||
var gun = Gun(location.origin + '/gun');
|
||||
angular.module('admin', []).controller('editor', function($scope){
|
||||
$scope.data = {};
|
||||
$scope.$data = gun.load('example/angular/data').blank(function(){
|
||||
$scope.$data = gun.get('example/angular/data')/*.not(function(){
|
||||
console.log("Initializing Data!");
|
||||
this.set({});
|
||||
}).on(function(data){
|
||||
this.put({});
|
||||
})*/.on(function(data){
|
||||
Gun.obj.map(data, function(val, field){
|
||||
if(val === $scope.data[field]){ return }
|
||||
$scope.data[field] = val;
|
||||
@@ -64,13 +64,13 @@
|
||||
$scope.$apply();
|
||||
});
|
||||
$scope.add = function(){
|
||||
$scope.$data.path($scope.field).set( $scope.data[$scope.field] = 'value' );
|
||||
$scope.$data.path($scope.field).put( $scope.data[$scope.field] = 'value' );
|
||||
$scope.field = '';
|
||||
};
|
||||
}).directive('gun', function(){
|
||||
return function(scope, elem){
|
||||
elem.on('keyup', function(){
|
||||
scope.$data.path(scope.key).set( scope.data[scope.key] = elem.text() );
|
||||
scope.$data.path(scope.key).put( scope.data[scope.key] = elem.text() );
|
||||
});
|
||||
};
|
||||
});
|
||||
|
||||
@@ -6,11 +6,11 @@ var gun = Gun({
|
||||
bucket: '' // The bucket you want to save into
|
||||
}
|
||||
});
|
||||
gun.set({ hello: 'world' }).key('my/first/data');
|
||||
gun.put({ hello: 'world' }).key('my/first/data');
|
||||
|
||||
var http = require('http');
|
||||
http.createServer(function(req, res){
|
||||
gun.load('my/first/data', function(err, data){
|
||||
gun.get('my/first/data', function(err, data){
|
||||
res.writeHead(200, {'Content-Type': 'application/json'});
|
||||
res.end(JSON.stringify(data));
|
||||
});
|
||||
|
||||
@@ -8,7 +8,7 @@
|
||||
}
|
||||
, "dependencies": {
|
||||
"express": "~>4.9.0",
|
||||
"gun": "0.1.5"
|
||||
"gun": "file:../"
|
||||
}
|
||||
, "scripts": {
|
||||
"start": "node express.js",
|
||||
|
||||
@@ -9,8 +9,9 @@
|
||||
<script>
|
||||
// by Forrest Tait! Edited by Mark Nadal.
|
||||
function ready(){
|
||||
Gun.log.verbose = true;
|
||||
var $ = document.querySelector.bind(document);
|
||||
var gun = Gun(location.origin + '/gun').load('example/todo/data').set({});
|
||||
var gun = Gun(location.origin + '/gun').get('example/todo/data');
|
||||
gun.on(function renderToDo(val){
|
||||
var todoHTML = '';
|
||||
for(key in val) {
|
||||
@@ -22,12 +23,12 @@
|
||||
});
|
||||
$("#addToDo").onsubmit = function(){
|
||||
var id = randomId();
|
||||
gun.path(id).set(($("#todoItem").value||'').toString().replace(/\</ig, '<'));
|
||||
gun.path(id).put(($("#todoItem").value||'').toString().replace(/\</ig, '<'));
|
||||
$("#todoItem").value = "";
|
||||
return false;
|
||||
};
|
||||
window.removeToDo = function(id){
|
||||
gun.path(id).set(null);
|
||||
gun.path(id).put(null);
|
||||
}
|
||||
}
|
||||
function randomId(){
|
||||
@@ -35,4 +36,4 @@
|
||||
}
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
||||
</html>
|
||||
Reference in New Issue
Block a user