diff --git a/test.A.js b/test.A.js deleted file mode 100644 index 6c4442952..000000000 --- a/test.A.js +++ /dev/null @@ -1,43 +0,0 @@ -/* @flow */ - -import $ from '../jquery' -import cast from '../typecast' -import {on} from 'delegated-events' -import {submit} from '../form' - -let allowSubmit = false - -function performHealthcheck() { - const repoName = cast(document.getElementById('showcase_item_name_with_owner'), HTMLInputElement).value - const submitButton = cast(document.getElementById('submit'), HTMLButtonElement) - const hiddenForm = cast(document.getElementsByClassName('js-submit-health-check')[0], HTMLFormElement) - const targetRepoName = cast(document.getElementById('repo_name'), HTMLInputElement) - document.getElementById("js-health").innerHTML = "Performing health check..." - targetRepoName.value = repoName - submitButton.disabled = false - allowSubmit = true - submit(hiddenForm) -} - -function test() { - console.log("hi"); - return 0; -} - -on('submit', '#new_showcase_item', function(e) { - if (!allowSubmit) { e.preventDefault() } -}) - -$(document).on('ajaxSuccess', '.js-health', function(event, xhr, settings, data) { - this.innerHTML = data -}) - -on('focusout', '#showcase_item_name_with_owner', function() { - performHealthcheck() -}) - -on('focusin', '#showcase_item_body', function() { - if (cast(document.getElementById('showcase_item_name_with_owner'), HTMLInputElement).type === 'hidden') { - performHealthcheck() - } -}) diff --git a/test.B.js b/test.B.js deleted file mode 100644 index 8c2d76650..000000000 --- a/test.B.js +++ /dev/null @@ -1,49 +0,0 @@ -/* @flow */ - -import cast from '../typecast' -import {changeValue} from '../form' -import {fetchSafeDocumentFragment} from '../fetch' -import {observe} from '../observe' - -function performHealthCheck(container, repoName) { - const formCheck = cast(document.querySelector('.js-repo-health-check'), HTMLFormElement) - const nameToCheck = cast(formCheck.querySelector('.js-repo-health-name'), HTMLInputElement) - nameToCheck.value = repoName - - const completedIndicator = cast(container.querySelector('.js-repo-health-check-completed'), HTMLInputElement) - changeValue(completedIndicator, '') - container.classList.remove('d-none') - container.classList.add('is-loading') - - return fetchSafeDocumentFragment(document, formCheck.action, { - method: 'POST', - body: new FormData(formCheck), - }).then(html => { - const results = cast(container.querySelector('.js-repo-health-results'), HTMLElement) - results.innerHTML = '' - results.appendChild(html) - - container.classList.remove('is-loading') - changeValue(completedIndicator, '1') - }) -} - -function test() { - return 0; -} - -observe('.js-repo-health', function(container: HTMLElement) { - const form = cast(container.closest('form'), HTMLFormElement) - const repoInput = cast(form.querySelector('.js-repo-name'), HTMLInputElement) - - if (repoInput.type === 'hidden') { - const description = cast(form.querySelector('.js-comment-field'), HTMLTextAreaElement) - description.addEventListener('focus', () => { - performHealthCheck(container, repoInput.value) - }) - } else { - repoInput.addEventListener('change', () => { - performHealthCheck(container, repoInput.value) - }) - } -})