javascript 将时间跳线按钮添加到日历V2
Posted
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了javascript 将时间跳线按钮添加到日历V2相关的知识,希望对你有一定的参考价值。
// SETUP GLOBAL CALENDAR VARIABLES
var calendarID = 302541,
activeButtonClass = "active";
var returnDate = function returnDate(numOfDays) {
var calculatedDate = new Date();
calculatedDate.setDate(calculatedDate.getDate() + numOfDays);
var d = calculatedDate.getDate();
var m = calculatedDate.getMonth();
m += 1; // JavaScript months are 0-11
var y = calculatedDate.getFullYear();
return(y + "-" + m + "-" + d);
}
var getURL = function getURL(numOfDays) {
var calendarPage = (window.location.pathname).match(/([^\/]*)\/*$/)[1];
var URLString = "/" + calendarPage + "?cal-" + calendarID + "-endDate=" + returnDate(numOfDays) + "&cal-" + calendarID + "-page=1&cal-" + calendarID + "-startDate=" + returnDate(0) + "&display=" + numOfDays;
return(URLString);
}
var getUrlParameter = function getUrlParameter(sParam) {
var sPageURL = decodeURIComponent(window.location.search.substring(1)),
sURLVariables = sPageURL.split('&'),
sParameterName,
i;
for (i = 0; i < sURLVariables.length; i++) {
sParameterName = sURLVariables[i].split('=');
if (sParameterName[0] === sParam) {
return sParameterName[1] === undefined ? true : sParameterName[1];
}
}
};
// Get current calendar view
var currentDisplay = getUrlParameter('display');
// Create our container div and add it to the calendar
$("<div id=\"time-jump-buttons\"></div>").insertBefore($("div.swCalEvents"));
// Add our button options as needed
$("#time-jump-buttons").append("<a href=" + getURL(0) + " class=\"btn 0 \">Today</a>");
$("#time-jump-buttons").append("<a href=" + getURL(7) +" class=\"btn 7 \">This Week</a>");
$("#time-jump-buttons").append("<a href=" + getURL(30) +" class=\"btn 30 \">Next 30 Days</a>");
$("#time-jump-buttons").append("<a href=" + getURL(90) +" class=\"btn 90 \">Next 90 Days</a>");
$("#time-jump-buttons").append("<a href=" + getURL(365) +" class=\"btn 365 \">One Year</a>");
// Add active class to button based on current calendar view
$("#time-jump-buttons a").each(function() {
if (currentDisplay.length && $(this).hasClass(currentDisplay)) {
$('#time-jump-buttons a').removeClass(activeButtonClass);
$(this).addClass(activeButtonClass);
}
});
以上是关于javascript 将时间跳线按钮添加到日历V2的主要内容,如果未能解决你的问题,请参考以下文章
javascript [userscript] [tabelog]通过发送链接将当前商店添加到Google日历(需要修复开始/结束日期)
使用 Javascript/JQuery/Rails 3 动态添加新行
如何使用 html 代码将事件添加到指定的谷歌日历
创建javascript ICS以添加到ios上的日历
如何使用离子电容器将事件添加到移动设备的日历
在 FSCalendar UIView 上放置按钮