File tree Expand file tree Collapse file tree 1 file changed +7
-8
lines changed Expand file tree Collapse file tree 1 file changed +7
-8
lines changed Original file line number Diff line number Diff line change 1
1
// MIT license, see: https://github.com/tjcrowder/simple-snippets-console/blob/master/LICENSE
2
2
var snippet = {
3
- version : "1.0 " ,
3
+ version : "1.1 " ,
4
4
5
5
// Writes out the given text in a monospaced paragraph tag, escaping
6
6
// & and < so they aren't rendered as HTML.
7
- log : function ( msg ) {
7
+ log : function ( msg , tag ) {
8
+ var elm = document . createElement ( tag || "p" ) ;
9
+ elm . style . fontFamily = "monospace" ;
10
+ elm . style . margin = "2px 0 2px 0" ;
8
11
if ( Object . prototype . toString . call ( msg ) === "[object Array]" ) {
9
12
msg = msg . join ( ) ;
10
13
} else if ( typeof object === "object" ) {
11
14
msg = msg === null ? "null" : JSON . stringify ( msg ) ;
12
15
}
13
- document . body . insertAdjacentHTML (
14
- 'beforeend' ,
15
- '<p style="font-family: monospace; margin: 2px 0 2px 0">' +
16
- msg . replace ( / & / g, '&' ) . replace ( / < / g, '<' ) +
17
- '</p>'
18
- ) ;
16
+ elm . innerHTML = msg . replace ( / & / g, '&' ) . replace ( / < / g, '<' ) ;
17
+ document . body . appendChild ( elm ) ;
19
18
} ,
20
19
21
20
// Writes out the given HTML at the end of the body,
You can’t perform that action at this time.
0 commit comments