diff --git a/static/js/pad.js b/static/js/pad.js index 172f9323f..e6d8dc9ae 100644 --- a/static/js/pad.js +++ b/static/js/pad.js @@ -401,6 +401,8 @@ var pad = { init: function() { + padutils.setupGlobalExceptionHandler(); + $(document).ready(function() { //start the costum js diff --git a/static/js/pad_utils.js b/static/js/pad_utils.js index 464c5058b..071185a80 100644 --- a/static/js/pad_utils.js +++ b/static/js/pad_utils.js @@ -459,17 +459,25 @@ var padutils = { } }; -//send javascript errors to the server -window.onerror = function test (msg, url, linenumber) -{ - var errObj = {errorInfo: JSON.stringify({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"; +var globalExceptionHandler = undefined; +function setupGlobalExceptionHandler() { + //send javascript errors to the server + if (!globalExceptionHandler) { + globalExceptionHandler = function test (msg, url, linenumber) + { + var errObj = {errorInfo: JSON.stringify({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"; - $.post(url, errObj); + $.post(url, errObj); - return false; -}; + return false; + }; + window.onerror = globalExceptionHandler; + } +} + +padutils.setupGlobalExceptionHandler = setupGlobalExceptionHandler; padutils.binarySearch = require('/ace2_common').binarySearch;