Skip to content

Commit

Permalink
Fixed Event Adding Issue
Browse files Browse the repository at this point in the history
  • Loading branch information
AsifulNobel committed Aug 6, 2018
1 parent a3d851a commit 8dee49c
Showing 1 changed file with 20 additions and 23 deletions.
43 changes: 20 additions & 23 deletions js/directive.js
Original file line number Diff line number Diff line change
Expand Up @@ -170,30 +170,27 @@ function saveEvent() {

if (eventName[0].value.length > 0 && regex.test(eventName[0].value)) {
if (eventDateObj - Date.now() > 0) {

storage.get('events', function(items) {
if (typeof items.events !== "undefined") {
var eventDict = items.events

if (eventDict[eventName[0].value])
eventDict[eventName[0].value][0] = eventDateObj.toUTCString()
else
eventDict[eventName[0].value] = [eventDateObj.toUTCString(), startDate.toUTCString()]

storage.set({events: eventDict}, function() {
timersList.insertAdjacentHTML('beforeend',
'<li id="'+ eventName[0].value + '">' + eventName[0].value + ': ' +
replaceTimezone(eventDateObj.toUTCString()) +
'<i class="fa fa-pencil-square-o edit-ev"></i><i class="fa fa-times delete-ev"></i>'
+ '</li>')

console.log("Successfully Added Event!");
});

clearError();
updateEvent();
window.location.reload();
}
var eventDict = items.hasOwnProperty('events') ? items.events : {};

if (eventDict.hasOwnProperty(eventName[0].value))
eventDict[eventName[0].value][0] = eventDateObj.toUTCString()
else
eventDict[eventName[0].value] = [eventDateObj.toUTCString(), startDate.toUTCString()]

storage.set({events: eventDict}, function() {
timersList.insertAdjacentHTML('beforeend',
'<li id="'+ eventName[0].value + '">' + eventName[0].value + ': ' +
replaceTimezone(eventDateObj.toUTCString()) +
'<i class="fa fa-pencil-square-o edit-ev"></i><i class="fa fa-times delete-ev"></i>'
+ '</li>')

console.log("Successfully Added Event!");
});

clearError();
updateEvent();
window.location.reload();
})
}
else {
Expand Down

0 comments on commit 8dee49c

Please sign in to comment.