2
0

htmldemo.lpr 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  1. program htmldemo;
  2. {$mode objfpc}
  3. {$R testres.html}
  4. uses
  5. browserconsole, JS, Classes, SysUtils, types, p2jsres, unita, unitb, web;
  6. function DoOnClick(aEvent: TJSMouseEvent): boolean;
  7. var
  8. el : TJSHTMLElement;
  9. aInfo : TResourceInfo;
  10. begin
  11. Result:=False;
  12. el:=TJSHTMLElement(document.getelementByid('playarea'));
  13. if not GetResourceInfo('testres',aInfo) then
  14. el.innerhtml:='resource testres not found !'
  15. else
  16. el.innerhtml:=window.atob(ainfo.Data);
  17. el:=TJSHTMLElement(document.getelementByid('headertext'));
  18. el.innertext:='Below HTML was inserted from resource data';
  19. end;
  20. Var
  21. RL : TStringDynArray;
  22. aInfo : TResourceInfo;
  23. el : TJSHTMLElement;
  24. S : String;
  25. begin
  26. Writeln('Javascript embedded resources:');
  27. SetResourceSource(rsJS);
  28. RL:=GetResourceNames;
  29. For S in RL do
  30. begin
  31. Writeln('--- Found resource name: ',S,' : ');
  32. if not GetResourceInfo(S,aInfo) then
  33. Writeln('No extra information for resource ',S,' available !')
  34. else
  35. begin
  36. Writeln('Name: ',aInfo.Name);
  37. Writeln('Format: ',aInfo.Format);
  38. Writeln('encoding: ',aInfo.Encoding);
  39. Writeln('unit: ',aInfo.resourceunit);
  40. Writeln('data length: ',Length(aInfo.data));
  41. end;
  42. end;
  43. el:=TJSHTMLButtonElement(document.getelementByid('doinsert'));
  44. el.onclick:=@DoOnClick;
  45. end.