ONE BIG MASSIVE UPDATE

This commit is contained in:
Mark Nadal
2015-05-29 16:01:00 -07:00
parent 2f59cb0ade
commit e89c19cdd8
26 changed files with 5319 additions and 796 deletions

View File

@@ -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() );
});
};
});

View File

@@ -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));
});

View File

@@ -8,7 +8,7 @@
}
, "dependencies": {
"express": "~>4.9.0",
"gun": "0.1.5"
"gun": "file:../"
}
, "scripts": {
"start": "node express.js",

View File

@@ -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, '&lt;'));
gun.path(id).put(($("#todoItem").value||'').toString().replace(/\</ig, '&lt;'));
$("#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>