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
b4abf0cd
Commit
b4abf0cd
authored
Oct 11, 2015
by
Sebastian
Browse files
ICalCalendar.url()
parent
2c4853de
Changes
3
Hide whitespace changes
Inline
Side-by-side
README.md
View file @
b4abf0cd
...
...
@@ -163,6 +163,15 @@ cal.prodId('//My Company//My Product//EN');
Use this method to set your feed's name. Is used to fill
`X-WR-CALNAME`
in your iCal file.
#### url([_String_ url])
Use this method to set your feed's URL.
```
javascript
var
cal
=
ical
().
url
(
'
https://example.com/calendar.ical
'
);
```
#### timezone([_String_ timezone])
Use this method to set your feed's timezone. Is used to fill
`X-WR-TIMEZONE`
in your iCal.
...
...
lib/calendar.js
View file @
b4abf0cd
...
...
@@ -8,7 +8,7 @@
*/
var
ICalCalendar
=
function
(
_data
)
{
var
data
=
{},
attributes
=
[
'
domain
'
,
'
prodId
'
,
'
name
'
,
'
timezone
'
,
'
events
'
],
attributes
=
[
'
domain
'
,
'
prodId
'
,
'
name
'
,
'
timezone
'
,
'
ttl
'
,
'
url
'
,
'
events
'
],
generate
,
i
;
...
...
@@ -23,6 +23,11 @@ var ICalCalendar = function(_data) {
// PRODID
g
+=
'
PRODID:-
'
+
data
.
prodid
+
'
\r\n
'
;
// URL
if
(
data
.
url
)
{
g
+=
'
URL:
'
+
data
.
url
+
'
\r\n
'
;
}
// NAME
if
(
data
.
name
)
{
g
+=
'
X-WR-CALNAME:
'
+
data
.
name
+
'
\r\n
'
;
...
...
@@ -224,6 +229,24 @@ var ICalCalendar = function(_data) {
};
/**
* Set/Get your feed's URL
*
* @param [url] URL
* @example cal.url('http://example.com/my/feed.ical');
* @since 0.2.5
* @returns {ICalCalendar}
*/
this
.
url
=
function
(
url
)
{
if
(
!
url
)
{
return
data
.
url
;
}
data
.
url
=
url
||
null
;
return
this
;
};
/**
* Set/Get your feed's TTL.
* Used to set `X-PUBLISHED-TTL` and `REFRESH-INTERVAL`.
...
...
test/test_0.2.x.js
View file @
b4abf0cd
...
...
@@ -180,6 +180,28 @@ describe('ical-generator 0.2.x / ICalCalendar', function() {
});
});
describe
(
'
url()
'
,
function
()
{
it
(
'
setter should return this
'
,
function
()
{
var
cal
=
ical
();
assert
.
deepEqual
(
cal
,
cal
.
url
(
'
https://example.com/calendar.ical
'
));
});
it
(
'
getter should return value
'
,
function
()
{
var
cal
=
ical
().
url
(
'
https://example.com/calendar.ical
'
);
assert
.
equal
(
cal
.
url
(),
'
https://example.com/calendar.ical
'
);
});
it
(
'
should change something
'
,
function
()
{
var
cal
=
ical
().
url
(
'
https://example.com/calendar.ical
'
);
cal
.
createEvent
({
start
:
new
Date
(),
end
:
new
Date
(
new
Date
().
getTime
()
+
3600000
),
summary
:
'
Example Event
'
});
assert
.
ok
(
cal
.
toString
().
indexOf
(
'
https://example.com/calendar.ical
'
)
>
-
1
);
});
});
describe
(
'
createEvent()
'
,
function
()
{
it
(
'
should return a ICalEvent instance
'
,
function
()
{
var
cal
=
ical
(),
...
...
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