]> _ Git - fluidbook-html5.git/commitdiff
wip #1744 @0:05
authorVincent Vanwaelscappel <vincent@cubedesigners.com>
Wed, 11 Oct 2017 13:21:14 +0000 (15:21 +0200)
committerVincent Vanwaelscappel <vincent@cubedesigners.com>
Wed, 11 Oct 2017 13:21:14 +0000 (15:21 +0200)
js/libs/cube/fb.js
js/libs/fluidbook/special/atlanticdownload.js

index f3ccc521a511691ed8812d24eff0ca961ac54fe1..479691aa2104cb57ec94a79387c2b510debc65ce 100644 (file)
@@ -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);
index f57935b46c59cb982db13dae2653d2a54c50d4f5..48c2972236fce548bd4591bc0db4777193debf5f 100644 (file)
@@ -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 += '<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>';
@@ -107,35 +107,35 @@ var AtlanticDL = {
         $('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;
@@ -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