diff --git a/src/General/lib/$.coffee b/src/General/lib/$.coffee index a0b8fcaab..1574641c7 100755 --- a/src/General/lib/$.coffee +++ b/src/General/lib/$.coffee @@ -42,11 +42,24 @@ $.ajax = do -> # With the `If-Modified-Since` header we only receive the HTTP headers and no body for 304 responses. # This saves a lot of bandwidth and CPU time for both the users and the servers. lastModified = {} + blockedURLs = {} + blockedError = (url) -> + return if blockedURLs[url] + blockedURLs[url] = true + h_message = '<%= meta.name %> was blocked from loading the following URL:

' + h_message += '[More info]' + message = $.el 'div', innerHTML: h_message + $('span', message).textContent = (if /^\/\//.test url then location.protocol else '') + url + new Notice 'error', message, 30, -> delete blockedURLs[url] (url, options, extra={}) -> {type, whenModified, upCallbacks, form} = extra r = new XMLHttpRequest() type or= form and 'post' or 'get' - r.open type, url, true + try + r.open type, url, true + catch err + blockedError url + return options.onerror?() if whenModified r.setRequestHeader 'If-Modified-Since', lastModified[url] if url of lastModified $.on r, 'load', -> lastModified[url] = r.getResponseHeader 'Last-Modified' diff --git a/src/General/lib/notice.class b/src/General/lib/notice.class index dad665e3e..0d4ae079a 100644 --- a/src/General/lib/notice.class +++ b/src/General/lib/notice.class @@ -1,5 +1,5 @@ class Notice - constructor: (type, content, @timeout) -> + constructor: (type, content, @timeout, @onclose) -> @el = $.el 'div', innerHTML: '
' @el.style.opacity = 0 @@ -27,3 +27,4 @@ class Notice close: => $.off d, 'visibilitychange', @add $.rm @el + @onclose?()