From e043788de86766eab2cf721f0e5c87364fc012ff Mon Sep 17 00:00:00 2001 From: gemu2015 Date: Mon, 18 May 2020 10:29:32 +0200 Subject: [PATCH] scripter support for google charts in WEBUI --- tasmota/xdrv_10_scripter.ino | 138 ++++++++++++++++++++++++++++++++++- 1 file changed, 134 insertions(+), 4 deletions(-) diff --git a/tasmota/xdrv_10_scripter.ino b/tasmota/xdrv_10_scripter.ino index 624237ab6..f0608fcfb 100755 --- a/tasmota/xdrv_10_scripter.ino +++ b/tasmota/xdrv_10_scripter.ino @@ -3592,6 +3592,11 @@ const char HTTP_FORM_SDC_HREF[] PROGMEM = uint8_t reject(char *name) { + char *lcp = strrchr(name,'/'); + if (lcp) { + name=lcp+1; + } + while (*name=='/') name++; if (*name=='_') return 1; if (*name=='.') return 1; @@ -4863,6 +4868,17 @@ const char SCRIPT_MSG_TEXTINP[] PROGMEM = const char SCRIPT_MSG_NUMINP[] PROGMEM = "
"; +const char SCRIPT_MSG_GTABLE[] PROGMEM = + "" + "" + ""; + +const char SCRIPT_MSG_GTE1[] PROGMEM = "'%s'"; + void ScriptGetVarname(char *nbuf,char *sp, uint32_t blen) { uint32_t cnt; @@ -4882,6 +4898,7 @@ void ScriptWebShow(char mc) { char tmp[128]; uint8_t optflg=0; char *lp=glob_script_mem.section_ptr+2; + uint8_t chartindex=1; while (lp) { while (*lp==SCRIPT_EOL) { lp++; @@ -5062,7 +5079,6 @@ void ScriptWebShow(char mc) { dtostrfd(max,4,maxstr); dtostrfd(step,4,stepstr); WSContentSend_PD(SCRIPT_MSG_NUMINP,label,minstr,maxstr,stepstr,vstr,vname); - } else { Replace_Cmd_Vars(lin,0,tmp,sizeof(tmp)); if (optflg) { @@ -5073,8 +5089,123 @@ void ScriptWebShow(char mc) { } } else { if (*lin==mc) { - Replace_Cmd_Vars(lin+1,0,tmp,sizeof(tmp)); - WSContentSend_PD(PSTR("%s"),tmp); + lin++; + if (!strncmp(lin,"tb(",3)) { + // get google table + struct T_INDEX ind; + uint8_t vtype; + char *lp=lin+3; + uint8 entries=0; + #define MAX_GARRAY 4 + float *arrays[MAX_GARRAY]; + uint8_t anum=0; + while (anum> 2 %d\n",(uint32_t)*fa); + if (fa && len>=entries) { + if (!entries) {entries = len;} + // add array to list + arrays[anum]=fa; + anum++; + } + } + } else { + lp=lp1; + break; + } + } + } + //Serial.printf("arrays %d\n",anum); + //Serial.printf("entries %d\n",entries); + + WSContentSend_PD(SCRIPT_MSG_GTABLE); + // we know how many arrays and the number of entries + // we need to fetch the labels now + WSContentSend_PD("["); + for (uint32_t cnt=0; cnt