Get files in Web directory and show thumbnails

As far as I see, your JSON is just returning an array of picture filenames.
Isn't

<img src="http://www.toolfolks.com/docs/(%Picture%)" height="95%" width="auto" >

setting the HTML in each responsive grid item as

<img src="http://www.toolfolks.com/docs/picturenameX.jpg" height="95%" width="auto" >

?
If not, what do you see?

The returned JSON is in the format.


[{"Picture":"UPVC1.jpg"},{"Picture":"batteries.jpg"},{"Picture":"DewaltOrbitalSander.jpg"}]

So this maps okay and populates the grid.

I need to know how to get the returned JSON into a Object - manipulate it ( eg remove index1 ) then populate the grid with the updated JSON.

Cheers

with TJSONObject.ParseJSONValue(jsonstring),you can do this.
When it can parse successfully, it returns a TJSONValue.

I have attempted the following but get a row count of 0.
I also used the AResponse for JSONObject

The grid is populated but what am I not understanding on this please.

procedure TForm1.WebHttpRequest1RequestResponse(Sender: TObject;
  ARequest: TJSXMLHttpRequestRecord; AResponse: string);
  var
  I : Integer;
  JSONObject     : TJSONObject;
  JsonArray  : TJsonArray ;
  ArrayElement: TJSonValue;
  FoundValue: TJSonValue;
  Result : String;
begin
      JSONObject := TJsonObject.ParseJSONValue('[{"Picture":"UPVC1.jpg"},{"Picture":"batteries.jpg"},{"Picture":"DewaltOrbitalSander.jpg"}]') as TJsonObject;
      showmessage('json Count = '+ JSONObject.Count.ToString );


         try
     for I := 0 to JSONObject.Count - 1 do begin
       WebMemo3.Lines.add(Format('Key=%s Value=%s', [JSONObject.Pairs[I].JsonString.ToString,JSONObject.Pairs[I].JsonValue.ToString]));
     end;
     finally
end;
end;

Don't you have to cast this JSONObject to a JSONArray before getting Count?

Yes. As usual not understanding the concepts.....

Got this from a guy in the Facebook groups.

procedure TForm1.WebButton2Click(Sender: TObject);
var
i: integer;
json: TJSON;
jarry: TJSONArray;
jobject: TJSONObject;
begin
json := TJSON.Create;
try
jarray := TJSONArray(json.Parse('[{"Picture":"UPVC1.jpg"},{"Picture":"batteries.jpg"},{"Picture":"DewaltOrbitalSander.jpg"}]'));
for i := 0 to jarray.Count - 1 do
begin
jobject := TJSONObject(jarray.Items[i]);
WebMemo1.Lines.Add (jobject.GetJSONValue('Picture'));
end; // for i
finally
json.Free;
end;

end;

Hi,

I have the following at TMS Web Project Press Refresh to load the directory.

Works on Android, Mac Chrome safari PC Chrome Edge.

On iOS devices I get ' A problem repeatedly occurred on "https:/toolfolks.com/docs/"

procedure TForm7.WebButton1Click(Sender: TObject);
var
req: TJSXMLHttpRequest;
begin
        WebImageSlider1.ImageURLs.Clear;
        WebHttpRequest1.URL := 'https://www.toolfolks.com/docs/files2.php';
          try
            req := await(TJSXMLHttpRequest, WebHttpRequest1.Perform());

          except
            // handle

          end;


end;
procedure TForm7.WebHttpRequest1RequestResponse(Sender: TObject;
  ARequest: TJSXMLHttpRequestRecord; AResponse: string);
var
  i: integer;
  json: TJSON;
  jobject: TJSONObject;
  begin
    WebImageSlider1.ImageURLs.Clear;
    json := TJSON.Create;
  try
    jArray := TJSONArray(json.Parse(AResponse));
    for i := 0 to jArray.Count - 1 do
    begin
    jobject := TJSONObject(jarray.Items[i]);
    WebImageSlider1.ImageURLs.Add('https://www.toolfolks.com/docs/' + jobject.GetJSONValue('Picture')) ;
  end; // for i
  finally
    json.Free;

  end;
    WebImageSlider1.RefreshImages;
end;

I have also noticed the navThumbnails show very slowly on Mac Safari.

I installed chrome on Iphone & Ipad and get the crashes in these.

Do you see errors in the browser console?
How to Activate the iPhone Debug Console or Web Inspector.

Hi Bruno,

the only thing showing is

Failed to load resource: the server responded with a status of 404 (Not Found) https://download.tmssoftware.com/tmsweb/slider/swiper.min.js.map

I have change the code to just populate the memo with the json and that works on IOS.

I presume populating the WebImageSlider is causing the issue.

offers.zip (735.5 KB)

Any update on this.

Should I do. Bug report ?

I am out of office at this moment and as such limited in my ability to do technical support these days.
As far as I see, this .map file doesn’t exist, so it is normal to get a 404. I guess this is because you deploy in debug mode. I would suggest to deploy your app in release mode where .map files are not used.

I'm in release mode.

I have adapted the example to have a tab to populate a WebRespnsiveGrid with videos ( Videos Tab )
This is the opening tab and it works ok.
When I move to the Offers tab (Which is populating WebImageSlider ) it crashed on IOS still.

www.toolfolks.com/docs

http://www.toolfolks.com/docs

I have added a third tab ( Contact ) using the same procedure as the videos code. It works okay. The crashing is just on the WebImageSlider. ( Only on IOS )

I have moved the error app to www.toolfolks.com/errors

I had to duplicate the mps & jpgs in this folder. However I noticed that with a lower number of image files in the folder the app did not crash. So I think the component WebImageSlider is struggling with the number of files.