Created
July 17, 2013 21:22
-
-
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.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(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