📄 plugins.js
字号:
/////////////////// Plug-in file for CalendarXP 9.0 /////////////////
// This file is totally configurable. You may remove all the comments in this file to minimize the download size.
/////////////////////////////////////////////////////////////////////
///////////// Calendar Onchange Handler ////////////////////////////
// It's triggered whenever the calendar gets changed to y(ear),m(onth),d(ay)
// d = 0 means the calendar is about to switch to the month of (y,m);
// d > 0 means a specific date [y,m,d] is about to be selected.
// e is a reference to the triggering event object
// Return a true value will cancel the change action.
// NOTE: DO NOT define this handler unless you really need to use it.
////////////////////////////////////////////////////////////////////
function fOnChange(y,m,d,e) {
if (d==0) return false;
_selDatesRange.length=0; // clear the week selection
return false; // return true to cancel the change.
}
///////////// Calendar AfterSelected Handler ///////////////////////
// It's triggered whenever a date gets fully selected.
// The selected date is passed in as y(ear),m(onth),d(ay)
// e is a reference to the triggering event object
// NOTE: DO NOT define this handler unless you really need to use it.
////////////////////////////////////////////////////////////////////
// function fAfterSelected(y,m,d,e) {}
///////////// Calendar Cell OnDrag Handler ///////////////////////
// It triggered when you try to drag a calendar cell. (y,m,d) is the cell date.
// aStat = 0 means a mousedown is detected (dragstart)
// aStat = 1 means a mouseover between dragstart and dragend is detected (dragover)
// aStat = 2 means a mouseup is detected (dragend)
// e is a reference to the triggering event object
// Return true (when aStat=0) to skip the set-date process, as well as any related event handlers (e.g. fAfterSelect).
// NOTE: DO NOT define this handler unless you really need to use it.
////////////////////////////////////////////////////////////////////
// function fOnDrag(y,m,d,aStat,e) {}
////////////////// Calendar OnResize Handler ///////////////////////
// It's triggered after the calendar panel has finished drawing.
// NOTE: DO NOT define this handler unless you really need to use it.
////////////////////////////////////////////////////////////////////
// function fOnResize() {}
////////////////// Calendar fOnWeekClick Handler ///////////////////////
// It's triggered when the week number is clicked.
// NOTE: DO NOT define this handler unless you really need to use it.
////////////////////////////////////////////////////////////////////
function fOnWeekClick(year, weekNo) {
gdCtrl.value=year+_separator_week+weekNo;
var wk=gdCtrl.value.split(_separator_week);
_selDatesRange[0]=fW2Date(wk[0],wk[1],1);
_selDatesRange[1]=fW2Date(wk[0],wk[1],7);
fHideCal(); // or use fRepaint() to refresh the calendar
}
////////////////// Calendar fIsSelected Callback ///////////////////////
// It's triggered for every date passed in as y(ear) m(onth) d(ay). And if
// the return value is true, that date will be rendered using the giMarkSelected,
// gcFGSelected, gcBGSelected and guSelectedBGImg theme options.
// NOTE: If NOT defined here, the engine will create one that checks the gdSelect only.
////////////////////////////////////////////////////////////////////
function fIsSelected(y,m,d) {
var dt=Date.UTC(y,m-1,d),s=_selDatesRange;
if (s.length==0)
return gdSelect[2]==d&&gdSelect[1]==m&&gdSelect[0]==y;
else
return (dt>=Date.UTC(s[0][0],s[0][1]-1,s[0][2])&&dt<=Date.UTC(s[1][0],s[1][1]-1,s[1][2]))
}
////////////////// Calendar fParseInput Handler ///////////////////////
// Once defined, it'll be used to parse the input string stored in gdCtrl.value.
// It's expected to return an array of [y,m,d] to indicate the parsed date,
// or null if the input str can't be parsed as a date.
// NOTE: If NOT defined here, the engine will create one matching fParseDate().
////////////////////////////////////////////////////////////////////
function fParseInput(str) {
var wk=str.split(_separator_week);
if (wk.length==2) { // select all week days
_selDatesRange[0]=fW2Date(wk[0],wk[1],1);
_selDatesRange[1]=fW2Date(wk[0],wk[1],7);
return _selDatesRange[0]; // return the 1st day of week so that the calendar can show up that month
} else {
return fParseDate(str);
}
}
////////////////// Calendar fFormatInput Handler ///////////////////////
// Once defined, it'll be used to format the selected date - y(ear) m(onth) d(ay)
// into gdCtrl.value.
// It's expected to return a formated date string.
// NOTE: If NOT defined here, the engine will create one matching fFormatDate().
////////////////////////////////////////////////////////////////////
function fFormatInput(y,m,d) {
if (_selDatesRange.length>0) { // week selection
var wd=fDate2W(_selDatesRange[0][0],_selDatesRange[0][1],_selDatesRange[0][2]);
return wd[0]+_separator_week+wd[1];
} else { // date selection
return fFormatDate(y,m,d);
}
}
// ====== predefined utility functions for use with agendas. ========
// load an url in the window/frame designated by "framename".
function popup(url,framename) {
var w=parent.open(url,framename,"top=200,left=200,width=400,height=200,scrollbars=1,resizable=1");
if (w&&url.split(":")[0]=="mailto") w.close();
else if (w&&!framename) w.focus();
}
// return the d(ate) of the q-th n-day of a specific m(onth) in a specific y(ear)
function getDateByDOW(y,m,q,n) {
// q: 1 - 5 ( 5 denotes the last n-day )
// n: 0 - Sunday, 1 - Monday ... 6 - Saturday
var dom=new Date(y,m-1,1).getDay();
var d=7*q-6+n-dom;
if (dom>n) d+=7;
if (d>fGetDays(y)[m]) d-=7;
return d; // ranged from 1 to 31
}
// ====== Following are self-defined and/or custom-built functions! =======
giWeekCol=-1; // set to show the week number column
var _separator_week="wk"; // separator char that sits between the year and week number
var _selDatesRange=[]; // a 2-element array contains the first week day and the last week day in format [y,m,d]
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -