diff --git a/src/_h5ai/client/js/inc/core/location.js b/src/_h5ai/client/js/inc/core/location.js index 0985450a..37409d94 100644 --- a/src/_h5ai/client/js/inc/core/location.js +++ b/src/_h5ai/client/js/inc/core/location.js @@ -95,7 +95,7 @@ modulejs.define('core/location', ['_', 'modernizr', 'core/event', 'core/settings _.each(json.items, function (jsonItem) { - var e = Item.get(jsonItem.href, jsonItem.time, jsonItem.size, jsonItem.isManaged, jsonItem.content); + var e = Item.get(jsonItem); found[e.absHref] = true; }); diff --git a/src/_h5ai/client/js/inc/model/item.js b/src/_h5ai/client/js/inc/model/item.js index d857c4ae..6bdf6975 100644 --- a/src/_h5ai/client/js/inc/model/item.js +++ b/src/_h5ai/client/js/inc/model/item.js @@ -46,26 +46,32 @@ modulejs.define('model/item', ['_', 'core/event', 'core/location', 'core/server' } } - function getItem(absHref, time, size, isManaged, isContentFetched) { + function getItem(options) { - absHref = location.forceEncoding(absHref); - - if (!startsWith(absHref, settings.rootHref)) { + if (_.isString(options)) { + options = {href: options}; + } else if (!options || !_.isString(options.href)) { return null; } - var self = cache[absHref] || new Item(absHref); + var href = location.forceEncoding(options.href); - if (_.isNumber(time)) { - self.time = time; + if (!startsWith(href, settings.rootHref)) { + return null; } - if (_.isNumber(size)) { - self.size = size; + + var self = cache[href] || new Item(href); + + if (_.isNumber(options.time)) { + self.time = options.time; } - if (isManaged) { + if (_.isNumber(options.size)) { + self.size = options.size; + } + if (options.managed) { self.isManaged = true; } - if (isContentFetched) { + if (options.fetched) { self.isContentFetched = true; } @@ -105,7 +111,8 @@ modulejs.define('model/item', ['_', 'core/event', 'core/location', 'core/server' if (response.items) { _.each(response.items, function (jsonItem) { - getItem(jsonItem.href, jsonItem.time, jsonItem.size, jsonItem.isManaged, jsonItem.content); + + getItem(jsonItem); }); } diff --git a/src/_h5ai/server/php/inc/class-item.php b/src/_h5ai/server/php/inc/class-item.php index 9eed1c14..578487c4 100644 --- a/src/_h5ai/server/php/inc/class-item.php +++ b/src/_h5ai/server/php/inc/class-item.php @@ -61,8 +61,8 @@ class Item { ); if ($this->is_folder) { - $obj["isManaged"] = $this->app->is_managed_href($this->href); - $obj["content"] = $this->is_content_fetched; + $obj["managed"] = $this->app->is_managed_href($this->href); + $obj["fetched"] = $this->is_content_fetched; } return $obj;