Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
SRCT
lib-ical
Commits
c37aa7f2
Commit
c37aa7f2
authored
May 21, 2016
by
Sebastian
Browse files
Merge branch 'develop' of
https://github.com/jen-huang/ical-generator
into jen-huang-develop
parents
42d85435
28964d98
Changes
2
Hide whitespace changes
Inline
Side-by-side
lib/calendar.js
View file @
c37aa7f2
...
...
@@ -8,10 +8,14 @@
*/
var
ICalCalendar
=
function
(
_data
)
{
var
data
=
{},
attributes
=
[
'
domain
'
,
'
prodId
'
,
'
name
'
,
'
description
'
,
'
timezone
'
,
'
ttl
'
,
'
url
'
,
'
events
'
],
attributes
=
[
'
domain
'
,
'
prodId
'
,
'
method
'
,
'
name
'
,
'
description
'
,
'
timezone
'
,
'
ttl
'
,
'
url
'
,
'
events
'
],
vars
,
generate
,
i
;
vars
=
{
allowedMethods
:
[
'
PUBLISH
'
,
'
REQUEST
'
,
'
REPLY
'
,
'
ADD
'
,
'
CANCEL
'
,
'
REFRESH
'
,
'
COUNTER
'
,
'
DECLINECOUNTER
'
]
};
generate
=
function
(
calendar
)
{
var
tools
=
require
(
'
./_tools.js
'
),
...
...
@@ -28,6 +32,11 @@ var ICalCalendar = function(_data) {
g
+=
'
URL:
'
+
data
.
url
+
'
\r\n
'
;
}
// METHOD
if
(
data
.
method
)
{
g
+=
'
METHOD:
'
+
data
.
method
+
'
\r\n
'
;
}
// NAME
if
(
data
.
name
)
{
g
+=
'
NAME:
'
+
data
.
name
+
'
\r\n
'
;
...
...
@@ -172,6 +181,31 @@ var ICalCalendar = function(_data) {
};
/**
* Set/Get your feed's method
*
* @param {String} method
* @since 0.2.0
* @returns {ICalEvent|String}
*/
this
.
method
=
function
(
method
)
{
if
(
method
===
undefined
)
{
return
data
.
method
;
}
if
(
!
method
)
{
data
.
method
=
null
;
return
this
;
}
if
(
vars
.
allowedMethods
.
indexOf
(
method
.
toUpperCase
())
===
-
1
)
{
throw
'
`method` must be one of the following:
'
+
vars
.
allowedMethods
.
join
(
'
,
'
)
+
'
!
'
;
}
data
.
method
=
method
.
toUpperCase
();
return
this
;
};
/**
* Set your feed's name…
*
...
...
@@ -450,6 +484,7 @@ var ICalCalendar = function(_data) {
this
.
clear
=
function
()
{
data
.
domain
=
require
(
'
os
'
).
hostname
();
data
.
prodid
=
'
//sebbo.net//ical-generator//EN
'
;
data
.
method
=
null
;
data
.
name
=
null
;
data
.
timezone
=
null
;
data
.
ttl
=
null
;
...
...
lib/event.js
View file @
c37aa7f2
...
...
@@ -7,7 +7,7 @@
* @constructor ICalEvent Event
*/
var
ICalEvent
=
function
(
_data
,
calendar
)
{
var
attributes
=
[
'
id
'
,
'
uid
'
,
'
sequence
'
,
'
start
'
,
'
end
'
,
'
timezone
'
,
'
stamp
'
,
'
timestamp
'
,
'
allDay
'
,
'
floating
'
,
'
repeating
'
,
'
summary
'
,
'
location
'
,
'
description
'
,
'
organizer
'
,
'
attendees
'
,
'
alarms
'
,
'
method
'
,
'
status
'
,
'
url
'
],
var
attributes
=
[
'
id
'
,
'
uid
'
,
'
sequence
'
,
'
start
'
,
'
end
'
,
'
timezone
'
,
'
stamp
'
,
'
timestamp
'
,
'
allDay
'
,
'
floating
'
,
'
repeating
'
,
'
summary
'
,
'
location
'
,
'
description
'
,
'
organizer
'
,
'
attendees
'
,
'
alarms
'
,
'
status
'
,
'
url
'
],
vars
,
i
,
data
;
...
...
@@ -17,7 +17,6 @@ var ICalEvent = function(_data, calendar) {
}
vars
=
{
allowedMethods
:
[
'
PUBLISH
'
,
'
REQUEST
'
,
'
REPLY
'
,
'
ADD
'
,
'
CANCEL
'
,
'
REFRESH
'
,
'
COUNTER
'
,
'
DECLINECOUNTER
'
],
allowedRepeatingFreq
:
[
'
SECONDLY
'
,
'
MINUTELY
'
,
'
HOURLY
'
,
'
DAILY
'
,
'
WEEKLY
'
,
'
MONTHLY
'
,
'
YEARLY
'
],
allowedStatuses
:
[
'
CONFIRMED
'
,
'
TENATIVE
'
,
'
CANCELLED
'
]
};
...
...
@@ -38,7 +37,6 @@ var ICalEvent = function(_data, calendar) {
organizer
:
null
,
attendees
:
[],
alarms
:
[],
method
:
null
,
status
:
null
,
url
:
null
};
...
...
@@ -309,12 +307,12 @@ var ICalEvent = function(_data, calendar) {
data
.
repeating
.
byDay
=
[];
repeating
.
byDay
.
forEach
(
function
(
symbol
)
{
var
s
=
symbol
.
toString
().
toUpperCase
();
if
([
'
SU
'
,
'
MO
'
,
'
TU
'
,
'
WE
'
,
'
TH
'
,
'
FR
'
,
'
SA
'
].
indexOf
(
s
)
===
-
1
)
{
throw
'
`repeating.byDay` contains invalid value `
'
+
s
+
'
`!
'
;
var
s
=
symbol
.
toString
().
toUpperCase
()
.
match
(
/^
(\d
*||-
\d
+
)(\w
+
)
$/
)
;
if
([
'
SU
'
,
'
MO
'
,
'
TU
'
,
'
WE
'
,
'
TH
'
,
'
FR
'
,
'
SA
'
].
indexOf
(
s
[
2
]
)
===
-
1
)
{
throw
'
`repeating.byDay` contains invalid value `
'
+
s
[
2
]
+
'
`!
'
;
}
data
.
repeating
.
byDay
.
push
(
s
);
data
.
repeating
.
byDay
.
push
(
s
[
1
]
+
s
[
2
]
);
});
}
...
...
@@ -541,31 +539,6 @@ var ICalEvent = function(_data, calendar) {
};
/**
* Set/Get the event's method
*
* @param {String} method
* @since 0.2.0
* @returns {ICalEvent|String}
*/
this
.
method
=
function
(
method
)
{
if
(
method
===
undefined
)
{
return
data
.
method
;
}
if
(
!
method
)
{
data
.
method
=
null
;
return
this
;
}
if
(
vars
.
allowedMethods
.
indexOf
(
method
.
toUpperCase
())
===
-
1
)
{
throw
'
`method` must be one of the following:
'
+
vars
.
allowedMethods
.
join
(
'
,
'
)
+
'
!
'
;
}
data
.
method
=
method
.
toUpperCase
();
return
this
;
};
/**
* Set/Get the event's status
*
...
...
@@ -728,10 +701,7 @@ var ICalEvent = function(_data, calendar) {
g
+=
'
URL;VALUE=URI:
'
+
tools
.
escape
(
data
.
url
)
+
'
\r\n
'
;
}
// METHOD & STATUS
if
(
data
.
method
)
{
g
+=
'
METHOD:
'
+
data
.
method
.
toUpperCase
()
+
'
\r\n
'
;
}
// STATUS
if
(
data
.
status
)
{
g
+=
'
STATUS:
'
+
data
.
status
.
toUpperCase
()
+
'
\r\n
'
;
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment