PageRenderTime 21ms CodeModel.GetById 10ms app.highlight 7ms RepoModel.GetById 1ms app.codeStats 1ms

/shared/classes/js/debug.js

https://github.com/deltafactory/leads
JavaScript | 37 lines | 33 code | 0 blank | 4 comment | 4 complexity | a91459b1a2c2975909e9e9db1b942828 MD5 | raw file
 1var errors = [];
 2window.onerror = function(msg, url, linenumber) {
 3  //alert('Error message: '+msg+' URL: '+url+' Line Number: '+linenumber);
 4  errors.push(msg + ' from ' + url + ' on line ' +linenumber);
 5}
 6jQuery(document).ready(function($) {
 7  var url = window.location.href;
 8  var match = url.match(/\?inbound_js/);
 9  var param = "?";
10  if(match) {
11  	var param = "?";
12  }
13  var url = url.replace('?inbound_js', '');
14  var url = url.replace('&inbound_js', '') + param + "inbound-dequeue-scripts";
15  setTimeout(function() {
16    document.write("<strong>Below are the javascript errors on this page</strong> " + "<br>");
17    /*if (errors.length === 0 ) {
18        document.write("<strong style="color:green;">None Detected</strong> " + "<br>");
19    }*/
20    document.write("<div id='errors-here'>");
21     for (var i=0,len=errors.length; i<len; i++){
22        document.write(i + 1 + ". " + errors[i] + "<br>");
23     }
24    document.write("</div>");
25    document.write("<div style=\'margin-top:20px;\'><strong>You need to fix these errors for things to work. There are 3 options:</strong> " + "<br>");
26    document.write("<strong>1. <a href=\'" +url+ "\'>Click here and dequeue (turn off) the broken javascript files</a> from this page.</strong> " + "<br>");
27    document.write("<strong>2. Contact the original developer of the plugin/theme causing the error.</strong> " + "<br>");
28    document.write("<strong>3. Disable the plugin or theme causing the conflict.</strong> " + "<br></div>");
29   }, 500);
30    setTimeout(function() {
31     var theDiv = document.getElementById("errors-here");
32         if(theDiv.innerHTML.length == 0){
33             theDiv.innerHTML = "<strong style='color:green;''>No JS Errors Detected</strong> " + "<br><br>" + "Sometimes errors are not detectatble by this handy tool, to double check please <a href='http://www.youtube.com/watch?v=x19VOytW9DM'>follow these instructions</a>";
34             theDiv.style.display="inline";
35         }
36    }, 1000);
37 });