Recent

Author Topic: (SOLVED) fphttpserver and External JavaScript files  (Read 4092 times)

xinyiman

  • Hero Member
  • *****
  • Posts: 1971
    • Lazarus and Free Pascal italian community
(SOLVED) fphttpserver and External JavaScript files
« on: December 14, 2016, 03:54:40 pm »
hello guys, how can I include in a project fpweb of JavaScript libraries? I would use the DHTMLX framework. To be clear in my response I go to insert this piece of code.

Code: Pascal  [Select]
  1.         <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
  2.         <meta http-equiv="X-UA-Compatible" content="IE=edge"/>
  3.         <link rel="stylesheet" type="text/css" href="dhtmlx/codebase/fonts/font_roboto/roboto.css"/>
  4.         <link rel="stylesheet" type="text/css" href="dhtmlx/codebase/dhtmlx.css"/>
  5.         <script src="dhtmlx/codebase/dhtmlx.js"></script>
  6.  


How do I make sure that my standalone server files such recoveries (placed in the folder where is the executable?

Thanks
« Last Edit: December 16, 2016, 02:43:57 pm by xinyiman »
Win10, Ubuntu and Mac
Lazarus: 2.1.0
FPC: 3.3.1

xinyiman

  • Hero Member
  • *****
  • Posts: 1971
    • Lazarus and Free Pascal italian community
Re: fphttpserver and External JavaScript files
« Reply #1 on: December 15, 2016, 08:34:21 am »
No idea to solve? I wonder others who use this component as insert external resources!
Win10, Ubuntu and Mac
Lazarus: 2.1.0
FPC: 3.3.1

xinyiman

  • Hero Member
  • *****
  • Posts: 1971
    • Lazarus and Free Pascal italian community
Re: fphttpserver and External JavaScript files
« Reply #2 on: December 16, 2016, 08:45:04 am »
I created a working example. CHe if completed and launched, when the page loads

localhost: 8080

The code that does this is:

Code: Pascal  [Select]
  1.  
  2.      myhtml:='<html>';
  3.      myhtml:=myhtml + '<head><title> Test web </title><head>';
  4.      myhtml:=myhtml + '<body onload="alert(''Hello World'');">Test web</body>';
  5.      myhtml:=myhtml + '</html>';    
  6.  
  7.  

launches an alert that says Hello World. Now I wish they would change the code so


Code: Pascal  [Select]
  1.  
  2.      myhtml:='<html>';
  3.      myhtml:=myhtml + '<head><title> Test web </title>';
  4.      [b]myhtml:='<script type="text/javascript" src="myjslib\miojavascript.js"></script><head>';[/b]
  5.      myhtml:=myhtml + '<body onload="MyFunction();">Test web</body>';
  6.      myhtml:=myhtml + '</html>';    
  7.  
  8.  

Where MyFunction (); It is contained in the Javascript file. Who tells me how to do?

I attach as upfront with the javascript file already created
Win10, Ubuntu and Mac
Lazarus: 2.1.0
FPC: 3.3.1

derek.john.evans

  • Guest
Re: fphttpserver and External JavaScript files
« Reply #3 on: December 16, 2016, 11:04:50 am »
If you are using TFPHTTPServer, then there is an example in:

\lazarus\fpc\3.0.0\source\packages\fcl-web\examples\httpserver

You want to map a HTTP request to a local file, which is then served.

xinyiman

  • Hero Member
  • *****
  • Posts: 1971
    • Lazarus and Free Pascal italian community
Re: fphttpserver and External JavaScript files
« Reply #4 on: December 16, 2016, 02:43:46 pm »
Thank you  ;)
Win10, Ubuntu and Mac
Lazarus: 2.1.0
FPC: 3.3.1

xinyiman

  • Hero Member
  • *****
  • Posts: 1971
    • Lazarus and Free Pascal italian community
Re: (SOLVED) fphttpserver and External JavaScript files
« Reply #5 on: December 17, 2016, 09:11:35 am »
Hello guys, I created a stand-alone server for testing with DHTMLX. Qui.Compilatelo can download it, run it, open the browser and type localhost: 8080

And you will see that the program brings in the content of flie index.html, but not js libraries including the offending file. How to solve?

Link: www.lazaruspascal.it/esempi/LazDHTMLX.zip

is a TFPWebModule project
Win10, Ubuntu and Mac
Lazarus: 2.1.0
FPC: 3.3.1

tatamata

  • Hero Member
  • *****
  • Posts: 693
    • ZMSQL - SQL enhanced in-memory database
Re: (SOLVED) fphttpserver and External JavaScript files
« Reply #6 on: March 18, 2019, 01:48:55 pm »
How to install dhtmlx?
I downloaded the package from https://github.com/cutec-chris/dhtmlx-for-pas2js
When I try to compile, I get error:
dhtmlx_laz.pas(10,5) Error: can't find unit "System"