json version...

Signed-off-by: Alex A. Naanou <alex.nanou@gmail.com>
This commit is contained in:
Alex A. Naanou 2013-02-02 01:51:08 +04:00
parent 0bd08709a1
commit 2c796d930d

View File

@ -1000,6 +1000,8 @@ function writeMetadata(elem, res, metadata){
return elem return elem
} }
var JSON_VERSION = 0.1
function buildJSON(export_bookmarks, export_position){ function buildJSON(export_bookmarks, export_position){
function _getContent(_, elem){ function _getContent(_, elem){
elem = $(elem) elem = $(elem)
@ -1040,6 +1042,8 @@ function buildJSON(export_bookmarks, export_position){
res.pages = $('.magazine > .page, .magazine > .article').map(_getContent).toArray(), res.pages = $('.magazine > .page, .magazine > .article').map(_getContent).toArray(),
res.bookmarks = export_bookmarks ? buildBookmarkList() : [] res.bookmarks = export_bookmarks ? buildBookmarkList() : []
res['format-version'] = JSON_VERSION
if(export_position){ if(export_position){
res.position = getPageNumber() res.position = getPageNumber()
} }
@ -1085,6 +1089,12 @@ function loadJSON(data, ignore_chrome){
writeMetadata(elem, res) writeMetadata(elem, res)
} }
// XXX check version...
var version = data['json-version']
if(version != JSON_VERSION){
console.warn('WARNING: JSON Format Version Mismatch.')
}
// create an empty magazine... // create an empty magazine...
var mag = createEmptyMagazine(data.title) var mag = createEmptyMagazine(data.title)
writeMetadata(mag, data) writeMetadata(mag, data)