/* Hightlight row by due date * --------------------------------------------- * Created by Alexander Bautz * alexander.bautz@gmail.com * http://sharepointjavascript.wordpress.com * v1.1 - 30.11.2011 */ $(document).ready(function(){ init_highlightOverdue(); }); function highlightOverdue(argObj){ var sep, df, yd, rd, now, r, split, m, d, y, date, color; sep = argObj.dateFormat.match(/[^dmy]/); df = argObj.dateFormat.split(sep); rd = argObj.redDays*86400000; yd = argObj.yellowDays*86400000; gd = argObj.greenDays*86400000; now = new Date(); now = now.getTime(); r = new RegExp(argObj.identifierText); $("table.ms-listviewtable >tbody >tr").each(function(){ if($(this).attr('beenthere')==='1'){ return; } $(this).attr('beenthere','1'); $(this).find('>td').each(function(){ if($(this).text().match(r)!==null){ color = ''; split = $(this).text().split(argObj.identifierText)[1].split(sep); m = split[$.inArray('mm',df)]; d = split[$.inArray('dd',df)]; y = split[$.inArray('yy',df)]; date = new Date(parseInt(y,10),parseInt(m-1,10),parseInt(d,10)); if(date.getTime()+rd" + d + ""; c.parentNode.replaceChild(b.firstChild.firstChild, c); if(typeof(_fV4UI)!=='undefined'){ customTimeoutLoop("tbod" + a + "_"); }else{ init_highlightOverdue(); } } function handleGroupedPaging(){ var loaded = true; $(".ms-listviewtable tbody").each(function(){ if(this.isloaded==='false'){ loaded = false; return false; } }); if(!loaded){ setTimeout(function(){ handleGroupedPaging(); },10); } $(".ms-listviewtable tbody[id$='__page'] a").click(function(){ setTimeout(function(){ handleGroupedPaging(); init_highlightOverdue(); },500); }); } function customTimeoutLoop(id){ var obj = $("#"+id); var isloaded = ($(obj).attr('isloaded')=='true')?true:false; if(!isloaded){ $(obj).hide(); setTimeout(function(){ customTimeoutLoop(id); },10); }else{ $(obj).show(); handleGroupedPaging(); init_highlightOverdue(); } }