corrade-nucleus-nucleons – Rev 28
?pathlinks?
function loadNucleon(nucleon) {
// If the nucleon already exists, then do not append the content again.
if($('#' + nucleon).length)
return;
// Disable button for successive clicks.
$('#' + nucleon + '-button').prop('disabled', true);
// Change the nucleon icon to a loading icon.
$('#' + nucleon + '-icon').attr('src', '/img/loader.svg');
// Load the nucleon.
$.get('/' + nucleon + '/index.html', function(data) {
$('#nucleons-container').append(data);
}).done(function(data) {
// Change the nucleon icon back.
$('#' + nucleon + '-icon').attr('src', '/' + nucleon + '/img/' + nucleon + '.png');
// Enable the button.
$('#' + nucleon + '-button').prop('disabled', false);
});
}
// Generate the nucleon selectors.
$(document).ready(function() {
// Search and load all nucleons.
$.get('/nucleons', function(data) {
var nucleons = wasCSVToArray(data);
$.each(nucleons, function(index, value) {
// Skip files starting with full stop (POSIX).
if (/^\./.test(value)) return;
$.get('/nucleons/' + value, function(doc) {
var div = $('<div class="col-xs-6 col-md-3">').html(doc);
$('#nucleons').append(div);
});
});
});
});