Skip to content

Commit f26f7a5

Browse files
author
ft
committed
pretty textarea
1 parent 01c6d16 commit f26f7a5

File tree

4 files changed

+13
-7
lines changed

4 files changed

+13
-7
lines changed

debug.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -72,10 +72,9 @@ exports.init = function(key) {
7272
enable(res[1])
7373
var doc = document
7474
var elem = doc.createElement('textarea')
75-
elem.style.cssText = 'width:100%;height:300px;overflow:auto;line-height:1.4;background:#333;color:#fff'
75+
elem.style.cssText = 'width:100%;height:300px;overflow:auto;line-height:1.4;background:#333;color:#fff;font:16px Consolas;border:none'
7676
var box = doc.body || doc.documentElement
7777
box.insertBefore(elem, box.firstChild)
78-
7978
exports.log = function(namespace, arr, color) {
8079
var ret = ['[' + namespace + ']']
8180
var len = arr.length
@@ -89,6 +88,7 @@ exports.init = function(key) {
8988
ret.push(val)
9089
}
9190
elem.value += ret.join(' ') + '\n'
91+
elem.scrollTop = elem.scrollHeight
9292
}
9393

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

dist/debug.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -78,10 +78,9 @@ exports.init = function(key) {
7878
enable(res[1])
7979
var doc = document
8080
var elem = doc.createElement('textarea')
81-
elem.style.cssText = 'width:100%;height:300px;overflow:auto;line-height:1.4;background:#333;color:#fff'
81+
elem.style.cssText = 'width:100%;height:300px;overflow:auto;line-height:1.4;background:#333;color:#fff;font:16px Consolas;border:none'
8282
var box = doc.body || doc.documentElement
8383
box.insertBefore(elem, box.firstChild)
84-
8584
exports.log = function(namespace, arr, color) {
8685
var ret = ['[' + namespace + ']']
8786
var len = arr.length
@@ -95,6 +94,7 @@ exports.init = function(key) {
9594
ret.push(val)
9695
}
9796
elem.value += ret.join(' ') + '\n'
97+
elem.scrollTop = elem.scrollHeight
9898
}
9999

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

index.html

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
<style>
77
* {
88
margin: 0;
9+
padding: 0;
910
}
1011
h1 {
1112
margin-top: 30px;
@@ -22,13 +23,18 @@
2223
var b = debug('worker:b')
2324
a('init')
2425
b('init')
25-
setInterval(function(){
26+
var timer1 = setInterval(function(){
2627
a('log some number', 1024)
2728
}, 1000)
2829

29-
setInterval(function(){
30+
var timer2 = setInterval(function(){
3031
b('log some object', {foo: 'bar'})
3132
}, 1200)
33+
34+
setTimeout(function() {
35+
clearInterval(timer1)
36+
clearInterval(timer2)
37+
}, 15 * 1000)
3238
</script>
3339
</body>
3440
</html>

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "min-debug",
3-
"version": "1.2.2",
3+
"version": "1.2.3",
44
"description": "Debug for browser in console or display on page",
55
"main": "debug.js",
66
"directories": {

0 commit comments

Comments
 (0)