From 4e76cbbb609076f5e4901c8b186c5ac00beddb9a Mon Sep 17 00:00:00 2001 From: "Alex A. Naanou" Date: Wed, 22 May 2013 03:41:51 +0400 Subject: [PATCH] more minor tweaks... Signed-off-by: Alex A. Naanou --- ui/data.js | 32 +++++++++++++++++++------------- ui/index.html | 33 ++++++++++++++------------------- 2 files changed, 33 insertions(+), 32 deletions(-) diff --git a/ui/data.js b/ui/data.js index 296ce677..7ea2c9d9 100755 --- a/ui/data.js +++ b/ui/data.js @@ -656,8 +656,12 @@ function loadFileImages(path, callback){ callback != null && callback() }) + .fail(function(){ + console.error('ERROR LOADING:', path) + }) } + function loadFile(data_path, image_path, callback){ // CEF return $.getJSON(data_path) @@ -695,8 +699,12 @@ function loadFile(data_path, image_path, callback){ return } }) + .fail(function(){ + console.error('ERROR LOADING:', data_path) + }) } + function saveFile(name){ // CEF if(window.CEF_dumpJSON != null){ @@ -716,7 +724,7 @@ function saveFile(name){ function openImage(){ // CEF - if(window.CEF_dumpJSON != null){ + if(window.CEF_runSystem != null){ // XXX if path is not present try and open the biggest preview... return CEF_runSystem(IMAGES[getImageGID()].path) @@ -727,22 +735,20 @@ function openImage(){ } +// XXX need revision... function loadDir(path){ - // CEF - if(window.CEF_loadDir != null){ - var dir = CEF_loadDir(path) - IMAGES = dir.images - DATA = dir.data - MARKED = dir.marked - loadData() - - // PhoneGap - } else if(false) { - // XXX - } + return loadFile(path +'/data.json') + .fail(function(){ + loadFile(path +'/.ImageGrindCache/data.json') + .fail(function(){ + // XXX load separate images... + // XXX + }) + }) } + /********************************************************************** * Image caching... */ diff --git a/ui/index.html b/ui/index.html index 121215d9..c77849f5 100755 --- a/ui/index.html +++ b/ui/index.html @@ -343,19 +343,10 @@ $(function(){ // we have an image file... if((DATA_ATTR + '_IMAGES_FILE') in localStorage){ - loadFileImages(localStorage[DATA_ATTR + '_IMAGES_FILE']) + var loading = loadFileImages(localStorage[DATA_ATTR + '_IMAGES_FILE']) .done(function(){ DATA = loadLocalStorageData() loadData() - - // XXX this will reload everything... - if('MARKED' in localStorage){ - loadLocalStorageMarks() - } - - // XXX stub... - //centerView(focusImage($('.image').first()), 'css') - updateImages() }) } else { @@ -370,17 +361,21 @@ $(function(){ IMAGES = DATA.images loadData() } - - // XXX this will reload everything... - if('MARKED' in localStorage){ - loadLocalStorageMarks() - } - - // XXX stub... - //centerView(focusImage($('.image').first()), 'css') - updateImages() + var loading = $.Deferred().resolve() } + loading + .done(function(){ + // XXX this will reload everything... + if('MARKED' in localStorage){ + loadLocalStorageMarks() + } + + // XXX stub... + //centerView(focusImage($('.image').first()), 'css') + updateImages() + }) + })