diff --git a/src/config/shim.js b/src/config/shim.js index c725f0508..5b7e21c5e 100644 --- a/src/config/shim.js +++ b/src/config/shim.js @@ -70,3 +70,17 @@ })(); } })(); + +/** + * In the case of a proxied URL, we want to show a warning message + * Do that by checking for the presence of the canonical URL ([ui|dev|qa].adsabs.harvard.edu) + */ +(function checkIfProxied() { + const canonicalUrlPattern = /^(ui|qa|dev)\.adsabs\.harvard\.edu$/; + + // if test fails, it is proxied url, set a class on body element + if (!canonicalUrlPattern.test(location.hostname)) { + const [bodyEl] = document.getElementsByTagName('body'); + bodyEl.classList.add('is-proxied'); + } +})(); diff --git a/src/js/apps/discovery/main.js b/src/js/apps/discovery/main.js index cba7b3134..3f2b0866e 100644 --- a/src/js/apps/discovery/main.js +++ b/src/js/apps/discovery/main.js @@ -21,8 +21,16 @@ define(['config/discovery.config', 'module'], function(config, module) { 'js/components/application', 'js/mixins/discovery_bootstrap', 'js/mixins/api_access', + 'js/components/api_feedback', 'analytics', - ], function(Router, Application, DiscoveryBootstrap, ApiAccess, analytics) { + ], function( + Router, + Application, + DiscoveryBootstrap, + ApiAccess, + ApiFeedback, + analytics + ) { var updateProgress = typeof window.__setAppLoadingProgress === 'function' ? window.__setAppLoadingProgress @@ -156,10 +164,25 @@ define(['config/discovery.config', 'module'], function(config, module) { // accessibility: skip to main content $('body').on('click', '#skip-to-main-content', function() { - $('#main-content').focus(); + $('#main-content').trigger('focus'); return false; }); + // check for is-proxied class, and if present, send alert + if ($('body').hasClass('is-proxied')) { + const msg = + 'You are using a proxied version of ADS, we recommend you switch to the regular non-proxied URL: https://ui.adsabs.harvard.edu'; + + pubsub.publish( + pubsub.getCurrentPubSubKey(), + pubsub.ALERT, + new ApiFeedback({ + type: 'danger', + msg, + }) + ); + } + // app is loaded, send timing event if (window.__PAGE_LOAD_TIMESTAMP) {