blob: cbff745f51a41d937738d159b192bff57e216d0f (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
|
{% extends "base.html" %}
{% load static from staticfiles %}
{% block title %}Arch Linux - {{ pkg.pkgname }} {{ pkg.full_version }} ({{ pkg.arch.name }}){% endblock %}
{% block navbarclass %}anb-packages{% endblock %}
{% block content %}
{% include "packages/package_details.html" %}
{% endblock %}
{% block script_block %}
{% load cdn %}{% jquery %}
<script type="text/javascript" nonce="{{ CSP_NONCE }}">
function ajaxifyFiles() {
$('#filelink').click(function(event) {
event.preventDefault();
$.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').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>');
}
});
});
}
function collapseDependsList(list) {
list = $(list);
// Hide everything past a given limit. Don't do anything if we don't have
// enough items, or the link already exists.
var limit = 20,
linkid = list.attr('id') + 'link',
items = list.find('li').slice(limit);
if (items.length <= 1 || $('#' + linkid).length > 0) {
return;
}
items.hide();
list.after('<p><a id="' + linkid + '" href="#">Show More…</a></p>');
// add link and wire it up to show the hidden items
$('#' + linkid).click(function(event) {
event.preventDefault();
list.find('li').show();
// remove the full <p/> node from the DOM
$(this).parent().remove();
});
}
function collapseRelatedTo(elements) {
var limit = 5;
$(elements).each(function(idx, ele) {
ele = $(ele);
// Hide everything past a given limit. Don't do anything if we don't
// have enough items, or the link already exists.
var items = ele.find('span.related').slice(limit);
if (items.length <= 1 || ele.find('a.morelink').length > 0) {
return;
}
items.hide();
ele.append('<a class="morelink" href="#">More…</a>');
// add link and wire it up to show the hidden items
ele.find('a.morelink').click(function(event) {
event.preventDefault();
ele.find('span.related').show();
$(this).remove();
});
});
}
$(document).ready(function() {
ajaxifyFiles();
collapseDependsList("#pkgdepslist");
collapseDependsList("#pkgreqslist");
collapseRelatedTo(".relatedto");
});
</script>
{% endblock %}
|