Selected dimensions convert to div table












0















Can anyone help me reverse engineer this or this page? Where the user selects the dimensions via a grid system. Then the amount of selected boxes gets converted into div's, in the same dimensions.



Or does anyone recommend and a JavaScript, if so which one?










share|improve this question





























    0















    Can anyone help me reverse engineer this or this page? Where the user selects the dimensions via a grid system. Then the amount of selected boxes gets converted into div's, in the same dimensions.



    Or does anyone recommend and a JavaScript, if so which one?










    share|improve this question



























      0












      0








      0








      Can anyone help me reverse engineer this or this page? Where the user selects the dimensions via a grid system. Then the amount of selected boxes gets converted into div's, in the same dimensions.



      Or does anyone recommend and a JavaScript, if so which one?










      share|improve this question
















      Can anyone help me reverse engineer this or this page? Where the user selects the dimensions via a grid system. Then the amount of selected boxes gets converted into div's, in the same dimensions.



      Or does anyone recommend and a JavaScript, if so which one?







      javascript html css reverse-engineering css-tables






      share|improve this question















      share|improve this question













      share|improve this question




      share|improve this question








      edited Nov 24 '18 at 23:19









      Brian Tompsett - 汤莱恩

      4,2321338102




      4,2321338102










      asked Nov 24 '18 at 22:14









      DogantrDogantr

      73




      73
























          1 Answer
          1






          active

          oldest

          votes


















          0














          we have two issues here, one is selecting and one is generating. Generating is simple:



          Notice: This is done quick and dirty; innerHtml should not be used, Ping me if you'd like to see it more polished :)
          https://jsfiddle.net/ynfb3Lh2/9/



          <div id="selection">
          </div>
          <div id="target">
          </div>
          <pre id="text">
          </pre>

          <script>
          // Prepare our targets
          const selectionContainer = document.getElementById("selection");
          const targetContainer = document.getElementById("target");
          const textContainer = document.getElementById("text");

          // rows: How many rows to generate?
          // cols: How many cols to generate?
          // [_insertCallback]: should we insert callback?
          // [_targetContainer]: where should we place created divs?
          // [_textContainer]: sWhere should we write our HTML as plain text?
          function generateDiv(rows, columns, _insertCallback, _targetContainer, _textContainer) {
          // Create our wrapping elements
          const table = document.createElement("table");
          const tbody = document.createElement("tbody");

          for (let r = 0; r < rows; ++r) {
          // Each row is created here...
          const tr = document.createElement("tr");

          for (let c = 0; c < columns; ++c) {
          const td = document.createElement("td");
          td.text = "&nbsp;"
          // if callback is defined, and we have a target - allow us to generate new table on each click
          if (_insertCallback && _targetContainer) {
          td.onclick = () => generateDiv(r + 1, c + 1, false, _targetContainer, _textContainer)
          }

          tr.appendChild(td)
          }


          // ... and added here
          tbody.appendChild(tr)
          }

          table.appendChild(tbody)

          if (_targetContainer && !_insertCallback ) {
          _targetContainer.innerHTML = '';
          _targetContainer.appendChild(table);
          }
          if (_textContainer && !_insertCallback ) {
          _textContainer.innerHTML = table.outerHTML
          .replace(/td><//gi, "td>&amp;nbsp;</")
          .replace(/</gi, "&lt;")
          .replace(/>/gi, ">n");
          }

          return table;
          }

          selectionContainer.appendChild(generateDiv(10, 10, true, targetContainer, textContainer));

          </script>


          and similarily, making a selectable table is done via similar function that adds row and col information to each cell. Then, a mouseClick event on table will read the rows and cols and pass to the generation code.






          share|improve this answer


























          • How can I make the function that adds the row and col, and how do i highlight them? I'm quite new at this, ty!

            – Dogantr
            Nov 24 '18 at 22:45











          • Here you go :) jsfiddle.net/ynfb3Lh2/4

            – Jacek Lipiec
            Nov 24 '18 at 23:18






          • 1





            Thank you very much!

            – Dogantr
            Nov 25 '18 at 20:30











          • Btw if you havent noticed, another revision is up: jsfiddle.net/ynfb3Lh2/9

            – Jacek Lipiec
            Nov 25 '18 at 20:41











          Your Answer






          StackExchange.ifUsing("editor", function () {
          StackExchange.using("externalEditor", function () {
          StackExchange.using("snippets", function () {
          StackExchange.snippets.init();
          });
          });
          }, "code-snippets");

          StackExchange.ready(function() {
          var channelOptions = {
          tags: "".split(" "),
          id: "1"
          };
          initTagRenderer("".split(" "), "".split(" "), channelOptions);

          StackExchange.using("externalEditor", function() {
          // Have to fire editor after snippets, if snippets enabled
          if (StackExchange.settings.snippets.snippetsEnabled) {
          StackExchange.using("snippets", function() {
          createEditor();
          });
          }
          else {
          createEditor();
          }
          });

          function createEditor() {
          StackExchange.prepareEditor({
          heartbeatType: 'answer',
          autoActivateHeartbeat: false,
          convertImagesToLinks: true,
          noModals: true,
          showLowRepImageUploadWarning: true,
          reputationToPostImages: 10,
          bindNavPrevention: true,
          postfix: "",
          imageUploader: {
          brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
          contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
          allowUrls: true
          },
          onDemand: true,
          discardSelector: ".discard-answer"
          ,immediatelyShowMarkdownHelp:true
          });


          }
          });














          draft saved

          draft discarded


















          StackExchange.ready(
          function () {
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53462807%2fselected-dimensions-convert-to-div-table%23new-answer', 'question_page');
          }
          );

          Post as a guest















          Required, but never shown

























          1 Answer
          1






          active

          oldest

          votes








          1 Answer
          1






          active

          oldest

          votes









          active

          oldest

          votes






          active

          oldest

          votes









          0














          we have two issues here, one is selecting and one is generating. Generating is simple:



          Notice: This is done quick and dirty; innerHtml should not be used, Ping me if you'd like to see it more polished :)
          https://jsfiddle.net/ynfb3Lh2/9/



          <div id="selection">
          </div>
          <div id="target">
          </div>
          <pre id="text">
          </pre>

          <script>
          // Prepare our targets
          const selectionContainer = document.getElementById("selection");
          const targetContainer = document.getElementById("target");
          const textContainer = document.getElementById("text");

          // rows: How many rows to generate?
          // cols: How many cols to generate?
          // [_insertCallback]: should we insert callback?
          // [_targetContainer]: where should we place created divs?
          // [_textContainer]: sWhere should we write our HTML as plain text?
          function generateDiv(rows, columns, _insertCallback, _targetContainer, _textContainer) {
          // Create our wrapping elements
          const table = document.createElement("table");
          const tbody = document.createElement("tbody");

          for (let r = 0; r < rows; ++r) {
          // Each row is created here...
          const tr = document.createElement("tr");

          for (let c = 0; c < columns; ++c) {
          const td = document.createElement("td");
          td.text = "&nbsp;"
          // if callback is defined, and we have a target - allow us to generate new table on each click
          if (_insertCallback && _targetContainer) {
          td.onclick = () => generateDiv(r + 1, c + 1, false, _targetContainer, _textContainer)
          }

          tr.appendChild(td)
          }


          // ... and added here
          tbody.appendChild(tr)
          }

          table.appendChild(tbody)

          if (_targetContainer && !_insertCallback ) {
          _targetContainer.innerHTML = '';
          _targetContainer.appendChild(table);
          }
          if (_textContainer && !_insertCallback ) {
          _textContainer.innerHTML = table.outerHTML
          .replace(/td><//gi, "td>&amp;nbsp;</")
          .replace(/</gi, "&lt;")
          .replace(/>/gi, ">n");
          }

          return table;
          }

          selectionContainer.appendChild(generateDiv(10, 10, true, targetContainer, textContainer));

          </script>


          and similarily, making a selectable table is done via similar function that adds row and col information to each cell. Then, a mouseClick event on table will read the rows and cols and pass to the generation code.






          share|improve this answer


























          • How can I make the function that adds the row and col, and how do i highlight them? I'm quite new at this, ty!

            – Dogantr
            Nov 24 '18 at 22:45











          • Here you go :) jsfiddle.net/ynfb3Lh2/4

            – Jacek Lipiec
            Nov 24 '18 at 23:18






          • 1





            Thank you very much!

            – Dogantr
            Nov 25 '18 at 20:30











          • Btw if you havent noticed, another revision is up: jsfiddle.net/ynfb3Lh2/9

            – Jacek Lipiec
            Nov 25 '18 at 20:41
















          0














          we have two issues here, one is selecting and one is generating. Generating is simple:



          Notice: This is done quick and dirty; innerHtml should not be used, Ping me if you'd like to see it more polished :)
          https://jsfiddle.net/ynfb3Lh2/9/



          <div id="selection">
          </div>
          <div id="target">
          </div>
          <pre id="text">
          </pre>

          <script>
          // Prepare our targets
          const selectionContainer = document.getElementById("selection");
          const targetContainer = document.getElementById("target");
          const textContainer = document.getElementById("text");

          // rows: How many rows to generate?
          // cols: How many cols to generate?
          // [_insertCallback]: should we insert callback?
          // [_targetContainer]: where should we place created divs?
          // [_textContainer]: sWhere should we write our HTML as plain text?
          function generateDiv(rows, columns, _insertCallback, _targetContainer, _textContainer) {
          // Create our wrapping elements
          const table = document.createElement("table");
          const tbody = document.createElement("tbody");

          for (let r = 0; r < rows; ++r) {
          // Each row is created here...
          const tr = document.createElement("tr");

          for (let c = 0; c < columns; ++c) {
          const td = document.createElement("td");
          td.text = "&nbsp;"
          // if callback is defined, and we have a target - allow us to generate new table on each click
          if (_insertCallback && _targetContainer) {
          td.onclick = () => generateDiv(r + 1, c + 1, false, _targetContainer, _textContainer)
          }

          tr.appendChild(td)
          }


          // ... and added here
          tbody.appendChild(tr)
          }

          table.appendChild(tbody)

          if (_targetContainer && !_insertCallback ) {
          _targetContainer.innerHTML = '';
          _targetContainer.appendChild(table);
          }
          if (_textContainer && !_insertCallback ) {
          _textContainer.innerHTML = table.outerHTML
          .replace(/td><//gi, "td>&amp;nbsp;</")
          .replace(/</gi, "&lt;")
          .replace(/>/gi, ">n");
          }

          return table;
          }

          selectionContainer.appendChild(generateDiv(10, 10, true, targetContainer, textContainer));

          </script>


          and similarily, making a selectable table is done via similar function that adds row and col information to each cell. Then, a mouseClick event on table will read the rows and cols and pass to the generation code.






          share|improve this answer


























          • How can I make the function that adds the row and col, and how do i highlight them? I'm quite new at this, ty!

            – Dogantr
            Nov 24 '18 at 22:45











          • Here you go :) jsfiddle.net/ynfb3Lh2/4

            – Jacek Lipiec
            Nov 24 '18 at 23:18






          • 1





            Thank you very much!

            – Dogantr
            Nov 25 '18 at 20:30











          • Btw if you havent noticed, another revision is up: jsfiddle.net/ynfb3Lh2/9

            – Jacek Lipiec
            Nov 25 '18 at 20:41














          0












          0








          0







          we have two issues here, one is selecting and one is generating. Generating is simple:



          Notice: This is done quick and dirty; innerHtml should not be used, Ping me if you'd like to see it more polished :)
          https://jsfiddle.net/ynfb3Lh2/9/



          <div id="selection">
          </div>
          <div id="target">
          </div>
          <pre id="text">
          </pre>

          <script>
          // Prepare our targets
          const selectionContainer = document.getElementById("selection");
          const targetContainer = document.getElementById("target");
          const textContainer = document.getElementById("text");

          // rows: How many rows to generate?
          // cols: How many cols to generate?
          // [_insertCallback]: should we insert callback?
          // [_targetContainer]: where should we place created divs?
          // [_textContainer]: sWhere should we write our HTML as plain text?
          function generateDiv(rows, columns, _insertCallback, _targetContainer, _textContainer) {
          // Create our wrapping elements
          const table = document.createElement("table");
          const tbody = document.createElement("tbody");

          for (let r = 0; r < rows; ++r) {
          // Each row is created here...
          const tr = document.createElement("tr");

          for (let c = 0; c < columns; ++c) {
          const td = document.createElement("td");
          td.text = "&nbsp;"
          // if callback is defined, and we have a target - allow us to generate new table on each click
          if (_insertCallback && _targetContainer) {
          td.onclick = () => generateDiv(r + 1, c + 1, false, _targetContainer, _textContainer)
          }

          tr.appendChild(td)
          }


          // ... and added here
          tbody.appendChild(tr)
          }

          table.appendChild(tbody)

          if (_targetContainer && !_insertCallback ) {
          _targetContainer.innerHTML = '';
          _targetContainer.appendChild(table);
          }
          if (_textContainer && !_insertCallback ) {
          _textContainer.innerHTML = table.outerHTML
          .replace(/td><//gi, "td>&amp;nbsp;</")
          .replace(/</gi, "&lt;")
          .replace(/>/gi, ">n");
          }

          return table;
          }

          selectionContainer.appendChild(generateDiv(10, 10, true, targetContainer, textContainer));

          </script>


          and similarily, making a selectable table is done via similar function that adds row and col information to each cell. Then, a mouseClick event on table will read the rows and cols and pass to the generation code.






          share|improve this answer















          we have two issues here, one is selecting and one is generating. Generating is simple:



          Notice: This is done quick and dirty; innerHtml should not be used, Ping me if you'd like to see it more polished :)
          https://jsfiddle.net/ynfb3Lh2/9/



          <div id="selection">
          </div>
          <div id="target">
          </div>
          <pre id="text">
          </pre>

          <script>
          // Prepare our targets
          const selectionContainer = document.getElementById("selection");
          const targetContainer = document.getElementById("target");
          const textContainer = document.getElementById("text");

          // rows: How many rows to generate?
          // cols: How many cols to generate?
          // [_insertCallback]: should we insert callback?
          // [_targetContainer]: where should we place created divs?
          // [_textContainer]: sWhere should we write our HTML as plain text?
          function generateDiv(rows, columns, _insertCallback, _targetContainer, _textContainer) {
          // Create our wrapping elements
          const table = document.createElement("table");
          const tbody = document.createElement("tbody");

          for (let r = 0; r < rows; ++r) {
          // Each row is created here...
          const tr = document.createElement("tr");

          for (let c = 0; c < columns; ++c) {
          const td = document.createElement("td");
          td.text = "&nbsp;"
          // if callback is defined, and we have a target - allow us to generate new table on each click
          if (_insertCallback && _targetContainer) {
          td.onclick = () => generateDiv(r + 1, c + 1, false, _targetContainer, _textContainer)
          }

          tr.appendChild(td)
          }


          // ... and added here
          tbody.appendChild(tr)
          }

          table.appendChild(tbody)

          if (_targetContainer && !_insertCallback ) {
          _targetContainer.innerHTML = '';
          _targetContainer.appendChild(table);
          }
          if (_textContainer && !_insertCallback ) {
          _textContainer.innerHTML = table.outerHTML
          .replace(/td><//gi, "td>&amp;nbsp;</")
          .replace(/</gi, "&lt;")
          .replace(/>/gi, ">n");
          }

          return table;
          }

          selectionContainer.appendChild(generateDiv(10, 10, true, targetContainer, textContainer));

          </script>


          and similarily, making a selectable table is done via similar function that adds row and col information to each cell. Then, a mouseClick event on table will read the rows and cols and pass to the generation code.







          share|improve this answer














          share|improve this answer



          share|improve this answer








          edited Nov 24 '18 at 23:53

























          answered Nov 24 '18 at 22:21









          Jacek LipiecJacek Lipiec

          1917




          1917













          • How can I make the function that adds the row and col, and how do i highlight them? I'm quite new at this, ty!

            – Dogantr
            Nov 24 '18 at 22:45











          • Here you go :) jsfiddle.net/ynfb3Lh2/4

            – Jacek Lipiec
            Nov 24 '18 at 23:18






          • 1





            Thank you very much!

            – Dogantr
            Nov 25 '18 at 20:30











          • Btw if you havent noticed, another revision is up: jsfiddle.net/ynfb3Lh2/9

            – Jacek Lipiec
            Nov 25 '18 at 20:41



















          • How can I make the function that adds the row and col, and how do i highlight them? I'm quite new at this, ty!

            – Dogantr
            Nov 24 '18 at 22:45











          • Here you go :) jsfiddle.net/ynfb3Lh2/4

            – Jacek Lipiec
            Nov 24 '18 at 23:18






          • 1





            Thank you very much!

            – Dogantr
            Nov 25 '18 at 20:30











          • Btw if you havent noticed, another revision is up: jsfiddle.net/ynfb3Lh2/9

            – Jacek Lipiec
            Nov 25 '18 at 20:41

















          How can I make the function that adds the row and col, and how do i highlight them? I'm quite new at this, ty!

          – Dogantr
          Nov 24 '18 at 22:45





          How can I make the function that adds the row and col, and how do i highlight them? I'm quite new at this, ty!

          – Dogantr
          Nov 24 '18 at 22:45













          Here you go :) jsfiddle.net/ynfb3Lh2/4

          – Jacek Lipiec
          Nov 24 '18 at 23:18





          Here you go :) jsfiddle.net/ynfb3Lh2/4

          – Jacek Lipiec
          Nov 24 '18 at 23:18




          1




          1





          Thank you very much!

          – Dogantr
          Nov 25 '18 at 20:30





          Thank you very much!

          – Dogantr
          Nov 25 '18 at 20:30













          Btw if you havent noticed, another revision is up: jsfiddle.net/ynfb3Lh2/9

          – Jacek Lipiec
          Nov 25 '18 at 20:41





          Btw if you havent noticed, another revision is up: jsfiddle.net/ynfb3Lh2/9

          – Jacek Lipiec
          Nov 25 '18 at 20:41




















          draft saved

          draft discarded




















































          Thanks for contributing an answer to Stack Overflow!


          • Please be sure to answer the question. Provide details and share your research!

          But avoid



          • Asking for help, clarification, or responding to other answers.

          • Making statements based on opinion; back them up with references or personal experience.


          To learn more, see our tips on writing great answers.




          draft saved


          draft discarded














          StackExchange.ready(
          function () {
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53462807%2fselected-dimensions-convert-to-div-table%23new-answer', 'question_page');
          }
          );

          Post as a guest















          Required, but never shown





















































          Required, but never shown














          Required, but never shown












          Required, but never shown







          Required, but never shown

































          Required, but never shown














          Required, but never shown












          Required, but never shown







          Required, but never shown







          Popular posts from this blog

          Costa Masnaga

          Fotorealismo

          Sidney Franklin