show-js-error
Advanced tools
Comparing version
@@ -8,6 +8,7 @@ /*! show-js-error | © 2016 Denis Seleznev | MIT License */ | ||
* @param {Object} [settings] | ||
* @param {string} [settings.title] | ||
* @param {string} [settings.userAgent] | ||
* @param {string} [settings.sendText] | ||
* @param {string} [settings.sendUrl] | ||
* @param {String} [settings.title] | ||
* @param {String} [settings.userAgent] | ||
* @param {String} [settings.sendText] | ||
* @param {String} [settings.sendUrl] | ||
* @param {String} [settings.additionalText] | ||
*/ | ||
@@ -83,17 +84,16 @@ init: function(settings) { | ||
text = this._getDetailedMessage(err), | ||
body = document.body; | ||
body = document.body, | ||
textarea = this.elem({ | ||
name: 'textarea', | ||
tag: 'textarea', | ||
props: { | ||
innerHTML: text | ||
}, | ||
container: body | ||
}); | ||
var textarea = this.elem({ | ||
name: 'textarea', | ||
tag: 'textarea', | ||
props: { | ||
innerHTML: text | ||
}, | ||
container: body | ||
}); | ||
try { | ||
textarea.select(); | ||
document.execCommand('copy'); | ||
} catch(e) { | ||
} catch (e) { | ||
alert('Copying text is not supported in this browser.'); | ||
@@ -108,5 +108,5 @@ } | ||
* @param {Object} data | ||
* @param {string} data.name | ||
* @param {String} data.name | ||
* @param {DOMElement} data.container | ||
* @param {string} [data.tag] | ||
* @param {String} [data.tag] | ||
* @param {Object} [data.props] | ||
@@ -134,5 +134,5 @@ * @returns {DOMElement} | ||
* | ||
* @param {string} [name] | ||
* @param {string} [mod] | ||
* @returns {string} | ||
* @param {String} [name] | ||
* @param {String} [mod] | ||
* @returns {String} | ||
*/ | ||
@@ -154,4 +154,4 @@ elemClass: function(name, mod) { | ||
* | ||
* @param {string} text | ||
* @returns {string} | ||
* @param {String} text | ||
* @returns {String} | ||
*/ | ||
@@ -226,2 +226,9 @@ escapeHTML: function(text) { | ||
if (this.settings.additionalText) { | ||
this._additionalText = this.elem({ | ||
name: 'additional-text', | ||
container: this._body | ||
}); | ||
} | ||
this.elem({ | ||
@@ -414,6 +421,10 @@ name: 'close', | ||
if (this.settings.userAgent) { | ||
if (this._ua) { | ||
this._ua.innerHTML = this.escapeHTML(this.settings.userAgent); | ||
} | ||
if (this._additionalText) { | ||
this._additionalText.innerHTML = this.escapeHTML(this.settings.additionalText); | ||
} | ||
if (this._sendLink) { | ||
@@ -420,0 +431,0 @@ this._sendLink.href = this.settings.sendUrl |
@@ -8,6 +8,7 @@ /*! show-js-error | © 2016 Denis Seleznev | MIT License */ | ||
* @param {Object} [settings] | ||
* @param {string} [settings.title] | ||
* @param {string} [settings.userAgent] | ||
* @param {string} [settings.sendText] | ||
* @param {string} [settings.sendUrl] | ||
* @param {String} [settings.title] | ||
* @param {String} [settings.userAgent] | ||
* @param {String} [settings.sendText] | ||
* @param {String} [settings.sendUrl] | ||
* @param {String} [settings.additionalText] | ||
*/ | ||
@@ -83,17 +84,16 @@ init: function(settings) { | ||
text = this._getDetailedMessage(err), | ||
body = document.body; | ||
body = document.body, | ||
textarea = this.elem({ | ||
name: 'textarea', | ||
tag: 'textarea', | ||
props: { | ||
innerHTML: text | ||
}, | ||
container: body | ||
}); | ||
var textarea = this.elem({ | ||
name: 'textarea', | ||
tag: 'textarea', | ||
props: { | ||
innerHTML: text | ||
}, | ||
container: body | ||
}); | ||
try { | ||
textarea.select(); | ||
document.execCommand('copy'); | ||
} catch(e) { | ||
} catch (e) { | ||
alert('Copying text is not supported in this browser.'); | ||
@@ -108,5 +108,5 @@ } | ||
* @param {Object} data | ||
* @param {string} data.name | ||
* @param {String} data.name | ||
* @param {DOMElement} data.container | ||
* @param {string} [data.tag] | ||
* @param {String} [data.tag] | ||
* @param {Object} [data.props] | ||
@@ -134,5 +134,5 @@ * @returns {DOMElement} | ||
* | ||
* @param {string} [name] | ||
* @param {string} [mod] | ||
* @returns {string} | ||
* @param {String} [name] | ||
* @param {String} [mod] | ||
* @returns {String} | ||
*/ | ||
@@ -154,4 +154,4 @@ elemClass: function(name, mod) { | ||
* | ||
* @param {string} text | ||
* @returns {string} | ||
* @param {String} text | ||
* @returns {String} | ||
*/ | ||
@@ -226,2 +226,9 @@ escapeHTML: function(text) { | ||
if (this.settings.additionalText) { | ||
this._additionalText = this.elem({ | ||
name: 'additional-text', | ||
container: this._body | ||
}); | ||
} | ||
this.elem({ | ||
@@ -414,6 +421,10 @@ name: 'close', | ||
if (this.settings.userAgent) { | ||
if (this._ua) { | ||
this._ua.innerHTML = this.escapeHTML(this.settings.userAgent); | ||
} | ||
if (this._additionalText) { | ||
this._additionalText.innerHTML = this.escapeHTML(this.settings.additionalText); | ||
} | ||
if (this._sendLink) { | ||
@@ -420,0 +431,0 @@ this._sendLink.href = this.settings.sendUrl |
{ | ||
"name": "show-js-error", | ||
"description": "Show a message about a js error in any browser", | ||
"version": "1.0.0", | ||
"version": "1.1.0", | ||
"author": { | ||
@@ -6,0 +6,0 @@ "name": "Denis Seleznev", |
Show js error | ||
============= | ||
[](https://www.npmjs.com/package/show-js-error) | ||
[](https://www.npmjs.org/package/show-js-error) | ||
[](https://david-dm.org/hcodes/show-js-error) | ||
Shows a message when an js error occurs in a browser.<br> | ||
@@ -10,3 +14,3 @@ Useful for developing and testing your site on mobile phones, tablets and desktop. | ||
### Browsers | ||
## Browsers | ||
Any. | ||
@@ -21,4 +25,4 @@ | ||
```html | ||
<link rel="stylesheet" href="dist/show-js-error.css" /> | ||
<script src="dist/show-js-error.js"></script> | ||
<link rel="stylesheet" href="./node_modules/show-js-error/dist/show-js-error.css" /> | ||
<script src="./node_modules/show-js-error/dist/show-js-error.js"></script> | ||
``` | ||
@@ -28,4 +32,4 @@ or | ||
```html | ||
<link rel="stylesheet" href="dist/show-js-error.css" /> | ||
<script src="dist/show-js-error.custom.js"></script> | ||
<link rel="stylesheet" href="./node_modules/show-js-error/dist/show-js-error.css" /> | ||
<script src="./node_modules/show-js-error/dist/show-js-error.custom.js"></script> | ||
<script> | ||
@@ -64,3 +68,3 @@ showJSError.init({ | ||
## [License](./LICENSE) | ||
## [License](https://github.com/hcodes/show-js-error/blob/gh-pages/LICENSE) | ||
MIT License |
Sorry, the diff of this file is not supported yet
29802
4.82%892
2.53%67
6.35%