Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //ver 2: do linebreaks
- function actualButton()
- {
- inputText = document.getElementById("inputBox").value;
- numberOfLineBreaks = (inputText.match(/\n/g)||[]).length;
- helloInputText = inputText.replace(/\n/g,"*");
- var LineStore = new Array();
- lineBreakIndex = 0;
- for (i = 1; i <= numberOfLineBreaks; i++)
- {
- LineStore[i-1] = helloInputText.substring(lineBreakIndex,helloInputText.indexOf("*",lineBreakIndex+1));
- lineBreakIndex = helloInputText.indexOf("*",lineBreakIndex+1);
- }
- LineStore[numberOfLineBreaks-1] = helloInputText.substring(lineBreakIndex,helloInputText.length);
- //________________successfully parses each line break into element of the array_________________
- //document.getElementById("lineOutput").innerHTML = LineStore.toString().replace(/\*/g,"");
- //lineInputText = LineStore[1].toString().replace(/\*/g,"");
- var tableStore = new Array();
- var interOutputString = new Array();
- var finalArray = new Array();
- for (k = 0; k < LineStore.length; k++)
- {
- lineInputText = LineStore[k].toString().replace(/\*/g,""); //maybe remove space
- numberOfSlash = (lineInputText.match(/\//g)||[]).length;
- slashIndex = 0;
- for (i = 1; i <= numberOfSlash; i++)
- {
- tableStore[i-1] = lineInputText.substring(slashIndex,lineInputText.indexOf("/",slashIndex+1)-1).replace("/ ","");
- slashIndex = lineInputText.indexOf("/",slashIndex+1);
- }
- tableStore[numberOfSlash] = lineInputText.substring(slashIndex+2,lineInputText.length);
- outputString = "";
- for (j = 0; j < tableStore.length; j++)
- {
- interOutputString = tableStore[j];
- outputString = outputString + "<td>" + interOutputString + "</td> \n";
- finalArray[k] = outputString;
- //"<table><tr><td>" + "</td></tr></table>"
- }
- }
- finaloutput = "";
- for (a = 0; a < finalArray.length; a++)
- {
- preTableRow = finalArray[a];
- finaloutput = finaloutput + "<tr> \n" + preTableRow + "</tr> \n";
- }
- document.getElementById("outputText").innerHTML = finaloutput;
- //document.getElementById("outputText").innerHTML = "<tr> \n" + outputString + "</tr>"; //numberOfSlash.toString()+ ", " + slashIndex.toString();
- //document.getElementById("otherOutput").innerHTML = "<table border='1'><tr>" + outputString + "</tr></table>"; //numberOfSlash.toString()+ ", " + slashIndex.toString();
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement