Add version diff to file

This commit is contained in:
Bruno SIMON
2016-06-03 14:54:15 +02:00
parent 9347b79423
commit c9e2a20343
2 changed files with 19 additions and 2 deletions
+12 -2
View File
@@ -19,15 +19,25 @@ class File
create_version( content )
{
// Create version
let version = {}
let version = {},
last_version = this.get_last_version()
// Set up
version.date = new Date()
version.content = content
version.diff = last_version ? diff.diffChars( last_version.content, version.content ) : false
// Save
this.versions.push( version )
}
get_last_version()
{
if( this.versions.length === 0 )
return false
return this.versions[ this.versions.length - 1 ]
}
destructor()
{
console.log( 'destruct' )