File tree Expand file tree Collapse file tree 1 file changed +26
-0
lines changed Expand file tree Collapse file tree 1 file changed +26
-0
lines changed Original file line number Diff line number Diff line change
1
+ // MIT license, see: https://github.com/tjcrowder/simple-snippets-console/blob/master/LICENSE
2
+ var snippet = {
3
+ version : "1.0" ,
4
+
5
+ // Writes out the given text in a monospaced paragraph tag, escaping
6
+ // & and < so they aren't rendered as HTML.
7
+ log : function ( msg ) {
8
+ if ( Object . prototype . toString . call ( msg ) === "[object Array]" ) {
9
+ msg = msg . join ( ) ;
10
+ } else if ( typeof object === "object" ) {
11
+ msg = msg === null ? "null" : JSON . stringify ( msg ) ;
12
+ }
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
+ ) ;
19
+ } ,
20
+
21
+ // Writes out the given HTML at the end of the body,
22
+ // exactly as-is
23
+ logHTML : function ( html ) {
24
+ document . body . insertAdjacentHTML ( "beforeend" , html ) ;
25
+ }
26
+ } ;
You can’t perform that action at this time.
0 commit comments