Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixed ics button doesn't work in chrome, added gulp for minifying #28

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
node_modules
12 changes: 12 additions & 0 deletions gulpfile.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
const gulp = require('gulp');
const uglify = require('gulp-uglify');
const rename = require('gulp-rename');

gulp.task('default', function () {
return gulp.src('ouical.js')
.pipe(uglify())
.pipe(rename(function (path) {
path.basename += '.min';
}))
.pipe(gulp.dest('./'))
});
29 changes: 18 additions & 11 deletions ouical.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,16 +35,23 @@
((event.end.getTime() - event.start.getTime())/ MS_IN_MINUTES) :
event.duration;

// Yahoo dates are crazy, we need to convert the duration from minutes to hh:mm
var yahooHourDuration = eventDuration < 600 ?
'0' + Math.floor((eventDuration / 60)) :
Math.floor((eventDuration / 60)) + '';

var yahooMinuteDuration = eventDuration % 60 < 10 ?
'0' + eventDuration % 60 :
eventDuration % 60 + '';

var yahooEventDuration = yahooHourDuration + yahooMinuteDuration;
if (event.allday)
{
var yahooEventDuration = 'allday';
}
else
{
// Yahoo dates are crazy, we need to convert the duration from minutes to hh:mm
var yahooHourDuration = eventDuration < 600 ?
'0' + Math.floor((eventDuration / 60)) :
Math.floor((eventDuration / 60)) + '';

var yahooMinuteDuration = eventDuration % 60 < 10 ?
'0' + eventDuration % 60 :
eventDuration % 60 + '';

var yahooEventDuration = yahooHourDuration + yahooMinuteDuration;
}

// Remove timezone from event time
var st = formatTime(new Date(event.start - (event.start.getTimezoneOffset() *
Expand Down Expand Up @@ -81,7 +88,7 @@
'END:VEVENT',
'END:VCALENDAR'].join('\n'));

return '<a class="' + eClass + '" target="_blank" href="' +
return '<a class="' + eClass + '" download href="' +
href + '">' + calendarName + ' Calendar</a>';
},

Expand Down
2 changes: 1 addition & 1 deletion ouical.min.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

24 changes: 24 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
{
"name": "add-to-calendar-buttons",
"version": "1.0.0",
"description": "Generate add to calendar buttons",
"main": "ouical.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
},
"repository": {
"type": "git",
"url": "git+https://github.com/carlsednaoui/add-to-calendar-buttons.git"
},
"author": "Carl Sednaoui",
"license": "MIT",
"bugs": {
"url": "https://github.com/carlsednaoui/add-to-calendar-buttons/issues"
},
"homepage": "https://github.com/carlsednaoui/add-to-calendar-buttons#readme",
"devDependencies": {
"gulp": "^3.9.1",
"gulp-rename": "^1.4.0",
"gulp-uglify": "^3.0.1"
}
}