<commit_before><!DOCTYPE html>
<html lang="en">
    <head>
        <meta charset="UTF-8">
        <title>GPF-JS</title>
        <link rel="stylesheet" type="text/css" href="res/html.css">
        <link rel="stylesheet" type="text/css" href="res/table.css">
        <link rel="stylesheet" type="text/css" href="res/sources.css">
        <script language="JavaScript" src="build/gpf.js"></script>
        <script language="JavaScript" src="res/xhr.js"></script>
        <script language="JavaScript" src="res/tpl.js"></script>
        <script language="JavaScript">

function wrap (item) {
    var result = Object.create(item);
    if (undefined === result.load) {
        result.load = true;
    }
    if (undefined === result.test && result.load) {
        result.test = true;
    }
    return result;
}

var tplFunc,
    parentNode,
    sources;

function getSourceByName (name) {
    var result;
    sources.every(function (source, index) {
        if (source.name === name) {
            result = {
                object: source,
                index: index
            };
            return false;
        }
        return true;
    });
    return result;
}

function refresh (target, source) {
    var parentTr = target.parentNode,
        refreshedTr = tplFunc(wrap(source.object), source.index);
    while (parentTr.tagName.toLowerCase() !== "tr") {
        parentTr = parentTr.parentNode;
    }
    parentNode.replaceChild(refreshedTr, parentTr);
}

function onClick (event) {
    var target = event.target,
        parts,
        source;
    if ("checkbox" === target.getAttribute("type")) {
        parts = target.id.split(":"); // property:name
        source = getSourceByName(parts[1]);
        source.object[parts[0]] = target.checked;
        refresh(target, source);
        document.getElementById("save").removeAttribute("disabled");
    } else if ("description" === target.className) {
        alert(target.innerHTML); // TODO propose an text field to edit the description
    }
}

function onLoad () {
    xhrGet("src/sources.json").then(function (responseText) {
        var tplRow = document.getElementById("tpl_row");
        tplFunc = tplRow.buildFactory();
        parentNode = tplRow.parentNode;
        sources = JSON.parse(responseText);
        sources.forEach(function (item, index) {
            parentNode.appendChild(tplFunc(wrap(item), index));
        });
        document.addEventListener("click", onClick);
    });
}

        </script>
    </head>
    <body onload="onLoad()">
        <table>
            <thead>
                <th>Name</th>
                <th>Load</th>
                <th>Test</th>
                <th>Doc</th>
                <th>Description</th>
                <th>Implements</th>
            </thead>
            <tbody>
                <template id="tpl_row">
{%
    function check(a, b) {
        if ($object.name === "boot") {
            $write("disabled=\"true\" ");
        }
        if ($object[a] && (b === undefined || $object[b])) {
            $write("checked");
        }
    }
%}
                    <tr>
                        <td>{{name}}</td>
                        <td><input id="load:{{name}}" type="checkbox" {%%}="check('load');"></td>
                        <td><input id="test:{{name}}" type="checkbox" {%%}="check('load', 'test');"></td>
                        <td><input id="doc:{{name}}" type="checkbox" {%%}="check('load', 'doc');"></td>
                        <td class="description">{{description}}</td>
                        <td>{%
var type, name;
if ($object.method) {
    type = "method";
    name = $object.method;
} else if ($object.class) {
    type = "class";
    name = $object.class;
}

if (name) {
    if (name.charAt(0) === "_") {
        %}<span class="internal">internal</span>{%
    }
    %}<span class="implements">{% $write(type); %}</span>{%
    $write(name);
} else {
    $write("&nbsp;");
}
                        %}</td>
                    </tr>
                </template>
              </tbody>
        </table>
        <button disabled="true" id="save">Save</button>
    </body>
</html><commit_msg>Includes dependency count<commit_after><!DOCTYPE html>
<html lang="en">
    <head>
        <meta charset="UTF-8">
        <title>GPF-JS</title>
        <link rel="stylesheet" type="text/css" href="res/html.css">
        <link rel="stylesheet" type="text/css" href="res/table.css">
        <link rel="stylesheet" type="text/css" href="res/sources.css">
        <script language="JavaScript" src="build/gpf.js"></script>
        <script language="JavaScript" src="res/xhr.js"></script>
        <script language="JavaScript" src="res/tpl.js"></script>
        <script language="JavaScript">

