POST caught errors to me.
This commit is contained in:
parent
5a04bba12d
commit
b09f790767
@ -41,10 +41,10 @@ $.extend $,
|
||||
fd.append key, val
|
||||
fd
|
||||
ajax: (url, callbacks, opts={}) ->
|
||||
{type, headers, upCallbacks, form} = opts
|
||||
{type, headers, upCallbacks, form, sync} = opts
|
||||
r = new XMLHttpRequest()
|
||||
type or= form and 'post' or 'get'
|
||||
r.open type, url, true
|
||||
r.open type, url, if sync then false else true
|
||||
for key, val of headers
|
||||
r.setRequestHeader key, val
|
||||
$.extend r, callbacks
|
||||
|
||||
@ -3517,7 +3517,6 @@ ExpandThread =
|
||||
threadRoot = thread.OP.nodes.root.parentNode
|
||||
a = $ '.summary', threadRoot
|
||||
|
||||
|
||||
switch thread.isExpanded
|
||||
when false, undefined
|
||||
thread.isExpanded = 'loading'
|
||||
|
||||
@ -527,7 +527,7 @@ Main =
|
||||
new Notification 'info', el, 120
|
||||
|
||||
handleErrors: (errors) ->
|
||||
unless 'length' of errors
|
||||
unless errors instanceof Array
|
||||
error = errors
|
||||
else if errors.length is 1
|
||||
error = errors[0]
|
||||
@ -538,12 +538,10 @@ Main =
|
||||
div = $.el 'div',
|
||||
innerHTML: "#{errors.length} errors occurred. [<a href=javascript:;>show</a>]"
|
||||
$.on div.lastElementChild, 'click', ->
|
||||
if @textContent is 'show'
|
||||
@textContent = 'hide'
|
||||
logs.hidden = false
|
||||
[@textContent, logs.hidden] = if @textContent is 'show'
|
||||
['hide', false]
|
||||
else
|
||||
@textContent = 'show'
|
||||
logs.hidden = true
|
||||
['show', true]
|
||||
|
||||
logs = $.el 'div',
|
||||
hidden: true
|
||||
@ -553,14 +551,30 @@ Main =
|
||||
new Notification 'error', [div, logs], 30
|
||||
|
||||
parseError: (data) ->
|
||||
{message, error} = data
|
||||
c.error message, error.stack
|
||||
Main.logError data
|
||||
message = $.el 'div',
|
||||
textContent: message
|
||||
textContent: data.message
|
||||
error = $.el 'div',
|
||||
textContent: error
|
||||
textContent: data.error
|
||||
[message, error]
|
||||
|
||||
errors: []
|
||||
logError: (data) ->
|
||||
unless Main.errors.length
|
||||
$.on window, 'unload', Main.postErrors
|
||||
c.error data.message, data.error.stack
|
||||
Main.errors.push data
|
||||
|
||||
postErrors: ->
|
||||
errors = Main.errors.map (d) -> d.message + ' ' + d.error.stack
|
||||
$.ajax '<%= meta.page %>errors', {},
|
||||
sync: true
|
||||
form: $.formData
|
||||
n: "<%= meta.name %> v#{g.VERSION}"
|
||||
t: '<%= type %>'
|
||||
ua: window.navigator.userAgent
|
||||
e: errors.join '\n'
|
||||
|
||||
isThisPageLegit: ->
|
||||
# 404 error page or similar.
|
||||
unless 'thisPageIsLegit' of Main
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user