diff --git a/physionet-django/project/static/project/js/dynamic-files-panel.js b/physionet-django/project/static/project/js/dynamic-files-panel.js new file mode 100644 index 0000000000..902f750f48 --- /dev/null +++ b/physionet-django/project/static/project/js/dynamic-files-panel.js @@ -0,0 +1,38 @@ +(function() { + 'use strict'; + + var panel = $('#files-panel'); + var cur_dir = panel.find('[data-dfp-cur-dir]').data('dfp-cur-dir'); + var panel_url = panel.find('[data-dfp-panel-url]').data('dfp-panel-url'); + + function navigateDir(subdir, page_url, push_history) { + $.ajax({ + type: 'GET', + url: panel_url, + data: {'subdir': subdir, 'v': '2'}, + success: function(result) { + if (push_history) + history.pushState(subdir, '', page_url); + else + history.replaceState(subdir, '', page_url); + panel.html(result); + setClickHandlers(); + }, + }); + } + + function setClickHandlers() { + panel.find('a[data-dfp-dir]').click(function(event) { + navigateDir($(this).data('dfp-dir'), this.href, true); + event.preventDefault(); + }); + } + setClickHandlers(); + + window.onpopstate = function(event) { + if (event.state !== null) { + navigateDir(event.state, window.location, false); + } + }; + history.replaceState(cur_dir, ''); +})(); diff --git a/physionet-django/project/templates/project/files_panel.html b/physionet-django/project/templates/project/files_panel.html index f4875a9f29..5caff7f0dd 100644 --- a/physionet-django/project/templates/project/files_panel.html +++ b/physionet-django/project/templates/project/files_panel.html @@ -1,3 +1,4 @@ +{# Note: This template is obsolescent. Use files_panel_v2 instead. #}
Name | +Size | +Modified | +
---|---|---|
Parent Directory | ++ | + |
{{ dir.name }} | ++ | + |
{{ file.name }} + + (download) + + | +{{ file.size }} | +{{ file.last_modified }} | +