languages: [],
currentLanguage: '',
- init: function() {
+ init: function () {
var self = AtlanticDL;
$(document).on('click', '[data-atlanticdownload-ref]', function (e) {
});
},
- filterData: function(product) {
+ filterData: function (product) {
// Normalise reference
product = String(product).toLowerCase();
'download_high': v[5]
});
- AtlanticDL.languages.addUnique(v[3]);
+ arrayAddUnique(AtlanticDL.languages, v[3]);
}
});
// }));
},
- openPopup: function() {
+ openPopup: function () {
var self = this,
html = '';
html += '<div class="language-wrapper">';
html += '<h3 class="language-heading">Language</h3>';
html += '<ul class="language-list">';
- html += this.languages.map(function(l) {
+ html += this.languages.map(function (l) {
var active = (l === self.getCurrentLanguage()) ? ' active' : '';
- return '<li><a href="#" data-language="'+ l +'" class="language-link'+ active +'">'+ self.getLanguage(l) +'</a></li>';
+ return '<li><a href="#" data-language="' + l + '" class="language-link' + active + '">' + self.getLanguage(l) + '</a></li>';
}).join('');
html += '</ul>';
html += '</div>';
$('body').append('<div id="' + this.popupID + '">' + html + '</div>');
},
- generateRows: function(language) {
+ generateRows: function (language) {
language = language || this.getCurrentLanguage();
// Highlight current language in the menu
$('.language-link')
.removeClass('active')
- .filter('[data-language="'+ language +'"]')
+ .filter('[data-language="' + language + '"]')
.addClass('active');
// console.info('Generating rows for language: ' + language);
- return this.data.filter(function(d) {
+ return this.data.filter(function (d) {
return d.language === language;
- }).map(function(d) {
+ }).map(function (d) {
var res = '',
dl_low = '-',
dl_high = '-',
reference = d.reference || '-';
- if (d.download_low) dl_low = '<a href="'+ d.download_low +'" class="atlantic-download-icon" target="_blank" rel="noopener"></a>';
- if (d.download_high) dl_high = '<a href="'+ d.download_high +'" class="atlantic-download-icon" target="_blank" rel="noopener"></a>';
+ if (d.download_low) dl_low = '<a href="' + d.download_low + '" class="atlantic-download-icon" target="_blank" rel="noopener"></a>';
+ if (d.download_high) dl_high = '<a href="' + d.download_high + '" class="atlantic-download-icon" target="_blank" rel="noopener"></a>';
res += '<tr>';
- res += '<td>'+ d.title +'</td>';
- res += '<td>'+ reference +'</td>';
- res += '<td class="atlantic-download">'+ dl_low +'</td>';
- res += '<td class="atlantic-download">'+ dl_high +'</td>';
+ res += '<td>' + d.title + '</td>';
+ res += '<td>' + reference + '</td>';
+ res += '<td class="atlantic-download">' + dl_low + '</td>';
+ res += '<td class="atlantic-download">' + dl_high + '</td>';
res += '</tr>';
return res;
},
- getLanguage: function(code) {
+ getLanguage: function (code) {
// Language lookup map
var languages = {
return languages[code] || code; // Return the original code if it's not found in the lookup
},
- getCurrentLanguage: function() {
+ getCurrentLanguage: function () {
// Ensure that we have a valid current language (must exist in the current data list)
if (this.languages.indexOf(this.currentLanguage) == -1) {
this.currentLanguage = this.languages[0];
});
// Allow adding of elements to an array without duplicate values
-Array.prototype.addUnique = function(elem) {
- if (this.indexOf(elem) == -1) {
- this.push(elem);
+function arrayAddUnique(array, elem) {
+ if (array.indexOf(elem) == -1) {
+ array.push(elem);
}
+ return array;
}
\ No newline at end of file