<commit_before>function callScriptFunction() {
    var scriptId = "1Z_td2xr1Hq9loDzSdojcCS_3qFwKJR3apBuR2zmcyUVpdhqvfJWyMMYZ";
  
    // Call the Apps Script API run method
    //   'scriptId' is the URL parameter that states what script to run
    //   'resource' describes the run request body (with the function name
    //              to execute)
    gapi.client.script.scripts.run({
    'scriptId': scriptId,
    'resource': {
        "function": "createForm",
        "parameters": [],
        "devMode": true
    }
    }).then(function(resp) {
        var result = resp.result;
        if (result.error && result.error.status) {
            // The API encountered a problem before the script started executing
            appendPre('Error calling API:');
            appendPre(JSON.stringify(result, null, 2));
        } else if (result.error) {
            // The API executed, but the script returned an error.
            var error = result.error.details[0];
            appendPre('Script error message: ' + error.errorMessage);

            if (error.scriptStackTraceElements) {
                appendPre('Script error stacktrace:');
                for (var i = 0; i < error.scriptStackTraceElements.length; i++) {
                    var trace = error.scriptStackTraceElements[i];
                    appendPre('\t' + trace.function + ':' + trace.lineNumber);
                }
            }
        } else { 
            formData = JSON.stringify(result.response.result);
            fetch("/form-handler", {method: "POST", body: formData}).then((response) => {
                console.log(response)
                console.log(JSON.stringify(response));
                return response.text();
            });   
        }
    });
}

function getForms() {
    fetch("/form-handler").then(response => response.json()).then((formsList) => {
        console.log(formsList);
        const formElement = document.getElementById("form-container");
        formsList.forEach((form) => {
            formElement.appendChild(createTeacherFormElement(form.editURL));
            formElement.appendChild(createStudentFormElement(form.URL)); 
        });
    });
}

function createTeacherFormElement(editURL) { 
    const aElement = document.createElement("a");
    aElement.innerText = "Form Edit Page";
    aElement.href = editURL;
    return aElement;
}

function createStudentFormElement(URL) {
    const iframeElement = document.createElement("iframe");
    iframeElement.src = URL;
    return iframeElement;
}



<commit_msg>Need to handle promise correctly<commit_after>function callScriptFunction() {
    var scriptId = "1Z_td2xr1Hq9loDzSdojcCS_3qFwKJR3apBuR2zmcyUVpdhqvfJWyMMYZ";
  
    // Call the Apps Script API run method
    //   'scriptId' is the URL parameter that states what script to run
    //   'resource' describes the run request body (with the function name
    //              to execute)
    gapi.client.script.scripts.run({
    'scriptId': scriptId,
    'resource': {
        "function": "createForm",
        "parameters": [],
        "devMode": true
    }
    }).then(function(resp) {
        var result = resp.result;
        if (result.error && result.error.status) {
            // The API encountered a problem before the script started executing
            appendPre('Error calling API:');
            appendPre(JSON.stringify(result, null, 2));
        } else if (result.error) {
            // The API executed, but the script returned an error.
            var error = result.error.details[0];
            appendPre('Script error message: ' + error.errorMessage);

            if (error.scriptStackTraceElements) {
                appendPre('Script error stacktrace:');
                for (var i = 0; i < error.scriptStackTraceElements.length; i++) {
                    var trace = error.scriptStackTraceElements[i];
                    appendPre('\t' + trace.function + ':' + trace.lineNumber);
                }
            }
        } else { 
            formData = JSON.stringify(result.response.result);
            fetch("/form-handler", {method: "POST", body: formData}).then(getForms());
        }
    })
}

function getForms() {
    fetch("/form-handler").then(response => response.json()).then((formsList) => {
        console.log(formsList);
        const formElement = document.getElementById("form-container");
        formElement.innerHTML = "";
        formsList.forEach((form) => {
            formElement.appendChild(createTeacherFormElement(form.editURL));
            formElement.appendChild(createStudentFormElement(form.URL)); 
        });
    });
}

function createTeacherFormElement(editURL) { 
    const aElement = document.createElement("a");
    aElement.innerText = "Form Edit Page";
    aElement.href = editURL;
    return aElement;
}

function createStudentFormElement(URL) {
    const iframeElement = document.createElement("iframe");
    iframeElement.src = URL;
    return iframeElement;
}




{'fraction_non_alphanumeric': 0.11954115516200443, 'fraction_numerical': 0.004024954719259408, 'mean_word_length': 2.346801346801347, 'pattern_counts': {'":': 6, '<': 5, '<?xml version=': 0, '>': 10, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4214557', 'n_tokens_mistral': 1374, 'n_tokens_neox': 1323, 'n_words': 299}