{"size": 1816, "ext": "js", "max_stars_repo_path": "mipsel-linux-gnu/share/fish/tools/web_config/js/filters.js", "max_stars_repo_name": "wtdcode/fish-shell-OpenWrt", "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "mipsel-linux-gnu/share/fish/tools/web_config/js/filters.js", "max_issues_repo_name": "wtdcode/fish-shell-OpenWrt", "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "mipsel-linux-gnu/share/fish/tools/web_config/js/filters.js", "max_forks_repo_name": "wtdcode/fish-shell-OpenWrt", "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null}
{"max_stars_count": null, "max_issues_count": null, "max_forks_count": null, "avg_line_length": 29.7704918033, "max_line_length": 127, "alphanum_fraction": 0.5154185022}
filters = angular.module("filters", []);

filters.filter("filterVariable", function() {
    return function(variables, query) {
        var result = []
        if (variables == undefined) return result;
        if (query == null) { return variables };

        for(i=0; i<variables.length; ++i) {
            variable = variables[i];
            if (variable.name.indexOf(query) != -1 ||  variable.value.indexOf(query) != -1) {
                result.push(variable);
            }
        }

        return result;
    }
});

filters.filter("filterBinding", function() {
    return function(bindings, query) {
        var result = []
        if (bindings == undefined) return result;
        if (query == null) { return bindings};

        for(i=0; i<bindings.length; ++i) {
            binding = bindings[i];
            if (binding.command.indexOf(query) != -1) {
                result.push(binding);
                continue;
            }
            varieties = binding.bindings;
            for (j=0; j<varieties.length; ++j) {
                if (varieties[j].readable_binding.toLowerCase().indexOf(query.toLowerCase()) != -1) {
                    result.push(binding);
                    break;
                }
            }
        }

        return result;
    }
});

filters.filter("filterAbbreviations", function() {
    return function(abbreviations, query) {
        var result = []
        if (abbreviations == undefined) return result;
        if (query == null) { return abbreviations};

        for(i=0; i<abbreviations.length; ++i) {
            abbr = abbreviations[i];
            if (abbr.word.toLowerCase().indexOf(query) != -1 || abbr.phrase.toLowerCase().indexOf(query.toLowerCase()) != -1) {
                result.push(abbr);
            }
        }

        return result;
    }
});
