You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
cryptpad/www/checkup/dependency-warning.js

44 lines
1.5 KiB
JavaScript

(function () {
var h = (tag, children) => {
var el = document.createElement(tag);
children.forEach(child => {
if (typeof(child) === 'string') {
return void el.appendChild(document.createTextNode(child));
}
el.appendChild(child);
});
return el;
};
var first = true;
window.addEventListener('error', function (ev) {
if (window.CHECKUP_MAIN_LOADED) { return; }
if (!ev) { return; }
var srcElement = ev.srcElement;
if (!srcElement) { return; }
var nodeName = srcElement.nodeName;
if (nodeName !== 'SCRIPT') { return; }
var src = srcElement.src;
if (/\/api\/.*/.test(src)) {
console.error("A serverside API endpoint could not be reached.", src);
}
//if (!/\/bower_components\/.*/.test(src)) { return; }
if (first) {
document.body.appendChild(h('h1', ['Oops!']));
document.body.appendChild(h('p', [
`It's possible that this server's administrators forgot to install its client-side dependencies with 'bower update',`,
` or that some other required resource couldn't be loaded.`,
` See your browser's console for more details.`,
]));
first = false;
}
document.body.appendChild(h('p', [
'Failed to load ',
h('code', [src]),
'.',
]));
}, true);
}());