var tplFunc,
    parentNode,
    sources,
    dependencies;

function wrap (item) {
    var result = Object.create(item);
    if (undefined === result.load) {
        result.load = true;
    }
    if (undefined === result.test && result.load) {
        result.test = true;
    }
    result.dependencies = dependencies[item.name] || [];
    return result;
}

function getSourceByName (name) {
    var result;
    sources.every(function (source, index) {
        if (source.name === name) {
            result = {
                object: source,
                index: index
            };
            return false;
        }
        return true;
    });
    return result;
}

function refresh (target, source) {
    var parentTr = target.parentNode,
        refreshedTr = tplFunc(wrap(source.object), source.index);
    while (parentTr.tagName.toLowerCase() !== "tr") {
        parentTr = parentTr.parentNode;
    }
    parentNode.replaceChild(refreshedTr, parentTr);
}

function onClick (event) {
    var target = event.target,
        parts,
        source;
    if ("checkbox" === target.getAttribute("type")) {
        parts = target.id.split(":"); // property:name
        source = getSourceByName(parts[1]);
        source.object[parts[0]] = target.checked;
        refresh(target, source);
        document.getElementById("save").removeAttribute("disabled");
    } else if ("description" === target.className) {
        alert(target.innerHTML); // TODO propose an text field to edit the description
    }
}

function onLoad () {
    Promise.all([xhrGet("src/sources.json"), xhrGet("build/dependencies.json")])
        .then(function (responseTexts) {
            var tplRow = document.getElementById("tpl_row");
            tplFunc = tplRow.buildFactory();
            parentNode = tplRow.parentNode;
            sources = JSON.parse(responseTexts[0]);
            dependencies = JSON.parse(responseTexts[1]);
            sources.forEach(function (item, index) {
                parentNode.appendChild(tplFunc(wrap(item), index));
            });
            document.addEventListener("click", onClick);
        }, function (reason) {
            alert("A problem occurred while loading src/sources.json and build/dependencies.json: " + reason);
        });
}

        </script>
    </head>
    <body onload="onLoad()">
        <table>
            <thead>
                <th>Name</th>
                <th>Load</th>
                <th>Test</th>
                <th>Doc</th>
                <th>Description</th>
                <th>Implements</th>
                <th>Dependencies</th>
            </thead>
            <tbody>
                <template id="tpl_row">
{%
    function check(a, b) {
        if ($object.name === "boot") {
            $write("disabled=\"true\" ");
        }
        if ($object[a] && (b === undefined || $object[b])) {
            $write("checked");
        }
    }
%}
                    <tr>
                        <td>{{name}}</td>
                        <td><input id="load:{{name}}" type="checkbox" {%%}="check('load');"></td>
                        <td><input id="test:{{name}}" type="checkbox" {%%}="check('load', 'test');"></td>
                        <td><input id="doc:{{name}}" type="checkbox" {%%}="check('load', 'doc');"></td>
                        <td class="description">{{description}}</td>
                        <td>{%
var type, name;
if ($object.method) {
    type = "method";
    name = $object.method;
} else if ($object.class) {
    type = "class";
    name = $object.class;
}

if (name) {
    if (name.charAt(0) === "_") {
        %}<span class="internal">internal</span>{%
    }
    %}<span class="implements">{% $write(type); %}</span>{%
    $write(name);
} else {
    $write("&nbsp;");
}
                        %}</td>
                        <td>{%

if ($object.dependencies.length) {
    %}<span class="dependencies">{% $write($object.dependencies.length); %}</span>{%
} else {
    $write("&nbsp;");
}
                        %}</td>
                    </tr>
                </template>
              </tbody>
        </table>
        <button disabled="true" id="save">Save</button>
    </body>
</html>
{'fraction_non_alphanumeric': 0.17445132245357345, 'fraction_numerical': 0.0011254924029262803, 'mean_word_length': 1.9919191919191919, 'pattern_counts': {'":': 2, '<': 137, '<?xml version=': 0, '>': 137, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1010353', 'n_tokens_mistral': 2637, 'n_tokens_neox': 2574, 'n_words': 500}