如何在每个时隙检测到最大条目时更改日历覆盖

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了如何在每个时隙检测到最大条目时更改日历覆盖相关的知识,希望对你有一定的参考价值。

请按以下步骤操作:

  1. 您需要创建一个视图来表示您的日历(您需要声明您的过滤器)。
  2. 创建一个日历覆盖,在这个例子中,我过滤了“ms-acal-item”,因为它是每小时日历项目所在的位置,你需要按F12打开IE Developer Tool,并跟踪...获取精确值getElementsByClassName。
var times = [
            "7:00 am - 7:30 am ", 
            "7:30 am - 8:00 am ", 
            "8:00 am - 8:30 am ", 
            "8:30 am - 9:00 am ",
            "9:00 am - 9:30 am ",
            "9:30 am - 10:00 am ",
            "10:00 am - 10:30 am ",
            "10:30 am - 11:00 am ",
            "11:00 am - 11:30 am ",
            "11:30 am - 12:00 pm ",
            "12:00 pm - 12:30 pm ",
            "12:30 pm - 1:00 pm ",
            "1:00 pm - 1:30 pm ",
            "1:30 pm - 2:00 pm ",
            "2:00 pm - 2:30 pm ",
            "2:30 pm - 3:00 pm ",
            "3:00 pm - 3:30 pm ",
            "3:30 pm - 4:00 pm ",
            "4:00 am - 4:30 am ",
            "4:30 am - 5:00 am ",
            "5:00 pm - 5:30 pm ",
            "5:30 pm - 6:00 pm ",
            "6:00 pm - 6:30 pm ",
            "6:30 pm - 7:00 pm "
            ];

function ApplyColor() {

    var nodes, iCount, TimeIdentifier;

    for (x = 0; x < times.length; x++){
        TimeIdentifier = times[x];
        console.log(times[x]);
        nodes = document.getElementsByClassName("ms-acal-item");

        iCount = 0;

        for (var i = 0; i < nodes.length; i++) {

            if (nodes[i].outerhtml.indexOf(TimeIdentifier) != -1) {

                console.log(nodes[i].outerHTML);
                var parts = nodes[i].outerHTML.split(TimeIdentifier);

                iCount += 1;

                // Set the maximim number of entries to make it red
                if (iCount >= 4)
                {
                    if (parts[1])
                    {
                        var color = GetCalendarColour("red");
                        nodes[i].style.background = color;
                    }
                }
            }
        }                       
    }
}

function GetCalendarColour(desc) {
    var colour;
    switch (desc.toLowerCase()) {

        case "red":
            colour = "rgb(255,000,000)";
            break;

        default:
            colour = "";
    }
    return colour;
}

window.setInterval(function () {
    ApplyColor();
}, 500);
答案

修改时间“下午3:30 - 下午4:00”,“上午4:00 - 凌晨4:30”,“上午4:30 - 上午5:00”,“下午5:00 - 下午5:30 “,应该是下午。谢谢

var times = [
            "7:00 am - 7:30 am ", 
            "7:30 am - 8:00 am ", 
            "8:00 am - 8:30 am ", 
            "8:30 am - 9:00 am ",
            "9:00 am - 9:30 am ",
            "9:30 am - 10:00 am ",
            "10:00 am - 10:30 am ",
            "10:30 am - 11:00 am ",
            "11:00 am - 11:30 am ",
            "11:30 am - 12:00 pm ",
            "12:00 pm - 12:30 pm ",
            "12:30 pm - 1:00 pm ",
            "1:00 pm - 1:30 pm ",
            "1:30 pm - 2:00 pm ",
            "2:00 pm - 2:30 pm ",
            "2:30 pm - 3:00 pm ",
            "3:00 pm - 3:30 pm ",
            "3:30 pm - 4:00 pm ",
            "4:00 pm - 4:30 pm ",
            "4:30 pm - 5:00 pm ",
            "5:00 pm - 5:30 pm ",
            "5:30 pm - 6:00 pm ",
            "6:00 pm - 6:30 pm ",
            "6:30 pm - 7:00 pm "
            ];

以上是关于如何在每个时隙检测到最大条目时更改日历覆盖的主要内容,如果未能解决你的问题,请参考以下文章

检测片段内的 ViewPager 选项卡更改

Google API:通过 Google Talk 通知日历条目更改

防止谷歌日历在远程 icalendar 文件更改时创建重复条目

带有 Google 日历 API(时隙)React/NodeJS 的预约系统

如何使用模块化代码片段中的LeakCanary检测内存泄漏?

Android - 多个视图或运行时片段替换​​?