/** * 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. */ /** */ var events_log = { events: {}, count: function (type, count) { if (type in this.events) { this.events[type] += count; } else { this.events[type] = 1; } }, reset: function () { this.events = {}; }, report: function () { s = []; for (i in this.events) { s.push(this.events[i] + ' ' + i); } return s.join(", "); } }; /** * 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(); if (["log", "done", "youri"].indexOf(ext) < 0) { return true; } 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(); var file = path.split("/").pop(); if (["done"].indexOf(ext) >= 0 || ["status.log"].indexOf(file) >= 0) { return true; } return false; } /** * Inject elements with appropriate classes into given text * to allow for highlighting specific portions of a text file. * * Here, log files with ok|success|test|warning|info|error|fail|etc. * * @param string text * * @return string */ function highlight_text(text) { return text.replace(/.*(ok|succe|test|warn|info|deprecat|error|fail|non\-standard|abort|missing\_deps).*/gi, function (match, p1, p2, offset, string) { var cl = 'none'; switch (p1.toLowerCase()) { case 'succe': case 'ok': cl = 'ok'; break case 'test': case 'info': cl = 'info'; break; case 'warn': case 'deprecat': case 'non-standard': cl = 'warn'; break; case 'error': case 'fail': case 'abort': case 'missing_deps': cl = 'error'; break; } events_log.count(cl, 1); return '' + match + ''; }); } /** * Load files list returned for current build (see href), * build it under the build status line and show it. */ 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($("