Merge git://github.com/Gared/etherpad-lite into develop

pull/555/head
Peter 'Pita' Martischka 2012-03-11 16:07:34 -07:00
commit cccd8a923c
1 changed files with 15 additions and 6 deletions

View File

@ -502,17 +502,26 @@ var padutils = {
var globalExceptionHandler = undefined; var globalExceptionHandler = undefined;
function setupGlobalExceptionHandler() { function setupGlobalExceptionHandler() {
//send javascript errors to the server
if (!globalExceptionHandler) { if (!globalExceptionHandler) {
globalExceptionHandler = function test (msg, url, linenumber) globalExceptionHandler = function test (msg, url, linenumber)
{ {
var errObj = {errorInfo: JSON.stringify({msg: msg, url: url, linenumber: linenumber, userAgent: navigator.userAgent})}; var errorId = randomString(20);
var loc = document.location; if ($("#editorloadingbox").attr("display") != "none"){
var url = loc.protocol + "//" + loc.hostname + ":" + loc.port + "/" + loc.pathname.substr(1, loc.pathname.indexOf("/p/")) + "jserror"; //show javascript errors to the user
$("#editorloadingbox").css("padding", "10px");
$("#editorloadingbox").css("padding-top", "45px");
$("#editorloadingbox").html("<div style='text-align:left;color:red;font-size:16px;'><b>An error occured</b><br>The error was reported with the following id: '" + errorId + "'<br><br><span style='color:black;font-weight:bold;font-size:16px'>Please send this error message to us: </span><div style='color:black;font-size:14px'>'"
+ "ErrorId: " + errorId + "<br>UserAgent: " + navigator.userAgent + "<br>" + msg + " in " + url + " at line " + linenumber + "'</div></div>");
}
$.post(url, errObj); //send javascript errors to the server
var errObj = {errorInfo: JSON.stringify({errorId: errorId, msg: msg, url: url, linenumber: linenumber, userAgent: navigator.userAgent})};
var loc = document.location;
var url = loc.protocol + "//" + loc.hostname + ":" + loc.port + "/" + loc.pathname.substr(1, loc.pathname.indexOf("/p/")) + "jserror";
return false; $.post(url, errObj);
return false;
}; };
window.onerror = globalExceptionHandler; window.onerror = globalExceptionHandler;
} }