Created
October 9, 2023 13:13
-
-
Save bjoerntx/edb5acca2daaa7fbc871c219cf46ea68 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function requestPrompt() { | |
const offset = $("#mainCanvas").offset(); | |
const $spinner = $("#chatgpt-spinner").css({ top: offset.top, left: offset.left, display: "block" }); | |
const prompt = $("#prompt").val(); | |
const serviceURL = "ChatGPT/PromptRequest"; | |
$.ajax({ | |
type: "POST", | |
url: serviceURL, | |
contentType: "application/json", | |
data: JSON.stringify({ text: prompt }), | |
success: successFunc, | |
error: errorFunc | |
}); | |
function hideSpinner() { | |
$spinner.css({ display: "none" }); | |
} | |
function successFunc(data) { | |
TXTextControl.selection.load(TXTextControl.StreamType.HTMLFormat, data); | |
hideSpinner(); | |
} | |
function errorFunc(data) { | |
console.log(data); | |
hideSpinner(); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment