From f81323ff6fe3416f7d50395658006223ae25c87c Mon Sep 17 00:00:00 2001 From: Dan McGee Date: Mon, 23 Jul 2012 21:13:30 -0500 Subject: Generate package filelist in JavaScript via AJAX This is a super-simple template to follow to make the filelists work, so we can do all the "hard" work client-side. This also removes the need for a header-dependent '/files/' URL, as we are now just using the JSON representation instead. Signed-off-by: Dan McGee --- sitestatic/archweb.js | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) (limited to 'sitestatic') diff --git a/sitestatic/archweb.js b/sitestatic/archweb.js index c0fb3a6..d17cc68 100644 --- a/sitestatic/archweb.js +++ b/sitestatic/archweb.js @@ -164,8 +164,13 @@ function enablePreview() { function ajaxifyFiles() { $('#filelink').click(function(event) { event.preventDefault(); - $.get(this.href, function(data) { - $('#pkgfilelist').html(data); + $.getJSON(this.href + 'json/', function(data) { + // Map each file item into an
  • with the correct class + var list_items = $.map(data.files, function(value, i) { + var cls = value.match(/\/$/) ? 'd' : 'f'; + return ['
  • ', value, '
  • ']; + }); + $('#pkgfilelist').html(''); }); }); } @@ -173,8 +178,8 @@ function ajaxifyFiles() { function collapseDependsList(list) { var limit = 20; list = $(list); - // Hide everything past a given limit. Don't do anything if we don't have - // enough items, or the link already exists. + // Hide everything past a given limit. Don't do anything if we don't have + // enough items, or the link already exists. var linkid = list.attr('id') + 'link'; var items = list.find('li').slice(limit); if (items.length == 0 || $('#' + linkid).length > 0) { -- cgit v1.2.3-24-g4f1b