Skip to content

Instantly share code, notes, and snippets.

@frikille
Created July 17, 2013 21:22
Show Gist options
  • Save frikille/6024622 to your computer and use it in GitHub Desktop.
Save frikille/6024622 to your computer and use it in GitHub Desktop.
Basic exporter for csslint.net. Exports table in to csv format and automatically downloads it.
(function exportTable() {
var table = document.getElementById('errors'),
header = 'type,line,column,title,description,browser\n',
csv,
data = [],
i, node;
for (i = 0; i < table.childNodes.length; i += 1) {
node = table.childNodes[i];
data.push({
type : '"' + node.childNodes[0].firstChild.getAttribute('title') + '"',
line : '"' + node.childNodes[1].innerHTML + '"',
column : '"' + node.childNodes[2].innerHTML + '"',
title : '"' + node.childNodes[3].innerHTML + '"',
description : '"' + node.childNodes[4].innerHTML.replace('<pre>', '').replace('</pre>', '') + '"',
browser : '"' + node.childNodes[5].innerHTML + '"',
});
}
csv = data.reduce(function (previousValue, currentValue, index, array) {
return previousValue + [
currentValue.type,
currentValue.line,
currentValue.column,
currentValue.title,
currentValue.description,
currentValue.browser,
'\n'
].join(',')
}, header);
window.location.href = 'data:text/csv;charset=UTF-8,'+ encodeURIComponent(csv);
})();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment