|
1 |
| -import EventDispatcher from "./EventDispatcher"; |
2 |
| -import SimplePage from "./SimplePage"; |
3 | 1 |
|
4 |
| -import JSFunctions from "../libs/JSFunctions" ; |
| 2 | +import PageData from "./PageData"; |
| 3 | +import EventDispatcher from "../EventDispatcher"; |
5 | 4 |
|
| 5 | +//import JSFunctions from "../libs/JSFunctions" ; |
6 | 6 |
|
| 7 | +const maximomAcceptableParamsOnURL = 10 ; |
7 | 8 |
|
8 | 9 | var PageManager = {};
|
9 | 10 | PageManager.dispatcher = new EventDispatcher();
|
10 | 11 | PageManager.PAGE_CHANGED = "PAGE_CHANGED" ;
|
11 | 12 |
|
| 13 | +PageManager.routerParamList = '' ; |
| 14 | +for(var i = 0 ; i<maximomAcceptableParamsOnURL ; i++) |
| 15 | +{ |
| 16 | + PageManager.routerParamList+='/:p'+i+'?'; |
| 17 | +} |
| 18 | + |
12 | 19 | ///Page list ↓
|
13 | 20 | PageManager.allPages = [] ;
|
14 | 21 | PageManager.menuPages = [] ;
|
15 | 22 |
|
16 | 23 |
|
17 |
| -var lastPage = new SimplePage(); |
| 24 | +var lastPage = new PageData(); |
18 | 25 |
|
19 |
| -PageManager.changePage = function(targetPage,pageData={}) |
| 26 | +PageManager.changePage = function(targetPage,pageData=[]) |
20 | 27 | {
|
21 | 28 | if(targetPage!==null)
|
22 | 29 | {
|
23 | 30 | 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 ; |
26 | 58 | }
|
27 | 59 | }
|
28 | 60 |
|
29 |
| -/**@return {SimplePage} */ |
| 61 | +/**@return {PageData} */ |
30 | 62 | PageManager.getCurrentPage = function()
|
31 | 63 | {
|
32 | 64 | /**@type {string} */
|
|
0 commit comments