Skip to content

Commit

Permalink
Merge pull request #1 from jordanlleslie/formatting
Browse files Browse the repository at this point in the history
formatting
  • Loading branch information
jordanlleslie authored Nov 30, 2023
2 parents 04da2d0 + 9ad06ae commit 6594471
Showing 1 changed file with 122 additions and 134 deletions.
256 changes: 122 additions & 134 deletions index.html
Original file line number Diff line number Diff line change
@@ -1,134 +1,122 @@
<link href="https://cdn.quilljs.com/1.3.6/quill.snow.css" rel="stylesheet">
<script src="https://cdn.quilljs.com/1.3.6/quill.js"></script>

<div id="toolbar">
<!-- Add a custom button -->
<style>
#myButton, #myButton1, #myButton2 {
margin-right: 10px;
}
</style>

<button id="myButton">GPT Call 1</button>
<button id="myButton1">GPT Call 2</button>
<button id="myButton2">GPT Call 3</button>
<!-- Other toolbar items -->

<button class="ql-bold">Bold</button>
<button class="ql-italic">Italic</button>
<!-- ... other toolbar items ... -->
</div>

<div id="editor">
<!-- This is where Quill will place the editor's content -->
</div>

<script>
var quill = new Quill('#editor', {
theme: 'snow',
modules: {
toolbar: '#toolbar'
}
});

// document.querySelector('#myButton').addEventListener('click', function() {
// let range = quill.getSelection(true);
// let aboutData;
// fetch('https://mocki.io/v1/baff67f5-4af8-4d62-86ad-f49d75ce98fc')
// .then(response => response.text())
// .then(data => {
// aboutData = data;
// console.log(aboutData);
// console.log(typeof(aboutData));
// })
// .catch(error => console.error(error));
// var parsed_data = JSON.parse(aboutData);
// console.log(parsed_data);
// quill.insertText(range.index, "CHATGBT ROCks");
// });

document.querySelector('#myButton').addEventListener('click', function() {
let range = quill.getSelection(true);
let aboutData;
const xhr = new XMLHttpRequest();
// Set the request method and URL.
xhr.open('GET', 'https://mocki.io/v1/baff67f5-4af8-4d62-86ad-f49d75ce98fc');

// Set the request header.
xhr.setRequestHeader('Accept', 'application/json');

// Send the request.
xhr.send();

// Listen for the response.
xhr.onload = function() {
if (xhr.status === 200) {
// Success!
const response = JSON.parse(xhr.responseText);
console.log(response);
quill.insertText(range.index, response.data);
} else {
// Error!
console.log(xhr.statusText);
}
};
// quill.insertText(range.index, response.data);
});

document.querySelector('#myButton1').addEventListener('click', function() {
let range = quill.getSelection(true);
let aboutData;
const xhr = new XMLHttpRequest();
// Set the request method and URL.
xhr.open('GET', 'https://mocki.io/v1/baff67f5-4af8-4d62-86ad-f49d75ce98fc');

// Set the request header.
xhr.setRequestHeader('Accept', 'application/json');

// Send the request.
xhr.send();

// Listen for the response.
xhr.onload = function() {
if (xhr.status === 200) {
// Success!
const response = JSON.parse(xhr.responseText);
console.log(response);
quill.insertText(range.index, response.data + "1");
} else {
// Error!
console.log(xhr.statusText);
}
};
// quill.insertText(range.index, response.data);
});

document.querySelector('#myButton2').addEventListener('click', function() {
let range = quill.getSelection(true);
let aboutData;
const xhr = new XMLHttpRequest();
// Set the request method and URL.
xhr.open('GET', 'https://mocki.io/v1/baff67f5-4af8-4d62-86ad-f49d75ce98fc');

// Set the request header.
xhr.setRequestHeader('Accept', 'application/json');

// Send the request.
xhr.send();

// Listen for the response.
xhr.onload = function() {
if (xhr.status === 200) {
// Success!
const response = JSON.parse(xhr.responseText);
console.log(response);
quill.insertText(range.index, response.data + "2");
} else {
// Error!
console.log(xhr.statusText);
}
};
// quill.insertText(range.index, response.data);
});

</script>
<html>
<head>
<link href="https://cdn.quilljs.com/1.3.6/quill.snow.css" rel="stylesheet">
<script src="https://cdn.quilljs.com/1.3.6/quill.js"></script>
</head>
<body>

<div id="toolbar">
<!-- Add a custom button -->
<style>
#myButton, #myButton1, #myButton2 {
margin-right: 10px;
}
</style>

<button id="myButton">GPT Call 1</button>
<button id="myButton1">GPT Call 2</button>
<button id="myButton2">GPT Call 3</button>
<!-- Other toolbar items -->

<button class="ql-bold">Bold</button>
<button class="ql-italic">Italic</button>
<!-- ... other toolbar items ... -->
</div>

<div id="editor">
<!-- This is where Quill will place the editor's content -->
</div>

<script>
var quill = new Quill('#editor', {
theme: 'snow',
modules: {
toolbar: '#toolbar'
}
});


document.querySelector('#myButton').addEventListener('click', function() {
let range = quill.getSelection(true);
let aboutData;
const xhr = new XMLHttpRequest();
// Set the request method and URL.
xhr.open('GET', 'https://mocki.io/v1/baff67f5-4af8-4d62-86ad-f49d75ce98fc');

// Set the request header.
xhr.setRequestHeader('Accept', 'application/json');

// Send the request.
xhr.send();

// Listen for the response.
xhr.onload = function() {
if (xhr.status === 200) {
// Success!
const response = JSON.parse(xhr.responseText);
console.log(response);
quill.insertText(range.index, response.data);
} else {
// Error!
console.log(xhr.statusText);
}
};
});

document.querySelector('#myButton1').addEventListener('click', function() {
let range = quill.getSelection(true);
let aboutData;
const xhr = new XMLHttpRequest();
// Set the request method and URL.
xhr.open('GET', 'https://mocki.io/v1/baff67f5-4af8-4d62-86ad-f49d75ce98fc');

// Set the request header.
xhr.setRequestHeader('Accept', 'application/json');

// Send the request.
xhr.send();

// Listen for the response.
xhr.onload = function() {
if (xhr.status === 200) {
// Success!
const response = JSON.parse(xhr.responseText);
console.log(response);
quill.insertText(range.index, response.data + "1");
} else {
// Error!
console.log(xhr.statusText);
}
};
});

document.querySelector('#myButton2').addEventListener('click', function() {
let range = quill.getSelection(true);
let aboutData;
const xhr = new XMLHttpRequest();
// Set the request method and URL.
xhr.open('GET', 'https://mocki.io/v1/baff67f5-4af8-4d62-86ad-f49d75ce98fc');

// Set the request header.
xhr.setRequestHeader('Accept', 'application/json');

// Send the request.
xhr.send();

// Listen for the response.
xhr.onload = function() {
if (xhr.status === 200) {
// Success!
const response = JSON.parse(xhr.responseText);
console.log(response);
quill.insertText(range.index, response.data + "2");
} else {
// Error!
console.log(xhr.statusText);
}
};
});

</script>
</body>
</html>

0 comments on commit 6594471

Please sign in to comment.