forked from inorganik/debugout.js
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.html
194 lines (179 loc) · 8.21 KB
/
index.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
<!DOCTYPE HTML>
<html>
<head>
<meta charset="UTF-8">
<meta name="robots" content="index,follow">
<meta name="apple-mobile-web-app-capable" content="yes">
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no">
<title>debugout.js</title>
<link rel="stylesheet" type="text/css" href="../inorganik.github.io/assets/css/style.css?v=20140820">
<script type="text/javascript" src="debugout.js"></script>
<script type="text/javascript">
(function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){
(i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),
m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)
})(window,document,'script','//www.google-analytics.com/analytics.js','ga');
ga('create', 'UA-7742845-9', 'inorganik.github.io');
ga('send', 'pageview');
</script>
</head>
<body>
<a class="forkMe" href="https://github.com/inorganik/debugout.js"><img src="../assets/img/forkme_custom_indigo.png" alt="Fork me on GitHub"></a>
<div id="wrap">
<header>
<div id="github"><a class="block" href="https://github.com/inorganik"></a></div>
<div class="leaderLine">////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////</div>
<div id="logo"><a class="block" href="http://inorganik.github.io"></a></div>
</header>
<section>
<h1>debugout.js <small id="version" class="lt-gray"></small></h1>
<p>debugout.js (debug output) generates a text file from your logs that can be searched, timestamped, downloaded and more. See examples and usage on GitHub.</p>
<p>Install via npm or bower using the package name <code class="indigo large"> debugout.js </code> or</p>
<h3 class="marginTop marginBottom"><a class="lime weight700" href="https://github.com/inorganik/debugout.js">Download on GitHub</a></h3>
</section>
<section>
<div class="col-inner-no-lr">
<p class="large weight300 noMargin">Create a new debugout object and replace all your console logs with debugout's log method: </p>
</div>
</section>
<section>
<div class="col full marginTop">
<div class="code-contain marginBottom indigo">
<code>var bugout = new debugout();<br>
bugout.log('A date:');<br>
bugout.log(d);<br>
bugout.log('An array:');<br>
bugout.log(arr);<br>
bugout.log('A function:');<br>
bugout.log(bugout.objectSize);<br>
bugout.log('A regex');<br>
bugout.log(rgx);<br>
bugout.log('an object with nested objects...');<br>
bugout.log(obj);<br>
bugout.log('an array of objects...');<br>
bugout.log(arrayWithObjects);<br>
</code>
</div>
</div>
</section>
<section>
<form>
<h4 class="inlineLeft noMargin marginRight weight300">Get the log at run-time or any time with these methods:</h4>
<input type="button" class="inlineLeft marginRight" value="download log" onClick="demoDownloadLog()">
<input type="button" class="inlineLeft marginRight" value="get log" onClick="demoGetLog()" style="width:100px;">
<input type="button" class="inlineLeft marginRight" value="tail" onClick="demoTail()" style="width:100px;">
</form>
</section>
<section>
<form>
<h4 class="inlineLeft noMargin marginRight weight300">Also, search:</h4>
<input type="text" class="inlineLeft" value="" id="search" style="width:140px; margin-right:5px" placeholder="ex: subgenre">
<input type="button" class="inlineLeft marginRight" value="search" onClick="demoSearch()" style="width:100px;">
<h4 class="inlineLeft noMargin marginRight weight300">And slice:</h4>
<input type="number" class="inlineLeft" value="" step="1" id="sliceStart" style="width:80px; margin-right:5px" placeholder="line">
<input type="number" class="inlineLeft marginRight" value="" step="1" id="sliceNumLines" style="width:80px" placeholder="# of lines">
<input type="button" class="inlineLeft" value="get slice" onClick="demoGetSlice()" style="width:100px;">
</form>
</section>
<section class="marginBottom">
<div class="col full marginBottom marginTop">
<h4 class="weight300">Console window:</h4>
<div class="code-contain marginBottom lime" style="min-height:500px">
<code id="codeVisualizer">// Use a method above and output will be displayed here</code>
</div>
</div>
</section>
</div>
</body>
<script type="text/javascript">
// declare a debugout instance in the global namespace
// that means: not inside any functions
var bugout = new debugout;
// a test object
var obj = {
name: 'Jamie',
age: 34,
arr: ['another', 'test', 'array', 4, true, false],
emptyString: '',
nestedObj: {
apple: 'red',
orange: 'orange',
pear: 'green',
nestedNestedObj: {
red: 0,
yellow: 6,
green: 4
}
},
date: new Date(),
flag: true,
anotherFlag: false,
}
// a date
var d = new Date();
// an array
var arr = ['some', 'test', 'array'];
// a function
var testFunc = function() {
return 'oh heck ya debugout';
}
// a regex
var rgx = new RegExp(/debugout/);
// array with objects
var songOne = { genre: 'Drum \'n Bass', subgenre: 'liquid' }
var songTwo = { genre: 'Dubstep', subgenre: 'brostep', someArray: arr }
var songThree = { genre: 'R&B', subgenre: 'soul revival' }
var arrayWithObjects = [songOne, songTwo, songThree];
window.onload = function() {
document.getElementById('version').innerHTML = 'v'+bugout.version();
// use debugout.log() instead of console.log()
bugout.log('A date:');
bugout.log(d);
bugout.log('An array:');
bugout.log(arr);
bugout.log('A function:');
bugout.log(bugout.objectSize);
bugout.log('A regex:');
bugout.log(rgx);
bugout.log('an object with nested objects and arrays...');
bugout.log(obj);
bugout.log('an array of objects...');
bugout.log(arrayWithObjects);
}
function demoDownloadLog() {
var output = "bugout.downloadLog();";
bugout.downloadLog();
displayOutput(output);
}
function demoGetLog() {
var output = "bugout.getLog();\n";
output += bugout.getLog();
displayOutput(output);
}
function demoTail() {
var output = "bugout.tail(20);\n";
output += bugout.tail(20);
displayOutput(output);
}
function demoSearch() {
var term = document.getElementById('search').value;
var output = "bugout.search('"+term+"'');\n";
output += bugout.search(term);
displayOutput(output);
}
function demoGetSlice() {
var startLine = Number(document.getElementById('sliceStart').value);
var numLines = Number(document.getElementById('sliceNumLines').value);
var output = "bugout.getSlice("+startLine+", "+numLines+");\n\n";
output += bugout.getSlice(startLine, numLines);
displayOutput(output);
}
function displayOutput(output) {
// simulate console
console.log(output);
// format for html
output = output.replace(/\n/g, '<br>').replace(/\t/g, ' ');
document.getElementById('codeVisualizer').innerHTML = output;
}
</script>
</html>