encryption updates
This commit is contained in:
3
app/assets/javascripts/app/frontend/models/group.js
Normal file
3
app/assets/javascripts/app/frontend/models/group.js
Normal file
@@ -0,0 +1,3 @@
|
||||
var Group = function (json_obj) {
|
||||
_.merge(this, json_obj);
|
||||
};
|
||||
@@ -23,6 +23,10 @@ var Note = function (json_obj) {
|
||||
enumerable: true,
|
||||
});
|
||||
|
||||
this.setContentRaw = function(rawContent) {
|
||||
content = rawContent;
|
||||
}
|
||||
|
||||
_.merge(this, json_obj);
|
||||
|
||||
if(!this.content) {
|
||||
@@ -30,17 +34,22 @@ var Note = function (json_obj) {
|
||||
}
|
||||
};
|
||||
|
||||
Note.filterDummyNotes = function(notes) {
|
||||
var filtered = notes.filter(function(note){return note.dummy == false || note.dummy == null});
|
||||
return filtered;
|
||||
}
|
||||
|
||||
/* Returns true if note is shared individually or via group */
|
||||
Note.prototype.isPublic = function() {
|
||||
return this.hasEnabledPresentation() || this.shared_via_group;
|
||||
return this.presentation || (this.group && this.group.presentation);
|
||||
};
|
||||
|
||||
Note.prototype.isEncrypted = function() {
|
||||
return (this.loc_eek || this.local_eek) && typeof this.content === 'string' ? true : false;
|
||||
return this.encryptionEnabled() && typeof this.content === 'string' ? true : false;
|
||||
}
|
||||
|
||||
Note.prototype.hasEnabledPresentation = function() {
|
||||
return this.presentation && this.presentation.enabled;
|
||||
Note.prototype.encryptionEnabled = function() {
|
||||
return this.loc_eek;
|
||||
}
|
||||
|
||||
Note.prototype.presentationURL = function() {
|
||||
|
||||
@@ -1,3 +1,23 @@
|
||||
var User = function (json_obj) {
|
||||
_.merge(this, json_obj);
|
||||
|
||||
this.notes = _.map(this.notes, function(json_obj) {
|
||||
return new Note(json_obj);
|
||||
});
|
||||
|
||||
this.groups = _.map(this.groups, function(json_obj) {
|
||||
return new Group(json_obj);
|
||||
});
|
||||
|
||||
this.groups.forEach(function(group){
|
||||
var notes = this.notes.filter(function(note){return note.group_id && note.group_id == group.id});
|
||||
notes.forEach(function(note){
|
||||
note.group = group;
|
||||
})
|
||||
group.notes = notes;
|
||||
}.bind(this))
|
||||
};
|
||||
|
||||
User.prototype.filteredNotes = function() {
|
||||
return Note.filterDummyNotes(this.notes);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user