Skip to content

Commit 8f73fd1

Browse files
committed
Fixes for "Create" function
1 parent 9a72971 commit 8f73fd1

2 files changed

Lines changed: 30 additions & 18 deletions

File tree

popup.js

Lines changed: 15 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -138,7 +138,7 @@ function update(container) {
138138
var has_tasks = false;
139139

140140
for (var key in item) {
141-
if (item[key].type === 'switch') {
141+
if (item[key].hasOwnProperty('type')) {
142142
has_tasks = true;
143143
}
144144
}
@@ -227,24 +227,30 @@ function create() {
227227

228228
Satus.storage.set('data', JSON.stringify(data));
229229

230-
data[folder_key][task_key] = {
230+
history_item[task_key] = {
231231
type: 'section',
232232

233-
folder: {
234-
type: 'folder',
233+
switch: {
234+
type: 'switch',
235235
class: 'satus-switch--checkbox',
236236
label: value,
237-
before: '<svg width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="feather feather-folder"><path d="M22 19a2 2 0 0 1-2 2H4a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h5l2 3h9a2 2 0 0 1 2 2z"></path></svg>',
238237
storage_key: task_key
238+
},
239+
240+
button: {
241+
type: 'button',
242+
class: 'satus-button--remove',
243+
before: '<svg width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.75" stroke-linecap="round" stroke-linejoin="round"><line x1="18" y1="6" x2="6" y2="18"></line><line x1="6" y1="6" x2="18" y2="18"></line></svg>',
244+
onclick: remove
239245
}
240246
};
241247

242-
for (var i = document.querySelectorAll('body > *:not(script)').length - 1; i > -1; i++) {
243-
document.querySelectorAll('body > *:not(script)')[i].remove();
244-
}
248+
document.querySelector('.satus-scrollbar__content').innerHTML = '';
245249

246-
//Satus.render(Menu, document.body);
250+
update();
247251
}
252+
253+
document.querySelector('.satus-dialog__scrim').click();
248254
}
249255
var Menu = {
250256
header: {

src/js/functions.js

Lines changed: 15 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -137,7 +137,7 @@ function update(container) {
137137
var has_tasks = false;
138138

139139
for (var key in item) {
140-
if (item[key].type === 'switch') {
140+
if (item[key].hasOwnProperty('type')) {
141141
has_tasks = true;
142142
}
143143
}
@@ -226,22 +226,28 @@ function create() {
226226

227227
Satus.storage.set('data', JSON.stringify(data));
228228

229-
data[folder_key][task_key] = {
229+
history_item[task_key] = {
230230
type: 'section',
231231

232-
folder: {
233-
type: 'folder',
232+
switch: {
233+
type: 'switch',
234234
class: 'satus-switch--checkbox',
235235
label: value,
236-
before: '<svg width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="feather feather-folder"><path d="M22 19a2 2 0 0 1-2 2H4a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h5l2 3h9a2 2 0 0 1 2 2z"></path></svg>',
237236
storage_key: task_key
237+
},
238+
239+
button: {
240+
type: 'button',
241+
class: 'satus-button--remove',
242+
before: '<svg width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.75" stroke-linecap="round" stroke-linejoin="round"><line x1="18" y1="6" x2="6" y2="18"></line><line x1="6" y1="6" x2="18" y2="18"></line></svg>',
243+
onclick: remove
238244
}
239245
};
240246

241-
for (var i = document.querySelectorAll('body > *:not(script)').length - 1; i > -1; i++) {
242-
document.querySelectorAll('body > *:not(script)')[i].remove();
243-
}
247+
document.querySelector('.satus-scrollbar__content').innerHTML = '';
244248

245-
//Satus.render(Menu, document.body);
249+
update();
246250
}
251+
252+
document.querySelector('.satus-dialog__scrim').click();
247253
}

0 commit comments

Comments
 (0)