|
20 | 20 | var consent = document.querySelector('input[name="consent"]'); |
21 | 21 | var action = document.querySelector('button#action'); |
22 | 22 | var blocking = null; |
| 23 | + var icon = ' <i class="fa fa-sign-in fa-fw"></i>'; |
23 | 24 |
|
24 | 25 | function onInput(aEv) { |
25 | 26 | var req = new XMLHttpRequest(); |
26 | 27 | var wantname = cleanFilename(aEv.target.value, ''); |
27 | 28 |
|
28 | 29 | function show(aConsent) { |
29 | | - action.innerHTML = action.innerHTML.replace(/Sign Up/, 'Sign In'); |
| 30 | + action.innerHTML = action.innerHTML = 'Sign In' + icon |
30 | 31 | action.classList.add('btn-success'); |
31 | 32 | action.classList.remove('btn-info'); |
| 33 | + action.classList.remove('btn-warning'); |
32 | 34 |
|
33 | 35 | if (captcha) { |
34 | 36 | if (!blocking) { |
|
46 | 48 | } |
47 | 49 |
|
48 | 50 | function hide() { |
49 | | - action.innerHTML = action.innerHTML.replace(/Sign In/, 'Sign Up'); |
| 51 | + action.innerHTML = action.innerHTML = 'Sign Up' + icon; |
50 | 52 | action.classList.remove('btn-success'); |
| 53 | + action.classList.remove('btn-warning'); |
51 | 54 | action.classList.add('btn-info'); |
52 | 55 |
|
53 | 56 | if (captcha) { |
|
57 | 60 | consent.checked = false; |
58 | 61 | } |
59 | 62 |
|
| 63 | + function hideEx() { |
| 64 | + action.innerHTML = action.innerHTML = 'Sign In / Sign Up' + icon; |
| 65 | + action.classList.remove('btn-info'); |
| 66 | + action.classList.remove('btn-success'); |
| 67 | + action.classList.add('btn-warning'); |
| 68 | + |
| 69 | + if (captcha) { |
| 70 | + captcha.style.display = 'block'; |
| 71 | + } |
| 72 | + |
| 73 | + consent.checked = false; |
| 74 | + } |
| 75 | + |
60 | 76 | if (wantname) { |
61 | 77 | req.open('HEAD', '/api/user/exist/' + wantname); |
62 | 78 | req.onreadystatechange = function () { |
|
72 | 88 | show(/ consent$/.test(this.getResponseHeader('Warning'))); |
73 | 89 | auth.value = ''; |
74 | 90 | break; |
| 91 | + case 429: |
| 92 | + hideEx(); |
| 93 | + auth.value = 'github'; |
| 94 | + break; |
75 | 95 | default: |
76 | 96 | hide(); |
77 | 97 | auth.value = 'github'; |
|
91 | 111 |
|
92 | 112 | if (username && auth && action) { |
93 | 113 | action.innerHTML = action.innerHTML.replace(/Next/, 'Sign Up'); |
| 114 | + action.classList.remove('btn-danger'); |
| 115 | + action.classList.add('btn-info'); |
94 | 116 |
|
95 | 117 | username.addEventListener('input', onInput, { |
96 | 118 | capture : true, |
|
0 commit comments