Showing the changes to assets/javascripts (5 of 5 files). Show all
Unified · Split
| @@ -75,6 +75,7 @@ · 74 unmodified lines | ||
| 75 | 75 | .install() |
| 76 | 76 | @previousErrorHandler = onerror |
| 77 | 77 | window.onerror = @onWindowError.bind(@) |
| 78 | + CookieStore.onBlocked = @onCookieBlocked | |
| 78 | 79 | return |
| 79 | 80 | |
| 80 | 81 | bootOne: -> |
| @@ -207,8 +208,17 @@ · 126 unmodified lines | ||
| 207 | 208 | @quotaExceeded = true |
| 208 | 209 | new app.views.Notif 'QuotaExceeded', autoHide: null |
| 209 | 210 | Raven.captureMessage 'QuotaExceededError', level: 'warning' |
| 211 | + return | |
| 212 | + | |
| 213 | + onCookieBlocked: (key, value, actual) -> | |
| 214 | + return if @cookieBlocked | |
| 215 | + @cookieBlocked = true | |
| 216 | + new app.views.Notif 'CookieBlocked', autoHide: null | |
| 217 | + Raven.captureMessage "CookieBlocked/#{key}", level: 'warning', extra: {value, actual} | |
| 218 | + return | |
| 210 | 219 | |
| 211 | 220 | onWindowError: (args...) -> |
| 221 | + return if @cookieBlocked | |
| 212 | 222 | if @isInjectionError args... |
| 213 | 223 | @onInjectionError() |
| 214 | 224 | else if @isAppError args... |
| @@ -1,6 +1,8 @@ | ||
| 1 | 1 | class @CookieStore |
| 2 | 2 | INT = /^\d+$/ |
| 3 | 3 | |
| 4 | + @onBlocked: -> | |
| 5 | + | |
| 4 | 6 | get: (key) -> |
| 5 | 7 | value = Cookies.get(key) |
| 6 | 8 | value = parseInt(value, 10) if value? and INT.test(value) |
| @@ -13,7 +15,7 @@ class @CookieStore · 6 unmodified lines | ||
| 13 | 15 | |
| 14 | 16 | value = 1 if value == true |
| 15 | 17 | Cookies.set(key, '' + value, path: '/', expires: 1e8) |
| 16 | − throw new Error("Failed to set cookie '#{key}'") unless @get(key) == value | |
| 18 | + @constructor.onBlocked(key, value, @get(key)) if @get(key) != value | |
| 17 | 19 | return |
| 18 | 20 | |
| 19 | 21 | del: (key) -> |
| @@ -23,6 +23,9 @@ app.templates.bootError = -> · 22 unmodified lines | ||
| 23 | 23 | If you keep seeing this, you're likely behind a proxy or firewall that blocks cross-domain requests. """ |
| 24 | 24 | |
| 25 | 25 | app.templates.offlineError = (reason) -> |
| 26 | + if reason is 'cookie_blocked' | |
| 27 | + return error """ Cookies must be enabled to use offline mode. """ | |
| 28 | + | |
| 26 | 29 | reason = switch reason |
| 27 | 30 | when 'not_supported' |
| 28 | 31 | """ Unfortunately your browser either doesn't support IndexedDB or does not make it available. """ |
| @@ -19,6 +19,10 @@ app.templates.notifQuotaExceeded = -> · 18 unmodified lines | ||
| 19 | 19 | textNotif """ The offline database has exceeded its size limitation. """, |
| 20 | 20 | """ Unfortunately this quota can't be detected programmatically, and the database can't be opened while over the quota, so it had to be reset. """ |
| 21 | 21 | |
| 22 | +app.templates.notifCookieBlocked = -> | |
| 23 | + textNotif """ Please enable cookies. """, | |
| 24 | + """ DevDocs will not work properly if cookies are disabled. """ | |
| 25 | + | |
| 22 | 26 | app.templates.notifInvalidLocation = -> |
| 23 | 27 | textNotif """ DevDocs must be loaded from #{app.config.production_host} """, |
| 24 | 28 | """ Otherwise things are likely to break. """ |
| @@ -11,6 +11,10 @@ class app.views.OfflinePage extends app.View · 10 unmodified lines | ||
| 11 | 11 | return |
| 12 | 12 | |
| 13 | 13 | render: -> |
| 14 | + if app.cookieBlocked | |
| 15 | + @html @tmpl('offlineError', 'cookie_blocked') | |
| 16 | + return | |
| 17 | + | |
| 14 | 18 | app.docs.getInstallStatuses (statuses) => |
| 15 | 19 | return unless @activated |
| 16 | 20 | if statuses is false |