83 lines
1.8 KiB
JavaScript
83 lines
1.8 KiB
JavaScript
/**
|
|
* @file page_handler.js
|
|
* @author frtk@tetalab
|
|
*/
|
|
|
|
NPGClient.PageHandler = {
|
|
|
|
currPage: '',
|
|
pages: [],
|
|
|
|
//
|
|
setup: function() {
|
|
var self = this;
|
|
self.currPage = 'login';
|
|
// create login page
|
|
self.createLoginPage();
|
|
},
|
|
|
|
//
|
|
getCurrPageUIElems: function() {
|
|
var self = this;
|
|
return self.getPageByName(self.currPage).getUIElems();
|
|
},
|
|
|
|
//
|
|
getCurrPageUIElemByName: function(name) {
|
|
var self = this;
|
|
if (self.pages.length > 0) {
|
|
for (var i = 0; i < self.pages.length; i++) {
|
|
if (self.pages[i].name == self.currPage) {
|
|
return self.pages[i].getUIElemByName(name);
|
|
}
|
|
}
|
|
}
|
|
return undefined;
|
|
},
|
|
|
|
// @need rework
|
|
getUIElemFromPage: function(elem, page) {
|
|
var self = this;
|
|
if (self.pages.length > 0) {
|
|
for (var i = 0; i < self.pages.length; i++) {
|
|
if (page == self.pages[i].name) {
|
|
// return self.pages[i];
|
|
}
|
|
}
|
|
}
|
|
return undefined;
|
|
},
|
|
|
|
|
|
//
|
|
getPageByName: function(name) {
|
|
var self = this;
|
|
if (self.pages.length > 0) {
|
|
for (var i = 0; i < self.pages.length; i++) {
|
|
if (name == self.pages[i].name) return self.pages[i];
|
|
}
|
|
}
|
|
return undefined;
|
|
},
|
|
|
|
// create login page
|
|
createLoginPage: function() {
|
|
//
|
|
console.log('[NPGClient] Creating Login Page');
|
|
var self = this;
|
|
var p = new NPGClient.AppPage('login');
|
|
// Title label
|
|
p.addUIObject(new NPGClient.UILabel('login_title', NPGClient.LOGIN.TITLE));
|
|
// name input
|
|
p.addUIObject(new NPGClient.UIInputText('login_input', NPGClient.LOGIN.INPUT));
|
|
// Server status
|
|
p.addUIObject(new NPGClient.UIStatusText('login_servstat', NPGClient.LOGIN.SERVSTATUS));
|
|
// test cursor
|
|
p.addUIObject(new NPGClient.UICursor('login_cursor', NPGClient.LOGIN.CURSOR));
|
|
//
|
|
self.pages.push(p);
|
|
},
|
|
|
|
};
|
|
|