@ranzenjs/client 0.4.2 → 0.4.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/apps/lessons/parse.js +4 -3
- package/dist/html.d.ts +2 -0
- package/dist/html.js +13 -0
- package/package.json +1 -1
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { layoutChanged } from '../../errors.js';
|
|
2
|
-
import { all, attr, cells, hasClass, one, ownText, rawText, rows, text } from '../../html.js';
|
|
2
|
+
import { all, attr, cells, hasClass, markupPath, one, ownText, rawText, rows, text } from '../../html.js';
|
|
3
3
|
import { ignoreDrift, isoDate, parseCount, queryParam } from '../../util.js';
|
|
4
4
|
export function parseOverview(document, drift = ignoreDrift) {
|
|
5
5
|
const folders = one('#mappen', document);
|
|
@@ -9,8 +9,9 @@ export function parseOverview(document, drift = ignoreDrift) {
|
|
|
9
9
|
// An empty #mappen is a valid account without courses; a skipped course would read as gone.
|
|
10
10
|
const links = all('a[href*="sus_view"]', folders);
|
|
11
11
|
const carded = new Set(cards.flatMap((card) => all('a[href*="sus_view"]', card)));
|
|
12
|
-
|
|
13
|
-
|
|
12
|
+
const uncarded = links.find((link) => !carded.has(link));
|
|
13
|
+
if (uncarded) {
|
|
14
|
+
throw layoutChanged(`.thumbnail cards around every course in #mappen, found ${markupPath(uncarded, folders)}`);
|
|
14
15
|
}
|
|
15
16
|
const latest = one('#aktuellTable', document);
|
|
16
17
|
if (!latest && one('tr[data-entry]', document)) {
|
package/dist/html.d.ts
CHANGED
|
@@ -20,5 +20,7 @@ export declare function rawText(node: Element | null | undefined, own?: boolean)
|
|
|
20
20
|
export declare function ownText(node: Element | null | undefined): string;
|
|
21
21
|
export declare function attr(node: Element | null | undefined, name: string): string | undefined;
|
|
22
22
|
export declare function hasClass(node: Element | null | undefined, name: string): boolean;
|
|
23
|
+
/** Tags and classes from root down to node, e.g. "#mappen > div.row > a.btn"; never text or other attributes. */
|
|
24
|
+
export declare function markupPath(node: Element, root: Element): string;
|
|
23
25
|
/** Markup inside portal JSON values, e.g. <del>Mül</del>, as plain text. */
|
|
24
26
|
export declare function stripTags(value: string): string;
|
package/dist/html.js
CHANGED
|
@@ -100,6 +100,19 @@ export function attr(node, name) {
|
|
|
100
100
|
export function hasClass(node, name) {
|
|
101
101
|
return (node?.attribs.class ?? '').split(/\s+/).includes(name);
|
|
102
102
|
}
|
|
103
|
+
/** Tags and classes from root down to node, e.g. "#mappen > div.row > a.btn"; never text or other attributes. */
|
|
104
|
+
export function markupPath(node, root) {
|
|
105
|
+
const steps = [];
|
|
106
|
+
for (let at = node; at && at !== root;) {
|
|
107
|
+
const classes = (at.attribs.class ?? '')
|
|
108
|
+
.split(/\s+/)
|
|
109
|
+
.filter((name) => /^[\w-]{1,40}$/.test(name));
|
|
110
|
+
steps.unshift([at.name, ...classes].join('.'));
|
|
111
|
+
at = at.parent && isTag(at.parent) ? at.parent : null;
|
|
112
|
+
}
|
|
113
|
+
const id = root.attribs.id;
|
|
114
|
+
return [id && /^[\w-]{1,40}$/.test(id) ? `#${id}` : root.name, ...steps].join(' > ');
|
|
115
|
+
}
|
|
103
116
|
/** Markup inside portal JSON values, e.g. <del>Mül</del>, as plain text. */
|
|
104
117
|
export function stripTags(value) {
|
|
105
118
|
if (!/[<&]/.test(value))
|