User:Iritscen/TestSpace.js: Difference between revisions

hmm, there's no infinite loop now
(oh, that's a capital 's'...)
(hmm, there's no infinite loop now)
Line 8: Line 8:
function sortSortableTables()
function sortSortableTables()
{
{
  alert("Looking for sortable tables.");
   // Iterate over all <div> elements
   // Iterate over all <div> elements
   var divs = document.getElementsByTagName("div");
   var divs = document.getElementsByTagName("div");
Line 19: Line 18:
       for (var j = 0; j < tables.length; j++)
       for (var j = 0; j < tables.length; j++)
       {
       {
        alert("Looking at table " + j);
         var theTable = tables[j];
         var theTable = tables[j];
         // If we found a sortable table...
         // If we found a sortable table...
         if (hasClass(theTable, "sortable"))
         if (hasClass(theTable, "sortable"))
         {
         {
            alert("Found a sortable one.");
             // ...Look for sort button
             // ...Look for sort button
             var allTHs = theTable.getElementsByTagName("th");
             var allTHs = theTable.getElementsByTagName("th");
             if (!allTHs) continue;
             if (!allTHs) continue;
            alert("Looking through " + allTHs.length + " THs.");
             for (var k = 0; k < allTHs.length; k++)
             for (var k = 0; k < allTHs.length; k++)
             {
             {
Line 34: Line 30:
               {
               {
                   alert("Found the arrow.");
                   alert("Found the arrow.");
                   allTHs[k].trigger(click); // use jQuery's trigger() to send click event to this arrow
                   allTHs[k].trigger("click"); // use jQuery's trigger() to send click event to this arrow
               }
               }
             }
             }