Forum > Pas2JS

pas2js configuration help

(1/1)

mr-highball:
I'm just starting to play around with pas2js, but I'm running into some issues getting things configured properly, here are my steps:

- installed pas2js wtih fpcupdelux
- installed pas2jsdsgn package
- configured pas2js.cfg to point properly to source files
- file -> New -> web browser application (choose default options)
  * create initial html page
  * maintain html page
- save project to empty directory, and following structure is created

when I attempt to compile, the following error occurs "custom js file not found: "rtl.js"
I have attempted to add the "small javascript file needed" specified in this wiki: http://wiki.freepascal.org/pas2js
to the same directory as my project which does allow for compiling however, when opening in the browser and inspecting
the console window the following errors are present:
"SyntaxError: expected expression, got '<'[Learn More] project1.js:1"
"ReferenceError: rtl is not defined[Learn More]"

inspecting project1.js which is generated by compiling, I see that it has appened the rtl.js file's contents to
top of the compiled code as such

--- Code: Pascal  [+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i < x.length; i++) { x[i].style.maxHeight='none'; x[i].style.height = Math.min(x[i].clientHeight+15,306)+'px'; x[i].style.resize = "vertical";}};} ---<script type="application/javascript">  rtl.run()</script>rtl.module("System",[],function () {  "use strict";  var $mod = this;  rtl.createClass($mod,"TObject",null,function () {    this.$init = function () {   
when I clear the contents of rtl.js to be an empty script file, then compile and refresh the project1.html file the following errors occur:
"ReferenceError: rtl is not defined[Learn More] project1.js:1:1"
"ReferenceError: rtl is not defined[Learn More]"

I know I must've missed a step along the process, or am doing something wrong since it seems others have gotten pas2js to work for some time now
but any help would be appreciated.

mr-highball:
so digging around I found the rtl script here:
C:\fpcupdeluxe\ccr\pas2js-rtl\compiler\utils\pas2js\dist

I added this location to the pas2js cfg file like this, so my full cfg looks like this:


--- Code: Pascal  [+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i < x.length; i++) { x[i].style.maxHeight='none'; x[i].style.height = Math.min(x[i].clientHeight+15,306)+'px'; x[i].style.resize = "vertical";}};} ---## Minimal config file for pas2js compiler## not yet implemented: -d is the same as #DEFINE# not yet implemented: -u is the same as #UNDEF## Write always a nice logo ;)-l # Display Hints, Warnings and Notes-vwnh# If you don't want so much verbosity use#-vw -Fu$CfgDir/..\..\packages\rtl-Fu$CfgDir/..\..\packages\fcl-base-Fu$CfgDir/..\..\packages\fcl-db-Fu$CfgDir/..\..\packages\fpcunit-Fu$CfgDir/..\..\compiler\utils\pas2js\dist #IFDEF nodejs-Jirtl.js#ENDIF # end.

and my CfgDir is : C:\fpcupdeluxe\ccr\pas2js-rtl\bin\x86_64-win64

These steps now let me compile a web project without compiler errors and having to drop a local rtl.js file in my project folder, but loading the web page still shows rtl being undefined... not sure what else is needed?

mr-highball:
Ok.. so after doing all of the above, and starting a new project, my output .js file seems to be working appropriately, however still getting an error in the browser:
Loading failed for the <script> with source

after a little bit of looking for answers, I tried a different browser (was using firefox) and things seem to working (possible related so post: https://stackoverflow.com/questions/45879671/only-on-firefox-loading-failed-for-the-script-with-source)

I'm not sure if everything is still configured 100% properly, but perhaps my steps will help someone else.

nouzi:
I'm sorry for my bad English
try this other component
https://www.lazarus-components.org/Components-with-sources/Web-XML/Web/ExtPascal/
old vidoe
https://www.youtube.com/watch?v=YE0ExvxVGTw

Leledumbo:
I've documented this rant here: http://forum.lazarus-ide.org/index.php/topic,43660.0.html
But you seem to have found the solution.

Navigation

[0] Message Index

Go to full version