Advertisement
Searqq

js file

Dec 7th, 2013
58
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.29 KB | None | 0 0
  1.  
  2. //ver 2: do linebreaks
  3. function actualButton()
  4. {
  5.  
  6. inputText = document.getElementById("inputBox").value;
  7. numberOfLineBreaks = (inputText.match(/\n/g)||[]).length;
  8.  
  9. helloInputText = inputText.replace(/\n/g,"*");
  10.  
  11. var LineStore = new Array();
  12. lineBreakIndex = 0;
  13. for (i = 1; i <= numberOfLineBreaks; i++)
  14. {
  15. LineStore[i-1] = helloInputText.substring(lineBreakIndex,helloInputText.indexOf("*",lineBreakIndex+1));
  16. lineBreakIndex = helloInputText.indexOf("*",lineBreakIndex+1);
  17. }
  18. LineStore[numberOfLineBreaks-1] = helloInputText.substring(lineBreakIndex,helloInputText.length);
  19.  
  20.  
  21. //________________successfully parses each line break into element of the array_________________
  22. //document.getElementById("lineOutput").innerHTML = LineStore.toString().replace(/\*/g,"");
  23.  
  24. //lineInputText = LineStore[1].toString().replace(/\*/g,"");
  25.  
  26. var tableStore = new Array();
  27. var interOutputString = new Array();
  28. var finalArray = new Array();
  29. for (k = 0; k < LineStore.length; k++)
  30. {
  31.  
  32. lineInputText = LineStore[k].toString().replace(/\*/g,""); //maybe remove space
  33.  
  34.  
  35. numberOfSlash = (lineInputText.match(/\//g)||[]).length;
  36. slashIndex = 0;
  37.  
  38.  
  39.  
  40.  
  41. for (i = 1; i <= numberOfSlash; i++)
  42. {
  43. tableStore[i-1] = lineInputText.substring(slashIndex,lineInputText.indexOf("/",slashIndex+1)-1).replace("/ ","");
  44. slashIndex = lineInputText.indexOf("/",slashIndex+1);
  45.  
  46. }
  47. tableStore[numberOfSlash] = lineInputText.substring(slashIndex+2,lineInputText.length);
  48.  
  49.  
  50. outputString = "";
  51.  
  52. for (j = 0; j < tableStore.length; j++)
  53. {
  54. interOutputString = tableStore[j];
  55. outputString = outputString + "<td>" + interOutputString + "</td> \n";
  56. finalArray[k] = outputString;
  57. //"<table><tr><td>" + "</td></tr></table>"
  58. }
  59. }
  60.  
  61. finaloutput = "";
  62. for (a = 0; a < finalArray.length; a++)
  63. {
  64. preTableRow = finalArray[a];
  65. finaloutput = finaloutput + "<tr> \n" + preTableRow + "</tr> \n";
  66. }
  67.  
  68. document.getElementById("outputText").innerHTML = finaloutput;
  69. //document.getElementById("outputText").innerHTML = "<tr> \n" + outputString + "</tr>"; //numberOfSlash.toString()+ ", " + slashIndex.toString();
  70. //document.getElementById("otherOutput").innerHTML = "<table border='1'><tr>" + outputString + "</tr></table>"; //numberOfSlash.toString()+ ", " + slashIndex.toString();
  71.  
  72. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement