CDE
This commit is contained in:
parent
518da4a923
commit
764da6cbbb
6144 changed files with 83610 additions and 11 deletions
|
|
@ -0,0 +1,30 @@
|
|||
var csv = "Character,Speech\n" +
|
||||
"The multitude,The messiah! Show us the messiah!\n" +
|
||||
"Brians mother,<angry>Now you listen here! He's not the messiah; he's a very naughty boy! Now go away!</angry>\n" +
|
||||
"The multitude,Who are you?\n" +
|
||||
"Brians mother,I'm his mother; that's who!\n" +
|
||||
"The multitude,Behold his mother! Behold his mother!";
|
||||
|
||||
csv = csv.replace(/&/g, '&')
|
||||
.replace(/</g, '<')
|
||||
.replace(/>/g, '>')
|
||||
.replace(/"/g, '"');
|
||||
|
||||
var lines = csv.split(/[\n\r]+/g),
|
||||
header = lines.shift().split(","),
|
||||
line,
|
||||
rows = "",
|
||||
thead = '<tr>'+
|
||||
'<th>'+header[0]+'</th>'+
|
||||
'<th>'+header[1]+'</th>'+
|
||||
'</tr>\n';
|
||||
|
||||
for (var i=0, len=lines.length; i<len; i++) {
|
||||
line = lines[i].split(",");
|
||||
rows += '<tr>'+
|
||||
'<td>'+line[0]+'</td>'+
|
||||
'<td>'+line[1]+'</td>'+
|
||||
'</tr>\n';
|
||||
}
|
||||
|
||||
console.log('<table><thead>\n' + thead + '</thead><tbody>\n' + rows + '</tbody></table>' );
|
||||
Loading…
Add table
Add a link
Reference in a new issue