8000 Page Manager and parameters · SaffronCode/SaffronCodeJS@a80f1bb · GitHub
[go: up one dir, main page]

Skip to content
This repository was archived by the owner on Jul 10, 2024. It is now read-only.

Commit a80f1bb

Browse files
committed
Page Manager and parameters
1 parent 1caae88 commit a80f1bb

File tree

1 file changed

+40
-8
lines changed

1 file changed

+40
-8
lines changed

framework/pageManager/PageManager.js

Lines changed: 40 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,32 +1,64 @@
1-
import EventDispatcher from "./EventDispatcher";
2-
import SimplePage from "./SimplePage";
31

4-
import JSFunctions from "../libs/JSFunctions" ;
2+
import PageData from "./PageData";
3+
import EventDispatcher from "../EventDispatcher";
54

5+
//import JSFunctions from "../libs/JSFunctions" ;
66

7+
const maximomAcceptableParamsOnURL = 10 ;
78

89
var PageManager = {};
910
PageManager.dispatcher = new EventDispatcher();
1011
PageManager.PAGE_CHANGED = "PAGE_CHANGED" ;
1112

13+
PageManager.routerParamList = '' ;
14+
for(var i = 0 ; i<maximomAcceptableParamsOnURL ; i++)
15+
{
16+
PageManager.routerParamList+='/:p'+i+'?';
17+
}
18+
1219
///Page list ↓
1320
PageManager.allPages = [] ;
1421
PageManager.menuPages = [] ;
1522

1623

17-
var lastPage = new SimplePage();
24+
var lastPage = new PageData();
1825

19-
PageManager.changePage = function(targetPage,pageData={})
26+
PageManager.changePage = function(targetPage,pageData=[])
2027
{
2128
if(targetPage!==null)
2229
{
2330
lastPage = JSON.parse(JSON.stringify(targetPage)) ;
24-
//lastPage.url += '/'+JSFunctions.
25-
PageManager.dispatcher.dispatchEvent(PageManager.PAGE_CHANGED,targetPage);
31+
for(var i = 0 ; i<pageData.length ; i++)
32+
{
33+
lastPage.url += '/'+encodeURIComponent(pageData[i]) ;
34+
}
35+
PageManager.dispatcher.dispatchEvent(PageManager.PAGE_CHANGED,lastPage);
36+
}
37+
}
38+
39+
/**@description pass the constructor's props to the function and retrive parameters list */
40+
PageManager.decodePageParams = function(props={})
41+
{
42+
if(
43+
props !== undefined &&
44+
props.match !== undefined &&
45+
props.match.params !==null
46+
)
47+
{
48+
var params = [] ;
49+
for(var i = 0 ; i<maximomAcceptableParamsOnURL ; i++)
50+
{
51+
var par = props.match.params['p'+i] ;
52+
if(par!==undefined)
53+
params.push(decodeURIComponent(par));
54+
else
55+
break ;
56+
}
57+
return params ;
2658
}
2759
}
2860

29-
/**@return {SimplePage} */
61+
/**@return {PageData} */
3062
PageManager.getCurrentPage = function()
3163
{
3264
/**@type {string} */

0 commit comments

Comments
 (0)
0