Snippets

John McDonald Sort eHour

Created by John McDonald last modified
// ==UserScript==
// @name        eHour Sort
// @namespace   frostbyte.ehour
// @description Sorts the assignments when you are entering your hours
// @include     http://timesheet.frostbyteconsulting.com/eh/consultant/overview*
// @require     http://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js
// @version     1.1
// @grant       none
// ==/UserScript==


setInterval(function(){
  if(typeof($('.timesheetTable').attr('test')) === 'undefined'){
    $('.timesheetTable').attr('test', 'exists');
    
    console.log("Sorted!");
    
    var tbody = $('.timesheetTable').find('tbody');
    tbody.find('tr').sort(function(a, b) {
        return $('td:eq(1)', a).text().localeCompare($('td:eq(1)', b).text());
    }).appendTo(tbody);
    
  }
}, 1000);

Comments (0)

HTTPS SSH

You can clone a snippet to your computer for local editing. Learn more.