Alex9090

Untitled

Jan 29th, 2019
157
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.71 KB | None | 0 0
  1. <!DOCTYPE html>
  2. <html>
  3. <link rel="stylesheet" type="text/css" href="style.css">.
  4.  
  5.  
  6. <body>
  7. <div id="container"
  8. <h1>Da</h1>
  9. </div>
  10.  
  11. <div class="patrat">
  12. <p>Nu</p>
  13. </div>
  14.  
  15. <div class="patrat">
  16. <p>Da</p>
  17. </div>
  18.  
  19. <button onclick="Start()">Start</button>
  20.  
  21. <script>
  22. var litere;
  23. function apasareButon() {
  24. litere = document.getElementById("textarea").value;
  25. console.log(litere);
  26. for (let i = 0; i < litere.length; i++) {
  27. button.addEventListener("click", newPatrat(litere[i]));
  28. }
  29. }
  30. function newPatrat(c) {
  31. patrat = document.createElement("div");
  32. patrat.className = "patrat";
  33. patrat.id = "patrat";
  34. var container = document.getElementById("container");
  35. var text = document.createTextNode(c);
  36. var stil = window.getComputedStyle(container,null);
  37. var w = parseInt(stil.getPropertyValue("width")) / 3;
  38. var h = parseInt(stil.getPropertyValue("height")) / 3;
  39. patrat.style.width = toString(w);
  40. patrat.style.height = toString(h);
  41. console.log(w);
  42. console.log(h);
  43. console.log(patrat.style.width);
  44. console.log(patrat.style.height);
  45. patrat.appendChild(text);
  46. container.appendChild(patrat);
  47. }
  48. function newTextarea() {
  49. var t = document.createElement("textarea");
  50. t.rows = "5";
  51. t.cols = "20";
  52. t.id = "textarea";
  53. document.body.appendChild(t);
  54. }
  55. function newButton() {
  56. var button = document.createElement("input");
  57. button.type = "button";
  58. button.id = "button";
  59. button.value = "Start";
  60. document.body.appendChild(button);
  61. button.addEventListener("click", apasareButon, false);
  62.  
  63. }
  64.  
  65. window.onload = function () {
  66. newTextarea();
  67. newButton();
  68.  
  69. }
  70.  
  71. </script>
  72.  
  73.  
  74. </body>
  75. </html>
Advertisement
Add Comment
Please, Sign In to add comment