Skip to content

Commit 37a5cd9

Browse files
author
ft
committed
new style of textarea
1 parent 35550ea commit 37a5cd9

File tree

5 files changed

+61
-39
lines changed

5 files changed

+61
-39
lines changed

_readme.md

Lines changed: 15 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,28 +1,35 @@
1-
inspired by [tj@debug](https://github.com/visionmedia/debug)
1+
[Demo](http://chunpu.github.io/min-debug/?debug=*)
22

3-
[demo](http://chunpu.github.io/min-debug/)
3+
min-debug is inspired by [tj@debug](https://github.com/visionmedia/debug)
44

55
Usage
66
---
77

8-
type `localStorage[mykey] = '*'`
8+
#### Debug with localStorage
99

10-
if browser not support localStorage or you want to see debug on page, use url debug
10+
Type `localStorage[mykey] = '*'`, and debug just like tj@debug
1111

12-
type `mykey='*'` in `location.search` or `location.hash`, and will see debug info in a textarea on page
1312

13+
#### Debug with page
1414

15-
differences with tj@debug
15+
If browser not support localStorage or you want to see debug on page, use url debug
16+
17+
Type `mykey='*'` in `location.search` or `location.hash`, and will see debug info in a textarea on page
18+
19+
20+
Differences
1621
---
1722

18-
- if you browserify your app, you should init the debug key self
23+
differences with th@debug
24+
25+
- if your program using browserify, you should init the debug key self
1926

2027
```js
2128
module.exports = exports = require('min-debug')
2229
exports.init('mykey') // default is debug
2330
```
2431

25-
- min-debug does not support print format
32+
- min-debug does not support print format, because we may need log on some old browser like IE6
2633

2734
```js
2835
debug('my data', {foo: 'bar'}) // min-debug style

debug.js

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -72,10 +72,7 @@ exports.init = function(key) {
7272
enable(res[1])
7373
var doc = document
7474
var elem = doc.createElement('textarea')
75-
var style = elem.style
76-
style.width = '100%'
77-
style.height = '300px'
78-
style.overflow = 'auto'
75+
elem.setAttribute('style', 'width:100%;height:300px;overflow:auto;line-height:1.4;background:#333;color:#fff')
7976
var box = doc.body || doc.documentElement
8077
box.insertBefore(elem, box.firstChild)
8178

@@ -91,7 +88,7 @@ exports.init = function(key) {
9188
}
9289
ret.push(val)
9390
}
94-
elem.value += ret.join(' ') + '\n\n'
91+
elem.value += ret.join(' ') + '\n'
9592
}
9693

9794
} else if (global.localStorage && console) {

dist/debug.js

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -78,10 +78,12 @@ exports.init = function(key) {
7878
enable(res[1])
7979
var doc = document
8080
var elem = doc.createElement('textarea')
81+
elem.setAttribute('style', 'width:100%;height:300px;overflow:auto;line-height:1.4;background:#333;color:#fff')
82+
/*
8183
var style = elem.style
8284
style.width = '100%'
8385
style.height = '300px'
84-
style.overflow = 'auto'
86+
style.overflow = 'auto'*/
8587
var box = doc.body || doc.documentElement
8688
box.insertBefore(elem, box.firstChild)
8789

@@ -97,7 +99,7 @@ exports.init = function(key) {
9799
}
98100
ret.push(val)
99101
}
100-
elem.value += ret.join(' ') + '\n\n'
102+
elem.value += ret.join(' ') + '\n'
101103
}
102104

103105
} else if (global.localStorage && console) {

index.html

Lines changed: 25 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,27 @@
1-
<script src='./dist/debug.js'></script>
2-
<a href='./?debug=*'>debug with textarea</a>
3-
<hr>
4-
<a href='./'>debug with localStorage, type `localStorage.debug = '*'` in Console and refresh</a>
1+
<!doctype html>
2+
<html>
3+
<head>
4+
<title>debug()</title>
5+
<meta name="viewport" content="width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, user-scalable=no">
6+
</head>
7+
<body>
8+
<script src='./dist/debug.js'></script>
9+
<a href='./?debug=*'><h1>debug with textarea</h1></a>
10+
<hr>
11+
<a href='./'><h1>debug with localStorage</h1></a><p>type `localStorage.debug = '*'` in Console and refresh</p>
512

6-
<script>
7-
var a = debug('worker:a')
8-
var b = debug('worker:b')
9-
a('init')
10-
b('init')
11-
setInterval(function(){
12-
a('doing some work')
13-
}, 1000)
13+
<script>
14+
var a = debug('worker:a')
15+
var b = debug('worker:b')
16+
a('init')
17+
b('init')
18+
setInterval(function(){
19+
a('log some number', 1024)
20+
}, 1000)
1421

15-
setInterval(function(){
16-
b('doing some work')
17-
}, 1200)
18-
</script>
22+
setInterval(function(){
23+
b('log some object', {foo: 'bar'})
24+
}, 1200)
25+
</script>
26+
</body>
27+
</html>

readme.md

Lines changed: 15 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -14,31 +14,38 @@ Installation
1414
npm install min-debug
1515
```
1616

17-
inspired by [tj@debug](https://github.com/visionmedia/debug)
17+
[Demo](http://chunpu.github.io/min-debug/?debug=*)
1818

19-
[demo](http://chunpu.github.io/min-debug/)
19+
min-debug is inspired by [tj@debug](https://github.com/visionmedia/debug)
2020

2121
Usage
2222
---
2323

24-
type `localStorage[mykey] = '*'`
24+
#### Debug with localStorage
2525

26-
if browser not support localStorage or you want to see debug on page, use url debug
26+
Type `localStorage[mykey] = '*'`, and debug just like tj@debug
2727

28-
type `mykey='*'` in `location.search` or `location.hash`, and will see debug info in a textarea on page
2928

29+
#### Debug with page
3030

31-
differences with tj@debug
31+
If browser not support localStorage or you want to see debug on page, use url debug
32+
33+
Type `mykey='*'` in `location.search` or `location.hash`, and will see debug info in a textarea on page
34+
35+
36+
Differences
3237
---
3338

34-
- if you browserify your app, you should init the debug key self
39+
differences with th@debug
40+
41+
- if your program using browserify, you should init the debug key self
3542

3643
```js
3744
module.exports = exports = require('min-debug')
3845
exports.init('mykey') // default is debug
3946
```
4047

41-
- min-debug does not support print format
48+
- min-debug does not support print format, because we may need log on some old browser like IE6
4249

4350
```js
4451
debug('my data', {foo: 'bar'}) // min-debug style

0 commit comments

Comments
 (0)