|
51 | 51 | // We want the lastest release (doesn't include draft or preview releases)
|
52 | 52 | xhr.open('GET', 'https://api.github.com/repos/mu-editor/mu/releases/latest');
|
53 | 53 | xhr.onload = function() {
|
54 |
| - // The request compleated |
55 |
| - if (xhr.readyState == 4) { |
56 |
| - // We got the data |
57 |
| - if (xhr.status === 200) { |
58 |
| - var lastest = {}; |
59 |
| - try { |
60 |
| - // IE6 & IE7 support is superfluous |
61 |
| - lastest = JSON.parse(xhr.responseText); |
62 |
| - } catch (e) { |
63 |
| - console.error('Unable to parse release information', e); |
64 |
| - } |
65 |
| - if (typeof lastest.tag_name !== "undefined") { |
66 |
| - // Drop the 'v' from the start of the tag name |
67 |
| - var version = lastest.tag_name.substr(0, 1) == 'v' ? lastest.tag_name.substr(1) : lastest.tag_name; |
68 |
| - // Run the callback |
69 |
| - cb(semverRegex().test(version) ? semverRegex().exec(version)[0] : null); |
70 |
| - } else { |
71 |
| - console.error('GitHub did not return the expected data'); |
72 |
| - } |
| 54 | + // We got the data |
| 55 | + if (xhr.status === 200) { |
| 56 | + var lastest = {}; |
| 57 | + try { |
| 58 | + // IE6 & IE7 support is superfluous |
| 59 | + lastest = JSON.parse(xhr.responseText); |
| 60 | + } catch (e) { |
| 61 | + console.error('Unable to parse release information', e); |
| 62 | + } |
| 63 | + if (typeof lastest.tag_name !== "undefined") { |
| 64 | + // Drop the 'v' from the start of the tag name |
| 65 | + var version = lastest.tag_name.substr(0, 1) == 'v' ? lastest.tag_name.substr(1) : lastest.tag_name; |
| 66 | + // Run the callback |
| 67 | + cb(semverRegex().test(version) ? semverRegex().exec(version)[0] : null); |
73 | 68 | } else {
|
74 |
| - // Something went wrong. Fail quietly |
75 |
| - console.error('Unable to fetch release information'); |
| 69 | + console.error('GitHub did not return the expected data'); |
76 | 70 | }
|
| 71 | + } else { |
| 72 | + // Something went wrong. Fail quietly |
| 73 | + console.error('Unable to fetch release information'); |
77 | 74 | }
|
78 | 75 | };
|
79 | 76 | // Unable to fetch (Blocked by filter, CORs or network error)
|
|
0 commit comments