BossBey File Manager
PHP:
8.2.30
OS:
Linux
User:
imagivibe
Root
/
home
/
imagivibe
/
public_html
/
CTR
/
wp-content
/
plugins
/
porto-functionality
/
lib
/
ai-generator
📤 Upload
📝 New File
📁 New Folder
Close
Editing: ai-generator.min.js
jQuery((function(t){"use strict";t("body").on("click",".porto-ai-dialog:not(.loading) .btn-close",(function(e){e.preventDefault(),t(".porto-ai-dialog").addClass("hide")})),t("body").on("click",".porto-ai-dialog .btn-copy",(function(e){e.preventDefault(),t("#ai-output").trigger("select"),document.execCommand("copy"),t(this).html(wp.i18n.__("Copied","porto-functionality"))})),t("body").on("click",".ai_generate, .button-plugin-gen",(function(e){e.preventDefault();t(this);var o=t(this).attr("name");if("undefined"!=typeof js_porto_admin_vars&&""!=js_porto_admin_vars.ai_key){var i=wp.i18n.__,a={content:{type:"Content",max_tokens:2048,temperature:.9,prompt:i('Please write a %1$s description about the "%2$s". %3$s %4$s',"porto-functionality"),addQuery:i("Write at least 5 paragraphs.","porto-functionality")},excerpt:{type:"Excerpt",max_tokens:64,temperature:.1,prompt:i('Please write a %1$s short excerpt about the "%2$s". %3$s %4$s',"porto-functionality"),addQuery:i("The excerpt must be between 55 and 75 characters.","porto-functionality")},meta_desc:{type:"Meta Description for SEO",max_tokens:265,temperature:.3,prompt:i('Please write a SEO friendly meta description for the %1$s "%2$s". %3$s %4$s',"porto-functionality"),addQuery:i("The description must be between 105 and 140 characters.","porto-functionality")},meta_title:{type:"Meta Title for SEO",max_tokens:64,temperature:.6,prompt:i('Please write a SEO friendly meta title for the %1$s "%2$s". %3$s %4$s',"porto-functionality"),addQuery:i("The title must be between 40 and 60 characters.","porto-functionality")},meta_key:{type:"Meta Keywords for SEO",max_tokens:265,temperature:.6,prompt:i('Please write a SEO friendly meta keywords for the %1$s "%2$s". %3$s %4$s',"porto-functionality"),addQuery:i("Write at least 10 words.","porto-functionality")},outline:{type:"Outline",max_tokens:2048,temperature:.9,prompt:i('Please write a %1$s outline about the "%2$s". %3$s %4$s',"porto-functionality"),addQuery:i("Outline type is a alphanumeric outline.","porto-functionality")}},n=t("#ai_topic").length?t("#ai_topic").val():"",r=t("#ai_content_type").length?t("#ai_content_type").val():"",s=t("#ai_write_style").length&&""!=t("#ai_write_style").val()?"Writing Style: "+t("#ai_write_style").val()+".":"",p=t(".porto-ai-dialog"),l=p.find(".output"),c=js_porto_admin_vars.post_type,d="",u=t("#user_word");if(""==n.trim()&&(n=t("input#title").length?t("input#title").val():t("h1.editor-post-title").text()),"ai_generate"!=o&&(s="",r="meta_desc"),""==n.trim())return void window.alert(i("Please input the title.","porto-functionality"));if(""==r)return void window.alert(i("Please select the Generate Type.","porto-functionality"));u.length&&u.val().trim().length&&"ai_generate"==o?"."!=(d=u.val().trim()).slice(-1)&&"。"!=d.slice(-1)&&(d+="."):d=a[r].addQuery,p.removeClass("hide").addClass("loading"),l.val(""),p.find(".btn-copy").html(i("Copy to Clipboard","porto-functionality")),p.find(".porto-dialog-title").text(i("%1$s Generating","porto-functionality").replace("%1$s",a[r].type));var m={model:"gpt-3.5-turbo-instruct",prompt:a[r].prompt.replace("%1$s",c).replace("%2$s",n).replace("%3$s",d).replace("%4$s",s).trim(),max_tokens:a[r].max_tokens,temperature:a[r].temperature,top_p:1},f=new XMLHttpRequest;f.open("POST","https://api.openai.com/v1/completions"),f.setRequestHeader("Accept","application/json"),f.setRequestHeader("Content-Type","application/json"),f.setRequestHeader("timeout","20000"),f.setRequestHeader("Authorization","Bearer "+js_porto_admin_vars.ai_key),f.onreadystatechange=function(){if(p.removeClass("loading"),4==f.readyState&&200==f.status){if(void 0!==(e=JSON.parse(f.response)).choices&&void 0!==e.choices[0]){var t=e.choices[0].text.trim();""==t?l.val(i("Generate Failed!\nThere is a problem with your prompt.\n\nFor more information about creating a prompt, please visit the following URL.\n\nhttps://www.portotheme.com/wordpress/porto/documentation/how-to-use-openai-for-content-creation/#from-outline","porto-functionality")):l.val(t)}}else if(void 0!==f.response&&null!==f.response.match("error")){var e,o=(e=JSON.parse(f.response)).error.message;o.match("API key provided(: .*).")&&(o=i("Incorrect API key provided.","porto-functionality")),l.val(i("Error: %s","porto-functionality").replace("%s",o))}},f.ontimeout=function(){l.val(i("Request time is out.","porto-functionality"))},f.send(JSON.stringify(m)),f.onerror=function(){l.val(i("Request Failed.","porto-functionality"))}}}));var e=function(t,e){if(e.length){var o=wp.i18n.__;e.after('<div class="button-plugin-gen components-button is-primary" name="'+t+'-seo"><svg version="1.2" xmlns="http://www.w3.org/2000/svg" style="margin-right: 5px;" viewBox="0 0 18 18" width="18" height="18"><g><path fill="#ffffffcc" d="m9.3 17.8c-4.9 0-8.8-3.9-8.8-8.7 0-4.9 3.9-8.8 8.8-8.8 4.8 0 8.7 3.9 8.7 8.8 0 4.8-3.9 8.7-8.8 8.7z"/><path fill="#08c" d="m9.4 13.8c-2.6 0-4.6-2.1-4.6-4.6 0-2.5 2-4.6 4.6-4.6 2.5 0 4.5 2.1 4.5 4.6 0 2.5-2 4.6-4.5 4.6z"/><path fill="#ffffffcc" d="m9.4 11.8c-1.5 0-2.6-1.2-2.6-2.6 0-1.4 1.1-2.6 2.6-2.6 1.4 0 2.5 1.2 2.5 2.6 0 1.4-1.1 2.6-2.5 2.6z"/></g></svg>'+o("AI Generate","porto-functionality")+"</div>")}};t(window).on("YoastSEO:ready",(function(){var o=t("#yoast-google-preview-description-metabox").closest(".yst-replacevar");o.length&&e("yoast",o.find("button")),t("body").on("click","#yoast-snippet-editor-metabox",(function(o){"true"==t(this).attr("aria-expanded")&&setTimeout((function(){var o=t("#yoast-google-preview-description-metabox").closest(".yst-replacevar");e("yoast",o.find("button"))}),3e3)}))})),t(document).ready((function(o){if(window.aioseo){var i=t("body").find(".aioseo-post-general #aioseo-post-settings-meta-description-row .add-tags .aioseo-view-all-tags");e("aio",i),t("body").on("click",".aioseo-app > .aioseo-tabs .md-tabs-navigation > button:first-child",(function(o){setTimeout((function(){var o=t("body").find(".aioseo-post-general #aioseo-post-settings-meta-description-row .add-tags .aioseo-view-all-tags");e("aio",o)}),3e3)})),t("body").on("click","#aioseo-post-settings-sidebar .aioseo-post-general .edit-snippet",(function(o){setTimeout((function(){var o=t("body").find(".aioseo-post-settings-modal #aioseo-post-settings-meta-description-row .add-tags .aioseo-view-all-tags");e("aio",o)}),3e3)}))}window.rankMath&&t("body").on("click",".rank-math-editor > .components-tab-panel__tabs > button:first-child, .rank-math-edit-snippet",(function(o){setTimeout((function(){var o=t("body").find('.rank-math-editor-general [for="rank-math-editor-description"]');e("rank",o)}),3e3)}))}))}));
Save
Cancel