POST caught errors to me.

This commit is contained in:
Nicolas Stepien 2013-04-07 21:41:31 +02:00
parent 5a04bba12d
commit b09f790767
3 changed files with 26 additions and 13 deletions

View File

@ -41,10 +41,10 @@ $.extend $,
fd.append key, val fd.append key, val
fd fd
ajax: (url, callbacks, opts={}) -> ajax: (url, callbacks, opts={}) ->
{type, headers, upCallbacks, form} = opts {type, headers, upCallbacks, form, sync} = opts
r = new XMLHttpRequest() r = new XMLHttpRequest()
type or= form and 'post' or 'get' 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 for key, val of headers
r.setRequestHeader key, val r.setRequestHeader key, val
$.extend r, callbacks $.extend r, callbacks

View File

@ -3517,7 +3517,6 @@ ExpandThread =
threadRoot = thread.OP.nodes.root.parentNode threadRoot = thread.OP.nodes.root.parentNode
a = $ '.summary', threadRoot a = $ '.summary', threadRoot
switch thread.isExpanded switch thread.isExpanded
when false, undefined when false, undefined
thread.isExpanded = 'loading' thread.isExpanded = 'loading'

View File

@ -527,7 +527,7 @@ Main =
new Notification 'info', el, 120 new Notification 'info', el, 120
handleErrors: (errors) -> handleErrors: (errors) ->
unless 'length' of errors unless errors instanceof Array
error = errors error = errors
else if errors.length is 1 else if errors.length is 1
error = errors[0] error = errors[0]
@ -538,12 +538,10 @@ Main =
div = $.el 'div', div = $.el 'div',
innerHTML: "#{errors.length} errors occurred. [<a href=javascript:;>show</a>]" innerHTML: "#{errors.length} errors occurred. [<a href=javascript:;>show</a>]"
$.on div.lastElementChild, 'click', -> $.on div.lastElementChild, 'click', ->
if @textContent is 'show' [@textContent, logs.hidden] = if @textContent is 'show'
@textContent = 'hide' ['hide', false]
logs.hidden = false
else else
@textContent = 'show' ['show', true]
logs.hidden = true
logs = $.el 'div', logs = $.el 'div',
hidden: true hidden: true
@ -553,14 +551,30 @@ Main =
new Notification 'error', [div, logs], 30 new Notification 'error', [div, logs], 30
parseError: (data) -> parseError: (data) ->
{message, error} = data Main.logError data
c.error message, error.stack
message = $.el 'div', message = $.el 'div',
textContent: message textContent: data.message
error = $.el 'div', error = $.el 'div',
textContent: error textContent: data.error
[message, 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: -> isThisPageLegit: ->
# 404 error page or similar. # 404 error page or similar.
unless 'thisPageIsLegit' of Main unless 'thisPageIsLegit' of Main