Description: We can create a specific pages from the router method which will only available for the specific dates or period of time specified in date by using this method, if the specified date not satisfied with the condition it will show Page Not Found page.
JavaScript:
Router.js
//MyNewModule.Router.js
define('Franchise.RegisterPage.Router',
[
'Franchise.RegisterPage.View',
'Backbone',
'SC.Configuration'
],
function (
FranchiseRegisterPageView,
Backbone,
Configuration
)
{
'use strict';
//@class Franchise.Router @extend Backbone.Router
//postCardExpairy is the expairy date which is from configuration record in the MM-DD-YYYY format.
var postCardExpairy = Configuration.get("jjRegisterPage.postCardDate") ? new Date(Configuration.get("jjRegisterPage.postCardDate")) : false;
var isMacOS = navigator.userAgent.indexOf("Mac OS") > -1;
var macOsPostCardExpairy = new Date((Configuration.get("jjRegisterPage.postCardDate")).replaceAll(['-'], '/'));
if ((postCardExpairy && Configuration.get("jjRegisterPage.postCardDate") !== "" && postCardExpairy >= new Date()) || (isMacOS && macOsPostCardExpairy && Configuration.get("jjRegisterPage.postCardDate") !== "" && macOsPostCardExpairy >= new Date())) {
// postcard is the route which will be awalable only till the expairation date.
return Backbone.Router.extend({
routes: {
'franchise': 'FranchiseRegisterPageRouter',
'postcard': 'FranchiseRegisterPageRouter'
},
initialize: function (application)
{
this.application = application;
},
//FranchiseRegisterPageRouter is used for creating new page for Franchise registration.
FranchiseRegisterPageRouter: function ()
{
var view = new FranchiseRegisterPageView({
application: this.application
})
view.showContent();
}
});
} else {
return Backbone.Router.extend({
routes: {
'franchise': 'FranchiseRegisterPageRouter'
},
initialize: function (application)
{
this.application = application;
},
//FranchiseRegisterPageRouter is used for creating new page for Franchise registration.
FranchiseRegisterPageRouter: function ()
{
var view = new FranchiseRegisterPageView({
application: this.application
})
view.showContent();
}
});
}
});