jpf-mobx 1.0.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/LICENSE.md +21 -0
- package/README.md +21 -0
- package/dist/controls/codeMirror/HtmlEditor/HtmlEditor.d.ts +0 -0
- package/dist/controls/codeMirror/HtmlEditor/HtmlEditor.js +1 -0
- package/dist/controls/codeMirror/HtmlEditor/HtmlEditor.js.map +1 -0
- package/dist/controls/codeMirror/JsonEditor/JsonEditor.d.ts +0 -0
- package/dist/controls/codeMirror/JsonEditor/JsonEditor.js +1 -0
- package/dist/controls/codeMirror/JsonEditor/JsonEditor.js.map +1 -0
- package/dist/controls/codeMirror/index.d.ts +0 -0
- package/dist/controls/codeMirror/index.js +1 -0
- package/dist/controls/codeMirror/index.js.map +1 -0
- package/dist/controls/custom/FileSelector/FileSelector.d.ts +0 -0
- package/dist/controls/custom/FileSelector/FileSelector.js +1 -0
- package/dist/controls/custom/FileSelector/FileSelector.js.map +1 -0
- package/dist/controls/custom/LabeledControl/LabeledControl.d.ts +15 -0
- package/dist/controls/custom/LabeledControl/LabeledControl.js +37 -0
- package/dist/controls/custom/LabeledControl/LabeledControl.js.map +1 -0
- package/dist/controls/custom/ListItem/ListItem.d.ts +0 -0
- package/dist/controls/custom/ListItem/ListItem.js +1 -0
- package/dist/controls/custom/ListItem/ListItem.js.map +1 -0
- package/dist/controls/custom/index.d.ts +1 -0
- package/dist/controls/custom/index.js +2 -0
- package/dist/controls/custom/index.js.map +1 -0
- package/dist/controls/html/Button/Button.d.ts +0 -0
- package/dist/controls/html/Button/Button.js +1 -0
- package/dist/controls/html/Button/Button.js.map +1 -0
- package/dist/controls/html/Div/Div.d.ts +14 -0
- package/dist/controls/html/Div/Div.js +25 -0
- package/dist/controls/html/Div/Div.js.map +1 -0
- package/dist/controls/html/Image/Image.d.ts +16 -0
- package/dist/controls/html/Image/Image.js +29 -0
- package/dist/controls/html/Image/Image.js.map +1 -0
- package/dist/controls/html/Input/Input.d.ts +0 -0
- package/dist/controls/html/Input/Input.js +1 -0
- package/dist/controls/html/Input/Input.js.map +1 -0
- package/dist/controls/html/Select/Select.d.ts +0 -0
- package/dist/controls/html/Select/Select.js +1 -0
- package/dist/controls/html/Select/Select.js.map +1 -0
- package/dist/controls/html/Span/Span.d.ts +11 -0
- package/dist/controls/html/Span/Span.js +23 -0
- package/dist/controls/html/Span/Span.js.map +1 -0
- package/dist/controls/html/index.d.ts +3 -0
- package/dist/controls/html/index.js +4 -0
- package/dist/controls/html/index.js.map +1 -0
- package/dist/controls/index.d.ts +6 -0
- package/dist/controls/index.js +7 -0
- package/dist/controls/index.js.map +1 -0
- package/dist/controls/jsonViewAwesome/index.d.ts +0 -0
- package/dist/controls/jsonViewAwesome/index.js +1 -0
- package/dist/controls/jsonViewAwesome/index.js.map +1 -0
- package/dist/controls/jsonViewAwesome/jsonFormatter/JsonFormatter.d.ts +0 -0
- package/dist/controls/jsonViewAwesome/jsonFormatter/JsonFormatter.js +1 -0
- package/dist/controls/jsonViewAwesome/jsonFormatter/JsonFormatter.js.map +1 -0
- package/dist/controls/kendo/Chart/Chart.d.ts +0 -0
- package/dist/controls/kendo/Chart/Chart.js +1 -0
- package/dist/controls/kendo/Chart/Chart.js.map +1 -0
- package/dist/controls/kendo/Culture/Culture.d.ts +1 -0
- package/dist/controls/kendo/Culture/Culture.js +26 -0
- package/dist/controls/kendo/Culture/Culture.js.map +1 -0
- package/dist/controls/kendo/DataSource/DataSource.d.ts +4 -0
- package/dist/controls/kendo/DataSource/DataSource.js +2 -0
- package/dist/controls/kendo/DataSource/DataSource.js.map +1 -0
- package/dist/controls/kendo/Dialog/Dialog.d.ts +0 -0
- package/dist/controls/kendo/Dialog/Dialog.js +1 -0
- package/dist/controls/kendo/Dialog/Dialog.js.map +1 -0
- package/dist/controls/kendo/Editor/Editor.d.ts +0 -0
- package/dist/controls/kendo/Editor/Editor.js +1 -0
- package/dist/controls/kendo/Editor/Editor.js.map +1 -0
- package/dist/controls/kendo/Grid/Grid.d.ts +0 -0
- package/dist/controls/kendo/Grid/Grid.js +1 -0
- package/dist/controls/kendo/Grid/Grid.js.map +1 -0
- package/dist/controls/kendo/Menu/Menu.d.ts +0 -0
- package/dist/controls/kendo/Menu/Menu.js +1 -0
- package/dist/controls/kendo/Menu/Menu.js.map +1 -0
- package/dist/controls/kendo/ObservableObject/ObservableObject.d.ts +0 -0
- package/dist/controls/kendo/ObservableObject/ObservableObject.js +1 -0
- package/dist/controls/kendo/ObservableObject/ObservableObject.js.map +1 -0
- package/dist/controls/kendo/Tree/Tree.d.ts +0 -0
- package/dist/controls/kendo/Tree/Tree.js +1 -0
- package/dist/controls/kendo/Tree/Tree.js.map +1 -0
- package/dist/controls/kendo/index.d.ts +0 -0
- package/dist/controls/kendo/index.js +1 -0
- package/dist/controls/kendo/index.js.map +1 -0
- package/dist/controls/leaflet/LabelControl/LabelControl.d.ts +12 -0
- package/dist/controls/leaflet/LabelControl/LabelControl.js +34 -0
- package/dist/controls/leaflet/LabelControl/LabelControl.js.map +1 -0
- package/dist/controls/leaflet/Map/Map.d.ts +0 -0
- package/dist/controls/leaflet/Map/Map.js +1 -0
- package/dist/controls/leaflet/Map/Map.js.map +1 -0
- package/dist/controls/leaflet/OpenStreetMapTileLayer/OpenStreetMapTileLayer.d.ts +8 -0
- package/dist/controls/leaflet/OpenStreetMapTileLayer/OpenStreetMapTileLayer.js +14 -0
- package/dist/controls/leaflet/OpenStreetMapTileLayer/OpenStreetMapTileLayer.js.map +1 -0
- package/dist/controls/leaflet/PointerEvent/PointerEvent.d.ts +2 -0
- package/dist/controls/leaflet/PointerEvent/PointerEvent.js +8 -0
- package/dist/controls/leaflet/PointerEvent/PointerEvent.js.map +1 -0
- package/dist/controls/leaflet/index.d.ts +3 -0
- package/dist/controls/leaflet/index.js +4 -0
- package/dist/controls/leaflet/index.js.map +1 -0
- package/dist/controls/svg/Circle/Circle.d.ts +0 -0
- package/dist/controls/svg/Circle/Circle.js +1 -0
- package/dist/controls/svg/Circle/Circle.js.map +1 -0
- package/dist/controls/svg/Ellipse/Ellipse.d.ts +0 -0
- package/dist/controls/svg/Ellipse/Ellipse.js +1 -0
- package/dist/controls/svg/Ellipse/Ellipse.js.map +1 -0
- package/dist/controls/svg/ForeignObject/ForeignObject.d.ts +0 -0
- package/dist/controls/svg/ForeignObject/ForeignObject.js +1 -0
- package/dist/controls/svg/ForeignObject/ForeignObject.js.map +1 -0
- package/dist/controls/svg/Group/Group.d.ts +0 -0
- package/dist/controls/svg/Group/Group.js +1 -0
- package/dist/controls/svg/Group/Group.js.map +1 -0
- package/dist/controls/svg/Line/Line.d.ts +0 -0
- package/dist/controls/svg/Line/Line.js +1 -0
- package/dist/controls/svg/Line/Line.js.map +1 -0
- package/dist/controls/svg/Pattern/Pattern.d.ts +0 -0
- package/dist/controls/svg/Pattern/Pattern.js +1 -0
- package/dist/controls/svg/Pattern/Pattern.js.map +1 -0
- package/dist/controls/svg/Polygon/Polygon.d.ts +0 -0
- package/dist/controls/svg/Polygon/Polygon.js +1 -0
- package/dist/controls/svg/Polygon/Polygon.js.map +1 -0
- package/dist/controls/svg/Polyline/Polyline.d.ts +0 -0
- package/dist/controls/svg/Polyline/Polyline.js +1 -0
- package/dist/controls/svg/Polyline/Polyline.js.map +1 -0
- package/dist/controls/svg/Rectangle/Rectangle.d.ts +0 -0
- package/dist/controls/svg/Rectangle/Rectangle.js +1 -0
- package/dist/controls/svg/Rectangle/Rectangle.js.map +1 -0
- package/dist/controls/svg/Svg/Svg.d.ts +0 -0
- package/dist/controls/svg/Svg/Svg.js +1 -0
- package/dist/controls/svg/Svg/Svg.js.map +1 -0
- package/dist/controls/svg/Text/Text.d.ts +0 -0
- package/dist/controls/svg/Text/Text.js +1 -0
- package/dist/controls/svg/Text/Text.js.map +1 -0
- package/dist/controls/svg/Title/Title.d.ts +0 -0
- package/dist/controls/svg/Title/Title.js +1 -0
- package/dist/controls/svg/Title/Title.js.map +1 -0
- package/dist/controls/svg/index.d.ts +0 -0
- package/dist/controls/svg/index.js +1 -0
- package/dist/controls/svg/index.js.map +1 -0
- package/dist/controls/svg/svg.d.ts +0 -0
- package/dist/controls/svg/svg.js +1 -0
- package/dist/controls/svg/svg.js.map +1 -0
- package/dist/framework/View.d.ts +62 -0
- package/dist/framework/View.js +148 -0
- package/dist/framework/View.js.map +1 -0
- package/dist/framework/ViewModel.d.ts +42 -0
- package/dist/framework/ViewModel.js +287 -0
- package/dist/framework/ViewModel.js.map +1 -0
- package/dist/framework/attributes.d.ts +90 -0
- package/dist/framework/attributes.js +2 -0
- package/dist/framework/attributes.js.map +1 -0
- package/dist/framework/event.d.ts +80 -0
- package/dist/framework/event.js +26 -0
- package/dist/framework/event.js.map +1 -0
- package/dist/framework/observable.d.ts +9 -0
- package/dist/framework/observable.js +24 -0
- package/dist/framework/observable.js.map +1 -0
- package/dist/framework/style.d.ts +658 -0
- package/dist/framework/style.js +154 -0
- package/dist/framework/style.js.map +1 -0
- package/dist/framework/types.d.ts +87 -0
- package/dist/framework/types.js +2 -0
- package/dist/framework/types.js.map +1 -0
- package/dist/framework/userAgent.d.ts +31 -0
- package/dist/framework/userAgent.js +47 -0
- package/dist/framework/userAgent.js.map +1 -0
- package/dist/index.d.ts +12 -0
- package/dist/index.js +13 -0
- package/dist/index.js.map +1 -0
- package/dist/utilities/blob/blob.d.ts +1 -0
- package/dist/utilities/blob/blob.js +18 -0
- package/dist/utilities/blob/blob.js.map +1 -0
- package/dist/utilities/cookie/cookie.d.ts +3 -0
- package/dist/utilities/cookie/cookie.js +27 -0
- package/dist/utilities/cookie/cookie.js.map +1 -0
- package/dist/utilities/dataReaderTable/dataReaderTable.d.ts +9 -0
- package/dist/utilities/dataReaderTable/dataReaderTable.js +24 -0
- package/dist/utilities/dataReaderTable/dataReaderTable.js.map +1 -0
- package/dist/utilities/fetch/fetch.d.ts +8 -0
- package/dist/utilities/fetch/fetch.js +138 -0
- package/dist/utilities/fetch/fetch.js.map +1 -0
- package/dist/utilities/float/float.d.ts +1 -0
- package/dist/utilities/float/float.js +4 -0
- package/dist/utilities/float/float.js.map +1 -0
- package/dist/utilities/formData/formData.d.ts +1 -0
- package/dist/utilities/formData/formData.js +12 -0
- package/dist/utilities/formData/formData.js.map +1 -0
- package/dist/utilities/html/html.d.ts +1 -0
- package/dist/utilities/html/html.js +8 -0
- package/dist/utilities/html/html.js.map +1 -0
- package/dist/utilities/htmlElement/htmlElement.d.ts +1 -0
- package/dist/utilities/htmlElement/htmlElement.js +17 -0
- package/dist/utilities/htmlElement/htmlElement.js.map +1 -0
- package/dist/utilities/image/image.d.ts +1 -0
- package/dist/utilities/image/image.js +2 -0
- package/dist/utilities/image/image.js.map +1 -0
- package/dist/utilities/index.d.ts +36 -0
- package/dist/utilities/index.js +37 -0
- package/dist/utilities/index.js.map +1 -0
- package/dist/utilities/integer/integer.d.ts +3 -0
- package/dist/utilities/integer/integer.js +28 -0
- package/dist/utilities/integer/integer.js.map +1 -0
- package/dist/utilities/key/key.d.ts +2 -0
- package/dist/utilities/key/key.js +7 -0
- package/dist/utilities/key/key.js.map +1 -0
- package/dist/utilities/navigator/navigator.d.ts +1 -0
- package/dist/utilities/navigator/navigator.js +9 -0
- package/dist/utilities/navigator/navigator.js.map +1 -0
- package/dist/utilities/notification/notification.d.ts +5 -0
- package/dist/utilities/notification/notification.js +67 -0
- package/dist/utilities/notification/notification.js.map +1 -0
- package/dist/utilities/querystring/querystring.d.ts +6 -0
- package/dist/utilities/querystring/querystring.js +54 -0
- package/dist/utilities/querystring/querystring.js.map +1 -0
- package/dist/utilities/router/router.d.ts +19 -0
- package/dist/utilities/router/router.js +81 -0
- package/dist/utilities/router/router.js.map +1 -0
- package/dist/utilities/stylesheet/stylesheet.d.ts +2 -0
- package/dist/utilities/stylesheet/stylesheet.js +48 -0
- package/dist/utilities/stylesheet/stylesheet.js.map +1 -0
- package/dist/utilities/uniqueId/uniqueId.d.ts +1 -0
- package/dist/utilities/uniqueId/uniqueId.js +5 -0
- package/dist/utilities/uniqueId/uniqueId.js.map +1 -0
- package/dist/utilities/webSocket/webSocket.d.ts +1 -0
- package/dist/utilities/webSocket/webSocket.js +55 -0
- package/dist/utilities/webSocket/webSocket.js.map +1 -0
- package/package.json +62 -0
- package/src/controls/codeMirror/HtmlEditor/HtmlEditor.ts +153 -0
- package/src/controls/codeMirror/JsonEditor/JsonEditor.ts +136 -0
- package/src/controls/codeMirror/index.ts +2 -0
- package/src/controls/custom/FileSelector/FileSelector.ts +74 -0
- package/src/controls/custom/LabeledControl/LabeledControl.ts +58 -0
- package/src/controls/custom/ListItem/ListItem.ts +99 -0
- package/src/controls/custom/index.ts +3 -0
- package/src/controls/html/Button/Button.ts +70 -0
- package/src/controls/html/Div/Div.ts +41 -0
- package/src/controls/html/Image/Image.ts +46 -0
- package/src/controls/html/Input/Input.ts +228 -0
- package/src/controls/html/Select/Select.ts +146 -0
- package/src/controls/html/Span/Span.ts +38 -0
- package/src/controls/html/index.ts +6 -0
- package/src/controls/index.ts +15 -0
- package/src/controls/jsonViewAwesome/index.ts +1 -0
- package/src/controls/jsonViewAwesome/jsonFormatter/JsonFormatter.ts +91 -0
- package/src/controls/kendo/Chart/Chart.ts +97 -0
- package/src/controls/kendo/Culture/Culture.ts +32 -0
- package/src/controls/kendo/DataSource/DataSource.ts +4 -0
- package/src/controls/kendo/Dialog/Dialog.ts +64 -0
- package/src/controls/kendo/Editor/Editor.ts +142 -0
- package/src/controls/kendo/Grid/Grid.ts +291 -0
- package/src/controls/kendo/Menu/Menu.ts +125 -0
- package/src/controls/kendo/ObservableObject/ObservableObject.ts +45 -0
- package/src/controls/kendo/Tree/Tree.ts +147 -0
- package/src/controls/kendo/index.ts +9 -0
- package/src/controls/leaflet/LabelControl/LabelControl.ts +42 -0
- package/src/controls/leaflet/Map/Map.ts +180 -0
- package/src/controls/leaflet/OpenStreetMapTileLayer/OpenStreetMapTileLayer.ts +19 -0
- package/src/controls/leaflet/PointerEvent/PointerEvent.ts +9 -0
- package/src/controls/leaflet/index.ts +4 -0
- package/src/controls/svg/Circle/Circle.ts +34 -0
- package/src/controls/svg/Ellipse/Ellipse.ts +36 -0
- package/src/controls/svg/ForeignObject/ForeignObject.ts +38 -0
- package/src/controls/svg/Group/Group.ts +38 -0
- package/src/controls/svg/Line/Line.ts +36 -0
- package/src/controls/svg/Pattern/Pattern.ts +49 -0
- package/src/controls/svg/Polygon/Polygon.ts +31 -0
- package/src/controls/svg/Polyline/Polyline.ts +31 -0
- package/src/controls/svg/Rectangle/Rectangle.ts +36 -0
- package/src/controls/svg/Svg/Svg.ts +43 -0
- package/src/controls/svg/Text/Text.ts +38 -0
- package/src/controls/svg/Title/Title.ts +28 -0
- package/src/controls/svg/index.ts +13 -0
- package/src/controls/svg/svg.ts +20 -0
- package/src/framework/View.ts +226 -0
- package/src/framework/ViewModel.ts +478 -0
- package/src/framework/attributes.ts +92 -0
- package/src/framework/event.ts +98 -0
- package/src/framework/observable.ts +40 -0
- package/src/framework/style.ts +3271 -0
- package/src/framework/types.ts +277 -0
- package/src/framework/userAgent.ts +51 -0
- package/src/index.ts +14 -0
- package/src/utilities/blob/blob.ts +19 -0
- package/src/utilities/cookie/cookie.ts +28 -0
- package/src/utilities/dataReaderTable/dataReaderTable.ts +34 -0
- package/src/utilities/fetch/fetch.ts +179 -0
- package/src/utilities/float/float.ts +3 -0
- package/src/utilities/formData/formData.ts +12 -0
- package/src/utilities/html/html.ts +8 -0
- package/src/utilities/htmlElement/htmlElement.ts +15 -0
- package/src/utilities/image/image.ts +1 -0
- package/src/utilities/index.ts +37 -0
- package/src/utilities/integer/integer.ts +31 -0
- package/src/utilities/key/key.ts +7 -0
- package/src/utilities/navigator/navigator.ts +7 -0
- package/src/utilities/notification/notification.ts +88 -0
- package/src/utilities/querystring/querystring.ts +61 -0
- package/src/utilities/router/router.ts +124 -0
- package/src/utilities/stylesheet/stylesheet.ts +58 -0
- package/src/utilities/uniqueId/uniqueId.ts +5 -0
- package/src/utilities/webSocket/webSocket.ts +72 -0
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
export function setScale(htmlElement: HTMLElement, scale: number) {
|
|
2
|
+
htmlElement.style.transformOrigin = "center";
|
|
3
|
+
|
|
4
|
+
const scaleValue = " scale(" + scale + ")";
|
|
5
|
+
const transform = htmlElement.style.transform;
|
|
6
|
+
if (transform) {
|
|
7
|
+
if (transform.indexOf("scale") > -1) {
|
|
8
|
+
htmlElement.style.transform = transform.replace(/scale\(.*\)/, scaleValue);
|
|
9
|
+
} else {
|
|
10
|
+
htmlElement.style.transform += scaleValue;
|
|
11
|
+
}
|
|
12
|
+
} else {
|
|
13
|
+
htmlElement.style.transform = scaleValue;
|
|
14
|
+
}
|
|
15
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export const blankGif = "data:image/gif;base64,R0lGODlhAQABAAD/ACwAAAAAAQABAAACADs=";
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import * as blob from "./blob/blob";
|
|
2
|
+
import * as cookie from "./cookie/cookie";
|
|
3
|
+
import * as dataReaderTable from "./dataReaderTable/dataReaderTable";
|
|
4
|
+
import * as fetch from "./fetch/fetch";
|
|
5
|
+
import * as float from "./float/float";
|
|
6
|
+
import * as formData from "./formData/formData";
|
|
7
|
+
import * as html from "./html/html";
|
|
8
|
+
import * as htmlElement from "./htmlElement/htmlElement";
|
|
9
|
+
import * as image from "./image/image";
|
|
10
|
+
import * as integer from "./integer/integer";
|
|
11
|
+
import * as key from "./key/key";
|
|
12
|
+
import * as navigator from "./navigator/navigator";
|
|
13
|
+
import * as notification from "./notification/notification";
|
|
14
|
+
import * as querystring from "./querystring/querystring";
|
|
15
|
+
import * as router from "./router/router";
|
|
16
|
+
import * as stylesheet from "./stylesheet/stylesheet";
|
|
17
|
+
import * as uniqueId from "./uniqueId/uniqueId";
|
|
18
|
+
import * as webSocket from "./webSocket/webSocket";
|
|
19
|
+
|
|
20
|
+
export { blob };
|
|
21
|
+
export { cookie };
|
|
22
|
+
export { dataReaderTable };
|
|
23
|
+
export { fetch };
|
|
24
|
+
export { float };
|
|
25
|
+
export { formData };
|
|
26
|
+
export { html };
|
|
27
|
+
export { htmlElement };
|
|
28
|
+
export { image };
|
|
29
|
+
export { integer };
|
|
30
|
+
export { key };
|
|
31
|
+
export { navigator };
|
|
32
|
+
export { notification };
|
|
33
|
+
export { querystring };
|
|
34
|
+
export { router };
|
|
35
|
+
export { stylesheet };
|
|
36
|
+
export { uniqueId };
|
|
37
|
+
export { webSocket };
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
export function isInteger(text: string): boolean {
|
|
2
|
+
if (!text) {
|
|
3
|
+
throw "parameter text not provided";
|
|
4
|
+
}
|
|
5
|
+
return text.match(/\D/) === null;
|
|
6
|
+
}
|
|
7
|
+
|
|
8
|
+
export function isIntegerOrNull(text: string): boolean {
|
|
9
|
+
if (text) {
|
|
10
|
+
return isInteger(text);
|
|
11
|
+
}
|
|
12
|
+
return true;
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
export function convertToInt(text: any) {
|
|
16
|
+
if (typeof text === "string") {
|
|
17
|
+
if (isInteger(text)) {
|
|
18
|
+
const intValue = Number.parseInt(text);
|
|
19
|
+
if (Number.isNaN(intValue)) {
|
|
20
|
+
return null;
|
|
21
|
+
}
|
|
22
|
+
return intValue;
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
if (typeof text === "number") {
|
|
27
|
+
return Math.trunc(text);
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
return null;
|
|
31
|
+
}
|
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
import * as toastr from "toastr";
|
|
2
|
+
import { extend } from "jquery";
|
|
3
|
+
|
|
4
|
+
//Set toastr options
|
|
5
|
+
toastr.options.closeButton = true;
|
|
6
|
+
toastr.options.positionClass = "toast-bottom-full-width";
|
|
7
|
+
toastr.options.hideDuration = 1000;
|
|
8
|
+
toastr.options.timeOut = 6000;
|
|
9
|
+
toastr.options.extendedTimeOut = 2000;
|
|
10
|
+
toastr.options.progressBar = true;
|
|
11
|
+
|
|
12
|
+
//Define the default logging options
|
|
13
|
+
const defaults: INotificationOptions = {
|
|
14
|
+
title: "",
|
|
15
|
+
message: "no message provided",
|
|
16
|
+
data: "",
|
|
17
|
+
showToast: true,
|
|
18
|
+
type: "info"
|
|
19
|
+
};
|
|
20
|
+
|
|
21
|
+
interface INotificationOptions {
|
|
22
|
+
source?: string;
|
|
23
|
+
title?: string;
|
|
24
|
+
message: string;
|
|
25
|
+
data?: any;
|
|
26
|
+
showToast: boolean;
|
|
27
|
+
type: string;
|
|
28
|
+
timeOut?: number;
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
function show(options: INotificationOptions) {
|
|
32
|
+
let extendedOptions = extend({}, defaults);
|
|
33
|
+
if (options) {
|
|
34
|
+
extendedOptions = extend(extendedOptions, options);
|
|
35
|
+
}
|
|
36
|
+
console.log("Notification " + extendedOptions.type + ": " + extendedOptions.message + " " + extendedOptions.data + " ");
|
|
37
|
+
|
|
38
|
+
if (extendedOptions.showToast) {
|
|
39
|
+
if (options.timeOut) {
|
|
40
|
+
toastr[extendedOptions.type](extendedOptions.message, extendedOptions.title, { timeOut: options.timeOut });
|
|
41
|
+
} else {
|
|
42
|
+
toastr[extendedOptions.type](extendedOptions.message, extendedOptions.title);
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
export type MessageType = "error" | "info" | "success" | "warning";
|
|
48
|
+
|
|
49
|
+
export function showError(error: string, title: string, autoHideAfter?: number): void {
|
|
50
|
+
show({
|
|
51
|
+
title: title,
|
|
52
|
+
message: error,
|
|
53
|
+
type: "error",
|
|
54
|
+
showToast: true,
|
|
55
|
+
timeOut: autoHideAfter
|
|
56
|
+
});
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
export function showInfo(info: string, title: string, autoHideAfter?: number): void {
|
|
60
|
+
show({
|
|
61
|
+
title: title,
|
|
62
|
+
message: info,
|
|
63
|
+
type: "info",
|
|
64
|
+
showToast: true,
|
|
65
|
+
timeOut: autoHideAfter
|
|
66
|
+
});
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
export function showSuccess(success: string, title: string, autoHideAfter?: number): void {
|
|
70
|
+
show({
|
|
71
|
+
title: title,
|
|
72
|
+
message: success,
|
|
73
|
+
type: "success",
|
|
74
|
+
showToast: true,
|
|
75
|
+
timeOut: autoHideAfter
|
|
76
|
+
});
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
export function showWarning(warning: string, title: string, autoHideAfter?: number): void {
|
|
80
|
+
show({
|
|
81
|
+
title: title,
|
|
82
|
+
message: warning,
|
|
83
|
+
type: "warning",
|
|
84
|
+
showToast: true,
|
|
85
|
+
timeOut: autoHideAfter
|
|
86
|
+
});
|
|
87
|
+
}
|
|
88
|
+
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
export function parameterExists(name: string): boolean {
|
|
2
|
+
return window.location.search.indexOf(name) >= 0;
|
|
3
|
+
}
|
|
4
|
+
|
|
5
|
+
export function getParameter(name: string): string {
|
|
6
|
+
name = name.replace(/[\[]/, "\\[").replace(/[\]]/, "\\]");
|
|
7
|
+
const regex = new RegExp("[\\?&]" + name + "=([^&#]*)", "i");
|
|
8
|
+
const results = regex.exec(location.search);
|
|
9
|
+
return results == null ? "" : decodeURIComponent(results[1].replace(/\+/g, " "));
|
|
10
|
+
};
|
|
11
|
+
|
|
12
|
+
export function objectToQueryString(object: object): string {
|
|
13
|
+
if (object && Object.keys(object).length > 0) {
|
|
14
|
+
const parametersArray = new Array<string>();
|
|
15
|
+
|
|
16
|
+
Object.keys(object).forEach((key) => {
|
|
17
|
+
const value = object[key];
|
|
18
|
+
parametersArray.push(encodeURIComponent(key) + "=" + encodeURIComponent(value));
|
|
19
|
+
});
|
|
20
|
+
|
|
21
|
+
if (parametersArray.length === 0) {
|
|
22
|
+
return null;
|
|
23
|
+
}
|
|
24
|
+
return parametersArray.join("&");
|
|
25
|
+
}
|
|
26
|
+
return null;
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
export function getObjectFromQueryString(): object {
|
|
30
|
+
const result = {};
|
|
31
|
+
|
|
32
|
+
const search = (window as Window).location.search;
|
|
33
|
+
if (search && search.length > 2) {
|
|
34
|
+
const parameters = search.split("&");
|
|
35
|
+
if (parameters) {
|
|
36
|
+
parameters.forEach((parameter) => {
|
|
37
|
+
const nameValuePair = parameter.split("=");
|
|
38
|
+
result[decodeURIComponent(nameValuePair[0])] = JSON.parse(decodeURIComponent(nameValuePair[1]));
|
|
39
|
+
});
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
return result;
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
export function objectToBase64SQueryString(object: object, parameterName: string): string {
|
|
47
|
+
if (object && Object.keys(object).length > 0) {
|
|
48
|
+
const stateJson = JSON.stringify(object);
|
|
49
|
+
return parameterName + "=" + btoa(stateJson);
|
|
50
|
+
}
|
|
51
|
+
return null;
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
export function getObjectFromBase64QueryString(parameterName: string): object {
|
|
55
|
+
const serializedBase64ParameterValue = getParameter(parameterName);
|
|
56
|
+
if (serializedBase64ParameterValue) {
|
|
57
|
+
const objectJson = atob(serializedBase64ParameterValue);
|
|
58
|
+
return JSON.parse(objectJson);
|
|
59
|
+
}
|
|
60
|
+
return null;
|
|
61
|
+
}
|
|
@@ -0,0 +1,124 @@
|
|
|
1
|
+
import { getObjectFromQueryString, getObjectFromBase64QueryString , objectToQueryString, objectToBase64SQueryString} from "../querystring/querystring";
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
|
|
5
|
+
function getStateFromQueryString(stateReadable: boolean): Object {
|
|
6
|
+
if (stateReadable) {
|
|
7
|
+
return getObjectFromQueryString();
|
|
8
|
+
}
|
|
9
|
+
return getObjectFromBase64QueryString("s");
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
function getSerializeState(object : object,stateReadable: boolean): string {
|
|
13
|
+
if (stateReadable) {
|
|
14
|
+
return objectToQueryString(object);
|
|
15
|
+
}
|
|
16
|
+
return objectToBase64SQueryString(object, "s");
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
export interface RouterOptions<TRoute> {
|
|
20
|
+
//List of routes to be registered on the router
|
|
21
|
+
routes?: Array<TRoute>;
|
|
22
|
+
|
|
23
|
+
//Function to resolve a url from a TRoute object
|
|
24
|
+
urlFunction: (route: TRoute) => string;
|
|
25
|
+
|
|
26
|
+
//Handler to be called when the route changes
|
|
27
|
+
change: (route: TRoute, state: object) => void;
|
|
28
|
+
|
|
29
|
+
//Handler to be called when the router does not have a handler for the given route
|
|
30
|
+
routeMissing: (pathname: string, state: object) => void;
|
|
31
|
+
|
|
32
|
+
routeReadable: boolean;
|
|
33
|
+
|
|
34
|
+
//The root path of the router
|
|
35
|
+
root?: string;
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
export class Router<TRoute>
|
|
39
|
+
{
|
|
40
|
+
constructor(options: RouterOptions<TRoute>) {
|
|
41
|
+
this.options = options;
|
|
42
|
+
|
|
43
|
+
if (options.routes) {
|
|
44
|
+
this.setRoutes(options.routes);
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
private routeDictionary: { [url: string]: TRoute } = {};
|
|
49
|
+
|
|
50
|
+
private popstateHandler(event: PopStateEvent) {
|
|
51
|
+
const pathname = window.location.pathname;
|
|
52
|
+
const state = event.state || getStateFromQueryString(this.options.routeReadable);
|
|
53
|
+
|
|
54
|
+
const route = this.routeDictionary[pathname];
|
|
55
|
+
if (route) {
|
|
56
|
+
this.options.change(route, state);
|
|
57
|
+
} else {
|
|
58
|
+
this.options.routeMissing(pathname, state);
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
options: RouterOptions<TRoute>;
|
|
63
|
+
|
|
64
|
+
start() {
|
|
65
|
+
//Start listening to url changes
|
|
66
|
+
(window as Window).addEventListener("popstate", (event: PopStateEvent) => { this.popstateHandler(event); });
|
|
67
|
+
|
|
68
|
+
//Trigger the popstate event so the initial page is loaded
|
|
69
|
+
(window as Window).dispatchEvent(new Event("popstate"));
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
setRoutes(routes: Array<TRoute>, replace = false) {
|
|
73
|
+
if (replace) {
|
|
74
|
+
this.routeDictionary = {};
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
if (routes) {
|
|
78
|
+
routes.forEach((route) => {
|
|
79
|
+
this.addRoute(route);
|
|
80
|
+
});
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
destroy() {
|
|
85
|
+
//Stop listening to url changes
|
|
86
|
+
(window as Window).removeEventListener("popstate", this.popstateHandler);
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
addRoute(route: TRoute) {
|
|
90
|
+
let url = this.options.urlFunction(route);
|
|
91
|
+
if (this.options.root) {
|
|
92
|
+
url = this.options.root + url;
|
|
93
|
+
}
|
|
94
|
+
if (url[0] !== "/") {
|
|
95
|
+
url = "/" + url;
|
|
96
|
+
}
|
|
97
|
+
this.routeDictionary[url] = route;
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
navigate(route: string, state?: object, addStateToQueryString: boolean = true, triggerChange = true) {
|
|
101
|
+
let url = route;
|
|
102
|
+
if (state && addStateToQueryString) {
|
|
103
|
+
const serializedState = getSerializeState(state, this.options.routeReadable);
|
|
104
|
+
//Find out if the url already contains a querystring
|
|
105
|
+
if (url.indexOf("?") > -1) {
|
|
106
|
+
//Add the serialized state to the existing querystring
|
|
107
|
+
url = url + "&" + serializedState;
|
|
108
|
+
} else {
|
|
109
|
+
//Add the serialized state as querystring
|
|
110
|
+
url = url + "?" + serializedState;
|
|
111
|
+
}
|
|
112
|
+
}
|
|
113
|
+
if (!state) {
|
|
114
|
+
state = {};
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
history.pushState(state, "", url);
|
|
118
|
+
|
|
119
|
+
if (triggerChange) {
|
|
120
|
+
//Trigger the popstate event on the window object
|
|
121
|
+
(window as Window).dispatchEvent(new PopStateEvent("popstate", { state: state }));
|
|
122
|
+
}
|
|
123
|
+
}
|
|
124
|
+
}
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
const dynamicKey = "dynamic";
|
|
2
|
+
const groupKey = "group";
|
|
3
|
+
|
|
4
|
+
let styleSheet: CSSStyleSheet;
|
|
5
|
+
|
|
6
|
+
function get(): CSSStyleSheet {
|
|
7
|
+
if (!styleSheet) {
|
|
8
|
+
if (document.styleSheets.length > 0) {
|
|
9
|
+
styleSheet = document.styleSheets.item(0) as CSSStyleSheet;
|
|
10
|
+
} else {
|
|
11
|
+
throw "No stylesheets loaded";
|
|
12
|
+
}
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
return styleSheet;
|
|
16
|
+
}
|
|
17
|
+
//Insert a dynamic Css rule
|
|
18
|
+
export function insertRule(selector: string, style: string, markAsDynamic: boolean, index?: number, group?: string): void {
|
|
19
|
+
const styleSheet = get();
|
|
20
|
+
|
|
21
|
+
if (typeof styleSheet.insertRule === "function") {
|
|
22
|
+
const ruleExpression = selector + " {" + style + "}";
|
|
23
|
+
if (!index) {
|
|
24
|
+
index = styleSheet.cssRules.length;
|
|
25
|
+
}
|
|
26
|
+
const ruleIndex = styleSheet.insertRule(ruleExpression, index);
|
|
27
|
+
|
|
28
|
+
if (markAsDynamic) {
|
|
29
|
+
const rule = styleSheet.cssRules.item(ruleIndex);
|
|
30
|
+
|
|
31
|
+
|
|
32
|
+
//Add the property "dynamic" so the rule can be distinguished from already existing ones
|
|
33
|
+
rule[dynamicKey] = true;
|
|
34
|
+
if (group) {
|
|
35
|
+
rule[groupKey] = group;
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
export function removeDynamicRules(group?: string) {
|
|
42
|
+
const styleSheet = get();
|
|
43
|
+
|
|
44
|
+
for (let ruleIndex = styleSheet.cssRules.length - 1; ruleIndex >= 0; ruleIndex--) {
|
|
45
|
+
const rule = styleSheet.cssRules[ruleIndex];
|
|
46
|
+
|
|
47
|
+
//Find out if this rule has been added dynamically
|
|
48
|
+
if (rule[dynamicKey]) {
|
|
49
|
+
if (group) {
|
|
50
|
+
if (rule[groupKey] === group) {
|
|
51
|
+
styleSheet.deleteRule(ruleIndex);
|
|
52
|
+
}
|
|
53
|
+
} else {
|
|
54
|
+
styleSheet.deleteRule(ruleIndex);
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
}
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
const reopenDelay = 10000;
|
|
2
|
+
var webSocket: WebSocket;
|
|
3
|
+
var webSocketProtocol: string;
|
|
4
|
+
if (location.protocol === "http:") {
|
|
5
|
+
webSocketProtocol = "ws";
|
|
6
|
+
} else {
|
|
7
|
+
webSocketProtocol = "wss";
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
document.addEventListener("visibilitychange", () => {
|
|
11
|
+
if (document.visibilityState === 'visible') {
|
|
12
|
+
if (!webSocket || webSocket.readyState === WebSocket.CLOSED) {
|
|
13
|
+
open();
|
|
14
|
+
}
|
|
15
|
+
}
|
|
16
|
+
});
|
|
17
|
+
|
|
18
|
+
var webSocketUrl: string;
|
|
19
|
+
var onMessageHandler: (websocketMessage) => void;
|
|
20
|
+
|
|
21
|
+
function open() {
|
|
22
|
+
if (webSocketUrl && onMessageHandler) {
|
|
23
|
+
webSocket = new WebSocket(webSocketProtocol + "://" + location.host + "/" + webSocketUrl);
|
|
24
|
+
|
|
25
|
+
webSocket.onopen = () => {
|
|
26
|
+
console.log("Websocket opened");
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
webSocket.onclose = () => {
|
|
30
|
+
console.log("Websocket closed");
|
|
31
|
+
webSocket = null;
|
|
32
|
+
|
|
33
|
+
setTimeout(
|
|
34
|
+
() => {
|
|
35
|
+
open();
|
|
36
|
+
},
|
|
37
|
+
reopenDelay
|
|
38
|
+
);
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
webSocket.onerror = (error) => {
|
|
42
|
+
try {
|
|
43
|
+
console.log("Websocket error" + JSON.stringify(error));
|
|
44
|
+
webSocket.close();
|
|
45
|
+
webSocket = null;
|
|
46
|
+
|
|
47
|
+
setTimeout(
|
|
48
|
+
() => {
|
|
49
|
+
open();
|
|
50
|
+
},
|
|
51
|
+
reopenDelay
|
|
52
|
+
);
|
|
53
|
+
} catch (e) {
|
|
54
|
+
//Ignore the exception
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
webSocket.onmessage = (messageEvent: MessageEvent) => {
|
|
59
|
+
//Get the typed message
|
|
60
|
+
var webSocketMessage = JSON.parse(messageEvent.data);
|
|
61
|
+
|
|
62
|
+
//Call the handler
|
|
63
|
+
onMessageHandler(webSocketMessage);
|
|
64
|
+
};
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
export function initializeWebSocket(url: string, handler: (websocketMessage) => void) {
|
|
69
|
+
webSocketUrl = url;
|
|
70
|
+
onMessageHandler = handler;
|
|
71
|
+
open();
|
|
72
|
+
}
|