mirror of
https://github.com/zombieFox/nightTab.git
synced 2024-12-27 00:59:00 +01:00
[refactor] improve bookmark edit function
This commit is contained in:
parent
f96f3552ea
commit
e87a00453b
@ -188,10 +188,17 @@ var bookmarks = (function() {
|
||||
all.push(newBookmark);
|
||||
};
|
||||
|
||||
var edit = function(object, timeStamp) {
|
||||
var edit = function(override) {
|
||||
var options = {
|
||||
bookmarkData: null,
|
||||
timeStamp: null
|
||||
};
|
||||
if (override) {
|
||||
options = helper.applyOptions(options, override);
|
||||
};
|
||||
for (var i = 0; i < all.length; i++) {
|
||||
if (all[i].timeStamp === timeStamp) {
|
||||
all[i] = object;
|
||||
if (all[i].timeStamp === options.timeStamp) {
|
||||
all[i] = options.bookmarkData;
|
||||
};
|
||||
};
|
||||
};
|
||||
|
@ -90,7 +90,10 @@ var link = (function() {
|
||||
options.bookmarkData.letter = options.form.querySelector(".link-form-input-letter").value;
|
||||
options.bookmarkData.name = options.form.querySelector(".link-form-input-name").value;
|
||||
options.bookmarkData.url = options.form.querySelector(".link-form-input-url").value;
|
||||
bookmarks.edit(options.bookmarkData, options.bookmarkData.timeStamp);
|
||||
bookmarks.edit({
|
||||
bookmarkData: options.bookmarkData,
|
||||
timeStamp: options.bookmarkData.timeStamp
|
||||
});
|
||||
}
|
||||
};
|
||||
action[options.action]();
|
||||
|
Loading…
Reference in New Issue
Block a user