<commit_before>/*jslint browser: true */
/*globals $, tangelo, d3 */

var app = {};

function createNew() {
    console.log("createNew");
    launchLyra();
}

function edit() {
    console.log("edit");
}

function launchLyra() {
    app.lyra = window.open("/lyra/editor.html", "_blank");
}

function receiveMessage(e) {
    console.log(e.data);

    vg.parse.spec(e.data, function (chart) {
        chart({
            el: "#vega",
            renderer: "svg"
        }).update();
    });
}

$(function () {
    "use strict";

    window.addEventListener("message", receiveMessage, false);

    d3.select("#create")
        .on("click", createNew);

    d3.select("#edit")
        .on("click", edit);
});<commit_msg>Implemented "edit" action, but doesn't seem to be working on the Lyra side.<commit_after>/*jslint browser: true */
/*globals $, tangelo, d3 */

var app = {};
app.lyra = null;
app.loaded = null;

function createNew() {
    launchLyra({
        editor: true
    });
}

function edit() {
    launchLyra({
        editor: true,
        filename: app.filename
    });
}

function launchLyra(qargs) {
    var query = $.param(qargs || {});
    if (query.length > 0) {
        query = "?" + query;
    }

    app.lyra = window.open("/lyra/editor.html" + query, "_blank");
}

function receiveMessage(e) {
    vg.parse.spec(e.data.vega, function (chart) {
        chart({
            el: "#vega",
            renderer: "svg"
        }).update();

        d3.select("#edit")
            .attr("disabled", null);

        app.filename = e.data.filename;

        app.lyra = null;
    });
}

$(function () {
    "use strict";

    window.addEventListener("message", receiveMessage, false);

    d3.select("#create")
        .on("click", createNew);

    d3.select("#edit")
        .on("click", edit);
});
{'fraction_non_alphanumeric': 0.18428334255672385, 'fraction_numerical': 0.004427227448810182, 'mean_word_length': 2.3921200750469045, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 4, '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': '4209583', 'n_tokens_mistral': 611, 'n_tokens_neox': 588, 'n_words': 124}