X-Git-Url: https://git.immae.eu/?a=blobdiff_plain;f=app%2FResources%2Fstatic%2Fthemes%2F_global%2Findex.js;h=b810e5d7358d53a13a382807e87379477079efaa;hb=fea68d1a723c3f84b48630df6f173bbca5db4a14;hp=00410754a244209c8b07bfa3dabb4152825626a2;hpb=64f81bc31699ed239e4becec1cfa7ebc0bef2b5a;p=github%2Fwallabag%2Fwallabag.git diff --git a/app/Resources/static/themes/_global/index.js b/app/Resources/static/themes/_global/index.js index 00410754..b810e5d7 100644 --- a/app/Resources/static/themes/_global/index.js +++ b/app/Resources/static/themes/_global/index.js @@ -9,7 +9,7 @@ import 'material-design-icons-iconfont/dist/material-design-icons.css'; import 'lato-font/css/lato-font.css'; import './global.scss'; -/* Shortcuts*/ +/* Shortcuts */ import './js/shortcuts/entry'; import './js/shortcuts/main'; @@ -28,8 +28,27 @@ $(document).ready(() => { element: document.querySelector('article'), }); + const authorization = { + permits() { return true; }, + }; + app.registry.registerUtility(authorization, 'authorizationPolicy'); + const x = JSON.parse($('#annotationroutes').html()); - app.include(annotator.storage.http, x); + app.include(annotator.storage.http, $.extend({}, x, { + onError(msg, xhr) { + if (!Object.prototype.hasOwnProperty.call(xhr, 'responseJSON')) { + annotator.notification.banner('An error occurred', 'error'); + return; + } + $.each(xhr.responseJSON.children, (k, v) => { + if (v.errors) { + $.each(v.errors, (n, errorText) => { + annotator.notification.banner(errorText, 'error'); + }); + } + }); + }, + })); app.start().then(() => { app.annotations.load({ entry: x.entryId }); @@ -46,7 +65,7 @@ $(document).ready(() => { retrievePercent(x.entryId); $(window).resize(() => { - retrievePercent(x.entryId); + retrievePercent(x.entryId, true); }); } });