Jump to content

picyka

uniGUI Subscriber
  • Posts

    1082
  • Joined

  • Last visited

  • Days Won

    34

Posts posted by picyka

  1. Good morning, I took a linux server to put NGINX, I'm using a reverse proxy

    port 8080 - Unigui
    port 8081 - API
    port 8082 - WS

    I wanted to continue using CloudFlare, in that environment, with hyperServer + IIS

    Would you work?

  2. A tip for those who want to copy text with few codes, I believe this could be implemented natively in unigui

    ServerModule -> CustomMeta
    
    <script language="JavaScript">
    
    function addslashes(str) {
        return (str + '').replace(/[\\"']/g, '\\$&').replace(/\u0000/g, '\\0');
    };
    
    async function copyText(texto) {
        try {
            await navigator.clipboard.writeText(texto);
        } catch (err) {
            console.error('Failed to copy: ', err);
        }
    };
    
    async function pasteText(jsName) {
        navigator.clipboard.readText().then(texto => {
            let txt = addslashes(texto);
            txt = txt.replace(/(?:\r\n|\r|\n)/g, '\\n');
            let cmd = jsName + ".setValue('" + txt + "');";
            eval(cmd);
        });
    };
    </script>
    procedure TUniMainModule.Copy(Control : TUniFormControl; MsgSucess : Boolean);
    begin
      var lTexto := String(Control.Text);
      Self.CopyStr(lTexto, MsgSucess);
    end;
    
    procedure TUniMainModule.CopyStr(Text: String; MsgSucess: Boolean);
    begin
      try
        var lTexto := TStringUtils.JsEncode(Text);
        var lJsString := 'copyText(' + QuotedStr(lTexto) + ');';
    
        UniSession.JSCode(lJsString);
    
        if MsgSucess then
          TToastUtils.Sucess('Copiado!',True,'Sucesso',1000);
      except
        on E: Exception do
          TMessageUtils.Error(E.Message);
      end;
    end;
    
    procedure TUniMainModule.Paste(Control : TUniFormControl);
    begin
      try
        var lJsName := Control.JSName;
        var lJsString := 'pasteText(' + QuotedStr(lJsName) + ');';
        UniSession.JSCode(lJsString);
      except
        on E: Exception do
          TMessageUtils.Error(E.Message);
      end;
    end;
    class function TStringUtils.JsEncode(const Src: String; const useNumericReference: boolean): String;
    var
      i, l: integer;
      Buf, P: PAnsiChar;
      ch: integer;
    begin
      Result := '';
    
      l := Length(Src);
    
      if l = 0 then Exit;
    
      if useNumericReference then
        GetMem(Buf, l * 6) // to be on the *very* safe side
      else
        GetMem(Buf, l * 2); // to be on the *very* safe side
    
      try
        P := Buf;
        for i := low(Src) to high(Src) do
        begin
          ch := Ord(Src[i]);
          case ch of
            8:
              begin // Backspace
                if useNumericReference then
                begin
                  ALStrMove('\u0008', P, 6);
                  Inc(P, 6);
                end
                else
                begin
                  ALStrMove('\b', P, 2);
                  Inc(P, 2);
                end;
              end;
            9:
              begin // Tab
                if useNumericReference then
                begin
                  ALStrMove('\u0009', P, 6);
                  Inc(P, 6);
                end
                else
                begin
                  ALStrMove('\t', P, 2);
                  Inc(P, 2);
                end;
              end;
            10:
              begin // New line
                if useNumericReference then
                begin
                  ALStrMove('\u000A', P, 6);
                  Inc(P, 6);
                end
                else
                begin
                  ALStrMove('\n', P, 2);
                  Inc(P, 2);
                end;
              end;
            11:
              begin // Vertical tab
                if useNumericReference then
                begin
                  ALStrMove('\u000B', P, 6);
                  Inc(P, 6);
                end
                else
                begin
                  ALStrMove('\v', P, 2);
                  Inc(P, 2);
                end;
              end;
            12:
              begin // Form feed
                if useNumericReference then
                begin
                  ALStrMove('\u000C', P, 6);
                  Inc(P, 6);
                end
                else
                begin
                  ALStrMove('\f', P, 2);
                  Inc(P, 2);
                end;
              end;
            13:
              begin // Carriage return
                if useNumericReference then
                begin
                  ALStrMove('\u000D', P, 6);
                  Inc(P, 6);
                end
                else
                begin
                  ALStrMove('\r', P, 2);
                  Inc(P, 2);
                end;
              end;
            34:
              begin // Double quote
                if useNumericReference then
                begin
                  ALStrMove('\u0022', P, 6);
                  Inc(P, 6);
                end
                else
                begin
                  ALStrMove('\"', P, 2);
                  Inc(P, 2);
                end;
              end;
            38:
              begin // & ... we need to encode it because in javascript &#39; or &amp; will be converted to ' and error unterminated string
                ALStrMove('\u0026', P, 6);
                Inc(P, 6);
              end;
            39:
              begin // Apostrophe or single quote
                if useNumericReference then
                begin
                  ALStrMove('\u0027', P, 6);
                  Inc(P, 6);
                end
                else
                begin
                  ALStrMove('\''', P, 2);
                  Inc(P, 2);
                end;
              end;
            60:
              begin // < ... mostly to hide all </script> tag inside javascript.
                // http://www.wwco.com/~wls/blog/2007/04/25/using-script-in-a-javascript-literal/
                ALStrMove('\u003C', P, 6);
                Inc(P, 6);
              end;
            62:
              begin // > ... mostly to hide all HTML tag inside javascript.
                ALStrMove('\u003E', P, 6);
                Inc(P, 6);
              end;
            92:
              begin // Backslash character (\).
                if useNumericReference then
                begin
                  ALStrMove('\u005C', P, 6);
                  Inc(P, 6);
                end
                else
                begin
                  ALStrMove('\\', P, 2);
                  Inc(P, 2);
                end;
              end;
          else
            Begin
              P^ := AnsiChar(ch);
              Inc(P);
            end;
          end;
        end;
        SetString(Result, Buf, P - Buf);
      finally
        FreeMem(Buf);
      end;
    end;





     

  3. Quote

     

    Version: 68

    When you send a file, where its name has blank spaces,

    unigui is putting %20 in place of the space

    MultiCompleted Event

    Object Files Files[0].FileName

×
×
  • Create New...