summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRomain d'Alverny <rda@mageia.org>2012-09-10 13:22:22 +0000
committerRomain d'Alverny <rda@mageia.org>2012-09-10 13:22:22 +0000
commit7454e1e9c28ae82ef6d3314d6991317f2d978ae4 (patch)
tree633ed3c42e47ffa37b106e3b4dcd94df98ff08b5
parentb5e9ac38472170a10f16887e3d56a891606d1745 (diff)
downloadpkgsubmit-7454e1e9c28ae82ef6d3314d6991317f2d978ae4.tar
pkgsubmit-7454e1e9c28ae82ef6d3314d6991317f2d978ae4.tar.gz
pkgsubmit-7454e1e9c28ae82ef6d3314d6991317f2d978ae4.tar.bz2
pkgsubmit-7454e1e9c28ae82ef6d3314d6991317f2d978ae4.tar.xz
pkgsubmit-7454e1e9c28ae82ef6d3314d6991317f2d978ae4.zip
reorganise js code, comments
-rw-r--r--js/pkgsubmit.js207
1 files changed, 124 insertions, 83 deletions
diff --git a/js/pkgsubmit.js b/js/pkgsubmit.js
index daa1f2e..8534195 100644
--- a/js/pkgsubmit.js
+++ b/js/pkgsubmit.js
@@ -1,3 +1,26 @@
+/**
+ * Mageia build-system quick status report script.
+ * Javascript utilities.
+ *
+ * @copyright Copyright (C) 2012 Mageia.Org
+ *
+ * @author Romain d'Alverny
+ * @license http://www.gnu.org/licenses/gpl-2.0.html GNU GPL v2
+ *
+ * This program is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License aspublished by the
+ * Free Software Foundation; either version 2 of the License, or (at your
+ * option) any later version.
+*/
+
+/**
+ * Is the file in path expected to be in text/plain or not?
+ * We just know what .log, .done and .youri files are.
+ *
+ * @param string path
+ *
+ * @return boolean
+*/
function isLogFile(path) {
var ext = path.split(".").pop();
@@ -8,6 +31,16 @@ function isLogFile(path) {
return false;
}
+/**
+ * Is the file in path expected to be a short one (1, 2 lines at most)
+ * or not?
+ *
+ * We just know that status.log and whatever.done files are one-liners.
+ *
+ * @param string path
+ *
+ * @return boolean
+*/
function isShortFile(path) {
var ext = path.split(".").pop();
@@ -60,94 +93,102 @@ function highlight_text(text) {
});
}
-$(function () {
-
- $('.status-link').on("click", function (ev) {
- if (!ev.metaKey) {
- ev.preventDefault();
-
- var key = $(this).attr("href");
- var elId = 'e' + key.replace(/\/|\./g, '-');
- var el = $("#" + elId);
-
- if (el.length == 0) {
- $(this).parent().parent().after($("<tr />",
- {
- class: "build-files-list",
- id: elId,
- html: '<td colspan="5">loading</td>'
- }
- ));
- $.get(
- "/log_files.php",
- {"k": $(this).attr("href")},
- function (data) {
- $("#" + elId).html('<td colspan="5">' + data + '</td>');
- }
- );
- } else {
- el.toggle();
- }
+/**
+*/
+function build_log_files_list(ev) {
+ if (!ev.metaKey) {
+ ev.preventDefault();
+
+ var key = $(this).attr("href");
+ var elId = 'e' + key.replace(/\/|\./g, '-');
+ var el = $("#" + elId);
+
+ if (el.length == 0) {
+ $(this).parent().parent().after($("<tr />",
+ {
+ class: "build-files-list",
+ id: elId,
+ html: '<td colspan="5">loading</td>'
+ }
+ ));
+ $.get(
+ "/log_files.php",
+ {"k": $(this).attr("href")},
+ function (data) {
+ $("#" + elId).html('<td colspan="5">' + data + '</td>');
+ }
+ );
+ } else {
+ el.toggle();
}
- });
+ }
+}
- $("table#submitted-packages tbody").on("click", "tr td li a.view-inline", function (ev) {
+/**
+*/
+function show_log_file(ev) {
- if (isLogFile($(this).attr("href"))) {
- return true;
- }
+ if (isLogFile($(this).attr("href"))) {
+ return true;
+ }
- if (!ev.metaKey) {
- ev.preventDefault();
-
- var elId = 'view-' + $(this).attr("href").replace(/\/|\./g, '-');
- var cId = elId + '-container';
- var c = $("#" + cId);
- var el = $("#" + elId);
-
- if (c.length == 0) {
- $(this).after($("<div />", {
- id: cId
- })
- .addClass(isShortFile($(this).attr("href")) ? "short" : "")
- .append($("<div />", {
- id: elId,
- class: "file-view",
- html: "loading..."
- }))
- );
-
- $.get(
- "/" + $(this).attr("href"),
- {},
- function (data) {
- $("#" + elId).html(highlight_text(data))
- .before(
- $("<div />", {
- class: "controls"
+ if (!ev.metaKey) {
+ ev.preventDefault();
+
+ var elId = 'view-' + $(this).attr("href").replace(/\/|\./g, '-');
+ var cId = elId + '-container';
+ var c = $("#" + cId);
+ var el = $("#" + elId);
+
+ if (c.length == 0) {
+ $(this).after($("<div />", {
+ id: cId
+ })
+ .addClass(isShortFile($(this).attr("href")) ? "short" : "")
+ .append($("<div />", {
+ id: elId,
+ class: "file-view",
+ html: "loading..."
+ }))
+ );
+
+ $.get(
+ "/" + $(this).attr("href"),
+ {},
+ function (data) {
+ $("#" + elId).html(highlight_text(data))
+ .before(
+ $("<div />", {
+ class: "controls"
+ })
+ .append($("<button />", {
+ class: "gototop",
+ html: "top"
+ }).on("click", function (ev) {
+ $("#" + elId).animate({ scrollTop: 0 }, 200);
})
- .append($("<button />", {
- class: "gototop",
- html: "top"
- }).on("click", function (ev) {
- $("#" + elId).animate({ scrollTop: 0 }, 200);
- })
- )
- .append($("<button />", {
- class: "gotobo",
- html: "bottom"
- }).on("click", function (ev) {
- var d = $("#" + elId);
- d.animate({ scrollTop: d.prop("scrollHeight") }, 200);
- })
- )
)
- .animate({ scrollTop: $("#" + elId).prop("scrollHeight") }, 1000);
- }
- );
- } else {
- c.toggle();
- }
+ .append($("<button />", {
+ class: "gotobo",
+ html: "bottom"
+ }).on("click", function (ev) {
+ var d = $("#" + elId);
+ d.animate({ scrollTop: d.prop("scrollHeight") }, 200);
+ })
+ )
+ )
+ .animate({ scrollTop: $("#" + elId).prop("scrollHeight") }, 1000);
+ }
+ );
+ } else {
+ c.toggle();
}
- });
+ }
+}
+
+$(function () {
+
+ $('.status-link').on("click", build_log_files_list);
+
+ $("table#submitted-packages tbody").on("click", "tr td li a.view-inline", show_log_file);
}); \ No newline at end of file