corrade-nucleus-nucleons – Blame information for rev 28
?pathlinks?
Rev | Author | Line No. | Line |
---|---|---|---|
28 | office | 1 | function loadNucleon(nucleon) { |
2 | // If the nucleon already exists, then do not append the content again. |
||
3 | if($('#' + nucleon).length) |
||
4 | return; |
||
5 | |||
6 | // Disable button for successive clicks. |
||
7 | $('#' + nucleon + '-button').prop('disabled', true); |
||
8 | |||
9 | // Change the nucleon icon to a loading icon. |
||
10 | $('#' + nucleon + '-icon').attr('src', '/img/loader.svg'); |
||
11 | |||
12 | // Load the nucleon. |
||
13 | $.get('/' + nucleon + '/index.html', function(data) { |
||
14 | $('#nucleons-container').append(data); |
||
15 | }).done(function(data) { |
||
16 | // Change the nucleon icon back. |
||
17 | $('#' + nucleon + '-icon').attr('src', '/' + nucleon + '/img/' + nucleon + '.png'); |
||
18 | // Enable the button. |
||
19 | $('#' + nucleon + '-button').prop('disabled', false); |
||
20 | }); |
||
21 | } |
||
22 | |||
23 | // Generate the nucleon selectors. |
||
25 | office | 24 | $(document).ready(function() { |
25 | // Search and load all nucleons. |
||
26 | $.get('/nucleons', function(data) { |
||
27 | var nucleons = wasCSVToArray(data); |
||
28 | $.each(nucleons, function(index, value) { |
||
29 | // Skip files starting with full stop (POSIX). |
||
30 | if (/^\./.test(value)) return; |
||
31 | $.get('/nucleons/' + value, function(doc) { |
||
32 | var div = $('<div class="col-xs-6 col-md-3">').html(doc); |
||
33 | $('#nucleons').append(div); |
||
34 | }); |
||
35 | }); |
||
36 | }); |
||
37 | }); |