/** * @classdesc Show an alert about the compatibility issues of the webapp * @constructor */ function CompatibilityManager() { var errors; var warnings; /** * Add an error to the list of compatibility issues. This is mainly intended * for issues that would not allow to the webapp to work correctly at all. * @param {String} component Name of the component that has the issue. * @param {String} msg Message to show to the user about the issue. */ this.addError = function(component, msg) { errors = errors || {}; errors[component] = msg; }; /** * Add a warning to the list of compatibility issues. This is mainly * intended for issues that would not allow to the webapp to work optimaly, * maybe using a polyfill or having some functionality disabled. * @param {String} component Name of the component that has the issue. * @param {String} msg Message to show to the user about the issue. */ this.addWarning = function(component, msg) { warnings = warnings || {}; warnings[component] = msg; }; /** * Show the alert to the user after all the issues have been collected. * It will be shown the first time the webapp is used on a browser, there're * error-cataloged issues or compatibility status has changed (mainly after * a browser update). */ this.show = function() { var msg = '
ShareIt! will not work '; var icon; if (errors) { icon = 'images/smiley-sad.svg'; msg += "on your browser because it doesn't meet the following requeriments:
"; msg += 'Also, it wouldn't work optimally because the following issues:
"; msg += 'Please upgrade to the latest version of Chrome/Chromium or Firefox.
'; showDialog(icon, msg); localStorage.compatibility = newCompatibility; } } // Browser have been upgraded and now it's fully compatible else if (localStorage.compatibility) { showDialog('images/smiley-happy.svg', 'Congratulations! Your browser is now fully compatible.'); localStorage.removeItem('compatibility'); } }; }