[ Index ]

PHP Cross Reference of YOURLS

title

Body

[close]

/js/ -> tablesorte.js (source)

   1  // Tablesorter comes from own file now.
   2  
   3  var yourls_defaultsort = 2; // default column to sort on (overwrite this inline in page)
   4  var yourls_defaultorder = 1; // default order ('asc':0, 'desc':1) to sort on (overwrite this inline in page)
   5  
   6  // Initialise the table to sort
   7  $(document).ready(function(){
   8      if ($("#main_table").tablesorter && $("#main_table tr#nourl_found").css('display') == 'none') {
   9          var order = {'keyword':0, 'url':1, 'timestamp':2, 'ip':3, 'clicks':4};
  10          var order_by = {'asc':0, 'desc':1};
  11          var sort_by = order[query_string('sort_by')];
  12          var sort_order = order_by[query_string('sort_order')];
  13          if( sort_by == undefined ) {
  14              sort_by = yourls_defaultsort;
  15              sort_order = yourls_defaultorder;
  16          }
  17          
  18          $("#main_table").tablesorter({
  19              textExtraction: {
  20                  1: function(node, table, cellIndex){return $(node).find("small a").text();} // Sort column "URL" by URL, not by whole cell content
  21              },
  22              sortList:[[ sort_by, sort_order ]], 
  23              headers: { 5: {sorter: false} }, // no sorter on column "Actions"
  24              widgets: ['zebra'], // prettify, see tr.normal-row and tr.alt-row in tablesorter.css
  25              widgetOptions : { zebra : [ "normal-row", "alt-row" ] }
  26          });
  27      }
  28  });
  29  
  30  // Get query string
  31  function query_string( key ) {
  32      default_="";
  33      key = key.replace(/[\[]/,"\\\[").replace(/[\]]/,"\\\]");
  34      var regex = new RegExp("[\\?&]"+key+"=([^&#]*)");
  35      var qs = regex.exec(window.location.href);
  36      if(qs == null)
  37          return yourls_defaultsort;
  38      else
  39          return qs[1];
  40  }


Generated: Tue Jan 21 05:10:11 2025 Cross-referenced by PHPXref 0.7.1