var CurrentIndex = 0; var dummyFileName = ''; var FileName = ''; var AI_KEYWORD = { sully_text_2_ppt: text_2_ppt, colour: ChangeColorSchemaPhase2, text:SaveText }; async function SaveText(payload) { try { // First AJAX call const response1 = await $.ajax({ url: `${API_URL}/api/Editor/single/tab/text/0`, type: "POST", contentType: 'application/json', headers: { email: "", token: "fortesting", hostname: "https://slideuplift.com", }, data: JSON.stringify(FileName), }); console.log('single tab text ', response1); // Second AJAX call const response2 = await $.ajax({ url: `${API_URL}/api/Editor/AITextSave`, type: "POST", contentType: 'application/json', headers: { email: "", token: "fortesting", hostname: "https://slideuplift.com", }, data: JSON.stringify({ FileName, SlideId: response1?.Slides[0]?.SlideId, SlideText: payload?.payload?.text_content || [], }), }); console.log('text save ', response2); await addImageToChat(response2?.Image, true); streamingCompleted =false; } catch (error) { apiFailed(); // console.error('Error occurred:', error); } } async function ChangeColorSchemaPhase2(payload) { try { const response = await fetch(`${API_URL}/api/Editor/ChangeColorSchema/0`, { method: 'POST', headers: { 'Content-Type': 'application/json', 'email': "", 'token': 'fortesting', 'hostname': "https://slideuplift.com", }, body: JSON.stringify({ FileName, SchemaFile: null, SchemaJSON: payload?.payload?.colour_palette?.Palette1 }) }); if (!response.ok) { apiFailed(); // throw new Error(`HTTP error! Status: ${response.status}`); } const result = await response.json(); console.log('sully color success ', result); console.log('sully color success ', result?.Slide?.Slides[0]?.Image); await addImageToChat(result?.Slide?.Slides[0]?.Image, true); streamingCompleted =false; } catch (error) { console.error('Error occurred:', error); } } async function text_2_ppt(response) { const dummyFileName = 'filename_' + (Math.floor(Math.random() * (100000 - 1 + 1)) + 1) + '.pptx'; console.log('text_2_ppt response reached', response); try { const res = await fetch(`${API_URL}/api/Editor/CreateNewTemplate/`, { method: 'POST', headers: { 'Content-Type': 'application/json', email: "", token: "fortesting", hostname: "https://slideuplift.com", }, body: JSON.stringify({ content: response.payload.content, S3Url: response.payload.slide_url, FileName: dummyFileName }) }); if (!res.ok) { // throw new Error(`HTTP error! status: ${res.status}`); apiFailed(); } const data = await res.json(); console.log('text 2 ppt success ', data); FileName = data.FileName; await addImageToChat(data.PreviewImage, true); streamingCompleted =false; } catch (error) { console.error('Error in text_2_ppt:', error); } } function text_2_ppt_handle_res(res){ console.log('text_2_ppt_handle_res ', res); } function apiFailed(){ const newMessageDiv = document.createElement('div'); newMessageDiv.className = 'messageWrapper'; newMessageDiv.innerHTML = `
User Icon
I apologize for the inconvenience. It seems that our servers are currently facing some technical difficulties. Please try again after some time. Thank you for your understanding.
`; const messageContainer = document.getElementById('messageContainer'); messageContainer.appendChild(newMessageDiv); return; } // function updateToken(){ // jQuery.ajax({ // type: "post", // url: "https://slideuplift.com/wp-admin/admin-ajax.php", // data: { // action: 'getMyToken' // }, // success: function (response) { // response = JSON.parse(response); // if (response.status == true) { // $('.tokenno').html(response.token); // } else { // $('.tokenno').html('Buy now'); // $('#messageInput').attr('disabled', true); // $('#messageInput').attr('placeholder', 'Please buy tokens to use this feature.'); // } // } // }); // } // updateToken(); // setInterval(() => { // const messageContainer = document.getElementById('messageContainer'); // messageContainer.scrollTop = messageContainer.scrollHeight; // }, 1000); setInterval(() => { const messageContainer = document.getElementById('messageContainer'); const isAtBottom = messageContainer.scrollHeight - messageContainer.scrollTop === messageContainer.clientHeight; if (isAtBottom) { messageContainer.scrollTop = messageContainer.scrollHeight; } }, 1000);