- Noch keine Dienste da
+ Noch keine Termine da
diff --git a/js/shift.js b/js/shift.js
index 11ffdd8..d0230a3 100644
--- a/js/shift.js
+++ b/js/shift.js
@@ -88,15 +88,42 @@ Rule.defaults = function () {
}
var DURATION_RULES = Rule.defaults();
-function Shift(kind, name, date, info) {
- 'use strict';
- this.Datum = date.format(DATE_INPUT_FORMAT);
- this.Beginn = date.format(TIME_FORMAT);
- this.Art = kind;
- this.Beschreibung = info;
- this.Name = name;
- Shift.setDurationFromRules(this);
+function Shift() {
+ var evt = window.event || arguments[1] || arguments.callee.caller.arguments[0];
+ var target = evt.target || evt.srcElement;
+
+ var options = {};
+
+ if (arguments[0]) options = arguments[0];
+
+ var default_args = {
+ 'art' : "",
+ 'name' : "DUMMY",
+ 'datum' : moment(),
+ 'beschreibung' : "",
+ 'ort' : "",
+ }
+ for (var index in default_args) {
+ if (typeof options[index] == "undefined") options[index] = default_args[index];
+ }
+
+ this.Datum = options.datum.format(DATE_INPUT_FORMAT);
+ this.Beginn = options.datum.format(TIME_FORMAT);
+ this.Art = options.art;
+ this.Beschreibung = options.beschreibung;
+ this.Name = options.name;
+ this.Ort = options.ort;
+
+ if (typeof options.ende != "undefined") {
+ this.Ende = options.ende;
+ } else {
+ if (!options.dontSetDurationFromRules) {
+ Shift.setDurationFromRules(this);
+ }
+ }
+
}
+
Shift.prototype = {
get Wochentag() {
return this._date.clone().locale(MOMENT_LOCALE).format(WEEKDAY_FORMAT);
@@ -153,6 +180,13 @@ Shift.prototype = {
this._name = value ? value.trim() : "";
},
+ get Ort() {
+ return this._ort;
+ },
+ set Ort(value) {
+ this._ort = value ? value.trim() : "";
+ },
+
get VEventTitle() {
return this.Name + " " + this.Art;
},
@@ -197,15 +231,25 @@ Shift.setDurationFromRules = function (shift) {
shift.Dauer = moment.duration(duration, 'm').locale(MOMENT_LOCALE);
}
Shift.prototype.toVEvent = function () {
- 'use strict';
var end = this._begin.clone().add(this._duration);
- return new VEvent(TIMEZONE_NAME, this._begin, end, this.VEventTitle, this.Beschreibung);
+ return new VEvent({
+ startMoment: this._begin,
+ endMoment: end,
+ title: this.VEventTitle,
+ description: this.Beschreibung,
+ location: this.Ort
+ });
};
Shift.thaw = function (jsonShift) {
- 'use strict';
moment.locale(MOMENT_LOCALE);
var begin = moment(jsonShift._begin);
- var shift = new Shift(jsonShift._kind, jsonShift._name, begin, jsonShift._description);
+ var shift = new Shift(
+ {
+ art: jsonShift._kind,
+ name: jsonShift._name,
+ datum: begin,
+ beschreibung: jsonShift._description
+ });
shift.id = jsonShift.id;
shift.Dauer = moment.duration(jsonShift._duration);
return shift;
diff --git a/js/vcal.js b/js/vcal.js
index 1fb0b4a..b8e4c78 100644
--- a/js/vcal.js
+++ b/js/vcal.js
@@ -72,21 +72,46 @@ function VCalendar(calendarName) {
VCalendar.prototype = Object.create(VMeta.prototype);
VCalendar.prototype.constructor = VCalendar;
-function VEvent(timezoneName, startMoment, endMoment, title, description) {
+function VEvent() {
+ var evt = window.event || arguments[1] || arguments.callee.caller.arguments[0];
+ var target = evt.target || evt.srcElement;
+
+ var options = {};
+
+ if (arguments[0]) options = arguments[0];
+
+ var default_args = {
+ 'tzName' : "Europe/Berlin",
+ 'startMoment' : moment(),
+ 'endMoment' : moment(),
+ 'uid' : VMeta.generateUID(),
+ 'dtStamp' : VMeta.formatDate(moment()) + "Z",
+ 'title' : "",
+ 'description' : "",
+ 'location' : "",
+ 'organizer' : "",
+
+ }
+ for (var index in default_args) {
+ if (typeof options[index] == "undefined") options[index] = default_args[index];
+ }
+
VMeta.call(this);
this.tag = "VEVENT";
- this.set('DTSTART;TZID=' + timezoneName, VMeta.formatDate(startMoment));
- this.set('DTEND;TZID=' + timezoneName, VMeta.formatDate(endMoment));
- this.set('DTSTAMP', VMeta.formatDate(moment()) + "Z");
- this.set('UID', VMeta.generateUID());
- this.set('SUMMARY', title);
- this.set('DESCRIPTION', description);
+ this.set('DTSTART;TZID=' + options.tzName, VMeta.formatDate(options.startMoment));
+ this.set('DTEND;TZID=' + options.tzName, VMeta.formatDate(options.endMoment));
+ this.set('DTSTAMP', options.dtStamp);
+ this.set('UID', options.uid);
+ this.set('SUMMARY', options.title);
+ this.set('DESCRIPTION', options.description);
+ this.set('LOCATION', options.location)
this.set('CLASS', "PUBLIC");
this.set('TRANSP', "OPAQUE");
this.set('STATUS', "CONFIRMED");
- this.set('ORGANIZER', "");
+ this.set('ORGANIZER', options.organizer);
}
+
VEvent.prototype = Object.create(VMeta.prototype);
VEvent.prototype.constructor = VEvent;