mirror of
https://gitlab.com/freepascal.org/fpc/pas2js.git
synced 2025-06-08 23:58:14 +02:00
* Add easy access method RouteFromURL
This commit is contained in:
parent
6ba4e00741
commit
e6d18fc1b4
@ -258,6 +258,8 @@ Type
|
|||||||
Function RouteRequest(Const ARouteURL : String; DoPush : Boolean = False) : TRoute;
|
Function RouteRequest(Const ARouteURL : String; DoPush : Boolean = False) : TRoute;
|
||||||
// Extract request path from URL. By default, returns the URL
|
// Extract request path from URL. By default, returns the URL
|
||||||
function GetRequestPath(const URL: String): String; virtual;
|
function GetRequestPath(const URL: String): String; virtual;
|
||||||
|
// Examine the URL hash and route the request. Returns the route. Use when arriving on a page do handle the initial route
|
||||||
|
Function RouteFromURL : String;
|
||||||
// Navigation. These are easy-access methods for history.
|
// Navigation. These are easy-access methods for history.
|
||||||
function GetCurrentLocation: String;
|
function GetCurrentLocation: String;
|
||||||
// These use the history mechanism
|
// These use the history mechanism
|
||||||
@ -644,6 +646,16 @@ begin
|
|||||||
Result:=SanitizeRoute(URL);
|
Result:=SanitizeRoute(URL);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
function TRouter.RouteFromURL: String;
|
||||||
|
|
||||||
|
begin
|
||||||
|
// Result:=Copy(window.location.hash,2,Length(window.location.hash)-1);
|
||||||
|
// Writeln('Curr ', GetCurrentLocation,' route : ',Result);
|
||||||
|
Result:=GetCurrentLocation;
|
||||||
|
if (Result<>'') then
|
||||||
|
Router.RouteRequest(Result,true);
|
||||||
|
end;
|
||||||
|
|
||||||
function TRouter.GetCurrentLocation: String;
|
function TRouter.GetCurrentLocation: String;
|
||||||
begin
|
begin
|
||||||
Result:=History.GetCurrentLocation;
|
Result:=History.GetCurrentLocation;
|
||||||
|
Loading…
Reference in New Issue
Block a user