Skip to content

Commit

Permalink
Improve Script handling
Browse files Browse the repository at this point in the history
  • Loading branch information
wakr70 committed Apr 1, 2024
1 parent 92e0631 commit e211e3a
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 7 deletions.
2 changes: 1 addition & 1 deletion h2-highchart/H2-HighChart.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion h2-highchart/H2-HighChart.js.map

Large diffs are not rendered by default.

19 changes: 14 additions & 5 deletions h2-highchart/H2-HighChart.src.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
/* eslint-env browser */

window.H2buffer = {
version: 'v7.3', // Version
version: 'v7.4', // Version
// Setup H2 Database Services, default set to same server as this webpage and port 8082
server: location.hostname,
port: (location.port === "") ? "80" : location.port,
Expand Down Expand Up @@ -1355,24 +1355,33 @@ function getDataH2(p_series, p_attrID, p_attr, datStart, datEnd) {
if (window.H2buffer.DataAttr[p_attr].script.length>0){

let txtScript = window.H2buffer.DataAttr[p_attr].script;

if (txtScript.toUpperCase().includes('.READ(') ) {
txtScript = txtScript.replace('BeginDate', 'new Date('+datStart.toString()+')');
txtScript = txtScript.replace('EndDate', 'new Date('+datEnd.toString()+')');

postData = '{"id":"'+key+'","method":"executeScript","params":["'+txtScript+'",false]}'
postData = {
id: key,
method: 'executeScript',
params: [txtScript, false]
};
} else {
postData = '{"id":"'+key+'","method":"calculateTimeSeries","params":["'+txtScript+'",'+datStart.toString()+','+datEnd.toString()+']}'
postData = {
id: key,
method: 'calculateTimeSeries',
params: [txtScript, datStart, datEnd]
};
}
} else {
postData = {
id: key,
method: 'getTimeSeriesRaw',
params: [p_id, datStart, datEnd]
};

postData = JSON.stringify(postData);
}

postData = JSON.stringify(postData);

$.ajax({
url: url,
dataType: "json",
Expand Down

0 comments on commit e211e3a

Please sign in to comment.