/
erroneous-duplicate-method.A.js
38 lines (31 loc) · 1.22 KB
/
erroneous-duplicate-method.A.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
/* @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)
}
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()
}
})