From b15348f7237a7aaf8777dd88e0615a8c137bbc3a Mon Sep 17 00:00:00 2001 From: Adam R Claxton Date: Sat, 3 Dec 2016 17:30:25 -0500 Subject: [PATCH] Return listings display time out in months instead of weeks if devices has been out for 2 or more months --- html/javascript/return.js | 48 ++++++++++++++++++++------------------- 1 file changed, 25 insertions(+), 23 deletions(-) diff --git a/html/javascript/return.js b/html/javascript/return.js index 8e230be..a2edada 100644 --- a/html/javascript/return.js +++ b/html/javascript/return.js @@ -64,32 +64,32 @@ function filterDeviceList() switch(id) { case "all": - populateDeviceList(null); - break; + populateDeviceList(null); + break; case "1month": - upperbound=new Date().getTime(); - lowerbound=upperbound-month; - filter=[lowerbound, upperbound]; - populateDeviceList(filter); - break; + upperbound=new Date().getTime(); + lowerbound=upperbound-month; + filter=[lowerbound, upperbound]; + populateDeviceList(filter); + break; case "1-3months": - upperbound=new Date().getTime()-month; - lowerbound=upperbound-2*month; - filter=[lowerbound, upperbound]; - populateDeviceList(filter); - break; + upperbound=new Date().getTime()-month; + lowerbound=upperbound-2*month; + filter=[lowerbound, upperbound]; + populateDeviceList(filter); + break; case "3-5months": - upperbound=new Date().getTime()-3*month; - lowerbound=upperbound-2*month; - filter=[lowerbound, upperbound]; - populateDeviceList(filter); - break; + upperbound=new Date().getTime()-3*month; + lowerbound=upperbound-2*month; + filter=[lowerbound, upperbound]; + populateDeviceList(filter); + break; case "5+months": - upperbound=new Date().getTime()-5*month; - lowerbound=0; - filter=[lowerbound, upperbound]; - populateDeviceList(filter); - break; + upperbound=new Date().getTime()-5*month; + lowerbound=0; + filter=[lowerbound, upperbound]; + populateDeviceList(filter); + break; } } @@ -116,7 +116,9 @@ function populateDeviceList(filter) var hours=Math.floor(minutes/60); var days=Math.floor(hours/24); var weeks=Math.floor(days/7); - htmlString+= weeks+ " weeks!"; + var months=Math.floor(weeks/4); + if(months>=2) htmlString+=months+" months"; + else htmlString+= weeks+ " weeks"; htmlString+="