|
|
пре 4 година | |
|---|---|---|
| .. | ||
| README.md | пре 7 година | |
| demorouter.html | пре 7 година | |
| demorouter.lpi | пре 4 година | |
| demorouter.pas | пре 7 година | |
| demorouter2.html | пре 7 година | |
| demorouter2.lpi | пре 6 година | |
| demorouter2.pas | пре 7 година | |
| frmdemo.pp | пре 4 година | |
| histsrv.js | пре 7 година | |
| histsrv2.js | пре 7 година | |
The 2 demos do the same, the difference is in how they achieve the same result:
demorouter is the simplest. It registers 5 static routes, one for each form.
demorouter2 is more advanced. It registers 1 route with a parameter.
pas2js -browser -Jc -Jirtl.js demorouter.pas
pas2js -browser -Jc -Jirtl.js demorouter2.pas
When using lazarus, you can also open the respective .lpi files, and compile your project.
The router supports 3 models
When in doubt, use the hash mechanism :
Router.InitHistory(hkHash)
If the history mechanism has set the url to e.g. http://localhost:3000/Form3 and the user returns back to this URL, the server needs to know it should serve the demorouter.html file; it needs to be configured that it serves the 'main page' of the project if it encounters an URL that it doesn't know.
You can start a small node server that does this:
for demorouter.html:
nodejs histsrv.js
for demorouter2.html:
nodejs histsrv2.js