Skip to content

Commit

Permalink
update to remoteStorage.js 0.8.1
Browse files Browse the repository at this point in the history
  • Loading branch information
xMartin committed Sep 30, 2013
1 parent 85dde20 commit bb3c525
Show file tree
Hide file tree
Showing 9 changed files with 41 additions and 35 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Expand Up @@ -3,3 +3,5 @@ js/dojo/
js/dojox/
js/util/
js/release/
js/remotestorage.js
js/remotestorage.min.js
5 changes: 3 additions & 2 deletions README.md
@@ -1,6 +1,6 @@
To use it you need the [Dojo Toolkit](http://dojotoolkit.org/) 1.9.

Additionally you need [master of remoteStorage.js](https://github.com/RemoteStorage/remoteStorage.js). Copy the `src/` directory and rename it to `remote-storage`.
Additionally you need [remoteStorage.js 0.8](http://remotestorage.io/integrate/).

Your `js/` directory should look like this:

Expand All @@ -10,8 +10,9 @@ root/
+ dijit/
+ dojo/
+ gka/
+ remote-storage/
+ util/
remotestorage.js
remotestorage.min.js
```

Use `index.dev.html` for development.
Expand Down
1 change: 1 addition & 0 deletions gruppenkasse.manifest
Expand Up @@ -3,6 +3,7 @@ CACHE MANIFEST

CACHE:
js/release/gka/css/style.css
js/remotestorage.min.js
js/release/dojo/dojo.js
js/release/dojo/nls/dojo_de.js
js/release/dojo/resources/blank.gif
Expand Down
1 change: 1 addition & 0 deletions index.dev.html
Expand Up @@ -7,6 +7,7 @@
<link rel="apple-touch-icon" href="apple-touch-icon.png">
<link rel="apple-touch-startup-image" href="splash.png">
<link rel="stylesheet" type="text/css" href="js/gka/css/style.css">
<script type="text/javascript" src="js/remotestorage.js"></script>
<script data-dojo-config="async:true" type="text/javascript" src="js/dojo/dojo.js"></script>
<script type="text/javascript">
require(["dojo/ready", "gka/app"], function(ready, app){
Expand Down
1 change: 1 addition & 0 deletions index.html
Expand Up @@ -7,6 +7,7 @@
<link rel="apple-touch-icon" href="apple-touch-icon.png">
<link rel="apple-touch-startup-image" href="splash.png">
<link rel="stylesheet" type="text/css" href="js/release/gka/css/style.css">
<script type="text/javascript" src="js/remotestorage.min.js"></script>
<script data-dojo-config="async:true" type="text/javascript" src="js/release/dojo/dojo.js"></script>
<script type="text/javascript">
require(["dojo/ready", "gka/app"], function(ready, app){
Expand Down
45 changes: 22 additions & 23 deletions js/gka/app.js
Expand Up @@ -5,11 +5,11 @@ define([
"gka/MainView",
"gka/NewEntryView",
"gka/ListView",
"gka/DetailsView",
"remote-storage/remoteStorage"
], function(RemoteStorageAdapter, viewController, BoxView, MainView, NewEntryView, ListView, DetailsView, remoteStorage){
"gka/DetailsView"
], function(RemoteStorageAdapter, viewController, BoxView, MainView, NewEntryView, ListView, DetailsView){

var store = new RemoteStorageAdapter().store
var remoteStorageAdapter = new RemoteStorageAdapter()
var store = remoteStorageAdapter.store

var obj = {

Expand Down Expand Up @@ -49,26 +49,25 @@ var obj = {
viewController.selectView(obj.box ? views["main"] : views["box"])

// init remote storage
remoteStorage.claimAccess("gruppenkasse", "rw").then(function(){
remoteStorage.displayWidget("remotestorage-connect")
remoteStorage.access.claim("gruppenkasse", "rw")
remoteStorage.displayWidget()
remoteStorage.gruppenkasse.init()
remoteStorageAdapter.init()
remoteStorage.gruppenkasse.on("change", function(event){
console.log(event.origin, "event")
if(event.newValue && event.oldValue){
console.log(event.path + " was updated")
}else if(event.newValue){
console.log(event.path + " was created")
}else if(event.oldValue){
console.log(event.path + " was deleted")
}
refreshData()

remoteStorage.gruppenkasse.on("change", function(event){
console.log(event.origin, "event")
if(event.newValue && event.oldValue){
console.log(event.path + " was updated")
}else if(event.newValue){
console.log(event.path + " was created")
}else if(event.oldValue){
console.log(event.path + " was deleted")
}
refreshData()
})

remoteStorage.onWidget("state", function(state){
if(state == "disconnected"){
emptyData()
}
})
remoteStorage.on("features-loaded", function(){
refreshData()
remoteStorage.on("disconnect", function(){
emptyData()
})
})

Expand Down
12 changes: 7 additions & 5 deletions js/gka/remoteStorageModule.js
@@ -1,17 +1,19 @@
define([
"remote-storage/remoteStorage"
], function(remoteStorage){
define(function(){

var moduleName = "gruppenkasse"

remoteStorage.defineModule(moduleName, function(privateClient, publicClient){
RemoteStorage.defineModule(moduleName, function(privateClient, publicClient){

return {

name: moduleName,

exports: {

init: function() {
privateClient.cache("", true)
},

// remoteStorage.gruppenkasse.on("change", function(changeEvent){
// if(changeEvent.newValue && changeEvent.oldValue){
// changeEvent.origin:
Expand Down
5 changes: 4 additions & 1 deletion js/gka/store/RemoteStorageAdapter.js
Expand Up @@ -15,8 +15,11 @@ return declare(null, {
dataArrayKey: "",

constructor: function(args){
this.store = new memoryStore
},

init: function(){
var _this = this
_this.store = new memoryStore
_this._connects = [
connect.connect(_this.store, "put", _this, "put"),
connect.connect(_this.store, "remove", _this, "remove")
Expand Down
4 changes: 0 additions & 4 deletions profile.js
Expand Up @@ -11,10 +11,6 @@ var profile = {
{
name: "gka",
location: "js/gka"
},
{
name: "remote-storage",
location: "js/remote-storage"
}
],
layers: {
Expand Down

0 comments on commit bb3c525

Please sign in to comment.