@sswroom/sswr 1.4.1 → 1.5.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/web.d.ts CHANGED
@@ -12,7 +12,8 @@ export function loadJSON(url: string, onResultFunc: Function): void;
12
12
  export function buildTable(o: object | object[]): string;
13
13
  export function openData(data: string, contentType: string, fileName?: string): void;
14
14
  export function parseCSSColor(c: string): Color;
15
- export function handleFileDrop(ele: HTMLElement, hdlr: (file: any)=>void): void;
15
+ export function handleFileDrop(ele: HTMLElement, hdlr: (file: File)=>void): void;
16
+ export function appendUrl(targetUrl: string, docUrl: string): string;
16
17
 
17
18
  declare class DialogButton
18
19
  {
package/web.js CHANGED
@@ -503,6 +503,48 @@ export function handleFileDrop(ele, hdlr)
503
503
  });
504
504
  }
505
505
 
506
+ export function appendUrl(targetUrl, docUrl)
507
+ {
508
+ if (targetUrl.indexOf(":") >= 0)
509
+ return targetUrl;
510
+ var i = docUrl.indexOf("://");
511
+ if (i < 0)
512
+ return targetUrl;
513
+ var j = docUrl.indexOf("/", i + 3);
514
+ if (j < 0)
515
+ {
516
+ j = docUrl.length;
517
+ }
518
+
519
+ if (targetUrl.startsWith("/"))
520
+ {
521
+ return docUrl.substring(0, j) + targetUrl;
522
+ }
523
+ i = docUrl.lastIndexOf("/");
524
+ while (true)
525
+ {
526
+ if (targetUrl.startsWith("./"))
527
+ {
528
+ targetUrl = targetUrl.substring(2);
529
+ }
530
+ else if (targetUrl.startsWith("../"))
531
+ {
532
+ targetUrl = targetUrl.substring(3);
533
+ if (i > j)
534
+ {
535
+ docUrl = docUrl.substring(0, i);
536
+ i = docUrl.lastIndexOf("/");
537
+ }
538
+ }
539
+ else
540
+ {
541
+ if (i >= j)
542
+ docUrl = docUrl.substring(0, i);
543
+ return docUrl + "/" + targetUrl;
544
+ }
545
+ }
546
+ }
547
+
506
548
  export class Dialog
507
549
  {
508
550
  constructor(content, options)