@sswroom/sswr 1.6.18 → 1.6.20

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@sswroom/sswr",
3
- "version": "1.6.18",
3
+ "version": "1.6.20",
4
4
  "description": "Libraries made by sswroom",
5
5
  "main": "sswr.js",
6
6
  "scripts": {
package/web.d.ts CHANGED
@@ -102,6 +102,7 @@ export function getParameterByName(name: string): string | null;
102
102
  export function loadJSON(url: string, onResultFunc: Function): void;
103
103
  export function buildTable(o: object | object[]): string;
104
104
  export function openData(data: string | Blob, contentType: string, fileName?: string): void;
105
+ export function openUrl(url: string, fileName?: string): void;
105
106
  export function parseCSSColor(c: string): Color;
106
107
  export function handleFileDrop(ele: HTMLElement, hdlr: (file: File)=>void): void;
107
108
  export function appendUrl(targetUrl: string, docUrl: string): string;
package/web.js CHANGED
@@ -222,6 +222,23 @@ export function openData(data, contentType, fileName)
222
222
  }
223
223
  }
224
224
 
225
+ /**
226
+ * @param {string} url
227
+ * @param {string|undefined} fileName
228
+ */
229
+ export function openUrl(url, fileName)
230
+ {
231
+ let ele = document.createElement("a");
232
+ ele.setAttribute('href', url);
233
+ if (fileName)
234
+ ele.setAttribute('download', fileName);
235
+ ele.style.display = 'none';
236
+
237
+ document.body.appendChild(ele);
238
+ ele.click();
239
+ document.body.removeChild(ele);
240
+ }
241
+
225
242
  /**
226
243
  * @param {number} c
227
244
  */