@pronto-tools-and-more/custom-js-functions 12.5.0 → 12.7.0
Sign up to get free protection for your applications and to get access to all the features.
- package/dist/main.js +40 -6
- package/package.json +1 -1
- package/src/parts/BookmarksKey/BookmarksKey.ts +1 -1
- package/src/parts/DisableBookmark/DisableBookmark.ts +16 -1
- package/src/parts/EnableBookmark/EnableBookmark.ts +3 -1
- package/src/parts/FunctionBookmarkIdString/FunctionBookmarkIdString.ts +3 -0
- package/src/parts/FunctionDebugId/FunctionDebugId.ts +1 -1
- package/src/parts/FunctionId/FunctionId.ts +1 -1
- package/src/parts/Functions/Functions.ts +1 -0
- package/src/parts/ToggleBookmarkArticle/ToggleBookmarkArticle.ts +12 -1
package/dist/main.js
CHANGED
@@ -405,6 +405,7 @@
|
|
405
405
|
// src/parts/Functions/Functions.ts
|
406
406
|
var Functions_exports = {};
|
407
407
|
__export(Functions_exports, {
|
408
|
+
bookmarkIdString: () => bookmarkIdString,
|
408
409
|
dateHelper: () => dateHelper,
|
409
410
|
debugId: () => debugId,
|
410
411
|
getPrimaryCategoryProperty: () => getPrimaryCategoryProperty,
|
@@ -422,6 +423,11 @@
|
|
422
423
|
var import_it = __toESM(require_it(), 1);
|
423
424
|
var dateHelper = import_dayjs.default;
|
424
425
|
|
426
|
+
// src/parts/FunctionBookmarkIdString/FunctionBookmarkIdString.ts
|
427
|
+
var bookmarkIdString = (bookmarks) => {
|
428
|
+
return `^(${bookmarks.join("|")})`;
|
429
|
+
};
|
430
|
+
|
425
431
|
// src/parts/FunctionDebugId/FunctionDebugId.ts
|
426
432
|
var debugId = (content, ...keys) => {
|
427
433
|
let current = content;
|
@@ -429,7 +435,7 @@
|
|
429
435
|
console.log({ content, key });
|
430
436
|
current = current?.[key];
|
431
437
|
}
|
432
|
-
return current;
|
438
|
+
return current || "";
|
433
439
|
};
|
434
440
|
|
435
441
|
// src/parts/FunctionId/FunctionId.ts
|
@@ -438,7 +444,7 @@
|
|
438
444
|
for (const key of keys) {
|
439
445
|
current = current?.[key];
|
440
446
|
}
|
441
|
-
return current;
|
447
|
+
return current || "";
|
442
448
|
};
|
443
449
|
|
444
450
|
// src/parts/GetCategoryProperty/GetCategoryProperty.ts
|
@@ -513,7 +519,7 @@
|
|
513
519
|
};
|
514
520
|
|
515
521
|
// src/parts/BookmarksKey/BookmarksKey.ts
|
516
|
-
var bookmarksKey = "bookmarks-
|
522
|
+
var bookmarksKey = "bookmarks-v3";
|
517
523
|
|
518
524
|
// src/parts/GetBookmarkedArticles/GetBookmarkedArticles.ts
|
519
525
|
var getBookmarkedArticles = () => {
|
@@ -619,11 +625,26 @@
|
|
619
625
|
}
|
620
626
|
return true;
|
621
627
|
});
|
628
|
+
const $Element = document.querySelector(
|
629
|
+
`[data-bookmark-article-id="${info.id}"]`
|
630
|
+
);
|
631
|
+
const shouldConfirm = $Element && $Element.closest(".BookmarkContent");
|
632
|
+
if (shouldConfirm) {
|
633
|
+
const reallyDelete = confirm(
|
634
|
+
"Sind Sie Sicher, dass Sie das Lesezeichen l\xF6schen m\xF6chten"
|
635
|
+
);
|
636
|
+
if (!reallyDelete) {
|
637
|
+
return;
|
638
|
+
}
|
639
|
+
}
|
622
640
|
localStorage.setItem(bookmarksKey, JSON.stringify(newBookmarks));
|
623
|
-
const $Element = document.querySelector(`[data-article-id="${info.id}"]`);
|
624
641
|
if ($Element && $Element instanceof HTMLElement) {
|
625
642
|
$Element.dataset.bookmarked = "false";
|
626
643
|
}
|
644
|
+
if (shouldConfirm) {
|
645
|
+
const $Parent = $Element?.closest(".ArticleTeaser");
|
646
|
+
$Parent?.remove();
|
647
|
+
}
|
627
648
|
};
|
628
649
|
|
629
650
|
// src/parts/EnableBookmark/EnableBookmark.ts
|
@@ -631,14 +652,27 @@
|
|
631
652
|
const bookmarks = getBookmarkedArticles();
|
632
653
|
const newBookmarks = [...bookmarks, info];
|
633
654
|
localStorage.setItem(bookmarksKey, JSON.stringify(newBookmarks));
|
634
|
-
const $Element = document.querySelector(
|
655
|
+
const $Element = document.querySelector(
|
656
|
+
`[data-bookmark-article-id="${info.id}"]`
|
657
|
+
);
|
635
658
|
if ($Element && $Element instanceof HTMLElement) {
|
636
659
|
$Element.dataset.bookmarked = "true";
|
637
660
|
}
|
638
661
|
};
|
639
662
|
|
640
663
|
// src/parts/ToggleBookmarkArticle/ToggleBookmarkArticle.ts
|
641
|
-
var toggleBookmarkArticle = (
|
664
|
+
var toggleBookmarkArticle = (node) => {
|
665
|
+
const info = {
|
666
|
+
id: node.dataset.bookmarkArticleId,
|
667
|
+
name: node.dataset.bookmarkArticleName,
|
668
|
+
description: node.dataset.bookmarkArticleDescription,
|
669
|
+
imageSrc: node.dataset.bookmarkArticleImagesrc,
|
670
|
+
slug: node.dataset.bookmarkArticleSlug,
|
671
|
+
metadataVideoPodcast: node.dataset.bookmarkArticleMetadatavideopodcast,
|
672
|
+
readTime: node.dataset.bookmarkArticleReadtime,
|
673
|
+
primaryCategoryId: node.dataset.bookmarkArticlePrimarycategoryid,
|
674
|
+
primaryCategoryName: node.dataset.bookmarkArticlePrimarycategoryname
|
675
|
+
};
|
642
676
|
if (isBookmarked(info.id)) {
|
643
677
|
disableBookmark(info);
|
644
678
|
} else {
|
package/package.json
CHANGED
@@ -1,2 +1,2 @@
|
|
1
1
|
// TODO version this
|
2
|
-
export const bookmarksKey = "bookmarks-
|
2
|
+
export const bookmarksKey = "bookmarks-v3";
|
@@ -9,10 +9,25 @@ export const disableBookmark = (info) => {
|
|
9
9
|
}
|
10
10
|
return true;
|
11
11
|
});
|
12
|
+
const $Element = document.querySelector(
|
13
|
+
`[data-bookmark-article-id="${info.id}"]`
|
14
|
+
);
|
15
|
+
const shouldConfirm = $Element && $Element.closest(".BookmarkContent");
|
16
|
+
if (shouldConfirm) {
|
17
|
+
const reallyDelete = confirm(
|
18
|
+
"Sind Sie Sicher, dass Sie das Lesezeichen löschen möchten"
|
19
|
+
);
|
20
|
+
if (!reallyDelete) {
|
21
|
+
return;
|
22
|
+
}
|
23
|
+
}
|
12
24
|
localStorage.setItem(bookmarksKey, JSON.stringify(newBookmarks));
|
13
|
-
const $Element = document.querySelector(`[data-article-id="${info.id}"]`);
|
14
25
|
|
15
26
|
if ($Element && $Element instanceof HTMLElement) {
|
16
27
|
$Element.dataset.bookmarked = "false";
|
17
28
|
}
|
29
|
+
if (shouldConfirm) {
|
30
|
+
const $Parent = $Element?.closest(".ArticleTeaser");
|
31
|
+
$Parent?.remove();
|
32
|
+
}
|
18
33
|
};
|
@@ -5,7 +5,9 @@ export const enableBookmark = (info) => {
|
|
5
5
|
const bookmarks = getBookmarkedArticles();
|
6
6
|
const newBookmarks = [...bookmarks, info];
|
7
7
|
localStorage.setItem(bookmarksKey, JSON.stringify(newBookmarks));
|
8
|
-
const $Element = document.querySelector(
|
8
|
+
const $Element = document.querySelector(
|
9
|
+
`[data-bookmark-article-id="${info.id}"]`
|
10
|
+
);
|
9
11
|
if ($Element && $Element instanceof HTMLElement) {
|
10
12
|
$Element.dataset.bookmarked = "true";
|
11
13
|
}
|
@@ -1,4 +1,5 @@
|
|
1
1
|
export * from "../DateHelper/DateHelper.ts";
|
2
|
+
export * from "../FunctionBookmarkIdString/FunctionBookmarkIdString.ts";
|
2
3
|
export * from "../FunctionDebugId/FunctionDebugId.ts";
|
3
4
|
export * from "../FunctionId/FunctionId.ts";
|
4
5
|
export * from "../GetCategoryProperty/GetCategoryProperty.ts";
|
@@ -2,7 +2,18 @@ import { disableBookmark } from "../DisableBookmark/DisableBookmark.ts";
|
|
2
2
|
import { enableBookmark } from "../EnableBookmark/EnableBookmark.ts";
|
3
3
|
import { isBookmarked } from "../IsBookmarked/IsBookmarked.ts";
|
4
4
|
|
5
|
-
export const toggleBookmarkArticle = (
|
5
|
+
export const toggleBookmarkArticle = (node: any) => {
|
6
|
+
const info = {
|
7
|
+
id: node.dataset.bookmarkArticleId,
|
8
|
+
name: node.dataset.bookmarkArticleName,
|
9
|
+
description: node.dataset.bookmarkArticleDescription,
|
10
|
+
imageSrc: node.dataset.bookmarkArticleImagesrc,
|
11
|
+
slug: node.dataset.bookmarkArticleSlug,
|
12
|
+
metadataVideoPodcast: node.dataset.bookmarkArticleMetadatavideopodcast,
|
13
|
+
readTime: node.dataset.bookmarkArticleReadtime,
|
14
|
+
primaryCategoryId: node.dataset.bookmarkArticlePrimarycategoryid,
|
15
|
+
primaryCategoryName: node.dataset.bookmarkArticlePrimarycategoryname,
|
16
|
+
};
|
6
17
|
if (isBookmarked(info.id)) {
|
7
18
|
disableBookmark(info);
|
8
19
|
} else {
|