File: //proc/self/root/proc/self/cwd/nueva/modules/chatgptcontentgenerator/views/js/admin.forms.js
/**
* 2007-2024 PrestaShop
*
* NOTICE OF LICENSE
*
* This source file is subject to the Academic Free License (AFL 3.0)
* that is bundled with this package in the file LICENSE.txt.
* It is also available through the world-wide-web at this URL:
* http://opensource.org/licenses/afl-3.0.php
* If you did not receive a copy of the license and are unable to
* obtain it through the world-wide-web, please send an email
* to license@prestashop.com so we can send you a copy immediately.
*
* DISCLAIMER
*
* Do not edit or add to this file if you wish to upgrade PrestaShop to newer
* versions in the future. If you wish to customize PrestaShop for your
* needs please refer to http://www.prestashop.com for more information.
*
* @author PrestaShop SA <contact@prestashop.com>
* @copyright 2007-2024 PrestaShop SA
* @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0)
* International Registered Trademark & Property of PrestaShop SA
*
* Don't forget to prefix your containers with your own identifier
* to avoid any conflicts with others containers.
*/
var ChatGptForm = (function () {
function ChatGptForm(options) {
var settings = Object.assign({}, {
}, options);
}
ChatGptForm.renderToolTip = function (content) {
return '<span class="help-box gpt-tooltip" data-toggle="popover" data-trigger="hover" data-html="true" data-content="' + content + '" data-original-title="" title="" style="margin: 0 0 2px"></span>';
}
ChatGptForm.descriptionForm = function () {
var output =
'<div class="tabs js-tabs">' +
'<ul class="nav nav-tabs js-nav-tabs" id="form-nav" role="tablist">' +
'<li id="tab_step1" class="nav-item"><a href="#gptgeneral" role="tab" data-toggle="tab" class="font-weight-bold nav-link active" aria-selected="true">General</a></li>' +
'</ul>' +
'</div>' +
'<div class="tab-content" style="border: 1px solid #25b9d7;">' +
'<div class="form-contenttab tab-pane active" role="tabpanel" id="gptgeneral">' +
(adminPageName != 'productForm' && adminPageName != 'categoryForm' && adminPageName != 'cmsForm'
? '<div class="row form-inline mb-3">' +
'<label class="control-label col-md-6 justify-content-end text-right">' + (adminPageName == 'categoriesList' ? gptI18n.bulkGeneratingSkipExistingCategoryDescription : gptI18n.bulkGeneratingSkipExistingDescription) + ':</label>' +
'<div class="col-md-3">' +
'<div class="input-group">' +
'<span class="ps-switch">' +
'<input id="skip_existing_content_0" class="ps-switch" name="check_empty_content" value="0" ' + (gptPageSettings[adminPageName].skipExistingDescription ? '' : 'checked="checked"') + ' type="radio" aria-label="No" onchange="document.getElementById(\'replacecontentswicher\').style.display=($(this).is(\':checked\') ? \'block\' : \'none\');">' +
'<label for="skip_existing_content_0">' + gptI18n.no + '</label>' +
'<input id="skip_existing_content_1" class="ps-switch" name="check_empty_content" value="1" ' + (gptPageSettings[adminPageName].skipExistingDescription ? 'checked="checked"' : '') + ' type="radio" aria-label="Yes" onchange="document.getElementById(\'replacecontentswicher\').style.display=($(this).is(\':checked\') ? \'none\' : \'block\');">' +
'<label for="skip_existing_content_1">' + gptI18n.yes + '</label>' +
'<span class="slide-button"></span>' +
'</span>' +
'</div>' +
'</div>' +
'</div>'
: ''
) +
'<div id="replacecontentswicher" style="' + (gptPageSettings[adminPageName].skipExistingDescription ? 'display: none;' : '') + '">' +
'<div class="row form-inline mb-3">' +
'<label class="control-label col-md-6 justify-content-end text-right">' + ChatGptForm.renderToolTip('<b>Add</b> - the new content generated by ChatGPT will be added after your current description.<br/><b>Replace</b> - your current description will be replaced with the new one generated by ChatGPT') + ' ' + (adminPageName == 'cmsForm' ? gptI18n.bulkConfirmGenerateContent : gptI18n.bulkConfirmGenerateDescription) + ':</label>' +
'<div class="col-md-3">' +
'<div class="input-group">' +
'<span class="ps-switch">' +
'<input id="allow_gen_content_0" class="ps-switch" name="allow_gen_content" value="1" ' + (gptPageSettings[adminPageName].replaceContent ? 'checked="checked"' : '') + ' type="radio" aria-label="No">' +
'<label for="allow_gen_content_0">Replace</label>' +
'<input id="allow_gen_content_1" class="ps-switch" name="allow_gen_content" value="0" ' + (gptPageSettings[adminPageName].replaceContent ? '' : 'checked="checked"') + ' type="radio" aria-label="Yes">' +
'<label for="allow_gen_content_1">Add</label>' +
'<span class="slide-button"></span>' +
'</span>' +
'</div>' +
'</div>' +
'</div>' +
'</div>' +
(Object.keys(gptContentTemplates).length > 0
? '<div class="row form-inline mb-3 content-templates">' +
ChatGptForm.getContentTemplatesChooserHtml(gptContentTemplates) +
'</div>'
: ''
) +
'<div class="row form-inline mb-3 template-hide-form">' +
'<label class="control-label col-md-6 justify-content-end text-right">' + gptI18n.maxNumberWords + ':</label>' +
'<div class="col-md-6">' +
'<div class="input-group">' +
'<input type="number" id="gpt_description_length" class="form-control" min="' + gptPageSettings[adminPageName].minWords + '" step="' + gptPageSettings[adminPageName].step + '" max="' + gptPageSettings[adminPageName].maxWords + '" value="' + gptPageSettings[adminPageName].words + '">' +
'<div class="input-group-append">' +
'<span class="input-group-text"> ' + gptI18n.words + '</span>' +
'</div>' +
'</div>' +
'</div>' +
'</div>' +
'<div class="mb-3" style="' + (gptLanguages.length <= 1 ? 'display: none;' : '') + '">' +
ChatGptContent.getLanguageChooserHtml(gptLanguages) +
'</div>' +
(adminPageName != 'productsList' && adminPageName != 'productForm'
? ''
: '<div class="template-hide-form">' +
ChatGptForm.getAdvancedFormHtml() +
'</div>'
) +
'</div>' +
'</div>';
return output;
};
ChatGptForm.traslationForm = function () {
var output =
'<div class="mb-2" style="' + (gptLanguages.length <= 1 ? 'display: none;' : '') + '">' +
ChatGptForm.getOneToManyLanguagesSelectorHtml(gptLanguages) +
'</div>' +
(adminPageName != 'productForm' && adminPageName != 'categoryForm' && adminPageName != 'cmsForm' && adminPageName != 'postForm'
? '<div class="row form-inline mt-4">' +
'<label class="control-label col-md-6 justify-content-end text-right">' + (adminPageName == 'categoriesList' ? gptI18n.bulkGeneratingSkipExistingCategoryDescription : gptI18n.bulkGeneratingSkipExistingDescription) + ':</label>' +
'<div class="col-md-3">' +
'<div class="input-group">' +
'<span class="ps-switch">' +
'<input id="skip_existing_content_0" class="ps-switch" name="check_empty_content" value="0" ' + (gptPageSettings[adminPageName].skipExistingDescription ? '' : 'checked="checked"') + ' type="radio" aria-label="No">' +
'<label for="skip_existing_content_0">' + gptI18n.no + '</label>' +
'<input id="skip_existing_content_1" class="ps-switch" name="check_empty_content" value="1" ' + (gptPageSettings[adminPageName].skipExistingDescription ? 'checked="checked"' : '') + ' type="radio" aria-label="Yes">' +
'<label for="skip_existing_content_1">' + gptI18n.yes + '</label>' +
'<span class="slide-button"></span>' +
'</span>' +
'</div>' +
'</div>' +
'</div>'
: ''
);
return output;
}
ChatGptForm.traslationTitleForm = function () {
var output =
'<div class="mb-2" style="' + (gptLanguages.length <= 1 ? 'display: none;' : '') + '">' +
ChatGptForm.getOneToManyLanguagesSelectorHtml(gptLanguages) +
'</div>' +
(adminPageName != 'productForm' && adminPageName != 'categoryForm' && adminPageName != 'cmsForm'
? '<div class="row form-inline mt-4">' +
'<label class="control-label col-md-6 justify-content-end text-right">' + (adminPageName == 'categoriesList' ? gptI18n.bulkGeneratingSkipExistingCategoryTitle : gptI18n.bulkGeneratingSkipExistingTitle) + ':</label>' +
'<div class="col-md-3">' +
'<div class="input-group">' +
'<span class="ps-switch">' +
'<input id="skip_existing_content_0" class="ps-switch" name="check_empty_content" value="0" ' + (gptPageSettings[adminPageName].skipExistingTitle ? '' : 'checked="checked"') + ' type="radio" aria-label="No">' +
'<label for="skip_existing_content_0">' + gptI18n.no + '</label>' +
'<input id="skip_existing_content_1" class="ps-switch" name="check_empty_content" value="1" ' + (gptPageSettings[adminPageName].skipExistingTitle ? 'checked="checked"' : '') + ' type="radio" aria-label="Yes">' +
'<label for="skip_existing_content_1">' + gptI18n.yes + '</label>' +
'<span class="slide-button"></span>' +
'</span>' +
'</div>' +
'</div>' +
'</div>'
: ''
);
return output;
}
ChatGptForm.traslationProcess = function () {
var output =
'<div>' +
'<span>Translating in progress...</span>' +
'<span id="process_translate_status" style="color: darkred;"></span>' +
'<div class="progress mt-2" style="width: 100%">' +
'<div class="progress-bar progress-bar-striped" role="progressbar" style="width: 0%">' +
'<span>0 %</span>' +
'</div>' +
'</div>' +
'<div id="process_translate_error_log" class="alert alert-danger mt-2" style="display: none;"><p class="alert-text"></p></div>' +
'<div id="process_translate_success_log" class="alert alert-success mt-2" style="display: none;"><p class="alert-text"></p></div>' +
'</div>';
return output;
}
/**
* Get html of language chooser
*
* @return string
*/
ChatGptForm.getOneToManyLanguagesSelectorHtml = function(languages, idLangDefault) {
if (typeof languages == 'undefined') {
languages = gptLanguages;
}
if (typeof idLangDefault == 'undefined') {
idLangDefault = (new ChatGptContent).getPageLanguageId();
}
var checkboxClass = 'checkbox-' + (new Date()).getTime();
var radioClass = 'radio-' + (new Date()).getTime();
var idLang = 0;
var checkboxLanguagesList = '';
for (var i = 0; i < languages.length; i++) {
checkboxLanguagesList +=
'<tr ' + (languages[i].id_lang == idLangDefault ? 'style="display: none;"' : '') + '>' +
'<td>' +
'<div class="checkbox">' +
'<div class="md-checkbox md-checkbox-inline"><label><input type="checkbox" class="gpt-languages-list ' + checkboxClass + '" name="" value="' + languages[i].id_lang + '" ' + (languages[i].id_lang == idLang ? 'checked="checked"' : '') +'><i class="md-checkbox-control"></i>' + languages[i].name + '</label></div>' +
'</div>' +
'</td>' +
'</tr>';
}
var radioLanguagesList = '';
for (var i = 0; i < languages.length; i++) {
radioLanguagesList +=
'<tr>' +
'<td>' +
'<div class="radio">' +
'<div class="m-0 form-check-radio"><label class="form-check-label"><input type="radio" class="' + radioClass + '" name="origin_language" value="' + languages[i].id_lang + '" ' + (languages[i].id_lang == idLangDefault ? 'checked="checked"' : '') +' onchange="var tmpLId=this.value; $(\'.' + checkboxClass + '\').each(function () {var w=$(this).closest(\'tr\'); if (this.value==tmpLId){ w.hide(); w.find(\'input\').prop(\'checked\', false); } else w.show();})"><i class="form-check-round"></i>' + languages[i].name + '</label></div>' +
'</div>' +
'</td>' +
'</tr>';
}
return '<div class="row type-choice">' +
'<label class="control-label col-md-6 justify-content-start">Translate from:</label>' +
'<label class="control-label col-md-6 justify-content-start">Translate to:</label>' +
'</div>' +
'<div class="row type-choice">' +
'<div class="col-md-6">' +
'<div class="choice-table pl-1px">' +
'<table class="table table-bordered mb-0">' +
'<thead>' +
'<tr>' +
'<th class="checkbox">Select one</th>' +
'</tr>' +
'</thead>' +
'<tbody>' +
radioLanguagesList +
'</tbody>' +
'</table>' +
'</div>' +
'</div>' +
'<div class="col-md-6">' +
'<div class="choice-table">' +
'<table class="table table-bordered mb-0">' +
'<thead>' +
'<tr>' +
'<th class="checkbox">' +
'<div class="md-checkbox"><label><input type="checkbox" class="js-choice-table-select-all" onchange="var p=$(this).prop(\'checked\'),tmpLId=$(\'input[name=\\\'origin_language\\\']:checked\').val(); $(\'.' + checkboxClass + '\').each(function () {if (this.value != tmpLId) $(this).prop(\'checked\', p);})"><i class="md-checkbox-control"></i> ' + gptI18n.selectAll + '</label></div>' +
'</th>' +
'</tr>' +
'</thead>' +
'<tbody>' +
checkboxLanguagesList +
'</tbody>' +
'</table>' +
'</div>' +
'</div>' +
'</div>';
};
/**
* Get html of language chooser
*
* @return string
*/
ChatGptForm.getContentTemplatesChooserHtml = function(contentTemplates) {
if (typeof contentTemplates == 'undefined') {
return '';
}
if (!contentTemplates) {
return '';
}
var contentTemplatesOptions = '<option value="0">' + gptI18n.defaultOptions + '</option>';
for (key in contentTemplates) {
contentTemplatesOptions +=
'<option value=' + contentTemplates[key].id_content_template + '>' +
contentTemplates[key].name +
'</option>';
}
return '<label class="control-label col-md-6 justify-content-end text-right">' + gptI18n.requestTemplate + ':</label>' +
'<div class="col-md-6">' +
'<select class="form-control" id="id_content_template" style="width:100%" onchange="ChatGptForm.templateChange()">' +
contentTemplatesOptions +
'</select>' +
'</div>';
};
/**
* Get html of language chooser
*
* @return string
*/
ChatGptForm.getAdvancedFormHtml = function() {
return '<div class="row form-inline mb-3">' +
'<label class="control-label col-md-6 justify-content-end text-right">' + ChatGptForm.renderToolTip('Improve results of ChatGPT content generation by using the <b>category</b> value of the product') + ' ' + gptI18n.useProductCategory + ':</label>' +
'<div class="col-md-3">' +
'<div class="input-group">' +
'<span class="ps-switch">' +
'<input id="use_product_category_0" class="ps-switch" name="use_product_category" value="0" type="radio" aria-label="No">' +
'<label for="use_product_category_0">' + gptI18n.no + '</label>' +
'<input id="use_product_category_1" class="ps-switch" name="use_product_category" value="1" checked="checked" type="radio" aria-label="Yes">' +
'<label for="use_product_category_1">' + gptI18n.yes + '</label>' +
'<span class="slide-button"></span>' +
'</span>' +
'</div>' +
'</div>' +
'</div>' +
'<div class="row form-inline mb-3">' +
'<label class="control-label col-md-6 justify-content-end text-right">' + ChatGptForm.renderToolTip('Improve results of ChatGPT content generation by using the <b>brand</b> value of the product') + ' ' + gptI18n.useProductBrand + ':</label>' +
'<div class="col-md-3">' +
'<div class="input-group">' +
'<span class="ps-switch">' +
'<input id="use_product_brand_0" class="ps-switch" name="use_product_brand" value="0" type="radio" aria-label="No">' +
'<label for="use_product_brand_0">' + gptI18n.no + '</label>' +
'<input id="use_product_brand_1" class="ps-switch" name="use_product_brand" value="1" checked="checked" type="radio" aria-label="Yes">' +
'<label for="use_product_brand_1">' + gptI18n.yes + '</label>' +
'<span class="slide-button"></span>' +
'</span>' +
'</div>' +
'</div>' +
'</div>' +
'<div class="row form-inline mb-3 use-ean">' +
'<label class="control-label col-md-6 justify-content-end text-right">' + ChatGptForm.renderToolTip('Improve results of ChatGPT content generation by using the <b>EAN</b> value of the product') + ' ' + gptI18n.useProductEan + ':</label>' +
'<div class="col-md-3">' +
'<div class="input-group">' +
'<span class="ps-switch">' +
'<input id="use_product_ean_0" class="ps-switch" name="use_product_ean" value="0" type="radio" aria-label="No">' +
'<label for="use_product_ean_0">' + gptI18n.no + '</label>' +
'<input id="use_product_ean_1" class="ps-switch" name="use_product_ean" value="1" checked="checked" type="radio" aria-label="Yes">' +
'<label for="use_product_ean_1">' + gptI18n.yes + '</label>' +
'<span class="slide-button"></span>' +
'</span>' +
'</div>' +
'</div>' +
'</div>' +
'<div class="row form-inline mb-3 desc-or-characteristics">' +
'<label class="control-label col-md-6 justify-content-end text-right">' + ChatGptForm.renderToolTip('<b>Description</b> - you will get a common description of the product.<br/><b>Characteristics</b> - you will the list of product features') + ' ' + gptI18n.descriptionOrCharacteristics + ':</label>' +
'<div class="col-md-3">' +
'<div class="input-group">' +
'<span class="ps-switch">' +
'<input id="desc_or_characteristics_0" class="ps-switch" name="desc_or_characteristics" value="characteristics" type="radio" aria-label="No">' +
'<label for="desc_or_characteristics_0">Charact</label>' +
'<input id="desc_or_characteristics_1" class="ps-switch" name="desc_or_characteristics" value="description" checked="checked" type="radio" aria-label="Yes">' +
'<label for="desc_or_characteristics_1">Descr</label>' +
'<span class="slide-button"></span>' +
'</span>' +
'</div>' +
'</div>' +
'</div>';
}
ChatGptForm.templateChange = function() {
var id_template = +$('#id_content_template').val();
var $modalLanguages = $('.gpt-modal-languages');
$modalLanguages.find('.gpt-modal-languages-template').remove();
if (id_template) {
var nameLanguages = [];
$('.gpt-modal .template-hide-form').slideUp();
$modalLanguages.find('table').hide();
gptContentTemplates[id_template].langs.forEach(function(el){
nameLanguages.push($('.gpt-languages-list[value=' + +el +']').parent('label').text());
})
$modalLanguages.find('.choice-table').append('<div class="gpt-modal-languages-template">' + nameLanguages.join(', ') + '</div>');
} else {
$('.gpt-modal .template-hide-form').slideDown();
$modalLanguages.find('table').show();
}
}
ChatGptForm.rewriteForm = function () {
var output = '<div class="form-contenttab tab-pane active" role="tabpanel" id="gptgeneral">';
output +=
'<div class="bootstrap">' +
'<div class="alert alert-warning">' +
gptI18n.warningRewrite +
'</div>' +
'</div>';
var replaceContentSwicherHtml =
'<div id="replacecontentswicher">' +
'<div class="row form-inline mb-3">' +
'<label class="control-label col-md-6 justify-content-end text-right">' + ChatGptForm.renderToolTip('<b>Add</b> - the new content generated by ChatGPT will be added after your current one.<br/><b>Replace</b> - your current content will be replaced with the new one generated by ChatGPT') + ' ' + gptI18n.bulkConfirmAddOrRaplace + ':</label>' +
'<div class="col-md-3">' +
'<div class="input-group">' +
'<span class="ps-switch">' +
'<input id="allow_gen_content_0" class="ps-switch" name="allow_gen_content" value="1" checked="checked" type="radio" aria-label="No">' +
'<label for="allow_gen_content_0">Replace</label>' +
'<input id="allow_gen_content_1" class="ps-switch" name="allow_gen_content" value="0" type="radio" aria-label="Yes">' +
'<label for="allow_gen_content_1">Add</label>' +
'<span class="slide-button"></span>' +
'</span>' +
'</div>' +
'</div>' +
'</div>' +
'</div>';
if (adminPageName == 'productsList' || adminPageName == 'categoriesList') {
var checkboxClass = 'checkbox-' + (new Date()).getTime();
var checkboxLanguagesList = '';
for (var i = 0; i < gptLanguages.length; i++) {
checkboxLanguagesList +=
'<tr>' +
'<td>' +
'<div class="checkbox">' +
'<div class="md-checkbox md-checkbox-inline"><label><input type="checkbox" class="gpt-languages-list ' + checkboxClass + '" name="" value="' + gptLanguages[i].id_lang + '"><i class="md-checkbox-control"></i>' + gptLanguages[i].name + '</label></div>' +
'</div>' +
'</td>' +
'</tr>';
}
output +=
'<div class="row type-choice">' +
'<label class="control-label col-md-6 justify-content-start">' + gptI18n.textFields + ':</label>' +
'<label class="control-label col-md-6 justify-content-start">' + gptI18n.languages + ':</label>' +
'</div>' +
'<div class="row type-choice">' +
'<div class="col-md-6">' +
ChatGptContent.getFieldsChooserHtml() +
'</div>' +
'<div class="col-md-6">' +
'<div class="choice-table">' +
'<table class="table table-bordered mb-0">' +
'<thead>' +
'<tr>' +
'<th class="checkbox">' +
'<div class="md-checkbox"><label><input type="checkbox" class="js-choice-table-select-all" onchange="var p=$(this).prop(\'checked\'),tmpLId=$(\'input[name=\\\'origin_language\\\']:checked\').val(); $(\'.' + checkboxClass + '\').each(function () {if (this.value != tmpLId) $(this).prop(\'checked\', p);})"><i class="md-checkbox-control"></i> ' + gptI18n.selectAll + '</label></div>' +
'</th>' +
'</tr>' +
'</thead>' +
'<tbody>' +
checkboxLanguagesList +
'</tbody>' +
'</table>' +
'</div>' +
'</div>' +
'</div>' +
'<div class="mt-4">' +
replaceContentSwicherHtml +
'</div>';
} else {
output +=
replaceContentSwicherHtml +
'<div class="mb-3" style="' + (gptLanguages.length <= 1 ? 'display: none;' : '') + '">' +
ChatGptContent.getLanguageChooserHtml(gptLanguages) +
'</div>';
}
output += '</div>';
return output;
}
ChatGptForm.productPostForm = function () {
var output = '';
output +=
'<div class="row form-inline mb-3 template-hide-form">' +
'<label class="control-label col-md-6 justify-content-end text-right">' + gptI18n.maxNumberWords + ':</label>' +
'<div class="col-md-6">' +
'<div class="input-group">' +
'<input type="number" id="gpt_description_length" class="form-control" min="' + gptPageSettings[adminPageName].minWords + '" step="' + gptPageSettings[adminPageName].step + '" max="' + gptPageSettings[adminPageName].maxWords + '" value="' + gptPageSettings[adminPageName].words + '">' +
'<div class="input-group-append">' +
'<span class="input-group-text"> ' + gptI18n.words + '</span>' +
'</div>' +
'</div>' +
'</div>' +
'</div>' +
'<div class="mb-3" style="' + (gptLanguages.length <= 1 ? 'display: none;' : '') + '">' +
ChatGptContent.getLanguageChooserHtml(gptLanguages) +
'</div>' +
ChatGptForm.getAdvancedFormHtml() +
'<div class="row form-inline mb-3">' +
'<label class="control-label col-md-6 justify-content-end text-right">' + gptI18n.useProductImages + '</label>' +
'<div class="col-md-3">' +
'<div class="input-group">' +
'<span class="ps-switch">' +
'<input id="use_product_images_0" class="ps-switch" name="use_product_images" value="0" type="radio" checked="checked" aria-label="No" onchange="document.getElementById(\'post-images\').style.display=\'block\';">' +
'<label for="use_product_images_0">' + gptI18n.no + '</label>' +
'<input id="use_product_images_1" class="ps-switch" name="use_product_images" value="1" type="radio" aria-label="Yes" onchange="document.getElementById(\'post-images\').style.display=\'none\';">' +
'<label for="use_product_images_1">' + gptI18n.yes + '</label>' +
'<span class="slide-button"></span>' +
'</span>' +
'</div>' +
'</div>' +
'</div>' +
ChatGptForm.filesUploaderForm('post-images', '');
return output;
}
ChatGptForm.postForm = function () {
var output = '';
output +=
'<div id="replacecontentswicher" style="' + (gptPageSettings[adminPageName].skipExistingDescription ? 'display: none;' : '') + '">' +
'<div class="row form-inline mb-3">' +
'<label class="control-label col-md-6 justify-content-end text-right">' + ChatGptForm.renderToolTip('<b>Add</b> - the new content generated by ChatGPT will be added after your current description.<br/><b>Replace</b> - your current description will be replaced with the new one generated by ChatGPT') + ' ' + (adminPageName == 'cmsForm' ? gptI18n.bulkConfirmGenerateContent : gptI18n.bulkConfirmGenerateDescription) + ':</label>' +
'<div class="col-md-3">' +
'<div class="input-group">' +
'<span class="ps-switch">' +
'<input id="allow_gen_content_0" class="ps-switch" name="allow_gen_content" value="1" ' + (gptPageSettings[adminPageName].replaceContent ? 'checked="checked"' : '') + ' type="radio" aria-label="No">' +
'<label for="allow_gen_content_0">Replace</label>' +
'<input id="allow_gen_content_1" class="ps-switch" name="allow_gen_content" value="0" ' + (gptPageSettings[adminPageName].replaceContent ? '' : 'checked="checked"') + ' type="radio" aria-label="Yes">' +
'<label for="allow_gen_content_1">Add</label>' +
'<span class="slide-button"></span>' +
'</span>' +
'</div>' +
'</div>' +
'</div>' +
'</div>' +
'<div class="row form-inline mb-3 template-hide-form">' +
'<label class="control-label col-md-6 justify-content-end text-right">' + gptI18n.maxNumberWords + ':</label>' +
'<div class="col-md-6">' +
'<div class="input-group">' +
'<input type="number" id="gpt_description_length" class="form-control" min="' + gptPageSettings[adminPageName].minWords + '" step="' + gptPageSettings[adminPageName].step + '" max="' + gptPageSettings[adminPageName].maxWords + '" value="' + gptPageSettings[adminPageName].words + '">' +
'<div class="input-group-append">' +
'<span class="input-group-text"> ' + gptI18n.words + '</span>' +
'</div>' +
'</div>' +
'</div>' +
'</div>' +
'<div class="mb-3" style="' + (gptLanguages.length <= 1 ? 'display: none;' : '') + '">' +
ChatGptContent.getLanguageChooserHtml(gptLanguages) +
'</div>' +
ChatGptForm.filesUploaderForm('post-images', '');
return output;
}
ChatGptForm.filesUploaderForm = function (formId, placeholder) {
var output = '',
formId = (typeof formId == 'undefined') ? '' : formId,
placeholder = (typeof placeholder == 'undefined') ? '' : placeholder;
output +=
'<div id="' + formId + '" class="row form-inline mb-3 m-0 template-hide-form gpt-images-uploader">' +
// '<label class="control-label col-md-12 justify-content-start">Images:</label>' +
'<div class="col-md-12 justify-content-center drag-zone">' +
'<div class="images-list d-flex flex-wrap"></div>' +
'<p>Drop your images here or <a href="#" class="btn-dialog">select images</a></p>' +
'<div class="drag-layer"></div>' +
'</div>' +
'<input type="file" multiple="multiple" accept="image/png, image/jpeg" style="display: none;"/>' +
'</div>'
return output;
}
ChatGptForm.rewriteProcess = function () {
var output =
'<div>' +
'<span>Rewriting in progress...</span>' +
'<span id="process_rewrite_status" style="color: darkred;"></span>' +
'<div class="progress mt-2" style="width: 100%">' +
'<div class="progress-bar progress-bar-striped" role="progressbar" style="width: 0%">' +
'<span>0 %</span>' +
'</div>' +
'</div>' +
'<div id="process_rewrite_error_log" class="alert alert-danger mt-2" style="display: none;"><p class="alert-text"></p></div>' +
'<div id="process_rewrite_success_log" class="alert alert-success mt-2" style="display: none;"><p class="alert-text"></p></div>' +
'<div class="alert alert-info mt-2" style="margin-top:1.875rem !important;margin-bottom:-1.25rem;"><p class="alert-text">' + gptI18n.bulkRewriteFYI + '</p></div>' +
'</div>';
return output;
}
/**
* Get html of quota limit message
*
* @return string
*/
ChatGptForm.quotaLimits = function(message) {
return '<div class="row form-inline mb-3">' +
'<div class="col-md-12">' +
message +
'</div>' +
'</div>' +
'<div class="row form-inline mb-3">' +
'<div class="col-md-12 d-flex">' +
'<label><input type="checkbox" id="not_display_again" value="1" onchange="(new ChatGptContent()).setCookieValue(\'gptc_quota_limit\', +this.checked);"/> Do not show again</label>' +
'</div>' +
'</div>';
}
ChatGptForm.handleModalError = function (modal, errorMessage) {
if (!!modal.find('.progress-bar') && modal.find('.progress-bar').length) {
progressBar = modal.find('.progress-bar');
progressBar.removeClass('progress-bar-success');
progressBar.addClass('progress-bar-danger');
modal.find('#process_translate_status').text(gptI18n.bulkTranslationProcessFail);
modal.find("#process_translate_error_log").show().text(errorMessage);
} else {
// clean body
modal.find('body').html('');
// render message
ChatGptForm.renderAlertMessage(errorMessage, modal.find('body'));
}
// render close button
modal
.setActions([])
.addAction({
title: gptI18n.buttonClose,
class: 'btn btn-outline-secondary'
}, function (closeButton) {
closeButton.getModal().destroy();
})
.renderActions();
}
ChatGptForm.renderAlertMessage = function (messageText, element) {
var object = $('<div class="alert alert-danger mt-2" role="alert">' +
'<p class="alert-text">' + messageText + '</p>' +
'</div>');
if (!!element && element.length) {
element.append(object);
}
}
ChatGptForm.displayRenewLimitsModal = function(message) {
if (typeof cookieQuotaLimit != 'undefined' && cookieQuotaLimit == 1) {
return;
}
(new ChatGptModal({
closable: true,
keyboard: false,
backdrop: false,
class: 'black-modal modal-with-tabs'
}))
.setHeader(gptI18n.renewOrderTitle)
.setBody(ChatGptForm.quotaLimits(message))
.addAction({
title: gptI18n.buttonCancel,
class: 'btn btn-outline-secondary'
}, function (actionInstance) {
actionInstance.getModal().destroy();
})
.addAction({
title: gptI18n.renewOrOrderBtn,
}, function (actionInstance) {
if (typeof gptRenewUrl != 'undefined') {
window.location.href = gptRenewUrl;
}
actionInstance.getModal().destroy();
})
.open();
};
ChatGptForm.displaySubscriptionAlertMessage = function (wraper, subscription, w) {
subscription = typeof subscription == 'undefined' ? gptShopInfo.subscription : subscription;
if (!subscription || subscription[w] == 0) {
var alertMessage = '';
if (!subscription || !subscription.plan) {
alertMessage = gptI18n.subscriptionNotAvaialable;
ChatGptForm.displayRenewLimitsModal(gptI18n.subscriptionNotAvaialable);
} else if (subscription[w] == 0) {
alertMessage = gptI18n.subscriptionLimitЕxceeded + ' ' + gptI18n.renewOrOrderSubscription;
ChatGptForm.displayRenewLimitsModal(gptI18n.subscriptionLimitЕxceeded);
}
// renderAlertMessage(alertMessage, gptWidgetSettings.descriptionWrapper);
var object = $('<div class="alert alert-danger mt-2" role="alert">' +
'<p class="alert-text">' + alertMessage + '</p>' +
'</div>');
if (!!wraper && wraper.length) {
wraper.append(object);
}
return;
}
}
ChatGptForm.spinOffForm = function () {
var output =
'<div class="tabs js-tabs">' +
'<ul class="nav nav-tabs js-nav-tabs" id="form-nav" role="tablist">' +
'<li id="tab_step1" class="nav-item"><a href="#gptgeneral" role="tab" data-toggle="tab" class="font-weight-bold nav-link active" aria-selected="true">General</a></li>' +
'</ul>' +
'</div>' +
'<div class="tab-content" style="border: 1px solid #25b9d7;">' +
'<div class="form-contenttab tab-pane active" role="tabpanel" id="gptgeneral">' +
'<div class="row form-inline mb-3 template-hide-form">' +
'<label class="control-label col-md-6 justify-content-end text-right">' + gptI18n.NumberOfSpinOffs + ':</label>' +
'<div class="col-md-6">' +
'<div class="input-group">' +
'<input type="number" id="gpt_spinoff_number" class="form-control" min="1" step="1" value="10">' +
'<div class="input-group-append">' +
'<span class="input-group-text"> ' + gptI18n.SpinOffs + '</span>' +
'</div>' +
'</div>' +
'</div>' +
'</div>' +
'<div class="row form-inline mt-4">' +
'<label class="control-label col-md-6 justify-content-end text-right">' + ChatGptForm.renderToolTip(gptI18n.spinOffButtonToolTipStock) + ' ' + gptI18n.bulkSpinOffButtonStock + ':</label>' +
'<div class="col-md-3">' +
'<div class="input-group">' +
'<span class="ps-switch">' +
'<input id="spinoff_stock_0" class="ps-switch" name="spinoff_stock" value="0" ' + (gptPageSettings.productForm.spinOffStock == gptPageSettings.productForm.spinOffStockIndividual ? 'checked="checked"' : '') + ' type="radio" aria-label="No">' +
'<label for="spinoff_stock_0">' + gptI18n.spinOffIndividual + '</label>' +
'<input id="spinoff_stock_1" class="ps-switch" name="spinoff_stock" value="1" ' + (gptPageSettings.productForm.spinOffStock == gptPageSettings.productForm.spinOffStockCommon ? 'checked="checked"' : '') + ' type="radio" aria-label="Yes">' +
'<label for="spinoff_stock_1">' + gptI18n.spinOffCommon + '</label>' +
'<span class="slide-button"></span>' +
'</span>' +
'</div>' +
'</div>' +
'</div>' +
(gptShopInfo && gptShopInfo.subscription && gptShopInfo.subscription.availableProductWords > 0
? '<div class="row form-inline mt-4">' +
'<label class="control-label col-md-6 justify-content-end text-right">' + ChatGptForm.renderToolTip(gptI18n.spinOffCreateUseChatGptTip) + ' ' + gptI18n.spinOffCreateUseChatGPT + ':</label>' +
'<div class="col-md-3">' +
'<div class="input-group">' +
'<span class="ps-switch">' +
'<input id="spinoff_usechatgpt_0" class="ps-switch" name="spinoff_usechatgpt" value="0" type="radio" aria-label="No">' +
'<label for="spinoff_usechatgpt_0">' + gptI18n.spinOffCreateUseChatGptNo + '</label>' +
'<input id="spinoff_usechatgpt_1" class="ps-switch" name="spinoff_usechatgpt" value="1" checked="checked" type="radio" aria-label="Yes">' +
'<label for="spinoff_usechatgpt_1">' + gptI18n.spinOffCreateUseChatGptYes + '</label>' +
'<span class="slide-button"></span>' +
'</span>' +
'</div>' +
'</div>' +
'</div>' +
'<div id="spinoff_rewrite_description" class="row form-inline mt-4">' +
'<label class="control-label col-md-6 justify-content-end text-right">' + ChatGptForm.renderToolTip(gptI18n.spinOffButtonToolTipRewrite) + ' ' + gptI18n.spinOffButtonDescription + ':</label>' +
'<div class="col-md-3">' +
'<div class="input-group">' +
'<span class="ps-switch">' +
'<input id="rewrite_description_0" class="ps-switch" name="rewrite_description" value="0" type="radio" aria-label="No">' +
'<label for="rewrite_description_0">' + gptI18n.spinOffRewriteNo + '</label>' +
'<input id="rewrite_description_1" class="ps-switch" name="rewrite_description" value="1" checked="checked" type="radio" aria-label="Yes">' +
'<label for="rewrite_description_1">' + gptI18n.spinOffRewriteYes + '</label>' +
'<span class="slide-button"></span>' +
'</span>' +
'</div>' +
'</div>' +
'</div>' +
'<div id="spinoff_rewrite_short_description" class="row form-inline mt-4">' +
'<label class="control-label col-md-6 justify-content-end text-right">' + ChatGptForm.renderToolTip(gptI18n.spinOffButtonToolTipRewrite) + ' ' + gptI18n.spinOffButtonShortDescription + ':</label>' +
'<div class="col-md-3">' +
'<div class="input-group">' +
'<span class="ps-switch">' +
'<input id="rewrite_short_description_0" class="ps-switch" name="rewrite_short_description" value="0" type="radio" aria-label="No">' +
'<label for="rewrite_short_description_0">' + gptI18n.spinOffRewriteNo + '</label>' +
'<input id="rewrite_short_description_1" class="ps-switch" name="rewrite_short_description" value="1" checked="checked" type="radio" aria-label="Yes">' +
'<label for="rewrite_short_description_1">' + gptI18n.spinOffRewriteYes + '</label>' +
'<span class="slide-button"></span>' +
'</span>' +
'</div>' +
'</div>' +
'</div>'
: ''
) +
'</div>' +
'</div>';
return output;
};
ChatGptForm.spinOffCreationProcess = function () {
var output =
'<div>' +
'<span>Spin-offs creation in progress...</span>' +
'<span id="process_spinoff_status" style="color: darkred;"></span>' +
'<div class="progress mt-2" style="width: 100%">' +
'<div class="progress-bar progress-bar-striped progress-bar-animated" role="progressbar" style="width: 0%">' +
'<span>0 %</span>' +
'</div>' +
'</div>' +
'<div id="process_spinoff_error_log" class="alert alert-danger mt-2" style="display: none;"><p class="alert-text"></p></div>' +
'<div id="process_spinoff_success_log" class="alert alert-success mt-2" style="display: none;"><p class="alert-text"></p></div>' +
'</div>';
return output;
}
ChatGptForm.spinOffDeleteConfirmation = function () {
var output =
'<div>' +
'<span>These spin-off product will be deleted for good. Please confirm.</span>' +
'<div id="process_spinoff_error_log" class="alert alert-danger mt-2" style="display: none;"><p class="alert-text"></p></div>' +
'<div id="process_spinoff_success_log" class="alert alert-success mt-2" style="display: none;"><p class="alert-text"></p></div>' +
'</div>';
return output;
}
ChatGptForm.metaDataForm = function() {
var output =
'<div class="tabs js-tabs">' +
'<ul class="nav nav-tabs js-nav-tabs" id="form-nav" role="tablist">' +
'<li id="tab_step1" class="nav-item"><a href="#gptgeneral" role="tab" data-toggle="tab" class="font-weight-bold nav-link active" aria-selected="true">General</a></li>' +
'</ul>' +
'</div>' +
'<div class="tab-content" style="border: 1px solid #25b9d7;">' +
'<div class="form-contenttab tab-pane active" role="tabpanel" id="gptgeneral">' +
'<div class="mb-3" style="' + (gptLanguages.length <= 1 ? 'display: none;' : '') + '">' +
ChatGptContent.getLanguageChooserHtml(gptLanguages) +
'</div>' +
'<div class="d-flex">' +
'<label class="control-label col-md-6 justify-content-end text-right">' + ChatGptForm.renderToolTip('Improve results of ChatGPT content generation by using the <b>product</b> value of the product') + ' ' + 'Use product description' + ':</label>' +
'<div class="col-md-3">' +
'<div class="input-group">' +
'<span class="ps-switch">' +
'<input id="use_product_description_0" class="ps-switch" name="use_product_description" value="0" type="radio" aria-label="No">' +
'<label for="use_product_description_0">' + gptI18n.no + '</label>' +
'<input id="use_product_description_1" class="ps-switch" name="use_product_description" value="1" checked="checked" type="radio" aria-label="Yes">' +
'<label for="use_product_description_1">' + gptI18n.yes + '</label>' +
'<span class="slide-button"></span>' +
'</span>' +
'</div>' +
'</div>' +
'</div>' +
'</div>' +
'</div>';
return output;
};
return ChatGptForm;
})();