@sswroom/sswr 1.6.4 → 1.6.6
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/Changelog +13 -0
- package/cert.d.ts +55 -53
- package/cert.js +733 -134
- package/certutil.d.ts +11 -11
- package/certutil.js +11 -6
- package/data.d.ts +4 -1
- package/data.js +119 -24
- package/geometry.d.ts +4 -2
- package/geometry.js +89 -13
- package/hash.js +7 -2
- package/kml.d.ts +1 -1
- package/kml.js +46 -4
- package/leaflet.d.ts +2 -2
- package/leaflet.js +2 -0
- package/map.d.ts +5 -1
- package/map.js +11 -0
- package/math.js +368 -29
- package/media.d.ts +1 -1
- package/media.js +20 -9
- package/package.json +1 -1
- package/parser.js +20 -10
- package/text.d.ts +1 -1
- package/text.js +9 -2
- package/unit.js +746 -663
- package/web.d.ts +3 -0
- package/web.js +138 -15
package/web.d.ts
CHANGED
|
@@ -25,6 +25,9 @@ export function mimeFromExt(ext: string): string;
|
|
|
25
25
|
export function getImageInfo(url: string): Promise<ImageInfo|null>;
|
|
26
26
|
export function propertiesToHTML(prop: object, nameMap?: object, timeFormat?: string): string;
|
|
27
27
|
export function getCacheSize(name: string): Promise<number>;
|
|
28
|
+
export function getInputOrSelectElement(id: string): HTMLInputElement|HTMLSelectElement;
|
|
29
|
+
export function getInputElement(id: string): HTMLInputElement;
|
|
30
|
+
export function getSelectElement(id: string): HTMLSelectElement;
|
|
28
31
|
|
|
29
32
|
declare class DialogButton
|
|
30
33
|
{
|
package/web.js
CHANGED
|
@@ -16,6 +16,9 @@ export function getRequestURLBase()
|
|
|
16
16
|
}
|
|
17
17
|
}
|
|
18
18
|
|
|
19
|
+
/**
|
|
20
|
+
* @param {string} name
|
|
21
|
+
*/
|
|
19
22
|
export function getParameterByName(name)
|
|
20
23
|
{
|
|
21
24
|
let url = window.location.href;
|
|
@@ -27,6 +30,10 @@ export function getParameterByName(name)
|
|
|
27
30
|
return decodeURIComponent(results[2].replace(/\+/g, ' '));
|
|
28
31
|
}
|
|
29
32
|
|
|
33
|
+
/**
|
|
34
|
+
* @param {string | URL} url
|
|
35
|
+
* @param {(arg0: object) => void} onResultFunc
|
|
36
|
+
*/
|
|
30
37
|
export function loadJSON(url, onResultFunc)
|
|
31
38
|
{
|
|
32
39
|
let xmlhttp = new XMLHttpRequest();
|
|
@@ -40,6 +47,9 @@ export function loadJSON(url, onResultFunc)
|
|
|
40
47
|
xmlhttp.send();
|
|
41
48
|
}
|
|
42
49
|
|
|
50
|
+
/**
|
|
51
|
+
* @param {object | any[]} o
|
|
52
|
+
*/
|
|
43
53
|
export function buildTable(o)
|
|
44
54
|
{
|
|
45
55
|
let name;
|
|
@@ -85,6 +95,11 @@ export function buildTable(o)
|
|
|
85
95
|
return ret.join("");
|
|
86
96
|
}
|
|
87
97
|
|
|
98
|
+
/**
|
|
99
|
+
* @param {string | Blob} data
|
|
100
|
+
* @param {string} contentType
|
|
101
|
+
* @param {string} fileName
|
|
102
|
+
*/
|
|
88
103
|
export function openData(data, contentType, fileName)
|
|
89
104
|
{
|
|
90
105
|
if (typeof data == "string")
|
|
@@ -113,6 +128,9 @@ export function openData(data, contentType, fileName)
|
|
|
113
128
|
}
|
|
114
129
|
}
|
|
115
130
|
|
|
131
|
+
/**
|
|
132
|
+
* @param {number} c
|
|
133
|
+
*/
|
|
116
134
|
function hexColor(c)
|
|
117
135
|
{
|
|
118
136
|
let b = c % 256;
|
|
@@ -120,13 +138,20 @@ function hexColor(c)
|
|
|
120
138
|
let r = (c >> 16) % 256;
|
|
121
139
|
return {a: 1.0, r: r / 255, g: g / 255, b: b / 255};
|
|
122
140
|
}
|
|
141
|
+
/**
|
|
142
|
+
* @param {string} s
|
|
143
|
+
* @param {number} maxVal
|
|
144
|
+
*/
|
|
123
145
|
function toRatio(s, maxVal)
|
|
124
146
|
{
|
|
125
147
|
if (s.endsWith("%"))
|
|
126
|
-
return s.substring(0, s.length - 1) / 100;
|
|
148
|
+
return Number(s.substring(0, s.length - 1)) / 100;
|
|
127
149
|
else
|
|
128
|
-
return s / maxVal;
|
|
150
|
+
return Number(s) / maxVal;
|
|
129
151
|
}
|
|
152
|
+
/**
|
|
153
|
+
* @param {string} c
|
|
154
|
+
*/
|
|
130
155
|
export function parseCSSColor(c)
|
|
131
156
|
{
|
|
132
157
|
let i;
|
|
@@ -473,14 +498,18 @@ export function parseCSSColor(c)
|
|
|
473
498
|
return {a: 0.0, r: 0.0, g: 0.0, b: 0.0};
|
|
474
499
|
}
|
|
475
500
|
|
|
501
|
+
/**
|
|
502
|
+
* @param {{ addEventListener: (arg0: string, arg1: { (ev: any): void; (ev: any): void; }) => void; }} ele
|
|
503
|
+
* @param {(arg0: any) => void} hdlr
|
|
504
|
+
*/
|
|
476
505
|
export function handleFileDrop(ele, hdlr)
|
|
477
506
|
{
|
|
478
|
-
ele.addEventListener("dragover",(ev)=>{
|
|
507
|
+
ele.addEventListener("dragover",(/** @type {{ preventDefault: () => void; dataTransfer: { dropEffect: string; }; }} */ ev)=>{
|
|
479
508
|
ev.preventDefault();
|
|
480
509
|
ev.dataTransfer.dropEffect = "copy";
|
|
481
510
|
});
|
|
482
511
|
|
|
483
|
-
ele.addEventListener("drop", (ev)=>{
|
|
512
|
+
ele.addEventListener("drop", (/** @type {{ preventDefault: () => void; dataTransfer: { items: { [x: string]: any; }; files: { [x: string]: any; }; }; }} */ ev)=>{
|
|
484
513
|
ev.preventDefault();
|
|
485
514
|
if (ev.dataTransfer.items)
|
|
486
515
|
{
|
|
@@ -505,6 +534,10 @@ export function handleFileDrop(ele, hdlr)
|
|
|
505
534
|
});
|
|
506
535
|
}
|
|
507
536
|
|
|
537
|
+
/**
|
|
538
|
+
* @param {string} targetUrl
|
|
539
|
+
* @param {string} docUrl
|
|
540
|
+
*/
|
|
508
541
|
export function appendUrl(targetUrl, docUrl)
|
|
509
542
|
{
|
|
510
543
|
if (targetUrl.indexOf(":") >= 0)
|
|
@@ -547,6 +580,9 @@ export function appendUrl(targetUrl, docUrl)
|
|
|
547
580
|
}
|
|
548
581
|
}
|
|
549
582
|
|
|
583
|
+
/**
|
|
584
|
+
* @param {string} fileName
|
|
585
|
+
*/
|
|
550
586
|
export function mimeFromFileName(fileName)
|
|
551
587
|
{
|
|
552
588
|
let i;
|
|
@@ -559,6 +595,9 @@ export function mimeFromFileName(fileName)
|
|
|
559
595
|
return "application/octet-stream";
|
|
560
596
|
}
|
|
561
597
|
|
|
598
|
+
/**
|
|
599
|
+
* @param {any} ext
|
|
600
|
+
*/
|
|
562
601
|
export function mimeFromExt(ext)
|
|
563
602
|
{
|
|
564
603
|
switch (ext)
|
|
@@ -702,15 +741,27 @@ export function mimeFromExt(ext)
|
|
|
702
741
|
}
|
|
703
742
|
}
|
|
704
743
|
|
|
744
|
+
/**
|
|
745
|
+
* @param {string} url
|
|
746
|
+
*/
|
|
705
747
|
export function getImageInfo(url)
|
|
706
748
|
{
|
|
707
749
|
return new Promise(function (resolve, reject) {
|
|
708
750
|
const image = document.createElement('img');
|
|
709
751
|
image.addEventListener('load', function (e) {
|
|
710
|
-
|
|
711
|
-
|
|
712
|
-
|
|
713
|
-
|
|
752
|
+
if (e.target)
|
|
753
|
+
{
|
|
754
|
+
resolve({
|
|
755
|
+
// @ts-ignore
|
|
756
|
+
width: e.target.width,
|
|
757
|
+
// @ts-ignore
|
|
758
|
+
height: e.target.height,
|
|
759
|
+
});
|
|
760
|
+
}
|
|
761
|
+
else
|
|
762
|
+
{
|
|
763
|
+
reject();
|
|
764
|
+
}
|
|
714
765
|
});
|
|
715
766
|
|
|
716
767
|
image.addEventListener('error', function () {
|
|
@@ -721,6 +772,11 @@ export function getImageInfo(url)
|
|
|
721
772
|
});
|
|
722
773
|
}
|
|
723
774
|
|
|
775
|
+
/**
|
|
776
|
+
* @param {{ [x: string]: any; }} prop
|
|
777
|
+
* @param {{ [x: string]: string; } | null} nameMap
|
|
778
|
+
* @param {any} timeFormat
|
|
779
|
+
*/
|
|
724
780
|
export function propertiesToHTML(prop, nameMap, timeFormat)
|
|
725
781
|
{
|
|
726
782
|
let ret = ["<ul>"];
|
|
@@ -772,6 +828,9 @@ export function propertiesToHTML(prop, nameMap, timeFormat)
|
|
|
772
828
|
return ret.join("");
|
|
773
829
|
}
|
|
774
830
|
|
|
831
|
+
/**
|
|
832
|
+
* @param {string} name
|
|
833
|
+
*/
|
|
775
834
|
export async function getCacheSize(name)
|
|
776
835
|
{
|
|
777
836
|
const cache = await caches.open(name);
|
|
@@ -789,8 +848,56 @@ export async function getCacheSize(name)
|
|
|
789
848
|
return size;
|
|
790
849
|
}
|
|
791
850
|
|
|
851
|
+
/**
|
|
852
|
+
* @param {string} id
|
|
853
|
+
* @returns {HTMLInputElement|HTMLSelectElement}
|
|
854
|
+
*/
|
|
855
|
+
export function getInputOrSelectElement(id)
|
|
856
|
+
{
|
|
857
|
+
let ele = document.getElementById(id);
|
|
858
|
+
if (ele == null)
|
|
859
|
+
throw new Error("Element with id \""+id+"\" not found");
|
|
860
|
+
if (ele instanceof HTMLInputElement)
|
|
861
|
+
return ele;
|
|
862
|
+
if (ele instanceof HTMLSelectElement)
|
|
863
|
+
return ele;
|
|
864
|
+
throw new Error("Element with id \""+id+"\" is not an input");
|
|
865
|
+
}
|
|
866
|
+
|
|
867
|
+
/**
|
|
868
|
+
* @param {string} id
|
|
869
|
+
* @returns {HTMLInputElement}
|
|
870
|
+
*/
|
|
871
|
+
export function getInputElement(id)
|
|
872
|
+
{
|
|
873
|
+
let ele = document.getElementById(id);
|
|
874
|
+
if (ele == null)
|
|
875
|
+
throw new Error("Element with id \""+id+"\" not found");
|
|
876
|
+
if (ele instanceof HTMLInputElement)
|
|
877
|
+
return ele;
|
|
878
|
+
throw new Error("Element with id \""+id+"\" is not an input");
|
|
879
|
+
}
|
|
880
|
+
|
|
881
|
+
/**
|
|
882
|
+
* @param {string} id
|
|
883
|
+
* @returns {HTMLSelectElement}
|
|
884
|
+
*/
|
|
885
|
+
export function getSelectElement(id)
|
|
886
|
+
{
|
|
887
|
+
let ele = document.getElementById(id);
|
|
888
|
+
if (ele == null)
|
|
889
|
+
throw new Error("Element with id \""+id+"\" not found");
|
|
890
|
+
if (ele instanceof HTMLSelectElement)
|
|
891
|
+
return ele;
|
|
892
|
+
throw new Error("Element with id \""+id+"\" is not a select");
|
|
893
|
+
}
|
|
894
|
+
|
|
792
895
|
export class Dialog
|
|
793
896
|
{
|
|
897
|
+
/**
|
|
898
|
+
* @param {string | HTMLElement} content
|
|
899
|
+
* @param {{width?:number,height?:number,zIndex?:number,buttonClass?:string,contentClass?:string,buttons?:{name:string,onclick:()=>void}[],margin?:number} | null} options
|
|
900
|
+
*/
|
|
794
901
|
constructor(content, options)
|
|
795
902
|
{
|
|
796
903
|
this.content = content;
|
|
@@ -808,8 +915,12 @@ export class Dialog
|
|
|
808
915
|
|
|
809
916
|
getDocBody()
|
|
810
917
|
{
|
|
811
|
-
|
|
918
|
+
let d = (top)?top.document:window.document;
|
|
919
|
+
if (d.body.nodeName.toLowerCase() == "frameset")
|
|
812
920
|
{
|
|
921
|
+
/**
|
|
922
|
+
* @type {Window}
|
|
923
|
+
*/
|
|
813
924
|
let w = window;
|
|
814
925
|
while (w.parent && w.parent.document.body.nodeName.toLowerCase() != "frameset")
|
|
815
926
|
{
|
|
@@ -819,7 +930,7 @@ export class Dialog
|
|
|
819
930
|
}
|
|
820
931
|
else
|
|
821
932
|
{
|
|
822
|
-
return
|
|
933
|
+
return d.body;
|
|
823
934
|
}
|
|
824
935
|
}
|
|
825
936
|
|
|
@@ -832,7 +943,7 @@ export class Dialog
|
|
|
832
943
|
darkColor.style.width = "100%";
|
|
833
944
|
darkColor.style.height = "100%";
|
|
834
945
|
darkColor.style.backgroundColor = "rgba(0, 0, 0, 0.7)";
|
|
835
|
-
darkColor.style.zIndex = this.options.zIndex;
|
|
946
|
+
darkColor.style.zIndex = ""+this.options.zIndex;
|
|
836
947
|
darkColor.style.display = "flex";
|
|
837
948
|
darkColor.style.alignItems = "center";
|
|
838
949
|
darkColor.style.justifyContent = "center";
|
|
@@ -864,7 +975,7 @@ export class Dialog
|
|
|
864
975
|
content.style.height = height;
|
|
865
976
|
let row = document.createElement("tr");
|
|
866
977
|
let contentCell = document.createElement("td");
|
|
867
|
-
contentCell.setAttribute("colspan", this.options.buttons.length);
|
|
978
|
+
contentCell.setAttribute("colspan", ""+this.options.buttons.length);
|
|
868
979
|
contentCell.className = this.options.contentClass;
|
|
869
980
|
contentCell.style.overflowY = "auto";
|
|
870
981
|
if (this.options.margin)
|
|
@@ -883,7 +994,8 @@ export class Dialog
|
|
|
883
994
|
row.setAttribute("height", "20");
|
|
884
995
|
let i;
|
|
885
996
|
let col;
|
|
886
|
-
|
|
997
|
+
i = 0;
|
|
998
|
+
while (i < this.options.buttons.length)
|
|
887
999
|
{
|
|
888
1000
|
col = document.createElement("td");
|
|
889
1001
|
col.style.textAlign = "center";
|
|
@@ -893,9 +1005,10 @@ export class Dialog
|
|
|
893
1005
|
col.style.marginLeft = this.options.margin+"px";
|
|
894
1006
|
}
|
|
895
1007
|
col.className = this.options.buttonClass;
|
|
896
|
-
col.addEventListener("click", this.options.buttons[i].onclick
|
|
1008
|
+
col.addEventListener("click", this.options.buttons[i].onclick);
|
|
897
1009
|
col.innerText = this.options.buttons[i].name;
|
|
898
1010
|
row.append(col);
|
|
1011
|
+
i++;
|
|
899
1012
|
}
|
|
900
1013
|
content.appendChild(row);
|
|
901
1014
|
dialog.appendChild(content);
|
|
@@ -903,7 +1016,7 @@ export class Dialog
|
|
|
903
1016
|
if (this.options.margin)
|
|
904
1017
|
{
|
|
905
1018
|
let minHeight = row.offsetHeight;
|
|
906
|
-
row.setAttribute("height", this.options.margin + minHeight);
|
|
1019
|
+
row.setAttribute("height", ""+(this.options.margin + minHeight));
|
|
907
1020
|
contentCell.style.height = (dialog.offsetHeight - minHeight - this.options.margin - this.options.margin)+"px";
|
|
908
1021
|
}
|
|
909
1022
|
else
|
|
@@ -921,16 +1034,26 @@ export class Dialog
|
|
|
921
1034
|
}
|
|
922
1035
|
}
|
|
923
1036
|
|
|
1037
|
+
/**
|
|
1038
|
+
* @param {string} content
|
|
1039
|
+
*/
|
|
924
1040
|
setContent(content)
|
|
925
1041
|
{
|
|
926
1042
|
this.content = content;
|
|
927
1043
|
}
|
|
928
1044
|
|
|
1045
|
+
/**
|
|
1046
|
+
* @param {string} name
|
|
1047
|
+
* @param {any} value
|
|
1048
|
+
*/
|
|
929
1049
|
updateOption(name, value)
|
|
930
1050
|
{
|
|
931
1051
|
this.options[name] = value;
|
|
932
1052
|
}
|
|
933
1053
|
|
|
1054
|
+
/**
|
|
1055
|
+
* @param {string | null | undefined} [name]
|
|
1056
|
+
*/
|
|
934
1057
|
closeButton(name)
|
|
935
1058
|
{
|
|
936
1059
|
if (name == null) name = "Close";
|