summaryrefslogtreecommitdiffstats
path: root/templates
diff options
context:
space:
mode:
authorDan McGee <dan@archlinux.org>2010-09-30 20:15:20 +0200
committerDan McGee <dan@archlinux.org>2010-09-30 20:15:20 +0200
commit3682fb285b9f131a56aed2c6cab8d303c6aae5ae (patch)
tree217509085054951d4fdcdb6d9f5c0b5099412e5b /templates
parent0eac9698c6bdebdf5056a97b7c979b526d54ec15 (diff)
downloadarchweb-3682fb285b9f131a56aed2c6cab8d303c6aae5ae.tar.gz
archweb-3682fb285b9f131a56aed2c6cab8d303c6aae5ae.tar.xz
Move most inline JS into script file
We're getting to the point where we are starting to have a good chunk of JS scattered about. Centralize a lot of it for maintenance and performance purposes. Signed-off-by: Dan McGee <dan@archlinux.org>
Diffstat (limited to 'templates')
-rw-r--r--templates/devel/index.html10
-rw-r--r--templates/mirrors/status.html31
-rw-r--r--templates/news/add.html13
-rw-r--r--templates/packages/details.html9
-rw-r--r--templates/packages/differences.html41
-rw-r--r--templates/todolists/view.html25
6 files changed, 7 insertions, 122 deletions
diff --git a/templates/devel/index.html b/templates/devel/index.html
index f285f7f..009a683 100644
--- a/templates/devel/index.html
+++ b/templates/devel/index.html
@@ -190,16 +190,8 @@
</div><!-- #dash-by-maintainer -->
{% load cdn %}{% jquery %}
<script type="text/javascript" src="/media/jquery.tablesorter.min.js"></script>
+<script type="text/javascript" src="/media/archweb.js"></script>
<script type="text/javascript">
-$.tablesorter.addParser({
- id: 'pkgcount',
- is: function(s) { return false; },
- format: function(s) {
- var m = s.match(/\d+/);
- return m ? parseInt(m[0]) : 0;
- },
- type: 'numeric'
-});
$(document).ready(function() {
$("#dash-myflagged:not(:has(tbody tr.empty))").tablesorter(
{widgets: ['zebra'], sortList: [[0,0]]});
diff --git a/templates/mirrors/status.html b/templates/mirrors/status.html
index 10f409c..d2e4537 100644
--- a/templates/mirrors/status.html
+++ b/templates/mirrors/status.html
@@ -98,37 +98,8 @@
</div>
{% load cdn %}{% jquery %}
<script type="text/javascript" src="/media/jquery.tablesorter.min.js"></script>
+<script type="text/javascript" src="/media/archweb.js"></script>
<script type="text/javascript">
-$.tablesorter.addParser({
- /* sorts numeric, but put '', 'unknown', and '∞' last. */
- id: 'mostlydigit',
- is: function(s,table) {
- var special = ['', 'unknown', '∞'];
- var c = table.config;
- return ($.inArray(s, special) > -1) || $.tablesorter.isDigit(s,c);
- },
- format: function(s) {
- var special = ['', 'unknown', '∞'];
- if($.inArray(s, special) > -1) return Number.MAX_VALUE;
- return $.tablesorter.formatFloat(s);
- },
- type: 'numeric'
-});
-$.tablesorter.addParser({
- /* sorts duration; put '', 'unknown', and '∞' last. */
- id: 'duration',
- is: function(s,table) {
- var special = ['', 'unknown', '∞'];
- return ($.inArray(s, special) > -1) || /^[0-9]+:[0-5][0-9]$/.test(s);
- },
- format: function(s) {
- var special = ['', 'unknown', '∞'];
- if($.inArray(s, special) > -1) return Number.MAX_VALUE;
- matches = /^([0-9]+):([0-5][0-9])$/.exec(s);
- return matches[1] * 60 + matches[2];
- },
- type: 'numeric'
-});
$(document).ready(function() {
$("#outofsync_mirrors:has(tbody tr)").tablesorter(
{widgets: ['zebra'], sortList: [[3,1]],
diff --git a/templates/news/add.html b/templates/news/add.html
index 48b013f..f580e0d 100644
--- a/templates/news/add.html
+++ b/templates/news/add.html
@@ -33,19 +33,8 @@
<div id="previewdata" class="article-content"></div>
</div>
{% load cdn %}{% jquery %}
+<script type="text/javascript" src="/media/archweb.js"></script>
<script type="text/javascript">
-function enablePreview() {
- $('#previewbtn').click(function(event) {
- event.preventDefault();
- $.post('/news/preview/',
- { data: $('#id_content').val() },
- function(data) {
- $('#previewdata').html(data);
- $('.news-article').show();
- });
- $('#previewtitle').html($('#id_title').val());
- });
-}
$(document).ready(enablePreview);
</script>
{% endblock %}
diff --git a/templates/packages/details.html b/templates/packages/details.html
index f84b85e..09df176 100644
--- a/templates/packages/details.html
+++ b/templates/packages/details.html
@@ -212,15 +212,8 @@
</div><!-- #pkgdetails -->
{% load cdn %}{% jquery %}
+<script type="text/javascript" src="/media/archweb.js"></script>
<script type="text/javascript">
-function ajaxifyFiles() {
- $('#filelink').click(function(event) {
- event.preventDefault();
- $.get(this.href, function(data) {
- $('#pkgfilelist').html(data);
- });
- });
-}
$(document).ready(ajaxifyFiles);
</script>
{% endblock %}
diff --git a/templates/packages/differences.html b/templates/packages/differences.html
index 2c1460e..49f23b7 100644
--- a/templates/packages/differences.html
+++ b/templates/packages/differences.html
@@ -59,47 +59,8 @@
</div>
{% load cdn %}{% jquery %}
<script type="text/javascript" src="/media/jquery.tablesorter.min.js"></script>
+<script type="text/javascript" src="/media/archweb.js"></script>
<script type="text/javascript">
-filter_packages = function() {
- // start with all rows, and then remove ones we shouldn't show
- var rows = $(".results tbody tr");
- if(!$('#id_multilib').is(':checked')) {
- rows = rows.not(".multilib");
- }
- var arch = $("#id_archonly").val();
- if(arch !== "all") {
- rows = rows.filter("." + arch);
- }
- if(!$('#id_minor').is(':checked')) {
- // this check is done last because it is the most expensive
- rows = rows.filter(function(index) {
- // all this just to get the split version out of the table cell
- var pat = /(.*)-(.+)/;
- var ver_a = $('td:eq(2) span', this).text().match(pat);
- var ver_b = $('td:eq(3) span', this).text().match(pat);
- // did we match at all?
- if(!ver_a || !ver_b) return true;
- // first check pkgver
- if(ver_a[1] !== ver_b[1]) return true;
- // pkgver matched, so see if rounded pkgrel matches
- if(Math.floor(parseFloat(ver_a[2])) ==
- Math.floor(parseFloat(ver_b[2]))) return false;
- // pkgrel didn't match, so keep the row
- return true;
- });
- }
- // hide all rows, then show the set we care about
- $('.results tbody tr').hide();
- rows.show();
- // make sure we update the odd/even styling from sorting
- $('.results').trigger("applyWidgets");
-};
-filter_reset = function() {
- $('#id_archonly').val("all");
- $('#id_multilib').removeAttr("checked");
- $('#id_minor').attr("checked", "checked");
- filter_packages();
-};
$(document).ready(function() {
$('.results').tablesorter({widgets: ['zebra'], sortList: [[1,0], [0,0]]});
$('#diff_filter select').change(filter_packages);
diff --git a/templates/todolists/view.html b/templates/todolists/view.html
index 504c8cb..0792d09 100644
--- a/templates/todolists/view.html
+++ b/templates/todolists/view.html
@@ -53,31 +53,10 @@
</div>
{% load cdn %}{% jquery %}
<script type="text/javascript" src="/media/jquery.tablesorter.min.js"></script>
+<script type="text/javascript" src="/media/archweb.js"></script>
<script type="text/javascript">
- $(function() {
- $('a[href*=todo/flag]').click(function() {
- var link = this;
-
- $.getJSON(link.href, function(data) {
- if (data.complete) {
- $(link).text('Complete').addClass('complete').removeClass('incomplete');
- } else {
- $(link).text('Incomplete').addClass('incomplete').removeClass('complete');
- }
- });
-
- return false;
- });
- });
-$.tablesorter.addParser({
- id: 'todostatus',
- is: function(s) { return false; },
- format: function(s) {
- return s.match(/incomplete/) ? 1 : 0;
- },
- type: 'numeric'
-});
$(document).ready(function() {
+ $('a[href*=todo/flag]').click(todolist_flag);
$(".results").tablesorter({
widgets: ['zebra'],
sortList: [[0,0], [1,0]],