// -*- coding: utf-8 -*- // report_modified.js // 2016-06-30 v2.01 // // Modified for old html, by H.H(Hamayama Hama). // // -- // report.js // 2016-05-20 // Copyright (c) 2015 Douglas Crockford (www.JSLint.com) // Generate JSLint HTML reports. /*property closure, column, context, edition, error, filter, forEach, fudge, function, functions, global, id, imports, isArray, join, json, keys, length, level, line, lines, message, module, name, names, option, parameters, property, push, replace, role, signature, sort, stop, warnings */ var REPORT = (function () { "use strict"; var rx_amp = /&/g; var rx_gt = />/g; var rx_lt = / with less destructive entities. return String(string) .replace(rx_amp, "&") .replace(rx_lt, "<") .replace(rx_gt, ">"); } return { error: function error_report(data) { // Produce the HTML Error Report. //
LINE_NUMBER
MESSAGE
// EVIDENCE var fudge = +!!data.option.fudge; // ***** H.H 変更 2016-6-26 ***** // ***** 出力追加 ***** // var output = []; var option = data.option; var output_err = []; var output_undecl = []; var output_unused = []; var output_outscope = []; var err_count = 0; var undecl_count = 0; var unused_count = 0; var outscope_count = 0; if (data.stop) { // ***** H.H 変更 2016-6-26 ***** // ***** デザイン変更 ***** // output.push("
JSLint was unable to finish.
"); output_err.push("<<< JSLint was unable to finish. >>>
"); } data.warnings.forEach(function (warning) { // ***** H.H 変更 2016-6-26 ***** // ***** 出力追加 ***** // output.push( // "
", // entityify(warning.line + fudge), // ".", // entityify(warning.column + fudge), // "
", // entityify(warning.message), // "
", // entityify(data.lines[warning.line] || ""), // "" // ); if (warning.code === "undeclared_a") { undecl_count++; if (undecl_count > 1) { output_undecl.push(" , "); } output_undecl.push( "
", entityify(warning.line + fudge), ".", entityify(warning.column + fudge), "
: ", entityify(warning.a), "" ); } if (warning.code === "unused_a") { unused_count++; if (unused_count > 1) { output_unused.push(" , "); } output_unused.push( "
", entityify(warning.line + fudge), ".", entityify(warning.column + fudge), "
: ", entityify(warning.a), "" ); } if (warning.code === "out_of_scope_a") { outscope_count++; if (outscope_count > 1) { output_outscope.push(" , "); } output_outscope.push( "
", entityify(warning.line + fudge), ".", entityify(warning.column + fudge), "
: ", entityify(warning.a), "" ); } if ((!option.undecl || warning.code !== "undeclared_a") && (!option.unused || warning.code !== "unused_a") && (!option.scope || warning.code !== "out_of_scope_a")) { err_count++; // ***** H.H 変更 2016-6-26 ***** // ***** デザイン変更 ***** // output.push( // "
", // entityify(warning.line + fudge), // ".", // entityify(warning.column + fudge), // "
", // entityify(warning.message), // "
", // entityify(data.lines[warning.line] || ""), // "" // ); output_err.push( "
", entityify(warning.line + fudge), ".", entityify(warning.column + fudge), "
: ", entityify(warning.message), "

",
                        entityify(data.lines[warning.line] || ""),
                        "
" ); } }); // ***** H.H 変更 2016-6-26 ***** // ***** 出力追加 ***** // return output.join(""); return [ err_count, output_err.join(""), undecl_count, output_undecl.join(""), unused_count, output_unused.join(""), outscope_count, output_outscope.join("") ]; }, function: function function_report(data) { // Produce the HTML Function Report. //
LINE_NUMBER
FUNCTION_NAME_AND_SIGNATURE //
DETAIL
NAMES
//
var fudge = +!!data.option.fudge; var mode = (data.module) ? "module" : "global"; var output = []; if (data.json) { // ***** H.H 変更 2016-6-26 ***** // ***** デザイン変更 ***** // return (data.warnings.length === 0) // ? "
JSON: good.
" // : "
JSON: bad.
"; return (data.warnings.length === 0) ? "JSON: good.
" : "JSON: bad.
"; } function detail(title, array) { if (Array.isArray(array) && array.length > 0) { output.push( "
", entityify(title), "
", array.join(", "), "
" ); } } if (data.functions.length === 0) { // ***** H.H 変更 2016-6-26 ***** // ***** デザイン変更 ***** // output.push("
There are no functions.
"); output.push("There are no functions.
"); } var global = Object.keys(data.global.context).sort(); var imports = data.imports.sort(); if (global.length + imports.length > 0) { output.push("
"); detail(mode, global); detail("imports", imports); output.push("
"); } if (data.functions.length > 0) { data.functions.forEach(function (the_function) { var context = the_function.context; var list = Object.keys(context); // ***** H.H 変更 2016-6-26 ***** // ***** デザイン変更 ***** // output.push( // "
", // entityify(the_function.line + fudge), // "
", // (the_function.name === "=>") // ? entityify(the_function.signature) + " =>" // : ( // (typeof the_function.name === "string") // ? "≪" + entityify(the_function.name) // + "≫" // : "" + entityify(the_function.name.id) // + "" // ) + entityify(the_function.signature), // "" // ); var i100; var level_st = ""; if (the_function.level > 1) { for (i100 = 0; i100 < the_function.level - 1; i100++) { level_st += "-"; } } output.push( "
", entityify(the_function.line + fudge), "
: " + level_st + " ", (the_function.name === "=>") ? entityify(the_function.signature) + " =>" : ( (typeof the_function.name === "string") ? "≪" + entityify(the_function.name) + "≫" : "" + entityify(the_function.name.id) + "" ) + entityify(the_function.signature), "" ); if (Array.isArray(the_function.parameters)) { var params = []; the_function.parameters.forEach(function extract(name) { if (name.id === "{" || name.id === "[") { name.names.forEach(extract); } else { if (name.id !== "ignore") { params.push(name.id); } } }); detail( "parameter", params.sort() ); } list.sort(); detail("variable", list.filter(function (id) { var the_variable = context[id]; return the_variable.role === "variable" && the_variable.function === the_function; })); detail("exception", list.filter(function (id) { return context[id].role === "exception"; })); detail("closure", list.filter(function (id) { var the_variable = context[id]; return the_variable.closure === true && the_variable.function === the_function; })); detail("outer", list.filter(function (id) { var the_variable = context[id]; return the_variable.function !== the_function && the_variable.function.id !== "(global)"; })); detail(mode, list.filter(function (id) { return context[id].function.id === "(global)"; })); detail("label", list.filter(function (id) { return context[id].role === "label"; })); output.push("
"); }); } // ***** H.H 変更 2016-6-26 ***** // ***** デザイン変更 ***** // output.push( // "
JSLint edition ", // entityify(data.edition), // "
" // ); return output.join(""); }, property: function property_directive(data) { // Produce the /*property*/ directive. var not_first = false; var output = ["/*property"]; var length = 1111; var properties = Object.keys(data.property); if (properties.length > 0) { properties.sort().forEach(function (key) { if (not_first) { output.push(","); length += 2; } not_first = true; if (length + key.length > 78) { length = 4; output.push("\n "); } output.push(" ", key); length += key.length; }); output.push("\n*/\n"); return output.join(""); } } }; }());