diff --git a/index.html b/index.html index 128c621..6ec46db 100644 --- a/index.html +++ b/index.html @@ -34,49 +34,40 @@ ["#FF6600", "#FCD202", "#309E09", "#0D8ECF", "#2A0CD0", "#CD0D74", "#CC0000", "#00CC00", "#0000CC", "#0D9D9D", "#999999", "#333333", "#990000", "#a0ee70", "#f0ff00",] ; - var guides = [{ - date: "2017/01/15 00:00", toDate: "2017/1/16 00:00", - fillColor: "#f08080", fillAlpha: 0.1, lineAlpha: 0 - },{ - date: "2017/01/14 00:00", toDate: "2017/1/15 00:00", - fillColor: "#8080f0", fillAlpha: 0.1, lineAlpha: 0 - },{ - date: "2017/01/08 00:00", toDate: "2017/1/9 00:00", - fillColor: "#f08080", fillAlpha: 0.1, lineAlpha: 0 - },{ - date: "2017/01/07 00:00", toDate: "2017/1/8 00:00", - fillColor: "#8080f0", fillAlpha: 0.1, lineAlpha: 0 - },{ - date: "2017/1/1", toDate: "2017/1/2", - fillColor: "#f08080", fillAlpha: 0.1, lineAlpha: 0 - },{ - date: "2016/12/31 0:0", toDate: "2017/1/1 0:0", - fillColor: "#8080f0", fillAlpha: 0.1, lineAlpha: 0 - },{ - date: "2016/12/24 0:0", toDate: "2016/12/25 0:0", - fillColor: "#8080f0", fillAlpha: 0.1, lineAlpha: 0 - },{ - date: "2016/12/25 0:0", toDate: "2016/12/26 0:0", - fillColor: "#f08080", fillAlpha: 0.1, lineAlpha: 0 - },{ - date: "2016/12/17 0:0", toDate: "2016/12/18 0:0", - fillColor: "#8080f0", fillAlpha: 0.1, lineAlpha: 0 - },{ - date: "2016/12/18 0:0", toDate: "2016/12/19 0:0", - fillColor: "#f08080", fillAlpha: 0.1, lineAlpha: 0 - },{ - date: "2016/12/10 0:0", toDate: "2016/12/11 0:0", - fillColor: "#8080f0", fillAlpha: 0.1, lineAlpha: 0 - },{ - date: "2016/12/11 0:0", toDate: "2016/12/12 0:0", - fillColor: "#f08080", fillAlpha: 0.1, lineAlpha: 0 - },{ - date: "2016/12/03 0:0", toDate: "2016/12/04 0:0", - fillColor: "#8080f0", fillAlpha: 0.1, lineAlpha: 0 - },{ - date: "2016/12/04 0:0", toDate: "2016/12/05 0:0", - fillColor: "#f08080", fillAlpha: 0.1, lineAlpha: 0 - }]; + + function paint_day(day, color) { + var today = new Date(day); + var tomorrow = new Date(day); + tomorrow.setDate(tomorrow.getDate() + 1); + return { + date: today, toDate: tomorrow, + fillColor: color, fillAlpha: 0.1, lineAlpha: 0 + }; + } + + function make_guides(data) { + var today = new Date(data[0].datetime); + var to = new Date(data[data.length-1].datetime); + var guides = []; + + for (;today <= to;) { // FF to Sat or Sun + var d = today.getDay(); + if (d == 0) { + guides.push(paint_day(today, "#f08080")); + today.setDate(today.getDate()+1); + } else if (d == 6) { + guides.push(paint_day(today, "#8080f0")); + today.setDate(today.getDate()+1); + guides.push(paint_day(today, "#f08080")); + today.setDate(today.getDate()+6); + } else { + today.setDate(today.getDate()+1); + } + } + return guides; + } + + var guides = make_guides(data); sensors = [ [ 1, "工作室"], [ 2, "実験室LB"],