From 4fdb02228fe4a41f71910c46d907cd8042cb395e Mon Sep 17 00:00:00 2001 From: Vincent Vanwaelscappel Date: Wed, 11 Oct 2017 15:21:14 +0200 Subject: [PATCH] wip #1744 @0:05 --- js/libs/cube/fb.js | 6 +-- js/libs/fluidbook/special/atlanticdownload.js | 43 ++++++++++--------- 2 files changed, 25 insertions(+), 24 deletions(-) diff --git a/js/libs/cube/fb.js b/js/libs/cube/fb.js index f3ccc521..479691aa 100644 --- a/js/libs/cube/fb.js +++ b/js/libs/cube/fb.js @@ -24,9 +24,9 @@ function fb(o, type) { return; } -window.onerror = function(errorMsg, url, lineNumber) { - fb(errorMsg + ' in ' + url + ' at line ' + lineNumber, 'error'); -}; +// window.onerror = function(errorMsg, url, lineNumber) { +// console.log(errorMsg + ' in ' + url + ' at line ' + lineNumber, 'error'); +// }; function is(type, obj) { var clas = Object.prototype.toString.call(obj).slice(8, -1); diff --git a/js/libs/fluidbook/special/atlanticdownload.js b/js/libs/fluidbook/special/atlanticdownload.js index f57935b4..48c29722 100644 --- a/js/libs/fluidbook/special/atlanticdownload.js +++ b/js/libs/fluidbook/special/atlanticdownload.js @@ -5,7 +5,7 @@ var AtlanticDL = { languages: [], currentLanguage: '', - init: function() { + init: function () { var self = AtlanticDL; $(document).on('click', '[data-atlanticdownload-ref]', function (e) { @@ -28,7 +28,7 @@ var AtlanticDL = { }); }, - filterData: function(product) { + filterData: function (product) { // Normalise reference product = String(product).toLowerCase(); @@ -50,7 +50,7 @@ var AtlanticDL = { 'download_high': v[5] }); - AtlanticDL.languages.addUnique(v[3]); + arrayAddUnique(AtlanticDL.languages, v[3]); } }); @@ -64,7 +64,7 @@ var AtlanticDL = { // })); }, - openPopup: function() { + openPopup: function () { var self = this, html = ''; @@ -75,9 +75,9 @@ var AtlanticDL = { html += '
'; html += '

Language

'; html += ''; html += '
'; @@ -107,35 +107,35 @@ var AtlanticDL = { $('body').append('
' + html + '
'); }, - 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 = ''; - if (d.download_high) dl_high = ''; + if (d.download_low) dl_low = ''; + if (d.download_high) dl_high = ''; res += ''; - res += ''+ d.title +''; - res += ''+ reference +''; - res += ''+ dl_low +''; - res += ''+ dl_high +''; + res += '' + d.title + ''; + res += '' + reference + ''; + res += '' + dl_low + ''; + res += '' + dl_high + ''; res += ''; return res; @@ -144,7 +144,7 @@ var AtlanticDL = { }, - getLanguage: function(code) { + getLanguage: function (code) { // Language lookup map var languages = { @@ -167,7 +167,7 @@ var AtlanticDL = { 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]; @@ -184,8 +184,9 @@ $(function () { }); // 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 -- 2.39.5