Guest User

Untitled

a guest
Feb 21st, 2018
94
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.90 KB | None | 0 0
  1. <html>
  2. <head>
  3. <script type="text/javascript" src="jquery-1.2.6.js"></script>
  4. <script type="text/javascript">
  5. // tablelize
  6. (function($){
  7. $.fn.tablize = function(){
  8. var store = new Array();
  9.  
  10. var toText = function(){ return $(this).text(); };
  11.  
  12. // function to take a tr and map it to a store row
  13. var toStoreRow = function(){
  14. var storeRow = new Array();
  15.  
  16. // stores raw html
  17. storeRow.push(this);
  18.  
  19. // stores values in locations 1...n
  20. storeRow.concat($(this).map(toText()));
  21. return storeRow;
  22. };
  23. // ** NOTES **
  24. // $('tr',$('tbody')).map(function(){return $(this).text();}).map(function(){alert(this);});
  25. // ** TODO **
  26. // create a table object
  27. // create a row object
  28. // var reDrawTable = function(table){};
  29. // var setListeners = function(){};
  30. // on click
  31. // - comparator = correct comparator; direction + column knowledge
  32. // - store.sortbo(comparator);
  33. // - store.redraw();
  34. //
  35. // should be in an initializer
  36. store = $('tbody tr',this).map(toStoreRow);
  37.  
  38. return this;
  39. };
  40. })(jQuery);
  41. $('document').ready(function(){
  42. $('#table').tablize();
  43. });
  44.  
  45. </script>
  46. </head>
  47. <body>
  48. <table id="table">
  49. <thead>
  50. <tr>
  51. <th>number</th>
  52. <th>name</th>
  53. <th>html</th>
  54. </tr>
  55. <tbody>
  56. <tr>
  57. <td>5</td>
  58. <td>stefan</td>
  59. <td><b>stefan</b></td>
  60. </tr>
  61. <tr>
  62. <td>-5</td>
  63. <td>sam</td>
  64. <td><b>sa,</b></td>
  65. </tr>
  66. <tr>
  67. <td>1</td>
  68. <td>gip</td>
  69. <td><b>gip</b></td>
  70. </tr>
  71. </table>
  72. </body>
  73. </html>
Add Comment
Please, Sign In to add comment