cssdemo.lpr 1.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  1. program cssdemo;
  2. uses js,web,main;
  3. Type
  4. TMainForm = Class(TBaseMainForm)
  5. Procedure doMinimize(Event : TJSEvent); override; async;
  6. Procedure doExtract(Event : TJSEvent); override; async;
  7. Function CreateURL(aPath : string) : string;
  8. end;
  9. Function TMainForm.CreateURL(aPath : string) : string;
  10. begin
  11. result:='fpcss.cgi/'+aPath;
  12. end;
  13. Procedure TMainForm.doMinimize(Event : TJSEvent);
  14. var
  15. Init : TJSObject;
  16. Resp: TJSResponse;
  17. CSS : String;
  18. begin
  19. Init:=New(['method','POST','cache','no-cache','body',userCss.Value]);
  20. Resp:=await(TJSResponse,window.fetch(createurl('minimize'),Init));
  21. CSS:=await(string,Resp.text());
  22. processedCss.Value:=CSS;
  23. end;
  24. Procedure TMainForm.doExtract(Event : TJSEvent);
  25. var
  26. Init : TJSObject;
  27. Resp: TJSResponse;
  28. CSS : String;
  29. begin
  30. Init:=New(['method','POST','cache','no-cache','body',userCss.Value]);
  31. Resp:=await(TJSResponse,window.fetch(createurl('classnames'),Init));
  32. CSS:=await(string,Resp.text());
  33. processedCss.Value:=CSS;
  34. end;
  35. begin
  36. TMainForm.Create(Nil);
  37. end.