From 5b4c7353efe0491e7a41dd120392fefd184489f6 Mon Sep 17 00:00:00 2001 From: "Alex A. Naanou" Date: Fri, 17 Nov 2017 18:00:34 +0300 Subject: [PATCH] more work on filenames... Signed-off-by: Alex A. Naanou --- ui (gen4)/imagegrid/formats.js | 20 ++++++++++++++++++++ ui (gen4)/imagegrid/images.js | 29 ++++++++++++++++++++++++++--- 2 files changed, 46 insertions(+), 3 deletions(-) diff --git a/ui (gen4)/imagegrid/formats.js b/ui (gen4)/imagegrid/formats.js index b8169f6f..4b55f8d3 100755 --- a/ui (gen4)/imagegrid/formats.js +++ b/ui (gen4)/imagegrid/formats.js @@ -142,6 +142,26 @@ function(data){ } */ +/* XXX we do not have a ref to images... +module.VERSIONS['3.1'] = +function(data){ + res = module.VERSIONS['3.0'](data) + + res.version = '3.1' + + // XXX we do not have a ref to images here... + Object.values(res.images || {}) + .forEach(function(img){ + Object.keys(img.preview) + .forEach(function(res){ + var p = img.preview[res] + img.preview[res] = p.indexOf('%20') >= 0 ? decodeURI(p) : p + }) + }) + + return res +} +//*/ // Get latest updater version... diff --git a/ui (gen4)/imagegrid/images.js b/ui (gen4)/imagegrid/images.js index 7bdcaa67..941cea1e 100755 --- a/ui (gen4)/imagegrid/images.js +++ b/ui (gen4)/imagegrid/images.js @@ -351,6 +351,9 @@ module.ImagesClassPrototype = { var ImagesPrototype = module.ImagesPrototype = { + //version: '3.1', + + get length(){ return Object.keys(this).length }, @@ -500,6 +503,10 @@ module.ImagesPrototype = { url = previews[k] } } + + // XXX LEGACY... + //url = url.indexOf('%20') >= 0 ? decodeURI(url) : url + return { url: (full_path && img_data.base_path ? img_data.base_path + '/' @@ -698,15 +705,31 @@ module.ImagesPrototype = { data = typeof(data) == typeof('str') ? JSON.parse(data) : JSON.parse(JSON.stringify(data)) + var version = data.versio for(var k in data){ - this[k] = data[k] + var img = this[k] = data[k] + + // keep the preview paths decoded... + // + // NOTE: updating from legacy format... + // XXX move this to version conversion... (???) + if(version == null){ + Object.keys(img && img.preview || {}) + .forEach(function(res){ + var p = img.preview[res] + img.preview[res] = p.indexOf(k+'%20-%20') >= 0 ? decodeURI(p) : p + }) + } } return this }, - // XXX this is really odd: renaming this to 'toJSON' breaks JavasCript + // XXX this is really odd: renaming this to 'toJSON' breaks JavaScript // making chrome/node just say: "" and a filename... dumpJSON: function(data){ - return JSON.parse(JSON.stringify(this)) + var res = JSON.parse(JSON.stringify(this)) + // XXX + res.version = '3.0' + return res }, _reset: function(){