|
| 1 | +<html> |
| 2 | + <head> |
| 3 | + <link href="https://fonts.googleapis.com/css?family=Lato|Roboto|Source+Code+Pro" rel="stylesheet"> |
| 4 | + <link rel="stylesheet" href="//cdnjs.cloudflare.com/ajax/libs/highlight.js/9.15.6/styles/monokai.min.css"> |
| 5 | + <link rel="stylesheet" href="_demo.css"> |
| 6 | + </head> |
| 7 | + |
| 8 | + <body> |
| 9 | + |
| 10 | + <div id="header"> |
| 11 | + <h1 id="title">$.csv.fromArrays()</h1> |
| 12 | + <div id="link"><a href="https://github.com/evanplaice/jquery-csv">GitHub</a></div> |
| 13 | + </div> |
| 14 | + <div id="container"> |
| 15 | + <section id="content"> |
| 16 | + <h2>Description</h2> |
| 17 | + <p>Used to format a fixed 2D array of data as CSV.</p> |
| 18 | + <hr> |
| 19 | + <h2>Usage</h2> |
| 20 | + <pre><code class="javascript">var result = $.csv.fromArrays(input);</code></pre> |
| 21 | + <hr /> |
| 22 | + <h2>Input</h2> |
| 23 | + <textarea id="input" style="height: 200px;"> |
| 24 | +[ |
| 25 | + ["All work","and no play","makes Jack","a dull boy..."], |
| 26 | + ["All work","and no play","makes Jack","a dull boy..."], |
| 27 | + ["All work","and no play","makes Jack","a dull boy..."], |
| 28 | + ["All work","and no play","makes Jack","a dull boy..."], |
| 29 | + ["All work","and no play","makes Jack","a dull boy..."], |
| 30 | + ["All work","and no play","makes Jack","a dull boy..."], |
| 31 | + ["All work","and no play","makes Jack","a dull boy..."], |
| 32 | + ["All work","and no play","makes Jack","a dull boy..."], |
| 33 | + ["All work","and no play","makes Jack","a dull boy..."], |
| 34 | + ["All work","and no play","makes Jack","a dull boy..."] |
| 35 | +] |
| 36 | + </textarea> |
| 37 | + <input id="run" type="button" value="Run" /> |
| 38 | + <hr /> |
| 39 | + <h2>Result</h2> |
| 40 | + <textarea id="result" style="height: 170px;"></textarea> |
| 41 | + </section> |
| 42 | + </div> |
| 43 | + |
| 44 | + <script src="http://code.jquery.com/jquery-3.3.1.slim.js" integrity="sha256-fNXJFIlca05BIO2Y5zh1xrShK3ME+/lYZ0j+ChxX2DA=" crossorigin="anonymous"></script> |
| 45 | + <script src="../src/jquery.csv.js"></script> |
| 46 | + <script src="//cdnjs.cloudflare.com/ajax/libs/highlight.js/9.15.6/highlight.min.js"></script> |
| 47 | + <script> |
| 48 | + // enable syntax highlighting |
| 49 | + hljs.initHighlightingOnLoad(); |
| 50 | + |
| 51 | + $(document).ready(() => { |
| 52 | + format(); |
| 53 | + }); |
| 54 | + |
| 55 | + $('#run').bind('click', function () { |
| 56 | + format(); |
| 57 | + }); |
| 58 | + |
| 59 | + function format() { |
| 60 | + const input = JSON.parse($('#input').val()); |
| 61 | + const csv = $.csv.fromArrays(input); |
| 62 | + $('#result').empty(); |
| 63 | + $('#result').html(csv); |
| 64 | + } |
| 65 | + </script> |
| 66 | + </body> |
| 67 | +</html> |
0 commit comments