Fixed bad name
This commit is contained in:
+34
-11
@@ -1,13 +1,5 @@
|
||||
<!DOCTYPE html>
|
||||
<head>
|
||||
<!-- <script type="text/javascript" src="https://rawgithub.com/nwcell/ics.js/master/ics.deps.min.js"></script> -->
|
||||
|
||||
<!-- include source files here... -->
|
||||
<script src="../bower_components/Blob.js/Blob.js"></script>
|
||||
<script src="../bower_components/file-saver/FileSaver.js"></script>
|
||||
<script src="../ics.js"></script>
|
||||
<script type="text/javascript" src="https://rawgithub.com/nwcell/ics.js/master/demo/demo.js"></script>
|
||||
|
||||
<style>
|
||||
html, body {
|
||||
height: 100%;
|
||||
@@ -52,10 +44,41 @@
|
||||
</head>
|
||||
<body>
|
||||
<div class="wrap">
|
||||
<a href="javascript:cal_single.download('Awesome Day')">Single Event</a>
|
||||
<a href="#" onclick="javascript:cal_single.download('Awesome Day')">Single Event</a>
|
||||
<br>
|
||||
<a href="javascript:cal.download('Holidays')">Multiple Events</a>
|
||||
<a href="#" onclick="javascript:cal.download('Holidays')">Multiple Events</a>
|
||||
<br>
|
||||
<a href="javascript:makelogs(cal)">Console Output</a>
|
||||
<a href="#" onclick="javascript:makelogs(cal)">Console Output</a>
|
||||
</div>
|
||||
|
||||
<!-- File Saver Dependency -->
|
||||
<script>/*! @source http://purl.eligrey.com/github/FileSaver.js/blob/master/FileSaver.js */
|
||||
var saveAs=saveAs||function(e){"use strict";if(typeof e==="undefined"||typeof navigator!=="undefined"&&/MSIE [1-9]\./.test(navigator.userAgent)){return}var t=e.document,n=function(){return e.URL||e.webkitURL||e},r=t.createElementNS("http://www.w3.org/1999/xhtml","a"),o="download"in r,a=function(e){var t=new MouseEvent("click");e.dispatchEvent(t)},i=/constructor/i.test(e.HTMLElement)||e.safari,f=/CriOS\/[\d]+/.test(navigator.userAgent),u=function(t){(e.setImmediate||e.setTimeout)(function(){throw t},0)},s="application/octet-stream",d=1e3*40,c=function(e){var t=function(){if(typeof e==="string"){n().revokeObjectURL(e)}else{e.remove()}};setTimeout(t,d)},l=function(e,t,n){t=[].concat(t);var r=t.length;while(r--){var o=e["on"+t[r]];if(typeof o==="function"){try{o.call(e,n||e)}catch(a){u(a)}}}},p=function(e){if(/^\s*(?:text\/\S*|application\/xml|\S*\/\S*\+xml)\s*;.*charset\s*=\s*utf-8/i.test(e.type)){return new Blob([String.fromCharCode(65279),e],{type:e.type})}return e},v=function(t,u,d){if(!d){t=p(t)}var v=this,w=t.type,m=w===s,y,h=function(){l(v,"writestart progress write writeend".split(" "))},S=function(){if((f||m&&i)&&e.FileReader){var r=new FileReader;r.onloadend=function(){var t=f?r.result:r.result.replace(/^data:[^;]*;/,"data:attachment/file;");var n=e.open(t,"_blank");if(!n)e.location.href=t;t=undefined;v.readyState=v.DONE;h()};r.readAsDataURL(t);v.readyState=v.INIT;return}if(!y){y=n().createObjectURL(t)}if(m){e.location.href=y}else{var o=e.open(y,"_blank");if(!o){e.location.href=y}}v.readyState=v.DONE;h();c(y)};v.readyState=v.INIT;if(o){y=n().createObjectURL(t);setTimeout(function(){r.href=y;r.download=u;a(r);h();c(y);v.readyState=v.DONE});return}S()},w=v.prototype,m=function(e,t,n){return new v(e,t||e.name||"download",n)};if(typeof navigator!=="undefined"&&navigator.msSaveOrOpenBlob){return function(e,t,n){t=t||e.name||"download";if(!n){e=p(e)}return navigator.msSaveOrOpenBlob(e,t)}}w.abort=function(){};w.readyState=w.INIT=0;w.WRITING=1;w.DONE=2;w.error=w.onwritestart=w.onprogress=w.onwrite=w.onabort=w.onerror=w.onwriteend=null;return m}(typeof self!=="undefined"&&self||typeof window!=="undefined"&&window||this.content);if(typeof module!=="undefined"&&module.exports){module.exports.saveAs=saveAs}else if(typeof define!=="undefined"&&define!==null&&define.amd!==null){define("FileSaver.js",function(){return saveAs})}
|
||||
</script>
|
||||
|
||||
|
||||
<script src="../ics.js"></script>
|
||||
|
||||
<script type="text/javascript">
|
||||
// Demo
|
||||
var cal = ics();
|
||||
cal.addEvent('Christmas', 'Christian holiday celebrating the birth of Jesus Christ', 'Bethlehem', '12/25/2013', '12/25/2013');
|
||||
cal.addEvent('Christmas', 'Christian holiday celebrating the birth of Jesus Christ', 'Bethlehem', '12/25/2014', '12/25/2014');
|
||||
cal.addEvent('New Years', 'Watch the ball drop!', 'New York', '01/01/2015', '01/01/2015');
|
||||
cal.addEvent('New Years', 'Watch the ball drop!', 'New York', '01/01/2016', '01/01/2016');
|
||||
|
||||
var cal_single = ics();
|
||||
cal_single.addEvent('Best Day', 'This is the best day to demonstrate a single event.', 'New York', '11/12/1987', '11/12/1987');
|
||||
|
||||
|
||||
// You can use this for easy debugging
|
||||
var makelogs = function(obj) {
|
||||
console.log('Events Array');
|
||||
console.log('=================');
|
||||
console.log(obj.events());
|
||||
console.log('Calendar With Header');
|
||||
console.log('=================');
|
||||
console.log(obj.calendar());
|
||||
}
|
||||
</script>
|
||||
</html>
|
||||
|
||||
@@ -47,7 +47,7 @@ var ics = function(uidDomain, prodId) {
|
||||
* @param {string} begin Beginning date of event
|
||||
* @param {string} stop Ending date of event
|
||||
*/
|
||||
'addEvent': function(subject, description, location, begin, stop, rule) {
|
||||
'addEvent': function(subject, description, location, begin, stop, rrule) {
|
||||
// I'm not in the mood to make these optional... So they are all required
|
||||
if (typeof subject === 'undefined' ||
|
||||
typeof description === 'undefined' ||
|
||||
@@ -58,48 +58,48 @@ var ics = function(uidDomain, prodId) {
|
||||
return false;
|
||||
}
|
||||
|
||||
// validate rule
|
||||
if (rule) {
|
||||
if (!rule.rule) {
|
||||
if (rule.freq !== 'YEARLY' && rule.freq !== 'MONTHLY' && rule.freq !== 'WEEKLY' && rule.freq !== 'DAILY') {
|
||||
throw "Recurrence rule frequency must be provided and be one of the following: 'YEARLY', 'MONTHLY', 'WEEKLY', or 'DAILY'";
|
||||
// validate rrule
|
||||
if (rrule) {
|
||||
if (!rrule.rrule) {
|
||||
if (rrule.freq !== 'YEARLY' && rrule.freq !== 'MONTHLY' && rrule.freq !== 'WEEKLY' && rrule.freq !== 'DAILY') {
|
||||
throw "Recurrence rrule frequency must be provided and be one of the following: 'YEARLY', 'MONTHLY', 'WEEKLY', or 'DAILY'";
|
||||
}
|
||||
|
||||
if (rule.until) {
|
||||
if (isNaN(Date.parse(rule.until))) {
|
||||
throw "Recurrence rule 'until' must be a valid date string";
|
||||
if (rrule.until) {
|
||||
if (isNaN(Date.parse(rrule.until))) {
|
||||
throw "Recurrence rrule 'until' must be a valid date string";
|
||||
}
|
||||
}
|
||||
|
||||
if (rule.interval) {
|
||||
if (isNaN(parseInt(rule.interval))) {
|
||||
throw "Recurrence rule 'interval' must be an integer";
|
||||
if (rrule.interval) {
|
||||
if (isNaN(parseInt(rrule.interval))) {
|
||||
throw "Recurrence rrule 'interval' must be an integer";
|
||||
}
|
||||
}
|
||||
|
||||
if (rule.count) {
|
||||
if (isNaN(parseInt(rule.count))) {
|
||||
throw "Recurrence rule 'count' must be an integer";
|
||||
if (rrule.count) {
|
||||
if (isNaN(parseInt(rrule.count))) {
|
||||
throw "Recurrence rrule 'count' must be an integer";
|
||||
}
|
||||
}
|
||||
|
||||
if (typeof rule.byday !== 'undefined') {
|
||||
if ((Object.prototype.toString.call(rule.byday) !== '[object Array]')) {
|
||||
throw "Recurrence rule 'byday' must be an array";
|
||||
if (typeof rrule.byday !== 'undefined') {
|
||||
if ((Object.prototype.toString.call(rrule.byday) !== '[object Array]')) {
|
||||
throw "Recurrence rrule 'byday' must be an array";
|
||||
}
|
||||
|
||||
if (rule.byday.length > 7) {
|
||||
throw "Recurrence rule 'byday' array must not be longer than the 7 days in a week";
|
||||
if (rrule.byday.length > 7) {
|
||||
throw "Recurrence rrule 'byday' array must not be longer than the 7 days in a week";
|
||||
}
|
||||
|
||||
// Filter any possible repeats
|
||||
rule.byday = rule.byday.filter(function(elem, pos) {
|
||||
return rule.byday.indexOf(elem) == pos;
|
||||
rrule.byday = rrule.byday.filter(function(elem, pos) {
|
||||
return rrule.byday.indexOf(elem) == pos;
|
||||
});
|
||||
|
||||
for (var d in rule.byday) {
|
||||
if (BYDAY_VALUES.indexOf(rule.byday[d]) < 0) {
|
||||
throw "Recurrence rule 'byday' values must include only the following: 'SU', 'MO', 'TU', 'WE', 'TH', 'FR', 'SA'";
|
||||
for (var d in rrule.byday) {
|
||||
if (BYDAY_VALUES.indexOf(rrule.byday[d]) < 0) {
|
||||
throw "Recurrence rrule 'byday' values must include only the following: 'SU', 'MO', 'TU', 'WE', 'TH', 'FR', 'SA'";
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -145,29 +145,29 @@ var ics = function(uidDomain, prodId) {
|
||||
var end = end_year + end_month + end_day + end_time;
|
||||
var now = now_year + now_month + now_day + now_time;
|
||||
|
||||
// recurrence rule vars
|
||||
var ruleString;
|
||||
if (rule) {
|
||||
if (rule.rule) {
|
||||
ruleString = rule.rule;
|
||||
// recurrence rrule vars
|
||||
var rruleString;
|
||||
if (rrule) {
|
||||
if (rrule.rrule) {
|
||||
rruleString = rrule.rrule;
|
||||
} else {
|
||||
ruleString = 'rule:FREQ=' + rule.freq;
|
||||
rruleString = 'rrule:FREQ=' + rrule.freq;
|
||||
|
||||
if (rule.until) {
|
||||
var uDate = new Date(Date.parse(rule.until)).toISOString();
|
||||
ruleString += ';UNTIL=' + uDate.substring(0, uDate.length - 13).replace(/[-]/g, '') + '000000Z';
|
||||
if (rrule.until) {
|
||||
var uDate = new Date(Date.parse(rrule.until)).toISOString();
|
||||
rruleString += ';UNTIL=' + uDate.substring(0, uDate.length - 13).replace(/[-]/g, '') + '000000Z';
|
||||
}
|
||||
|
||||
if (rule.interval) {
|
||||
ruleString += ';INTERVAL=' + rule.interval;
|
||||
if (rrule.interval) {
|
||||
rruleString += ';INTERVAL=' + rrule.interval;
|
||||
}
|
||||
|
||||
if (rule.count) {
|
||||
ruleString += ';COUNT=' + rule.count;
|
||||
if (rrule.count) {
|
||||
rruleString += ';COUNT=' + rrule.count;
|
||||
}
|
||||
|
||||
if (rule.byday && rule.byday.length > 0) {
|
||||
ruleString += ';BYDAY=' + rule.byday.join(',');
|
||||
if (rrule.byday && rrule.byday.length > 0) {
|
||||
rruleString += ';BYDAY=' + rrule.byday.join(',');
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -188,8 +188,8 @@ var ics = function(uidDomain, prodId) {
|
||||
'END:VEVENT'
|
||||
];
|
||||
|
||||
if (ruleString) {
|
||||
calendarEvent.splice(4, 0, ruleString);
|
||||
if (rruleString) {
|
||||
calendarEvent.splice(4, 0, rruleString);
|
||||
}
|
||||
|
||||
calendarEvent = calendarEvent.join(SEPARATOR);
|
||||
|
||||
Reference in New Issue
Block a user