Skip to content

Instantly share code, notes, and snippets.

@bjoerntx
Created February 16, 2023 15:02
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save bjoerntx/60a20e70b0b20d2e72879e903d73089e to your computer and use it in GitHub Desktop.
Save bjoerntx/60a20e70b0b20d2e72879e903d73089e to your computer and use it in GitHub Desktop.
function getSnippet(snippetName, snippetFormat) {
var serviceURL = "@Url.Action("Content", "Snippets")";
console.log(snippetName);
$.ajax({
type: "POST",
url: serviceURL,
data: {
name: snippetName,
format: snippetFormat
},
success: successFunc,
error: errorFunc
});
function successFunc(data, status) {
if (snippetFormat == "HTM")
document.querySelector('[tx-snippet-name="' + snippetName + '"] .snippet-preview').innerHTML = data + "...";
else
TXTextControl.selection.load(TXTextControl.StreamType.InternalUnicodeFormat, data);
}
function errorFunc() {
$("#myToast .toast-body").text("Error! :-(");
$("#myToast").toast("show");
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment