This repository has been archived by the owner on Oct 1, 2019. It is now read-only.
forked from thoughtbot/hoptoad_notifier
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add development error lookup support.
- Loading branch information
1 parent
54acf3e
commit 16ef6df
Showing
7 changed files
with
226 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,96 @@ | ||
<script type="text/javascript"> | ||
var Hoptoad = { | ||
host : <%= host.to_json %>, | ||
api_key : <%= api_key.to_json %>, | ||
notice : <%= notice.to_json %>, | ||
message : 'This error exists in production!', | ||
|
||
initialize: function() { | ||
if (this.initialized) { | ||
return; | ||
} else { | ||
this.initialized = true; | ||
} | ||
|
||
var data = []; | ||
|
||
for (var key in this.notice) { | ||
data[data.length] = 'notice[' + key + ']=' + this.notice[key]; | ||
} | ||
|
||
data[data.length] = 'notice[api_key]=' + this.api_key; | ||
data[data.length] = 'callback=Hoptoad.onSuccess'; | ||
data[data.length] = '_=' + (new Date()).getTime(); | ||
|
||
var head = document.getElementsByTagName('head')[0]; | ||
var done = false; | ||
|
||
var | ||
script = document.createElement('script'); | ||
script.src = 'http://' + this.host + '/notices/exist?' + data.join('&'); | ||
script.type = 'text/javascript'; | ||
script.onload = script.onreadystatechange = function(){ | ||
if (!done && (!this.readyState || | ||
this.readyState == 'loaded' || this.readyState == 'complete')) { | ||
|
||
done = true; | ||
|
||
// Handle memory leak in IE. (via jQuery) | ||
script.onload = script.onreadystatechange = null; | ||
head.removeChild(script); | ||
} | ||
}; | ||
|
||
head.appendChild(script); | ||
}, | ||
|
||
onSuccess: function(error) { | ||
var body = document.getElementsByTagName('body')[0]; | ||
var text = document.createTextNode(this.message); | ||
var element = document.createElement('a'); | ||
|
||
element.id = 'hoptoad'; | ||
element.href = 'http://' + this.host + '/projects/' + error.project_id + | ||
'/errors/' + error.id; | ||
element.appendChild(text); | ||
|
||
body.insertBefore(element, body.firstChild); | ||
|
||
var h1 = document.getElementsByTagName('h1')[0]; | ||
var pre = document.getElementsByTagName('pre')[0]; | ||
var wrapper = document.createElement('div'); | ||
|
||
wrapper.id = 'wrapper'; | ||
wrapper.appendChild(h1); | ||
wrapper.appendChild(pre); | ||
|
||
body.insertBefore(wrapper, body.children[1]); | ||
} | ||
}; | ||
|
||
/*if (document.addEventListener) { | ||
document.addEventListener('DOMContentLoaded', function() { | ||
Hoptoad.initialize.apply(Hoptoad); | ||
}, false); | ||
}*/ | ||
|
||
window.onload = function() { | ||
Hoptoad.initialize.apply(Hoptoad); | ||
}; | ||
</script> | ||
|
||
<style type="text/css"> | ||
#hoptoad { | ||
background: #FFF url(http://hoptoadapp.com/images/fell-off-the-toad.gif) no-repeat top right; | ||
color: #F00; | ||
padding: 45px 101px 45px 12px; | ||
font-size: 14px; | ||
font-weight: bold; | ||
display: block; | ||
float: right; | ||
} | ||
|
||
#wrapper { | ||
padding-right: 360px; | ||
} | ||
</style> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters