diff options
author | Dan McGee <dan@archlinux.org> | 2012-07-24 04:31:17 +0200 |
---|---|---|
committer | Dan McGee <dan@archlinux.org> | 2012-07-24 04:31:17 +0200 |
commit | 211340c8bd6ccd6b16f3115a71fce4abedcc4c06 (patch) | |
tree | 4c3f77685f3d2f6f5e62284ef3098fd3ef0c4481 /sitestatic | |
parent | 374bf53505480eebd675e95f975dc908c485a6fa (diff) | |
download | archweb-211340c8bd6ccd6b16f3115a71fce4abedcc4c06.tar.gz archweb-211340c8bd6ccd6b16f3115a71fce4abedcc4c06.tar.xz |
Ensure package files JS can support corner cases
We should handle the cases dealing with no filelist available, outdated
filelist, or a package without files, just as the HTML server-side page
does. Add a bit more info to the JSON returned so we can do so.
Signed-off-by: Dan McGee <dan@archlinux.org>
Diffstat (limited to 'sitestatic')
-rw-r--r-- | sitestatic/archweb.js | 12 |
1 files changed, 11 insertions, 1 deletions
diff --git a/sitestatic/archweb.js b/sitestatic/archweb.js index d17cc68..b04b1d0 100644 --- a/sitestatic/archweb.js +++ b/sitestatic/archweb.js @@ -170,7 +170,17 @@ function ajaxifyFiles() { var cls = value.match(/\/$/) ? 'd' : 'f'; return ['<li class="', cls, '">', value, '</li>']; }); - $('#pkgfilelist').html('<ul>' + list_items.join('') + '</ul>'); + $('#pkgfilelist').empty(); + if (data.pkg_last_update > data.files_last_update) { + $('#pkgfilelist').append('<p class="message">Note: This file list was generated from a previous version of the package; it may be out of date.</p>'); + } + if (list_items.length > 0) { + $('#pkgfilelist').append('<ul>' + list_items.join('') + '</ul>'); + } else if (data.files_last_update == null) { + $('#pkgfilelist').append('<p class="message">No file list available.</p>'); + } else { + $('#pkgfilelist').append('<p class="message">Package has no files.</p>'); + } }); }); } |