2018-12-26 08:45:53 +01:00
|
|
|
var bookmarks = (function() {
|
|
|
|
|
|
|
|
var all = [{
|
2019-05-11 09:33:19 +02:00
|
|
|
display: "icon",
|
2018-12-28 14:21:16 +01:00
|
|
|
letter: "DEV",
|
2019-05-11 09:33:19 +02:00
|
|
|
icon: {
|
|
|
|
name: "code",
|
|
|
|
prefix: "fas",
|
|
|
|
label: "Code"
|
|
|
|
},
|
2018-12-26 08:45:53 +01:00
|
|
|
name: "Devdocs",
|
2019-01-03 23:30:27 +01:00
|
|
|
url: "http://devdocs.io/",
|
2019-05-04 14:53:18 +02:00
|
|
|
accent: {
|
|
|
|
override: false,
|
|
|
|
color: {
|
|
|
|
r: null,
|
|
|
|
g: null,
|
|
|
|
b: null
|
|
|
|
}
|
|
|
|
},
|
2019-01-03 23:30:27 +01:00
|
|
|
timeStamp: 1546453101749
|
2018-12-26 08:45:53 +01:00
|
|
|
}, {
|
2019-05-11 09:33:19 +02:00
|
|
|
display: "icon",
|
2019-01-03 23:30:27 +01:00
|
|
|
letter: "AS",
|
2019-05-11 09:33:19 +02:00
|
|
|
icon: {
|
|
|
|
name: "dice-d20",
|
|
|
|
prefix: "fas",
|
|
|
|
label: "Dice D20"
|
|
|
|
},
|
2019-01-03 23:30:27 +01:00
|
|
|
name: "awesomeSheet",
|
|
|
|
url: "https://zombiefox.github.io/awesomeSheet/",
|
2019-05-04 14:53:18 +02:00
|
|
|
accent: {
|
|
|
|
override: false,
|
|
|
|
color: {
|
|
|
|
r: null,
|
|
|
|
g: null,
|
|
|
|
b: null
|
|
|
|
}
|
|
|
|
},
|
2019-01-03 23:30:27 +01:00
|
|
|
timeStamp: 1546453104010
|
2018-12-26 08:45:53 +01:00
|
|
|
}, {
|
2019-05-11 09:33:19 +02:00
|
|
|
display: "icon",
|
2018-12-28 14:21:16 +01:00
|
|
|
letter: "N",
|
2019-05-11 09:33:19 +02:00
|
|
|
icon: {
|
|
|
|
name: "film",
|
|
|
|
prefix: "fas",
|
|
|
|
label: "Film"
|
|
|
|
},
|
2018-12-26 08:45:53 +01:00
|
|
|
name: "Netflix",
|
2019-01-03 23:30:27 +01:00
|
|
|
url: "https://www.netflix.com/",
|
2019-05-04 14:53:18 +02:00
|
|
|
accent: {
|
|
|
|
override: false,
|
|
|
|
color: {
|
|
|
|
r: null,
|
|
|
|
g: null,
|
|
|
|
b: null
|
|
|
|
}
|
|
|
|
},
|
2019-01-03 23:30:27 +01:00
|
|
|
timeStamp: 1546453104460
|
|
|
|
}, {
|
2019-05-11 09:33:19 +02:00
|
|
|
display: "icon",
|
2019-01-03 23:30:27 +01:00
|
|
|
letter: "AZ",
|
2019-05-11 09:33:19 +02:00
|
|
|
icon: {
|
|
|
|
name: "amazon",
|
|
|
|
prefix: "fab",
|
|
|
|
label: "Amazon"
|
|
|
|
},
|
2019-01-03 23:30:27 +01:00
|
|
|
name: "Amazon",
|
|
|
|
url: "https://www.amazon.co.uk/",
|
2019-05-04 14:53:18 +02:00
|
|
|
accent: {
|
2019-05-23 20:15:14 +02:00
|
|
|
override: true,
|
2019-05-04 14:53:18 +02:00
|
|
|
color: {
|
2019-05-23 20:15:14 +02:00
|
|
|
r: 255,
|
|
|
|
g: 168,
|
|
|
|
b: 0
|
2019-05-04 14:53:18 +02:00
|
|
|
}
|
|
|
|
},
|
2019-01-03 23:30:27 +01:00
|
|
|
timeStamp: 1546453107633
|
2018-12-26 08:45:53 +01:00
|
|
|
}, {
|
2019-05-11 09:33:19 +02:00
|
|
|
display: "icon",
|
2018-12-28 14:21:16 +01:00
|
|
|
letter: "YT",
|
2019-05-11 09:33:19 +02:00
|
|
|
icon: {
|
|
|
|
name: "youtube",
|
|
|
|
prefix: "fab",
|
|
|
|
label: "YouTube"
|
|
|
|
},
|
2018-12-26 08:45:53 +01:00
|
|
|
name: "Youtube",
|
2019-01-03 23:30:27 +01:00
|
|
|
url: "https://www.youtube.com/",
|
2019-05-04 14:53:18 +02:00
|
|
|
accent: {
|
|
|
|
override: false,
|
|
|
|
color: {
|
|
|
|
r: null,
|
|
|
|
g: null,
|
|
|
|
b: null
|
|
|
|
}
|
|
|
|
},
|
2019-01-03 23:30:27 +01:00
|
|
|
timeStamp: 1546453108071
|
|
|
|
}, {
|
2019-05-11 09:33:19 +02:00
|
|
|
display: "icon",
|
2019-01-03 23:30:27 +01:00
|
|
|
letter: "GIT",
|
2019-05-11 09:33:19 +02:00
|
|
|
icon: {
|
|
|
|
name: "github",
|
|
|
|
prefix: "fab",
|
|
|
|
label: "GitHub"
|
|
|
|
},
|
2019-01-03 23:30:27 +01:00
|
|
|
name: "Github",
|
2019-01-05 23:38:54 +01:00
|
|
|
url: "https://github.com/",
|
2019-05-04 14:53:18 +02:00
|
|
|
accent: {
|
|
|
|
override: false,
|
|
|
|
color: {
|
|
|
|
r: null,
|
|
|
|
g: null,
|
|
|
|
b: null
|
|
|
|
}
|
|
|
|
},
|
2019-01-03 23:30:27 +01:00
|
|
|
timeStamp: 1546453108926
|
|
|
|
}, {
|
2019-05-11 09:33:19 +02:00
|
|
|
display: "icon",
|
2019-01-03 23:30:27 +01:00
|
|
|
letter: "GM",
|
2019-05-11 09:33:19 +02:00
|
|
|
icon: {
|
|
|
|
name: "envelope",
|
|
|
|
prefix: "fas",
|
|
|
|
label: "Envelope"
|
|
|
|
},
|
2019-01-03 23:30:27 +01:00
|
|
|
name: "Gmail",
|
|
|
|
url: "https://mail.google.com/",
|
2019-05-04 14:53:18 +02:00
|
|
|
accent: {
|
|
|
|
override: false,
|
|
|
|
color: {
|
|
|
|
r: null,
|
|
|
|
g: null,
|
|
|
|
b: null
|
|
|
|
}
|
|
|
|
},
|
2019-01-03 23:30:27 +01:00
|
|
|
timeStamp: 1546453110265
|
|
|
|
}, {
|
2019-05-11 09:33:19 +02:00
|
|
|
display: "icon",
|
2019-01-03 23:30:27 +01:00
|
|
|
letter: "R",
|
2019-05-11 09:33:19 +02:00
|
|
|
icon: {
|
|
|
|
name: "reddit-alien",
|
|
|
|
prefix: "fab",
|
|
|
|
label: "reddit Alien"
|
|
|
|
},
|
2019-01-03 23:30:27 +01:00
|
|
|
name: "Reddit",
|
|
|
|
url: "https://www.reddit.com/",
|
2019-05-04 14:53:18 +02:00
|
|
|
accent: {
|
2019-05-23 20:15:14 +02:00
|
|
|
override: true,
|
2019-05-04 14:53:18 +02:00
|
|
|
color: {
|
2019-05-23 20:15:14 +02:00
|
|
|
r: 255,
|
|
|
|
g: 69,
|
|
|
|
b: 0
|
2019-05-04 14:53:18 +02:00
|
|
|
}
|
|
|
|
},
|
2019-01-03 23:30:27 +01:00
|
|
|
timeStamp: 1546453111491
|
|
|
|
}, {
|
2019-05-11 09:33:19 +02:00
|
|
|
display: "letter",
|
2019-01-03 23:30:27 +01:00
|
|
|
letter: "DR",
|
2019-05-11 09:33:19 +02:00
|
|
|
icon: {
|
|
|
|
name: null,
|
|
|
|
prefix: null,
|
|
|
|
label: null
|
|
|
|
},
|
2019-01-03 23:30:27 +01:00
|
|
|
name: "Drive",
|
|
|
|
url: "https://drive.google.com/drive/",
|
2019-05-04 14:53:18 +02:00
|
|
|
accent: {
|
|
|
|
override: false,
|
|
|
|
color: {
|
|
|
|
r: null,
|
|
|
|
g: null,
|
|
|
|
b: null
|
|
|
|
}
|
|
|
|
},
|
2019-01-03 23:30:27 +01:00
|
|
|
timeStamp: 1546453111953
|
2018-12-26 08:45:53 +01:00
|
|
|
}];
|
|
|
|
|
2019-05-11 09:33:19 +02:00
|
|
|
var get = function(data) {
|
2019-01-03 23:30:27 +01:00
|
|
|
var _singleBookmark = function() {
|
2019-01-13 23:54:48 +01:00
|
|
|
var found = false;
|
2019-01-03 23:30:27 +01:00
|
|
|
for (var i = 0; i < all.length; i++) {
|
2019-05-11 09:33:19 +02:00
|
|
|
if (all[i].timeStamp === data.timeStamp) {
|
2019-01-13 23:54:48 +01:00
|
|
|
found = all[i];
|
2019-01-03 23:30:27 +01:00
|
|
|
};
|
|
|
|
};
|
2019-01-13 23:54:48 +01:00
|
|
|
return found;
|
2019-01-03 23:30:27 +01:00
|
|
|
};
|
|
|
|
var _allBookmarks = function() {
|
2019-01-13 23:54:48 +01:00
|
|
|
var action = {
|
2019-01-03 23:30:27 +01:00
|
|
|
none: function(array) {
|
|
|
|
return helper.sortObject(array, "timeStamp");
|
|
|
|
},
|
|
|
|
name: function(array) {
|
|
|
|
return helper.sortObject(array, "name");
|
|
|
|
},
|
|
|
|
letter: function(array) {
|
|
|
|
return helper.sortObject(array, "letter");
|
2019-05-11 09:33:19 +02:00
|
|
|
},
|
|
|
|
icon: function(array) {
|
|
|
|
return helper.sortObject(array, "icon.name");
|
2019-01-03 23:30:27 +01:00
|
|
|
}
|
|
|
|
};
|
2019-05-23 20:15:14 +02:00
|
|
|
return action[state.get().link.sort](all);
|
2019-01-03 23:30:27 +01:00
|
|
|
};
|
2019-05-11 09:33:19 +02:00
|
|
|
if (data && typeof data.timeStamp == "number") {
|
|
|
|
return _singleBookmark();
|
2019-01-03 23:30:27 +01:00
|
|
|
} else {
|
|
|
|
return _allBookmarks();
|
|
|
|
};
|
2018-12-26 08:45:53 +01:00
|
|
|
};
|
|
|
|
|
2019-01-03 23:30:27 +01:00
|
|
|
var restore = function(data) {
|
|
|
|
if ("bookmarks" in data) {
|
|
|
|
all = data.bookmarks;
|
|
|
|
};
|
2018-12-26 08:45:53 +01:00
|
|
|
};
|
|
|
|
|
2019-05-11 09:33:19 +02:00
|
|
|
var add = function(data) {
|
|
|
|
all.push(data);
|
2018-12-26 08:45:53 +01:00
|
|
|
};
|
|
|
|
|
2019-05-11 09:33:19 +02:00
|
|
|
var edit = function(data) {
|
2019-01-03 23:30:27 +01:00
|
|
|
for (var i = 0; i < all.length; i++) {
|
2019-05-11 09:33:19 +02:00
|
|
|
if (all[i].timeStamp === data.timeStamp) {
|
|
|
|
all[i] = data;
|
2019-01-03 23:30:27 +01:00
|
|
|
};
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
2019-05-11 09:33:19 +02:00
|
|
|
var remove = function(data) {
|
2019-01-03 23:30:27 +01:00
|
|
|
for (var i = 0; i < all.length; i++) {
|
2019-05-11 09:33:19 +02:00
|
|
|
if (all[i].timeStamp === data.timeStamp) {
|
2019-01-03 23:30:27 +01:00
|
|
|
all.splice(all.indexOf(all[i]), 1);
|
|
|
|
};
|
|
|
|
};
|
2018-12-26 08:45:53 +01:00
|
|
|
};
|
|
|
|
|
2019-01-03 23:30:27 +01:00
|
|
|
var init = function() {
|
|
|
|
if (data.load()) {
|
|
|
|
restore(data.load());
|
2018-12-27 00:46:53 +01:00
|
|
|
};
|
2018-12-26 08:45:53 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
// exposed methods
|
|
|
|
return {
|
2019-01-03 23:30:27 +01:00
|
|
|
all: all,
|
|
|
|
init: init,
|
2018-12-26 08:45:53 +01:00
|
|
|
get: get,
|
|
|
|
add: add,
|
|
|
|
edit: edit,
|
2019-05-23 20:15:14 +02:00
|
|
|
remove: remove,
|
|
|
|
restore: restore
|
2018-12-26 08:45:53 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
})();
|