<commit_before>const showPopup        = require('./popup');
const elementInnerHtml = require('../../../_common/common_functions').elementInnerHtml;
const urlFor           = require('../../../_common/url').urlFor;

const Dialog = (() => {
    const baseDialog = (options, is_alert = false) => (
        new Promise((resolve) => {
            showPopup({
                url               : urlFor('dialog'),
                popup_id          : options.id,
                form_id           : '#frm_confirm',
                content_id        : '#dialog_content',
                additionalFunction: (container) => {
                    const el_dialog     = container;
                    const el_btn_ok     = container.querySelector('#btn_ok');
                    const el_btn_cancel = container.querySelector('#btn_cancel');
                    const el_title      = container.querySelector('#dialog_title');

                    if (!el_dialog) return;

                    const localized_message = Array.isArray(options.localized_message) ? options.localized_message.join('<p />') : options.localized_message;
                    elementInnerHtml(container.querySelector('#dialog_message'), localized_message);

                    const localized_title = Array.isArray(options.localized_title) ? options.localized_title.join('<h1 />') : options.localized_title;
                    if (localized_title && el_title) {
                        el_title.setVisibility(1);
                        elementInnerHtml(container.querySelector('#dialog_title'), localized_title);
                    }

                    if (is_alert) {
                        el_btn_cancel.classList.add('invisible');
                    } else {
                        el_btn_cancel.addEventListener('click', () => {
                            el_dialog.remove();
                            if (typeof options.onAbort === 'function') {
                                options.onAbort();
                            }
                            resolve(false);
                        });
                    }

                    if (options.ok_text && el_btn_ok.firstElementChild) {
                        el_btn_ok.firstElementChild.textContent = options.ok_text;
                    }

                    if (options.cancel_text && el_btn_cancel.firstElementChild) {
                        el_btn_cancel.firstElementChild.textContent = options.cancel_text;
                    }

                    if (options.title_message && el_title.firstElementChild) {
                        el_title.firstElementChild.textContent = options.title_message;
                    }

                    el_btn_ok.addEventListener('click', () => {
                        el_dialog.remove();
                        if (typeof options.onConfirm === 'function') {
                            options.onConfirm();
                        }
                        resolve(true);
                    });
                },
            });
        })
    );

    return {
        alert  : (options) => baseDialog(options, true),
        confirm: (options) => baseDialog(options),
    };
})();

module.exports = Dialog;
<commit_msg>remove multiple titles<commit_after>const showPopup        = require('./popup');
const elementInnerHtml = require('../../../_common/common_functions').elementInnerHtml;
const urlFor           = require('../../../_common/url').urlFor;

const Dialog = (() => {
    const baseDialog = (options, is_alert = false) => (
        new Promise((resolve) => {
            showPopup({
                url               : urlFor('dialog'),
                popup_id          : options.id,
                form_id           : '#frm_confirm',
                content_id        : '#dialog_content',
                additionalFunction: (container) => {
                    const el_dialog     = container;
                    const el_btn_ok     = container.querySelector('#btn_ok');
                    const el_btn_cancel = container.querySelector('#btn_cancel');
                    const el_title      = container.querySelector('#dialog_title');

                    if (!el_dialog) return;

                    const localized_message = Array.isArray(options.localized_message) ? options.localized_message.join('<p />') : options.localized_message;
                    elementInnerHtml(container.querySelector('#dialog_message'), localized_message);

                    const localized_title = options.localized_title;
                    if (localized_title && el_title) {
                        el_title.setVisibility(1);
                        elementInnerHtml(container.querySelector('#dialog_title'), localized_title);
                    }

                    if (is_alert) {
                        el_btn_cancel.classList.add('invisible');
                    } else {
                        el_btn_cancel.addEventListener('click', () => {
                            el_dialog.remove();
                            if (typeof options.onAbort === 'function') {
                                options.onAbort();
                            }
                            resolve(false);
                        });
                    }

                    if (options.ok_text && el_btn_ok.firstElementChild) {
                        el_btn_ok.firstElementChild.textContent = options.ok_text;
                    }

                    if (options.cancel_text && el_btn_cancel.firstElementChild) {
                        el_btn_cancel.firstElementChild.textContent = options.cancel_text;
                    }

                    if (options.title_message && el_title.firstElementChild) {
                        el_title.firstElementChild.textContent = options.title_message;
                    }

                    el_btn_ok.addEventListener('click', () => {
                        el_dialog.remove();
                        if (typeof options.onConfirm === 'function') {
                            options.onConfirm();
                        }
                        resolve(true);
                    });
                },
            });
        })
    );

    return {
        alert  : (options) => baseDialog(options, true),
        confirm: (options) => baseDialog(options),
    };
})();

module.exports = Dialog;

{'fraction_non_alphanumeric': 0.10673183036418099, 'fraction_numerical': 0.00047296232066845344, 'mean_word_length': 1.3027223230490017, 'pattern_counts': {'":': 0, '<': 6, '<?xml version=': 0, '>': 22, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 2, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5208785', 'n_tokens_mistral': 1503, 'n_tokens_neox': 1413, 'n_words': 214}