Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
33 changes: 33 additions & 0 deletions js/formDataToJson.js
Original file line number Diff line number Diff line change
Expand Up @@ -86,10 +86,23 @@ async function createCodeJson(data) {
document.getElementById("json-result").value = jsonString;
}

function checkIfResponseGenerated() {
const textArea = document.getElementById("json-result");
if(!textArea.value || textArea.value.trim() === '') {
alert("Please generate your response first by clicking 'Generate your response!' button.");
return false;
}
return true;
}

// Copies json to clipboard
async function copyToClipboard(event) {
event.preventDefault();

if (!checkIfResponseGenerated()) {
return;
}

var textArea = document.getElementById("json-result");
textArea.select();
document.execCommand("copy")
Expand Down Expand Up @@ -243,6 +256,10 @@ async function createPR(projectURL, token) {
async function createProjectPR(event) {
event.preventDefault();

if (!checkIfResponseGenerated()) {
return;
}

const textArea = document.getElementById("json-result");
const JSONObj = JSON.parse(textArea.value)

Expand Down Expand Up @@ -285,6 +302,10 @@ async function createProjectPR(event) {
async function downloadFile(event) {
event.preventDefault();

if (!checkIfResponseGenerated()) {
return;
}

const codeJson = document.getElementById("json-result").value
const jsonObject = JSON.parse(codeJson);
const jsonString = JSON.stringify(jsonObject, null, 2);
Expand Down Expand Up @@ -326,6 +347,10 @@ function generateIssueBody(JSONObj) {
async function createGitHubIssueForm(event) {
event.preventDefault();

if (!checkIfResponseGenerated()) {
return;
}

const textArea = document.getElementById("json-result");
const JSONObj = JSON.parse(textArea.value);

Expand Down Expand Up @@ -377,6 +402,10 @@ function createGitHubNewIssueURL(title, body) {
async function createAutoGitHubIssue(event) {
event.preventDefault();

if (!checkIfResponseGenerated()) {
return;
}

const textArea = document.getElementById("json-result");
const JSONObj = JSON.parse(textArea.value);

Expand Down Expand Up @@ -446,6 +475,10 @@ async function createIssueOnGitHub(token, title, body) {
async function emailFile(event) {
event.preventDefault();

if (!checkIfResponseGenerated()) {
return;
}

const codeJson = document.getElementById("json-result").value
const jsonObject = JSON.parse(codeJson);

Expand Down
Loading