From a76753eaa57d9622255c1cc33a708aff59e41cff Mon Sep 17 00:00:00 2001 From: "Alex A. Naanou" Date: Thu, 16 Jan 2014 04:52:11 +0400 Subject: [PATCH] fixed a bug in getLoadedGIDs(..), now it will sort the results... Signed-off-by: Alex A. Naanou --- ui/crop.js | 12 +++++++++++- ui/data.js | 15 ++++++--------- ui/marks.js | 5 +++++ 3 files changed, 22 insertions(+), 10 deletions(-) diff --git a/ui/crop.js b/ui/crop.js index e39224b7..b22ced54 100755 --- a/ui/crop.js +++ b/ui/crop.js @@ -277,6 +277,12 @@ function filterImagesDialog(){ updateStatus('Filter...').show() cfg = {} + cfg['GID |' + +'Use gid or gid tail part to find an\n' + +'image.\n' + +'\n' + +'NOTE: use of at least 6 characters is\n' + +'recommended.'] = '' cfg['sep0'] = '---' cfg['Name'] = '' cfg['Path |' @@ -345,7 +351,11 @@ function filterImagesDialog(){ var filter = {} // build the filter... for(var field in res){ - if(/^Name/.test(field) && res[field].trim() != ''){ + // this will search for gid or gid part at the end of a gid... + if(/^GID/.test(field) && res[field].trim() != ''){ + filter['id'] = res[field] + '$' + + } else if(/^Name/.test(field) && res[field].trim() != ''){ filter['name'] = res[field] } else if(/^Path/.test(field) && res[field].trim() != ''){ diff --git a/ui/data.js b/ui/data.js index 276c4cd1..f6006320 100755 --- a/ui/data.js +++ b/ui/data.js @@ -536,9 +536,6 @@ function linSearch(target, lst, check, return_position, get){ // no hit... return return_position ? -1 : null } -Array.prototype.linSearch = function(target, cmp, get){ - return linSearch(target, this, cmp, true, get) -} */ @@ -575,11 +572,6 @@ function binSearch(target, lst, check, return_position, get){ // no result... return return_position ? -1 : null } -/* XXX do we actually need to patch Array??? -Array.prototype.binSearch = function(target, cmp, get){ - return binSearch(target, this, cmp, true, get) -} -*/ // This is a cheating fast sort... @@ -800,7 +792,9 @@ function getAllGids(data){ // Get all the currently loaded gids... // // NOTE: this will return an unsorted list of gids... -function getLoadedGIDs(gids, data){ +// NOTE: this will sort the result unless either no_sort is true or gids +// is not given... +function getLoadedGIDs(gids, data, no_sort){ data = data == null ? DATA : data var res = [] data.ribbons.forEach(function(r){ @@ -811,6 +805,9 @@ function getLoadedGIDs(gids, data){ return res.indexOf(e) >= 0 }) } + if(!no_sort){ + res = fastSortGIDsByOrder(res) + } return res } diff --git a/ui/marks.js b/ui/marks.js index 4b2ec9e0..1d8fe57f 100755 --- a/ui/marks.js +++ b/ui/marks.js @@ -236,6 +236,11 @@ function makeMarkUpdater(img_class, mark_class, test){ // NOTE: this supports only shifts by one position... +// XXX this is similar to insertGIDToPosition(..) do we need both? +// ...this one is a special case and insertGIDToPosition(..) is +// general, the later uses search to find the position, here we +// know the aproximate location, the question is if this speedup +// is worth the effort of maintaining a special case function... function shiftGIDToOrderInList(gid, direction, list){ var gid_o = DATA.order.indexOf(gid) var gid_m = list.indexOf(gid)