Add: Console api doc

This commit is contained in:
surunzi
2016-09-04 14:55:44 +08:00
parent 5611e3a264
commit 0baafbd4c6
5 changed files with 26 additions and 12 deletions

View File

@@ -33,14 +33,14 @@ javascript:(function () { var script = document.createElement('script'); script.
## Features
* Console: Display JavaScript logs.
* Elements: Check dom state.
* Network: Show performance timing, ajax requests status.
* Resource: Show localStorage, cookie information.
* Info: Show url, user agent info.
* Snippets: Include snippets used most often.
* Sources: Html, js, css source viewer.
* Features: Browser feature detections.
* [Console](https://github.com/liriliri/eruda/blob/master/doc/Tool_Api.md#console): Display JavaScript logs.
* [Elements](https://github.com/liriliri/eruda/blob/master/doc/Tool_Api.md#elements): Check dom state.
* [Network](https://github.com/liriliri/eruda/blob/master/doc/Tool_Api.md#network): Show performance timing, ajax requests status.
* [Resource](https://github.com/liriliri/eruda/blob/master/doc/Tool_Api.md#resources): Show localStorage, cookie information.
* [Info](https://github.com/liriliri/eruda/blob/master/doc/Tool_Api.md#info): Show url, user agent info.
* [Snippets](https://github.com/liriliri/eruda/blob/master/doc/Tool_Api.md#snippets): Include snippets used most often.
* [Sources](https://github.com/liriliri/eruda/blob/master/doc/Tool_Api.md#sources): Html, js, css source viewer.
* [Features](https://github.com/liriliri/eruda/blob/master/doc/Tool_Api.md#features): Browser feature detections.
## Install

View File

@@ -1,7 +1,21 @@
# Tool Api
Each default tool provided by eruda can be accessed by `eruda.get('Tool Name')`.
## Console
Displays console logs. Implementation detail follows the [console api spec](https://github.com/DeveloperToolsWG/console-object/blob/master/api.md).
### log, error, info, warn, dir, time/timeEnd, clear, count, assert, table
All these methods can be used in the same way as window.console object.
```javascript
var console = eruda.get('console');
console.log('eruda is a console for %s.', 'mobile browsers');
console.table([{test: 1}, {test: 2, test2: 3}], 'test');
```
## Elements
## Network
@@ -16,4 +30,4 @@
## Features
## Settings
## Settings

View File

@@ -1,6 +1,6 @@
{
"name": "eruda",
"version": "1.1.1",
"version": "1.1.2",
"description": "Console for Mobile Browsers",
"main": "eruda.js",
"scripts": {

View File

@@ -220,7 +220,7 @@ export default class Network extends Tool
data.push(getData('Total', navigationStart, loadEventEnd));
data.push(getData('Network/Server', navigationStart, responseStart));
data.push(getData('App cache', fetchStart, domainLookupStart));
data.push(getData('App Cache', fetchStart, domainLookupStart));
data.push(getData('DNS', domainLookupStart, domainLookupEnd));
data.push(getData('TCP', connectStart, connectEnd));
data.push(getData('Time to First Byte', requestStart, responseStart));

View File

@@ -126,6 +126,6 @@ function createEl(key, val, firstLevel)
}
const LIGHTER_KEY = ['__proto__', 'constructor', 'toString', 'valueOf'];
const LIGHTER_KEY = ['__proto__', 'constructor', 'toString', 'valueOf', 'length'];
var encode = str => util.escape(util.toStr(str));