Page 4 of 4 FirstFirst ... 234
Results 31 to 36 of 36

Thread: Is it possible to make webserver play nice with special characters in variables?

  1. #31
    Join Date
    Jan 1998
    Location
    Jupiter, FL
    Posts
    13,541

    Default

    Do you get a Lua/Logger error? Can you show me the output that you do get?
    Ron
    No support through PM

  2. #32
    Join Date
    Jul 2001
    Location
    Risør - Norway
    Posts
    5,477

    Default

    Hi, Ron! No, I don't. There's no unusual output in Girder, the log display shows the same stuff as when I'm not using this line (it's constantly refreshing to reflect changes from clicking or entering temperatures). This is with the line:

    Code:
    Time    Date    Source    Details    Payloads
    14:12:47:954    5/10/2015    WebServer    /ajaxreqjson.lhtml    Data=myVal,Temperaturstyring.Nettside.Termostatmodus.0    _=1431259970364
    14:12:47:959    5/10/2015    WebServer    /ajaxreqjson.lhtml    Data=myVal,Temperaturstyring.Nettside.Termostatmodus.1    _=1431259970367
    14:12:47:964    5/10/2015    WebServer    /ajaxreqjson.lhtml    Data=myVal,Temperaturstyring.Nettside.Termostatmodus.2    _=1431259970369

    This is without it:
    Code:
    Time    Date    Source    Details    Payloads
    14:14:48:658    5/10/2015    WebServer    /ajaxreqjson.lhtml    Data=myVal,Temperaturstyring.Nettside.Termostatmodus.0    _=1431260090787
    14:14:48:664    5/10/2015    WebServer    /ajaxreqjson.lhtml    Data=myVal,Temperaturstyring.Nettside.Termostatmodus.1    _=1431260090789
    The difference is in what I see. If I click on one of the (invisible) buttons the reaction is what I get as well:

    Code:
    Time    Date    Source    Details    Payloads
    14:15:54:090    5/10/2015    WebServer    /ajax_sendevent_payload.lhtml    device=18    event=SettTermostatmodus    payload1=1    payload2    payload3=1    payload4=FromWeb
    14:15:54:094    5/10/2015    Girder    SettTermostatmodus    1        1    FromWeb
    This tells girder to set room number 1 (payload1) to day temp (payload3), and that this comes from the webpage, and not a timer (payload4). Here are screenshots of the difference.
    Attached Thumbnails Attached Thumbnails Click image for larger version. 

Name:	with line.jpg 
Views:	63 
Size:	291.1 KB 
ID:	6885   Click image for larger version. 

Name:	without line.jpg 
Views:	67 
Size:	162.9 KB 
ID:	6886  
    Tor - managing director of the Cinema Inferno home theater and multi-zone sound system with Girder running the show in the back, NetRemote as the GUI and Media Center 17, PowerDVD and ZoomPlayer as playback software
    Hobsyssel mastiffs: http://www.hobsyssel.no

  3. #33
    Join Date
    Jan 1998
    Location
    Jupiter, FL
    Posts
    13,541

    Default

    Try this one: ( I didn't try on Girder 5, we're about to head out, it's mothersday after all. )

    Code:
    <%
    webserver:SetHeader("Content-Type: application/json; charset=ISO-8859-1", true);
    
    function getfield (f)
        local v = _G    -- start with the table of globals
        for w in string.gfind(f, "[%w_]+") do
            if type(v) == 'table' then --v ~= nil
                v = v[w]
            else
                return false
            end
        end
        return v
    end
    
    local s,vartype
    local t = webserver:GetCGI()    
    
    if t.Data then
      local json = require('json.json')
      local data = string.Split(t.Data,",")
      webserver:print('{')
      for i in ipairs(data) do
        if (i~=1) then 
          webserver:print(',')
        end
        webserver:print('"' .. data[i] .. '":')
        s=getfield(data[i])
        if s then
            vartype = type(s)
        if ( vartype =='function' ) or ( vartype =='thread' ) or ( vartype == 'userdata' ) then
                webserver:print('"[' .. vartype .. ']"')
            else 
                if (s==nil) then
                  webserver:print('null')
                else
                  webserver:print(json.encode(s))
                end
            end
        else
            webserver:print('"[Variable Not found]"')
        end
      end
      webserver:print('}')
    end
    
    
            
    %>
    Ron
    No support through PM

  4. #34
    Join Date
    Jul 2001
    Location
    Risør - Norway
    Posts
    5,477

    Default

    Nope, sorry. Same thing. As for mother's day, I didn't know the US had another day then us. We have it the second Sunday in February. And it's not a big hurry, but I would appreciate it if you could have a look at it when you get the time! It's sort of the only remaining thing on that temperature control system, at least the only thing I know about!
    Tor - managing director of the Cinema Inferno home theater and multi-zone sound system with Girder running the show in the back, NetRemote as the GUI and Media Center 17, PowerDVD and ZoomPlayer as playback software
    Hobsyssel mastiffs: http://www.hobsyssel.no

  5. #35
    Join Date
    Jul 2001
    Location
    Risør - Norway
    Posts
    5,477

    Default

    I'm dragging zombie up again here, but I have from time to time thought about asking again, and since it's only five months unil til system should be totally glitch free because I'm putting the house up for sale, I thought I'd ask if you have any ideas. Everything is still as before. Execution of the main script just stops by adding the first line of your previous script to the setup. And I have those pesky � instead of ø here. Do you have any idea what this can be? Please?
    Tor - managing director of the Cinema Inferno home theater and multi-zone sound system with Girder running the show in the back, NetRemote as the GUI and Media Center 17, PowerDVD and ZoomPlayer as playback software
    Hobsyssel mastiffs: http://www.hobsyssel.no

  6. #36
    Join Date
    Jul 2001
    Location
    Risør - Norway
    Posts
    5,477

    Default

    Finally found it with help from a local web guru. This line in the ajaxreqson script fixed it:

    webserver:SetHeaderEx("Content-Type", "text/plain; charset=iso-8859-1", true)
    Tor - managing director of the Cinema Inferno home theater and multi-zone sound system with Girder running the show in the back, NetRemote as the GUI and Media Center 17, PowerDVD and ZoomPlayer as playback software
    Hobsyssel mastiffs: http://www.hobsyssel.no

Page 4 of 4 FirstFirst ... 234

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •