@frangoteam/fuxa-min 1.2.0 → 1.2.2
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/README.md +4 -3
- package/_widgets/README.md +25 -0
- package/_widgets/controls/draggingIndicatorExample.svg +243 -0
- package/_widgets/controls/timePickerHHmmSS.svg +396 -0
- package/_widgets/controls/timePickerHHmmSSsss.svg +428 -0
- package/_widgets/dynamicSVG/blower3.svg +282 -0
- package/_widgets/dynamicSVG/blower3_flipped.svg +282 -0
- package/_widgets/dynamicSVG/blower4.svg +304 -0
- package/_widgets/dynamicSVG/blower4_flipped.svg +304 -0
- package/_widgets/dynamicSVG/checkvalve_closed.svg +333 -0
- package/_widgets/dynamicSVG/checkvalve_closed_flipped.svg +333 -0
- package/_widgets/dynamicSVG/checkvalve_open.svg +316 -0
- package/_widgets/dynamicSVG/checkvalve_open_flipped.svg +316 -0
- package/_widgets/dynamicSVG/compressor3.svg +361 -0
- package/_widgets/dynamicSVG/compressor6.svg +299 -0
- package/_widgets/dynamicSVG/condensor_3d_h1.svg +300 -0
- package/_widgets/dynamicSVG/conveyor.svg +316 -0
- package/_widgets/dynamicSVG/conveyor4.svg +314 -0
- package/_widgets/dynamicSVG/conveyor_20degdecline.svg +341 -0
- package/_widgets/dynamicSVG/conveyor_20degincline.svg +340 -0
- package/_widgets/dynamicSVG/cyclonicseparator.svg +317 -0
- package/_widgets/dynamicSVG/fanblades.svg +280 -0
- package/_widgets/dynamicSVG/flange_3d_1.svg +286 -0
- package/_widgets/dynamicSVG/flowmeter.svg +305 -0
- package/_widgets/dynamicSVG/flowmeter1.svg +281 -0
- package/_widgets/dynamicSVG/gaugedial_3d_h1.svg +288 -0
- package/_widgets/dynamicSVG/generator_1.svg +534 -0
- package/_widgets/dynamicSVG/heatexchanger_pipetopipe.svg +329 -0
- package/_widgets/dynamicSVG/heatexchanger_shelltube.svg +329 -0
- package/_widgets/dynamicSVG/heatexchanger_singlepipetopipe.svg +299 -0
- package/_widgets/dynamicSVG/meter_3d_h1.svg +299 -0
- package/_widgets/dynamicSVG/meter_3d_h2.svg +293 -0
- package/_widgets/dynamicSVG/mixer1.svg +369 -0
- package/_widgets/dynamicSVG/motor.svg +285 -0
- package/_widgets/dynamicSVG/motor1.svg +300 -0
- package/_widgets/dynamicSVG/motor1_flipped.svg +300 -0
- package/_widgets/dynamicSVG/motor_wshaft.svg +325 -0
- package/_widgets/dynamicSVG/pipe_3d_elbow.svg +287 -0
- package/_widgets/dynamicSVG/pipe_3d_elbow2.svg +285 -0
- package/_widgets/dynamicSVG/pipe_3d_h1.svg +286 -0
- package/_widgets/dynamicSVG/pipe_3d_h2.svg +287 -0
- package/_widgets/dynamicSVG/pipe_3d_h3.svg +286 -0
- package/_widgets/dynamicSVG/pipe_3d_heatexchange1.svg +298 -0
- package/_widgets/dynamicSVG/pipe_3d_heatexchange2.svg +293 -0
- package/_widgets/dynamicSVG/pipe_3d_heatexchange3.svg +289 -0
- package/_widgets/dynamicSVG/pipe_3d_tjunction.svg +286 -0
- package/_widgets/dynamicSVG/piperedirect1.svg +294 -0
- package/_widgets/dynamicSVG/piperedirect1_flipped.svg +294 -0
- package/_widgets/dynamicSVG/pressure_regulator.svg +374 -0
- package/_widgets/dynamicSVG/pulsationdampener.svg +300 -0
- package/_widgets/dynamicSVG/pump1.svg +328 -0
- package/_widgets/dynamicSVG/pump2.svg +310 -0
- package/_widgets/dynamicSVG/pump2_flipped.svg +310 -0
- package/_widgets/dynamicSVG/pump_3d_180.svg +323 -0
- package/_widgets/dynamicSVG/pump_3d_180_flipped.svg +323 -0
- package/_widgets/dynamicSVG/pump_3d_90_1.svg +318 -0
- package/_widgets/dynamicSVG/pump_3d_90_1_flipped.svg +318 -0
- package/_widgets/dynamicSVG/pump_3d_example.svg +292 -0
- package/_widgets/dynamicSVG/pump_3d_straight1.svg +321 -0
- package/_widgets/dynamicSVG/pump_3d_straight1_flipped.svg +321 -0
- package/_widgets/dynamicSVG/pumphead_profile_3d.svg +303 -0
- package/_widgets/dynamicSVG/reducer_3d_1.svg +290 -0
- package/_widgets/dynamicSVG/reducer_3d_2.svg +287 -0
- package/_widgets/dynamicSVG/sensor_rtd.svg +391 -0
- package/_widgets/dynamicSVG/sensor_rtd_silhouette.svg +286 -0
- package/_widgets/dynamicSVG/strainer_basket.svg +376 -0
- package/_widgets/dynamicSVG/strainer_basket_r.svg +377 -0
- package/_widgets/dynamicSVG/strainer_wye.svg +401 -0
- package/_widgets/dynamicSVG/strainer_wye_r.svg +403 -0
- package/_widgets/dynamicSVG/tank_3d_medium_rtop1.svg +286 -0
- package/_widgets/dynamicSVG/tank_3d_v1.svg +291 -0
- package/_widgets/dynamicSVG/tank_3d_v2.svg +295 -0
- package/_widgets/dynamicSVG/tank_3d_v4.svg +290 -0
- package/_widgets/dynamicSVG/tank_3d_v5.svg +295 -0
- package/_widgets/dynamicSVG/tank_3d_v6.svg +290 -0
- package/_widgets/dynamicSVG/tank_3d_v7.svg +292 -0
- package/_widgets/dynamicSVG/trucking.svg +297 -0
- package/_widgets/dynamicSVG/turbine1.svg +284 -0
- package/_widgets/dynamicSVG/turbine2.svg +329 -0
- package/_widgets/dynamicSVG/turbinerounded.svg +291 -0
- package/_widgets/dynamicSVG/valve_1path_down.svg +291 -0
- package/_widgets/dynamicSVG/valve_3d_3way1.svg +329 -0
- package/_widgets/dynamicSVG/valve_3d_3way1_nopipe.svg +310 -0
- package/_widgets/dynamicSVG/valve_3d_4way1.svg +358 -0
- package/_widgets/dynamicSVG/valve_3d_4way1_nopipe.svg +328 -0
- package/_widgets/dynamicSVG/valve_3d_angled1.svg +325 -0
- package/_widgets/dynamicSVG/valve_3d_angled1_nopipe.svg +305 -0
- package/_widgets/dynamicSVG/valve_3d_angled2.svg +323 -0
- package/_widgets/dynamicSVG/valve_3d_angled2_nopipe.svg +301 -0
- package/_widgets/dynamicSVG/valve_3d_common1.svg +321 -0
- package/_widgets/dynamicSVG/valve_3d_common2.svg +327 -0
- package/_widgets/dynamicSVG/valve_3d_common2_nopipe.svg +298 -0
- package/_widgets/dynamicSVG/valve_3d_common3.svg +327 -0
- package/_widgets/dynamicSVG/valve_3d_common4.svg +329 -0
- package/_widgets/dynamicSVG/valve_3d_common4_nopipe.svg +299 -0
- package/_widgets/dynamicSVG/valve_3d_h1.svg +286 -0
- package/_widgets/dynamicSVG/valve_3d_h2_closed.svg +299 -0
- package/_widgets/dynamicSVG/valve_3d_h2_open.svg +291 -0
- package/_widgets/dynamicSVG/valve_circle.svg +295 -0
- package/_widgets/indicators/analogIndicatorExample.svg +272 -0
- package/_widgets/indicators/timeDisplayHHmmSS.svg +160 -0
- package/_widgets/indicators/timeDisplayHHmmSSsss.svg +164 -0
- package/api/alarms/index.js +2 -1
- package/api/command/index.js +7 -36
- package/api/index.js +12 -6
- package/api/reports/reports.service.ts +173 -0
- package/api/resources/index.js +38 -1
- package/api/scripts/index.js +6 -4
- package/dist/assets/i18n/de.json +2 -2
- package/dist/assets/i18n/en.json +56 -1
- package/dist/assets/i18n/pt.json +4 -1
- package/dist/assets/i18n/zh-cn.json +4 -1
- package/dist/assets/lib/svgeditor/fuxa-editor.min.js +6 -6
- package/dist/index.html +1 -1
- package/dist/{main.5077e611f1edda9a.js → main.2d2f80d247cc5c25.js} +36 -36
- package/dist/reports.service.js +166 -0
- package/main.js +10 -4
- package/package.json +7 -4
- package/runtime/alarms/index.js +64 -33
- package/runtime/devices/bacnet/index.js +33 -33
- package/runtime/devices/device-utils.js +11 -6
- package/runtime/devices/device.js +28 -29
- package/runtime/devices/ethernetip/index.js +14 -14
- package/runtime/devices/fuxaserver/index.js +13 -13
- package/runtime/devices/httprequest/index.js +19 -19
- package/runtime/devices/index.js +36 -38
- package/runtime/devices/modbus/datatypes.js +8 -8
- package/runtime/devices/modbus/index.js +132 -54
- package/runtime/devices/mqtt/index.js +15 -15
- package/runtime/devices/opcua/index.js +27 -51
- package/runtime/devices/s7/index.js +22 -21
- package/runtime/index.js +126 -23
- package/runtime/plugins/index.js +1 -1
- package/runtime/project/index.js +67 -55
- package/runtime/scripts/index.js +33 -7
- package/runtime/scripts/msm.js +8 -7
- package/runtime/storage/tdengine/index.js +8 -6
- package/runtime/utils.js +35 -6
- package/settings.default.js +86 -64
package/README.md
CHANGED
|
@@ -9,7 +9,7 @@ FUXA is a web-based Process Visualization (SCADA/HMI/Dashboard) software. With F
|
|
|
9
9
|

|
|
10
10
|
|
|
11
11
|
## Features
|
|
12
|
-
- Devices connectivity with Modbus RTU/TCP, OPC-UA, BACnet IP, MQTT, WebAPI, Ethernet/IP (Allen Bradley)
|
|
12
|
+
- Devices connectivity with Modbus RTU/TCP, Siemens S7 Protocol, OPC-UA, BACnet IP, MQTT, WebAPI, Ethernet/IP (Allen Bradley), ODBC
|
|
13
13
|
- SCADA/HMI Web-Editor - Engineering and Design completely web-based
|
|
14
14
|
- Cross-Platform Full-Stack - Backend with NodeJs and Frontend with Web technologies (HTML5, CSS, Javascript, Angular, SVG)
|
|
15
15
|
|
|
@@ -21,9 +21,9 @@ FUXA is developed with NodeJS (backend) and Angular (frontend).
|
|
|
21
21
|
|
|
22
22
|
**WARNING** You need to have installed [Node](https://nodejs.org/en/about/previous-releases) Version 14 || 16 || 18
|
|
23
23
|
|
|
24
|
-
Install from [NPM](https://www.npmjs.com/package/@frangoteam/fuxa
|
|
24
|
+
Install from [NPM](https://www.npmjs.com/package/@frangoteam/fuxa)
|
|
25
25
|
```
|
|
26
|
-
npm install -g --unsafe-perm @frangoteam/fuxa
|
|
26
|
+
npm install -g --unsafe-perm @frangoteam/fuxa
|
|
27
27
|
fuxa
|
|
28
28
|
```
|
|
29
29
|
|
|
@@ -34,6 +34,7 @@ Open up a browser (better Chrome) and navigate to http://localhost:1881
|
|
|
34
34
|
- Look video from [frangoteam](https://www.youtube.com/@umbertonocelli5301)
|
|
35
35
|
- Look video from [Fusion Automate - Urvish Nakum](https://youtube.com/playlist?list=PLxrSjjYyzaaK8uY3kVaFzfGnwhVXiCEAO&si=aU1OxgkUvLQ3bXHq)
|
|
36
36
|
|
|
37
|
+
|
|
37
38
|
## Let us know!
|
|
38
39
|
We’d be really happy if you send us your own shapes in order to collect a library to share it with others. Just send an email to 4frango@gmail.com and do let us know if you have any questions or suggestions regarding our work.
|
|
39
40
|
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
**How to use**
|
|
2
|
+
|
|
3
|
+
The widgets will be displayed in the editor panel and can be used from there directly, or download the SVG from here make your edits and follow the steps:
|
|
4
|
+
```
|
|
5
|
+
1. Select desired SVG image
|
|
6
|
+
2. Click download Icon
|
|
7
|
+
3. Import SVG in Fuxa project using embedded Image Import
|
|
8
|
+
```
|
|
9
|
+
|
|
10
|
+
**How to contribute**
|
|
11
|
+
```
|
|
12
|
+
1. Fork the Project
|
|
13
|
+
2. In your Fork enter FUXA/server/_widgets/(what type your SVG is, control, indicator, dynamicSVG)
|
|
14
|
+
3. Add File Arrow, Upload file
|
|
15
|
+
4. Select your SVG and name the commit
|
|
16
|
+
5. Commit the changes
|
|
17
|
+
6. Go back to FUXA main page in your Fork
|
|
18
|
+
7. Click Contribute
|
|
19
|
+
8. Open a Pull Request
|
|
20
|
+
```
|
|
21
|
+
Please Include a description in the How to Use section of the SVG file, how your SVG control/indicator/dynamicSVG works and how to use it in Fuxa
|
|
22
|
+
|
|
23
|
+
For more details on building SVG widgets and using them please see the Wiki
|
|
24
|
+
|
|
25
|
+
https://github.com/frangoteam/FUXA/wiki/HowTo-Widgets
|
|
@@ -0,0 +1,243 @@
|
|
|
1
|
+
<svg
|
|
2
|
+
viewBox="0 0 300 100"
|
|
3
|
+
version="1.1"
|
|
4
|
+
id="indicatorSVG"
|
|
5
|
+
xmlns="http://www.w3.org/2000/svg">
|
|
6
|
+
<g
|
|
7
|
+
id="layer1"
|
|
8
|
+
transform="translate(0,0)">
|
|
9
|
+
<rect
|
|
10
|
+
style="fill:#cccccc;fill-rule:evenodd;stroke:#4d4d4d;stroke-width:1.0413;stroke-linecap:round;stroke-linejoin:round;stroke-miterlimit:1"
|
|
11
|
+
id="rectBackground"
|
|
12
|
+
width="280"
|
|
13
|
+
height="40"
|
|
14
|
+
x="10"
|
|
15
|
+
y="30" />
|
|
16
|
+
<circle
|
|
17
|
+
style="fill:#ff0000;fill-rule:evenodd;stroke:#4d4d4d;stroke-width:1.0413;stroke-linecap:round;stroke-linejoin:round;stroke-miterlimit:1; cursor: pointer; transition: fill 0.2s ease;"
|
|
18
|
+
id="movingIndicator"
|
|
19
|
+
cx="10"
|
|
20
|
+
cy="50"
|
|
21
|
+
r="10" />
|
|
22
|
+
</g>
|
|
23
|
+
<script type="text/javascript">
|
|
24
|
+
<![CDATA[
|
|
25
|
+
|
|
26
|
+
/*
|
|
27
|
+
|
|
28
|
+
#####################################
|
|
29
|
+
# How to Use #
|
|
30
|
+
#####################################
|
|
31
|
+
|
|
32
|
+
Variables with the following prefix:
|
|
33
|
+
|
|
34
|
+
_pb_ = bool parameter ( true or false )
|
|
35
|
+
_pn_ = number parameter ( Int, Float, Real etc )
|
|
36
|
+
_ps_ = string parameter ( string can be entered directly )
|
|
37
|
+
_pc_ = color parameter in hex color code ( #00ff00ff )
|
|
38
|
+
|
|
39
|
+
Indicate variable type to be used in Fuxa Properties and binding of Tags, Important! they have to be place within:
|
|
40
|
+
|
|
41
|
+
//!export-start
|
|
42
|
+
let _pn_setState = 0;
|
|
43
|
+
//!export-end
|
|
44
|
+
|
|
45
|
+
|
|
46
|
+
There are 2x Functions to handle sending and receiving data between Fuxa and the SVG
|
|
47
|
+
|
|
48
|
+
// Recieve Variables From Fuxa
|
|
49
|
+
function putValue(id, value) { }
|
|
50
|
+
|
|
51
|
+
// Send Variables To Fuxa
|
|
52
|
+
function postValue(id, value) {
|
|
53
|
+
console.error('Not defined!');
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
The ID is the name of the variable _pn_setState for example and value is the value to be sent or received from Fuxa
|
|
57
|
+
|
|
58
|
+
The scripts etc need to be within the SVG tags
|
|
59
|
+
|
|
60
|
+
<svg>
|
|
61
|
+
SVG Content Here
|
|
62
|
+
<script>
|
|
63
|
+
JS Script Content Here
|
|
64
|
+
</script>
|
|
65
|
+
</svg>
|
|
66
|
+
|
|
67
|
+
|
|
68
|
+
The below example uses simple SVG elements as an example, but complex logig to handle everything fully dynamic
|
|
69
|
+
you can drag the indicator within if the bounds of the rectangle
|
|
70
|
+
You can change the angle of the SVG in Fuxa editor to 45 degrees for example and it will still work
|
|
71
|
+
You and resize the slider in Fuxa editor and dragging adjusts to the new size
|
|
72
|
+
This can be edited even further to suit your needs, just a good starting point
|
|
73
|
+
|
|
74
|
+
*/
|
|
75
|
+
|
|
76
|
+
//!export-start
|
|
77
|
+
let _pn_currentValue = 0; // Current value of the indicator
|
|
78
|
+
let _pn_initValue = 0; // Initial value of the indicator
|
|
79
|
+
let _pn_minVal = -100; // Minimum value for scaling
|
|
80
|
+
let _pn_maxVal = 100; // Maximum value for scaling
|
|
81
|
+
let _pc_defaultColour = '#ff0000'; // Default color of the indicator
|
|
82
|
+
let _pc_clickedColour = '#00ff00'; // Color when the indicator is clicked
|
|
83
|
+
//!export-end
|
|
84
|
+
|
|
85
|
+
let isDragging = false; // Indicates if the indicator is currently being dragged
|
|
86
|
+
let dragOffsetX = 0; // Offset between mouse and indicator when drag starts
|
|
87
|
+
let rectLeft = 0; // Left position of the rectangle
|
|
88
|
+
let rectWidth = 0; // Width of the rectangle
|
|
89
|
+
let indicatorRadius = 0; // Variable to hold the radius of the indicator
|
|
90
|
+
|
|
91
|
+
// Get the bounding box of the SVG to adjust for its size and position
|
|
92
|
+
const svgElement = document.getElementById('indicatorSVG');
|
|
93
|
+
|
|
94
|
+
// Update the indicator's position based on the provided value
|
|
95
|
+
function updateIndicator(value) {
|
|
96
|
+
const rect = document.getElementById('rectBackground');
|
|
97
|
+
const indicator = document.getElementById('movingIndicator');
|
|
98
|
+
|
|
99
|
+
// Get dimensions and position
|
|
100
|
+
rectWidth = rect.width.baseVal.value;
|
|
101
|
+
rectLeft = rect.x.baseVal.value;
|
|
102
|
+
|
|
103
|
+
const scaledValue = (value - _pn_minVal) / (_pn_maxVal - _pn_minVal); // Scale value to range
|
|
104
|
+
|
|
105
|
+
// Calculate position of the indicator
|
|
106
|
+
const indicatorX = scaledValue * (rectWidth - 2 * indicatorRadius) + rectLeft + indicatorRadius; // Adjust for radius
|
|
107
|
+
|
|
108
|
+
// Update the position of the indicator
|
|
109
|
+
indicator.setAttribute('cx', indicatorX);
|
|
110
|
+
// Update the current value
|
|
111
|
+
_pn_currentValue = value;
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
// Change the indicator's color when clicked
|
|
115
|
+
function changeColor() {
|
|
116
|
+
const indicator = document.getElementById('movingIndicator');
|
|
117
|
+
if (indicator) {
|
|
118
|
+
indicator.style.fill = _pc_clickedColour; // Change the fill color
|
|
119
|
+
}
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
// Reset the indicator's color to default
|
|
123
|
+
function resetColor() {
|
|
124
|
+
const indicator = document.getElementById('movingIndicator');
|
|
125
|
+
if (indicator) {
|
|
126
|
+
indicator.style.fill = _pc_defaultColour; // Change the fill color
|
|
127
|
+
}
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
// Start dragging the indicator
|
|
131
|
+
function startDrag(event) {
|
|
132
|
+
isDragging = true;
|
|
133
|
+
|
|
134
|
+
// Get transformation matrix for correct mouse-to-SVG coordinate mapping
|
|
135
|
+
const matrix = svgElement.getScreenCTM().inverse();
|
|
136
|
+
const point = svgElement.createSVGPoint();
|
|
137
|
+
|
|
138
|
+
point.x = event.clientX || (event.touches ? event.touches[0].clientX : 0);
|
|
139
|
+
point.y = event.clientY || (event.touches ? event.touches[0].clientY : 0);
|
|
140
|
+
const transformedPoint = point.matrixTransform(matrix);
|
|
141
|
+
|
|
142
|
+
const indicator = document.getElementById('movingIndicator');
|
|
143
|
+
dragOffsetX = transformedPoint.x - parseFloat(indicator.getAttribute('cx')); // Offset between mouse and indicator center
|
|
144
|
+
event.preventDefault(); // Prevent default actions
|
|
145
|
+
}
|
|
146
|
+
|
|
147
|
+
// Handle dragging the indicator (corrected for rotation)
|
|
148
|
+
function dragMove(event) {
|
|
149
|
+
if (!isDragging) return;
|
|
150
|
+
|
|
151
|
+
const indicator = document.getElementById('movingIndicator');
|
|
152
|
+
if (indicator) {
|
|
153
|
+
// Get the inverse of the current transformation matrix (to map mouse coordinates correctly)
|
|
154
|
+
const matrix = svgElement.getScreenCTM().inverse();
|
|
155
|
+
const point = svgElement.createSVGPoint();
|
|
156
|
+
|
|
157
|
+
// Get the current mouse position in client coordinates
|
|
158
|
+
point.x = event.clientX || (event.touches ? event.touches[0].clientX : 0);
|
|
159
|
+
point.y = event.clientY || (event.touches ? event.touches[0].clientY : 0);
|
|
160
|
+
|
|
161
|
+
// Transform the point into the SVG's local coordinates
|
|
162
|
+
const transformedPoint = point.matrixTransform(matrix);
|
|
163
|
+
|
|
164
|
+
// Calculate the new position for the indicator (adjust for drag offset)
|
|
165
|
+
let newCx = transformedPoint.x - dragOffsetX;
|
|
166
|
+
|
|
167
|
+
// Constrain the new position within the rectangle bounds
|
|
168
|
+
const minX = rectLeft + indicatorRadius;
|
|
169
|
+
const maxX = rectLeft + rectWidth - indicatorRadius;
|
|
170
|
+
newCx = Math.max(minX, Math.min(maxX, newCx));
|
|
171
|
+
|
|
172
|
+
// Update the indicator's position
|
|
173
|
+
indicator.setAttribute('cx', newCx);
|
|
174
|
+
|
|
175
|
+
// Update the current value based on the new position
|
|
176
|
+
const scaledValue = (newCx - rectLeft - indicatorRadius) / (rectWidth - 2 * indicatorRadius);
|
|
177
|
+
_pn_currentValue = _pn_minVal + scaledValue * (_pn_maxVal - _pn_minVal);
|
|
178
|
+
|
|
179
|
+
// Send Value to Fuxa
|
|
180
|
+
postValue('_pn_currentValue', _pn_currentValue);
|
|
181
|
+
}
|
|
182
|
+
}
|
|
183
|
+
|
|
184
|
+
// End dragging the indicator
|
|
185
|
+
function endDrag() {
|
|
186
|
+
if (isDragging) {
|
|
187
|
+
resetColor(); // Reset color when dragging ends
|
|
188
|
+
isDragging = false;
|
|
189
|
+
}
|
|
190
|
+
}
|
|
191
|
+
|
|
192
|
+
// Initial setup and event listeners
|
|
193
|
+
function init() {
|
|
194
|
+
updateIndicator(_pn_initValue); // Set initial position based on initial value
|
|
195
|
+
|
|
196
|
+
const indicator = document.getElementById('movingIndicator');
|
|
197
|
+
if (indicator) {
|
|
198
|
+
indicatorRadius = indicator.r.baseVal.value; // Get the radius once during initialization
|
|
199
|
+
indicator.addEventListener('mousedown', function(event) {
|
|
200
|
+
changeColor();
|
|
201
|
+
startDrag(event);
|
|
202
|
+
});
|
|
203
|
+
indicator.addEventListener('mouseup', endDrag);
|
|
204
|
+
indicator.addEventListener('touchstart', function(event) {
|
|
205
|
+
changeColor();
|
|
206
|
+
startDrag(event);
|
|
207
|
+
});
|
|
208
|
+
indicator.addEventListener('touchend', endDrag);
|
|
209
|
+
}
|
|
210
|
+
|
|
211
|
+
// Add global listeners for drag
|
|
212
|
+
window.addEventListener('mousemove', dragMove);
|
|
213
|
+
window.addEventListener('mouseup', endDrag);
|
|
214
|
+
|
|
215
|
+
// Add global listeners for touch drag
|
|
216
|
+
window.addEventListener('touchmove', dragMove);
|
|
217
|
+
window.addEventListener('touchend', endDrag);
|
|
218
|
+
}
|
|
219
|
+
|
|
220
|
+
// Variables received from Fuxa
|
|
221
|
+
function putValue(id, value) {
|
|
222
|
+
if (id === '_pn_currentValue') {
|
|
223
|
+
updateIndicator(value);
|
|
224
|
+
}
|
|
225
|
+
if (id === '_pn_initValue' ) _pn_initValue = value;
|
|
226
|
+
if (id === '_pn_minVal' ) _pn_minVal = value;
|
|
227
|
+
if (id === '_pn_maxVal' ) _pn_maxVal = value;
|
|
228
|
+
if (id === '_pc_defaultColour') _pc_defaultColour = value;
|
|
229
|
+
if (id === '_pc_clickedColour') _pc_clickedColour = value;
|
|
230
|
+
}
|
|
231
|
+
|
|
232
|
+
// Send Variables to Fuxa
|
|
233
|
+
function postValue(id, value) {
|
|
234
|
+
console.error('Not defined!');
|
|
235
|
+
}
|
|
236
|
+
|
|
237
|
+
init(); // Start initialization
|
|
238
|
+
]]>
|
|
239
|
+
</script>
|
|
240
|
+
</svg>
|
|
241
|
+
|
|
242
|
+
|
|
243
|
+
|