{"size": 1668, "ext": "js", "max_stars_repo_path": "corehq/apps/appstore/static/appstore/js/project_info.js", "max_stars_repo_name": "rochakchauhan/commcare-hq", "max_stars_repo_stars_event_min_datetime": "2020-05-05T13:10:01.000Z", "max_stars_repo_stars_event_max_datetime": "2020-05-05T13:10:01.000Z", "max_issues_repo_path": "corehq/apps/appstore/static/appstore/js/project_info.js", "max_issues_repo_name": "rochakchauhan/commcare-hq", "max_issues_repo_issues_event_min_datetime": "2019-12-09T14:00:14.000Z", "max_issues_repo_issues_event_max_datetime": "2019-12-09T14:00:14.000Z", "max_forks_repo_path": "corehq/apps/appstore/static/appstore/js/project_info.js", "max_forks_repo_name": "rochakchauhan/commcare-hq", "max_forks_repo_forks_event_min_datetime": "2015-11-30T13:12:45.000Z", "max_forks_repo_forks_event_max_datetime": "2019-07-01T19:27:07.000Z"}
{"max_stars_count": 1, "max_issues_count": 1, "max_forks_count": 5, "avg_line_length": 33.36, "max_line_length": 93, "alphanum_fraction": 0.5455635492}
hqDefine('appstore/js/project_info', [
    'jquery',
    'hqwebapp/js/initial_page_data',
    'analytix/js/google',
], function (
    $,
    initialPageData,
    googleAnalytics
) {
    function update_import_into_button() {
        var project = $('#project_select option:selected').text();
        $("#import-into-button").text("Import into " + project);
    }

    $(function () {
        update_import_into_button();

        $("#import-app-button").click(function () {
            $('#import-app').removeClass('hide');
        });

        $('#project_select').change(update_import_into_button);

        $('[data-target="#licenseAgreement"]').click(function () {
            var new_form = $(this).attr('data-form');
            $('#agree-button').attr('data-form', new_form);
        });
        $('#agree-button').click(function () {
            $('#agree-button').unbind()
                .addClass('disabled');
            $('#download-new-project').removeProp('data-toggle');
            $('#download-new-project').removeProp('href');
            $('#import-into-button').removeProp('data-toggle');
            $('#import-into-button').removeProp('href');
            var form = $("#" + $(this).attr('data-form'));
            form.submit();
        });

        // Analytics
        var project = initialPageData.get('project');
        $('#download-new-project').click(function () {
            googleAnalytics.track.event('Exchange', 'Download As New Project', project);
        });

        $('#import-app-button').click(function () {
            googleAnalytics.track.event('Exchange', 'Download to Existing Project', project);
        });
    });
});
