Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/PhieF/CarnetElectron.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/utils
diff options
context:
space:
mode:
authorPhie <phie@phie.ovh>2019-04-08 01:32:04 +0300
committerPhie <phie@phie.ovh>2019-04-08 01:32:04 +0300
commit7dadc1d5502d05197fd27dcd23ef6a165e44011d (patch)
tree112041632515014c4c310c008dd430a7b51eb2e1 /utils
parent9fe1557b9b2ae6650a311d130cff7cabe3161f2d (diff)
sort-by option + moving settingshelper + cleaning
Diffstat (limited to 'utils')
-rw-r--r--utils/utils.js46
1 files changed, 46 insertions, 0 deletions
diff --git a/utils/utils.js b/utils/utils.js
index 5b830cf..c28443f 100644
--- a/utils/utils.js
+++ b/utils/utils.js
@@ -11,6 +11,52 @@ Utils.caseInsensitiveSrt = function (a, b) {
return a.toLowerCase().localeCompare(b.toLowerCase());
}
+Utils.sortByDefault = function (a, b) {
+ return a.originalIndex < b.originalIndex ? -1 : 1
+}
+
+Utils.sortByCreationDate = function (a, b) {
+ var dateA = a.metadata.last_modification_date
+ if (a.metadata.creation_date != undefined && a.metadata.creation_date !== "") {
+ dateA = a.metadata.creation_date
+ }
+ var dateB = b.metadata.last_modification_date
+ if (b.metadata.creation_date != undefined && b.metadata.creation_date !== "") {
+ dateB = b.metadata.creation_date
+ }
+ return dateA < dateB ? -1 : 1
+}
+
+Utils.sortByCustomDate = function (a, b) {
+ var dateA = a.metadata.custom_date
+ if (dateA == undefined || dateA == "") {
+ dateA = a.metadata.creation_date
+ }
+ if (dateA == undefined || dateA == "") {
+ dateA = a.metadata.last_modification_date
+ }
+ var dateB = b.metadata.custom_date
+ if (dateB == undefined) {
+ dateB = b.metadata.creation_date
+ }
+ if (dateB == undefined) {
+ dateB = b.metadata.last_modification_date
+ }
+ return dateA < dateB ? -1 : 1
+}
+
+Utils.sortByModificationDate = function (a, b) {
+ var dateA = a.metadata.creation_date
+ if (a.metadata.last_modification_date != undefined) {
+ dateA = a.metadata.last_modification_date
+ }
+ var dateB = b.metadata.creation_date
+ if (b.metadata.last_modification_date != undefined) {
+ dateB = b.metadata.last_modification_date
+ }
+ return dateA < dateB ? -1 : 1
+}
+
Utils.httpReg = /(?:(?:https?|ftp|file):\/\/|www\.|ftp\.)(?:\([-A-Z0-9+&@#\/%=~_|$?!:,.]*\)|[-A-Z0-9+&@#\/%=~_|$?!:,.])*(?:\([-A-Z0-9+&@#\/%=~_|$?!:,.]*\)|[A-Z0-9+&@#\/%=~_|$])/igm