From 7454e1e9c28ae82ef6d3314d6991317f2d978ae4 Mon Sep 17 00:00:00 2001 From: Romain d'Alverny Date: Mon, 10 Sep 2012 13:22:22 +0000 Subject: reorganise js code, comments --- js/pkgsubmit.js | 207 +++++++++++++++++++++++++++++++++----------------------- 1 file changed, 124 insertions(+), 83 deletions(-) (limited to 'js/pkgsubmit.js') 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($("", - { - class: "build-files-list", - id: elId, - html: 'loading' - } - )); - $.get( - "/log_files.php", - {"k": $(this).attr("href")}, - function (data) { - $("#" + elId).html('' + data + ''); - } - ); - } 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($("", + { + class: "build-files-list", + id: elId, + html: 'loading' + } + )); + $.get( + "/log_files.php", + {"k": $(this).attr("href")}, + function (data) { + $("#" + elId).html('' + data + ''); + } + ); + } 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($("
", { - id: cId - }) - .addClass(isShortFile($(this).attr("href")) ? "short" : "") - .append($("
", { - id: elId, - class: "file-view", - html: "loading..." - })) - ); - - $.get( - "/" + $(this).attr("href"), - {}, - function (data) { - $("#" + elId).html(highlight_text(data)) - .before( - $("
", { - 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($("
", { + id: cId + }) + .addClass(isShortFile($(this).attr("href")) ? "short" : "") + .append($("
", { + id: elId, + class: "file-view", + html: "loading..." + })) + ); + + $.get( + "/" + $(this).attr("href"), + {}, + function (data) { + $("#" + elId).html(highlight_text(data)) + .before( + $("
", { + class: "controls" + }) + .append($("