summaryrefslogtreecommitdiff
path: root/sitestatic
diff options
context:
space:
mode:
authorDan McGee <dan@archlinux.org>2012-07-23 21:13:30 -0500
committerDan McGee <dan@archlinux.org>2012-07-23 21:13:30 -0500
commitf81323ff6fe3416f7d50395658006223ae25c87c (patch)
treecb768ca2d229a9fb4bc661273e907cde0fb1eadb /sitestatic
parenta4de5b50279c876cc7a3afb2ea18d477bbb25ec1 (diff)
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 <dan@archlinux.org>
Diffstat (limited to 'sitestatic')
-rw-r--r--sitestatic/archweb.js13
1 files changed, 9 insertions, 4 deletions
diff --git a/sitestatic/archweb.js b/sitestatic/archweb.js
index c0fb3a60..d17cc68f 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 <li/> with the correct class
+ var list_items = $.map(data.files, function(value, i) {
+ var cls = value.match(/\/$/) ? 'd' : 'f';
+ return ['<li class="', cls, '">', value, '</li>'];
+ });
+ $('#pkgfilelist').html('<ul>' + list_items.join('') + '</ul>');
});
});
}
@@ -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) {