Added WebDAV syncing
This commit is contained in:
parent
b9e8278689
commit
d5518a164e
13 changed files with 284 additions and 70 deletions
11
js/file.js
11
js/file.js
|
|
@ -2,13 +2,16 @@ function File(id){
|
|||
let _this = this;
|
||||
if(!id) id = File.uuid();
|
||||
let info = this.info = {id, enabled:true};
|
||||
|
||||
|
||||
this.changeInfo = function(i){
|
||||
for(let _i in i){
|
||||
info[_i] = i[_i];
|
||||
}
|
||||
};
|
||||
|
||||
this.touch = function(){
|
||||
info.lastModified = ((new Date()).getTime() / 1000)|0;
|
||||
}
|
||||
|
||||
this.save = function(){
|
||||
return new Promise(function(succ, err){
|
||||
Storage.save({[File.PREFIX+info.id]:info}).then(_ => {
|
||||
|
|
@ -16,12 +19,14 @@ function File(id){
|
|||
});
|
||||
});
|
||||
};
|
||||
|
||||
|
||||
this.onChange = function(info){}; //Placeholder function
|
||||
Storage.onChange(File.PREFIX+id, newInfo => {
|
||||
_this.changeInfo(newInfo);
|
||||
_this.onChange(newInfo);
|
||||
});
|
||||
|
||||
return this;
|
||||
}
|
||||
File.PREFIX = "FILE-";
|
||||
File.saveIndex = function(id, enabled){
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue