From 3e6da90b74d8ccf7c475687dfb812df2a942f3c8 Mon Sep 17 00:00:00 2001 From: surunzi Date: Wed, 16 Mar 2016 22:04:39 +0800 Subject: [PATCH] Dev: README --- .npmignore | 9 ++++++++ README.md | 48 +++++++++++++++++++++++++++++++++++++-- package.json | 2 +- src/DevTools/DevTools.es6 | 9 +++++++- src/index.es6 | 4 +++- test/index.html | 2 +- util.js | 18 --------------- 7 files changed, 68 insertions(+), 24 deletions(-) create mode 100644 .npmignore delete mode 100644 util.js diff --git a/.npmignore b/.npmignore new file mode 100644 index 0000000..fc9c475 --- /dev/null +++ b/.npmignore @@ -0,0 +1,9 @@ +/dev/ +/eustia/ +/.idea/ +/src/ +/test/ +.gitignore +.eustia +.npmignore +webpack.config.js \ No newline at end of file diff --git a/README.md b/README.md index e547a57..47fbd92 100644 --- a/README.md +++ b/README.md @@ -1,2 +1,46 @@ -# eruda -Console for mobile JavaScript +# Eruda + +Console for Mobile Browsers. + +![Eruda](http://7xn2zy.com1.z0.glb.clouddn.com/github_eruda.jpg) + +## Why + +Logging things out on mobile browser is never an easy stuff. I used to include `window onerror alert` script inside pages to find out JavaScript errors, kind of stupid and inefficient. Desktop browser DevTools is great, and I wish there is a similar one on mobile side, which leads to the creation of Eruda. + +## Features + +* Console: Display JavaScript logs. +* Network: Show performance timing. +* Elements: Check dom state. +* Snippets: Include snippets you used most often. +* Resource: Show localStorage, cookie information. + +## Install + +You can get it on npm. + +``` +npm install eruda --save +``` + +Add this script to your page. + +```javascript +(function () { + var src = 'node_modules/eruda/dist/eruda.min.js'; + if (!/eruda=true/.test(window.location) && localStorage.getItem('active-eruda') != 'true') return; + document.write(''); +})(); +``` + +> The JavaScript file size is quite huge and therefore not suitable to include in mobile pages. We add this script to make sure eruda is loaded only when eruda is set to true on url(http://example.com/?eruda=true). + +## License + +Eruda is released under the MIT license. Please see [LICENSE](https://opensource.org/licenses/MIT) for full details. + + + + + diff --git a/package.json b/package.json index 7c47723..0a4e3af 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "eruda", - "version": "1.0.0", + "version": "0.0.3", "description": "Console for mobile JavaScript", "main": "index.js", "scripts": { diff --git a/src/DevTools/DevTools.es6 b/src/DevTools/DevTools.es6 index 22f0e97..16ead65 100644 --- a/src/DevTools/DevTools.es6 +++ b/src/DevTools/DevTools.es6 @@ -4,6 +4,11 @@ import config from '../config/config.es6' require('./DevTools.scss'); +function activeEruda(flag) +{ + window.localStorage.setItem('active-eruda', flag); +} + export default class DevTools { constructor($parent) @@ -85,7 +90,8 @@ export default class DevTools cfg.set(util.defaults(cfg.get(), { transparent: false, - halfScreen: false + halfScreen: false, + activeEruda: false })); if (cfg.get('transparent')) this._setTransparency(true); @@ -97,6 +103,7 @@ export default class DevTools { case 'transparent': return this._setTransparency(val); case 'halfScreen': return this._setHalfScreen(val); + case 'activeEruda': return activeEruda(val); } }); } diff --git a/src/index.es6 b/src/index.es6 index aefcbf9..21a330a 100644 --- a/src/index.es6 +++ b/src/index.es6 @@ -14,7 +14,7 @@ require('./style.scss'); var $container; -var isDebugMode = /eruda=true/.test(window.location); +var isDebugMode = /eruda=true/.test(window.location) || localStorage.getItem('active-eruda') == 'true'; if (isDebugMode) { @@ -46,6 +46,8 @@ if (isDebugMode) .showTool('console'); settings.separator() + .add(devTools.config, 'activeEruda', 'Always Activated') + .separator() .add(devTools.config, 'transparent', 'Transparent') .add(devTools.config, 'halfScreen', 'Half Screen Size'); } diff --git a/test/index.html b/test/index.html index c3d91fe..95adbbf 100644 --- a/test/index.html +++ b/test/index.html @@ -14,7 +14,7 @@ diff --git a/util.js b/util.js deleted file mode 100644 index 11e86c3..0000000 --- a/util.js +++ /dev/null @@ -1,18 +0,0 @@ -// Built by eustia. -(function(root, factory) -{ - if (typeof define === 'function' && define.amd) - { - define([], factory); - } else if (typeof module === 'object' && module.exports) - { - module.exports = factory(); - } else { root._ = factory() } -}(this, function () -{ - var _ = {}; - - if (typeof window === 'object' && window._) _ = window._; - - return _; -})); \ No newline at end of file