Browse Source

* Allow display of not found elements

michael 5 years ago
parent
commit
e4dbc23e67
1 changed files with 20 additions and 4 deletions
  1. 20 4
      packages/fcl-base/browserapp.pas

+ 20 - 4
packages/fcl-base/browserapp.pas

@@ -17,6 +17,7 @@ type
     function CreateHTMLElement(aTag : String; aID : String = '') : TJSHTMLElement;
     function CreateHTMLElement(aTag : String; aID : String = '') : TJSHTMLElement;
     procedure DoRun; override;
     procedure DoRun; override;
     function GetConsoleApplication: boolean; override;
     function GetConsoleApplication: boolean; override;
+    Function LogGetElementErrors : Boolean;
     function GetLocation: String; override;
     function GetLocation: String; override;
   public
   public
     procedure GetEnvironmentList(List: TStrings; NamesOnly: Boolean); override;
     procedure GetEnvironmentList(List: TStrings; NamesOnly: Boolean); override;
@@ -36,7 +37,7 @@ procedure ReloadEnvironmentStrings;
 
 
 var
 var
   I : Integer;
   I : Integer;
-  S : String;
+  S,N : String;
   A,P : TStringDynArray;
   A,P : TStringDynArray;
 begin
 begin
   if Assigned(EnvNames) then
   if Assigned(EnvNames) then
@@ -48,10 +49,11 @@ begin
   for I:=0 to Length(A)-1 do
   for I:=0 to Length(A)-1 do
     begin
     begin
     P:=TJSString(A[i]).split('=');
     P:=TJSString(A[i]).split('=');
+    N:=LowerCase(decodeURIComponent(P[0]));
     if Length(P)=2 then
     if Length(P)=2 then
-      EnvNames[decodeURIComponent(P[0])]:=decodeURIComponent(P[1])
+      EnvNames[N]:=decodeURIComponent(P[1])
     else if Length(P)=1 then
     else if Length(P)=1 then
-      EnvNames[decodeURIComponent(P[0])]:=''
+      EnvNames[N]:=''
     end;
     end;
 end;
 end;
 
 
@@ -75,8 +77,15 @@ end;
 
 
 function MyGetEnvironmentVariable(Const EnvVar: String): String;
 function MyGetEnvironmentVariable(Const EnvVar: String): String;
 
 
+Var
+  aName : String;
+
 begin
 begin
-  Result:=String(EnvNames[envvar]);
+  aName:=Lowercase(EnvVar);
+  if EnvNames.hasOwnProperty(aName) then
+    Result:=String(EnvNames[aName])
+  else
+    Result:='';
 end;
 end;
 
 
 function MyGetEnvironmentVariableCount: Integer;
 function MyGetEnvironmentVariableCount: Integer;
@@ -94,6 +103,8 @@ end;
 function TBrowserApplication.GetHTMLElement(aID: String): TJSHTMLElement;
 function TBrowserApplication.GetHTMLElement(aID: String): TJSHTMLElement;
 begin
 begin
   Result:=TJSHTMLElement(Document.getElementById(aID));
   Result:=TJSHTMLElement(Document.getElementById(aID));
+  if (Result=Nil) and LogGetElementErrors then
+    Writeln('Could not find element with ID ',aID);
 end;
 end;
 
 
 function TBrowserApplication.CreateHTMLElement(aTag: String; aID: String): TJSHTMLElement;
 function TBrowserApplication.CreateHTMLElement(aTag: String; aID: String): TJSHTMLElement;
@@ -113,6 +124,11 @@ begin
   Result:=true;
   Result:=true;
 end;
 end;
 
 
+function TBrowserApplication.LogGetElementErrors: Boolean;
+begin
+  Result:=True;
+end;
+
 function TBrowserApplication.GetLocation: String;
 function TBrowserApplication.GetLocation: String;
 begin
 begin
   Result:=''; // ToDo ExtractFilePath(GetExeName);
   Result:=''; // ToDo ExtractFilePath(GetExeName);