remove clone from visible attribute

This commit is contained in:
Klemek
2022-01-14 20:15:52 +01:00
parent eea9f652bc
commit 9e56878b11
+6 -6
View File
@@ -59,8 +59,8 @@ Date.prototype.formatSimple = function() {
return `${this.getFullYear()}-${('00' + (this.getMonth() + 1)).substr(-2)}-${('00' + this.getDate()).substr(-2)}`;
};
Object.prototype.clone = function() {
return JSON.parse(JSON.stringify(this));
const cloneObject = function(obj) {
return JSON.parse(JSON.stringify(obj));
};
const COLOR_PALETTE = [
@@ -133,7 +133,7 @@ const deserialize = function(rawData) {
text: subData2[3],
};
}),
newPeriod: NEW_PERIOD.clone(),
newPeriod: cloneObject(NEW_PERIOD),
};
}),
};
@@ -246,7 +246,7 @@ let app = {
},
addEvent() {
if (this.newEvent.color && this.newEvent.text && this.newEvent.date) {
this.events.push(this.newEvent.clone());
this.events.push(cloneObject(this.newEvent));
}
},
deleteView(viewIndex) {
@@ -256,7 +256,7 @@ let app = {
this.views.push({
name: 'New View',
periods: [],
newPeriod: NEW_PERIOD.clone(),
newPeriod: cloneObject(NEW_PERIOD),
});
},
deletePeriod(viewIndex, periodIndex) {
@@ -264,7 +264,7 @@ let app = {
},
addPeriod(viewIndex) {
if (this.views[viewIndex].newPeriod.color && this.views[viewIndex].newPeriod.text && this.views[viewIndex].newPeriod.startDate) {
this.views[viewIndex].periods.push(this.views[viewIndex].newPeriod.clone());
this.views[viewIndex].periods.push(cloneObject(this.views[viewIndex].newPeriod));
this.views[viewIndex].newPeriod.startDate = this.views[viewIndex].newPeriod.endDate;
this.views[viewIndex].newPeriod.endDate = '';
}