<commit_before>// http://www.jblotus.com/2011/05/24/keeping-your-handlebars-js-templates-organized/
function getTemplateAjax(path, callback) {
    var source;
    var template;

    $.ajax({
      url: path,
        success: function(data) {
          source    = data;
          template  = Handlebars.compile(source);

          //execute the callback if passed
          if (callback) callback(template);
        }
    });
}

function loadYAML(name, f) {
    var client = new XMLHttpRequest();
    client.open('GET', 'data/' + name + '.yaml');
    client.onreadystatechange = function() {
        if (client.readyState == 4) {
            var yaml = jsyaml.load(client.responseText);
            if (yaml) {
                f(yaml);
            }
        }
    }
    client.send();
}

function loadLists() {
    getTemplateAjax('templates/to-read.hbars.html', function(tmpl) {
        loadYAML("to-read", function(yaml) {
            yaml.sort(function(a,b) {
                return a.author.localeCompare(b.author);
            });
            $("#to-read").html(tmpl(yaml));
        });
    });

    getTemplateAjax('templates/finished.hbars.html', function(tmpl) {
        loadYAML("finished", function(yaml) {
            yaml.sort(function(a,b) {
                if (a.finished > b.finished) return -1;
                if (a.finished < b.finished) return 1;
                return 0;
            });
            function dateString(d) {
                return d.getFullYear().toString() + "/" +
                    (d.getMonth() + 1).toString() + "/" +
                    (d.getDate() + 1).toString();
            }
            var len = yaml.length;
            for (var i = 0; i < len; i++) {
                yaml[i].finished = dateString(yaml[i].finished);
            }
            $("#finished").html(tmpl(yaml));
            finished_yaml = yaml;

            getTemplateAjax('templates/timeline-body.hbars.html', function(timeline_body_tmpl) {
                loadTimeline(yaml,timeline_body_tmpl);
            });
        });
    });<commit_msg>Resolves #19.<commit_after>// http://www.jblotus.com/2011/05/24/keeping-your-handlebars-js-templates-organized/
function getTemplateAjax(path, callback) {
    var source;
    var template;

    $.ajax({
      url: path,
        success: function(data) {
          source    = data;
          template  = Handlebars.compile(source);

          //execute the callback if passed
          if (callback) callback(template);
        }
    });
}

function loadYAML(name, f) {
    var client = new XMLHttpRequest();
    client.open('GET', 'data/' + name + '.yaml');
    client.onreadystatechange = function() {
        if (client.readyState == 4) {
            var yaml = jsyaml.load(client.responseText);
            if (yaml) {
                f(yaml);
            }
        }
    }
    client.send();
}

function loadLists() {
    getTemplateAjax('templates/to-read.hbars.html', function(tmpl) {
        loadYAML("to-read", function(yaml) {
            yaml.sort(function(a,b) {
                return a.author.localeCompare(b.author);
            });
            $("#to-read").html(tmpl(yaml));
        });
    });

    getTemplateAjax('templates/finished.hbars.html', function(tmpl) {
        loadYAML("finished", function(yaml) {
            yaml.sort(function(a,b) {
                if (a.finished > b.finished) return -1;
                if (a.finished < b.finished) return 1;
                return 0;
            });
            function dateString(d) {
                return d.getUTCFullYear().toString() + "/" +
                    (d.getUTCMonth()).toString() + "/" +
                    (d.getUTCDate()).toString();
            }
            var len = yaml.length;
            for (var i = 0; i < len; i++) {
                yaml[i].finished = dateString(yaml[i].finished);
            }
            $("#finished").html(tmpl(yaml));
            finished_yaml = yaml;

            getTemplateAjax('templates/timeline-body.hbars.html', function(timeline_body_tmpl) {
                loadTimeline(yaml,timeline_body_tmpl);
            });
        });
    });
{'fraction_non_alphanumeric': 0.1478787878787879, 'fraction_numerical': 0.007272727272727273, 'mean_word_length': 1.702030124426981, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, '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': '5586856', 'n_tokens_mistral': 1265, 'n_tokens_neox': 1198, 'n_words': 203}