JSFiddle - React, Tailwind, and code Playground
by liammccann1992
HTML
<input type="button" onclick="makeTable();" value="Make Table" />
<input type='checkbox' id="bold" />Bold
<br/>
<textarea id="input" style="width:100%;height:200px"></textarea>
JavaScript
var b = false;
function f1(s) {
if (b == true) {
return "<td class='shadowright tLeft indent bold'>" + s + "</td>";
} else {
return "<td class='shadowright tLeft indent'>" + s + "</td>";
}
}
function f2(s) {
if (b == true) {
return "<td class='shadowrigh tLeft bold'>" + s + "</td>";
} else {
return "<td class='shadowrigh tLeft'>" + s + "</td>";
}
}
function f3(s) {
if (b == true) {
return "<td class='shadownone bold'>" + s + "</td>";
} else {
return "<td class='shadownone'>" + s + "</td>";
}
}
function makeTable() {
if ($('#bold').is(':checked')) {
b = true;
} else {
b = false;
}
var outputString = "";
var input = $("#input").val();
var lines = input.split("\n");
for (var a = 0; a < lines.length; a++) {
input = lines[a];
alert(input);
input = input.replace(/ +(?= )/g, '');
var toTable = input.split("\t");
outputString = outputString + "<tr class='tableRowAlt Bold-Indent'>";
for (var i = 0; i < toTable.length; i++) {
if (i == 0) {
outputString = outputString + f1(toTable[i]);
} else if (i == 1) {
outputString = outputString + f2(toTable[i]);
} else {
outputString = outputString + f3(toTable[i]);
}
}
outputString = outputString + "</tr> \n \n";
//window.prompt("Copy to clipboard: Ctrl+C, Enter", outputString);
}
$("#input").val(outputString);
}