-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathuiState.js
More file actions
59 lines (52 loc) · 1.28 KB
/
uiState.js
File metadata and controls
59 lines (52 loc) · 1.28 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
var self = this;
self.currentState = {
validLogin: false,
validToken: false,
validNodeLoc: false
};
self.lastMessage = undefined;
var loginState = function(valid, msg){
"use strict";
if(typeof valid === "undefined"){
return self.currentState.validLogin;
}
self.currentState.validLogin = valid;
self.lastMessage = msg;
};
var tokenState = function (valid, msg){
"use strict";
if(typeof valid === "undefined"){
return self.currentState.validToken;
}
self.currentState.validToken = valid;
self.lastMessage = msg;
};
var nodeLocState = function (valid, msg){
"use strict";
if(typeof valid === "undefined"){
return self.currentState.validNodeLoc;
}
self.currentState.validNodeLoc = valid;
self.lastMessage = msg;
};
var UIState = function(){
"use strict";
var state = {
id: 'statusPane',
message: ''
};
if (typeof self.lastMessage !== undefined){
state.message = self.lastMessage;
}
if(!loginState()){
state.id = 'loginPane';
}
else if(!nodeLocState()){
state.id = 'nodeLocPane';
}
return state;
};
exports.UIState = UIState;
exports.loginState = loginState;
exports.tokenState = tokenState;
exports.nodeLocState = nodeLocState;