chuvsu-js 2.8.0 → 2.8.1

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/tt/parse.js CHANGED
@@ -397,6 +397,26 @@ export function parseAudienceInfo(html) {
397
397
  const audImg = doc.querySelector("#audsrc");
398
398
  const blockImg = doc.querySelector("#blocksrc");
399
399
  const floorImg = doc.querySelector("#floorsrc");
400
+ // Highlight rect from the image map: prefer the <area> whose id matches
401
+ // the current audience (planaudNNNN); fall back to the first rect area.
402
+ let floorplanRect;
403
+ const areas = doc.querySelectorAll('map[name="flooraud"] area[shape="rect"]');
404
+ let chosen = undefined;
405
+ for (const a of areas) {
406
+ if (a.getAttribute("alt")?.trim() === name) {
407
+ chosen = a;
408
+ break;
409
+ }
410
+ }
411
+ if (!chosen && areas.length > 0)
412
+ chosen = areas[0];
413
+ if (chosen) {
414
+ const coords = chosen.getAttribute("coords") ?? "";
415
+ const parts = coords.split(",").map((s) => parseInt(s.trim(), 10));
416
+ if (parts.length === 4 && parts.every((n) => Number.isFinite(n))) {
417
+ floorplanRect = { x1: parts[0], y1: parts[1], x2: parts[2], y2: parts[3] };
418
+ }
419
+ }
400
420
  return {
401
421
  name,
402
422
  building,
@@ -405,6 +425,7 @@ export function parseAudienceInfo(html) {
405
425
  audImageUrl: audImg?.getAttribute("src") || undefined,
406
426
  blockImageUrl: blockImg?.getAttribute("src") || undefined,
407
427
  floorplanUrl: floorImg?.getAttribute("src") || undefined,
428
+ floorplanRect,
408
429
  };
409
430
  }
410
431
  function parseAudienceSemesterEntry(el) {
@@ -27,6 +27,13 @@ export interface AudienceInfo {
27
27
  blockImageUrl?: string;
28
28
  /** Relative URL of the floor plan image (/index/floorplan/...). */
29
29
  floorplanUrl?: string;
30
+ /** Rectangle (in floorplan image pixels) highlighting this audience. */
31
+ floorplanRect?: {
32
+ x1: number;
33
+ y1: number;
34
+ x2: number;
35
+ y2: number;
36
+ };
30
37
  }
31
38
  /** A date-specific substitution (room and/or teacher change). */
32
39
  export interface Substitution {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "chuvsu-js",
3
- "version": "2.8.0",
3
+ "version": "2.8.1",
4
4
  "description": "Node.js library for ChuvSU student portal (lk.chuvsu.ru) and schedule (tt.chuvsu.ru)",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",