Comparing version 0.1.2 to 0.1.3
81
index.js
@@ -0,6 +1,15 @@ | ||
'use strict'; | ||
var byestyle = module.exports = { | ||
calculate: function () { | ||
function getDisplayName(el) { | ||
return el.tagName.toLowerCase() + (el.className ? '.' : '') + el.className; | ||
} | ||
function logElHeading(el) { | ||
console.info('%cElement: (right-click to inspect)\n ', 'font-style: italic;', el); | ||
} | ||
if (++byestyle.calculatedCount === 1) { | ||
console.log(byestyle.spacer); | ||
console.error('Consider moving these to classes...'); | ||
console.groupCollapsed('Consider moving these to classes...'); | ||
@@ -10,9 +19,10 @@ byestyle.els. | ||
var lastStyle = elObject.properties.styleLog[elObject.properties.styleLog.length - 1]; | ||
console.info(elObject.el); | ||
console.log([ | ||
'Styles at page load:', | ||
byestyle.format(lastStyle), | ||
byestyle.separator].join('\n')); | ||
console.groupCollapsed(getDisplayName(elObject.el)); | ||
logElHeading(elObject.el); | ||
console.info('%cStyles at page load:', 'font-style: italic;'); | ||
console.log(byestyle.format(lastStyle)); | ||
console.groupEnd(); | ||
}); | ||
console.groupEnd(); | ||
return; | ||
@@ -41,5 +51,3 @@ } | ||
if (els.length) { | ||
console.log(byestyle.spacer); | ||
console.warn('Elements that have been modified by JavaScript...'); | ||
console.log(byestyle.separator); | ||
console.groupCollapsed('Elements that have been modified by JavaScript...'); | ||
@@ -51,17 +59,20 @@ els. | ||
console.info(elObject.el); | ||
console.groupCollapsed(getDisplayName(elObject.el)); | ||
logElHeading(elObject.el); | ||
if (styleLog.length > 1 && styleLog[styleLog.length - 2] !== styleLog[styleLog.length - 1]) { | ||
console.log('Style log:'); | ||
console.info('%cStyle log:', 'font-style: italic;'); | ||
console.dir(styleLog); | ||
console.log([ | ||
'Previous style:', | ||
byestyle.format(styleLog[styleLog.length - 2])].join('\n')); | ||
console.info('%cPrevious style:', 'font-style: italic;'); | ||
console.log(byestyle.format(styleLog[styleLog.length - 2])); | ||
} | ||
console.log([ | ||
'Current style:', | ||
byestyle.format(style), | ||
byestyle.separator].join('\n')); | ||
console.info('%cCurrent style:', 'font-style: italic;'); | ||
console.log(byestyle.format(style)); | ||
console.groupEnd(); | ||
}); | ||
console.groupEnd(); | ||
} | ||
@@ -74,11 +85,2 @@ }, | ||
fade: function (direction) { | ||
console.log([ | ||
'--', | ||
'------', | ||
'-----------------------', | ||
'-------------------------------------' | ||
][direction === 'in' ? 'sort' : 'reverse']().join('\n')); | ||
}, | ||
find: function (el) { | ||
@@ -101,18 +103,7 @@ return byestyle.els.filter(function (elObject) { | ||
help: function () { | ||
byestyle.fade('in'); | ||
console.log('%cbyestyle.', 'font-size: 18px; color: #B75AD6;'); | ||
console.log([ | ||
'', | ||
'H O W . B Y E S T Y L E . W O R K S', | ||
''].join('\n')); | ||
console.error( | ||
'console.error = styles are on an element before any JS has executed.'); | ||
console.warn( | ||
'console.warn = styles are on an element after JS has executed.'); | ||
console.info( | ||
'console.info = the element being analyzed.'); | ||
console.log([ | ||
'', | ||
'Help this tool improve:', | ||
'https://github.com/stephenplusplus/byestyle'].join('\n')); | ||
byestyle.fade('out'); | ||
'https://github.com/stephenplusplus/byestyle' | ||
].join('\n')); | ||
}, | ||
@@ -133,7 +124,3 @@ | ||
}); | ||
}, | ||
separator: '-------------------------------------', | ||
spacer: ['', ''].join('\n') | ||
} | ||
}; | ||
@@ -140,0 +127,0 @@ |
{ | ||
"name": "byestyle", | ||
"version": "0.1.2", | ||
"version": "0.1.3", | ||
"author": "Stephen Sawchuk <sawchuk@gmail.com> (http://sawchuk.me)", | ||
@@ -5,0 +5,0 @@ "description": "Keep an eye on those pesky inline styles.", |
4395
98