window.insertListToPerf = function()
{
    const dtable      = zui.DTable.query($('#bugs_table'));
    const checkedList = dtable.$.getChecks();
    if(!checkedList.length) return;

    const url      = $.createLink('perfproject', 'create', `analysisID=${analysisID}`);
    const formData = new FormData();
    formData.append('source', 1);
    formData.append('name', perfTableList['productBug'] + dataAnalysisLang);
    formData.append('acl', 'private');
    formData.append('table', tableName);
    formData.append('tabletype', 'table');
    formData.append('datatype', 'view');
    formData.append('whitelist', '');
    formData.append('sourcetype', 'select');
    formData.append('idList', checkedList.join(','));

    $.post(url, formData, function(resp)
    {
        resp = JSON.parse(resp);
        if(resp.result == 'success')
        {
            zui.Modal.hide();
            const url = $.createLink('perfproject', 'analysis', 'analysisID=' + analysisID);
            analysisID != 0 ? location.href = url : loadPage($.createLink('perfproject', 'firstanalysis', 'projectID=' + resp.projectID));
        }
    });
}

window.changeListType = function(event)
{
    const data = tableList.filter(item => item.key == $(event).val())[0];
    data.params = `${data.params}&blockID=${analysisID}`;
    zui.Modal.hide();
    zui.Modal.open({
        size: 'lg',
        url: $.createLink(data.module, data.method, data.params)
    });
}
