forked from jettero/jlt
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathstage-assistant.js
104 lines (80 loc) · 3.07 KB
/
stage-assistant.js
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
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
/*jslint white: false, onevar: false
*/
/*global Mojo $ StageAssistant
*/
var OPT;
function StageAssistant() {
Mojo.Log.info("StageAssistant()");
// OPT = Mojo.loadJSONFile(Mojo.appPath + "runtime_options.json");
OPT = {};
}
StageAssistant.prototype.setup = function() {
Mojo.Log.info("StageAssistant()::setup()");
this.showScene('ControlPanel');
if( CHANGELOG_COOKIE.get() !== CHANGELOG_KEY )
this.showScene("ChangeLog");
/* DEBUG
** this.showScene("Webview", {
** title: "Frobby Debug",
** URL: "https://voltar.org/id?tr=1",
** donecb: function(){}
** });
*/
this._count = 0;
};
StageAssistant.prototype.showScene = function (sceneName, args) {
Mojo.Log.info("StageAssistant()::showScene(%s) [ss: %d]", sceneName, this._count);
if( this.controller.getScenes().length < 2 ) {
if (args === undefined) {
this.controller.pushScene({name: sceneName, sceneTemplate: sceneName});
} else {
this.controller.pushScene({name: sceneName, sceneTemplate: sceneName}, args);
}
} else {
if (args === undefined) {
this.controller.swapScene({name: sceneName, sceneTemplate: sceneName});
} else {
this.controller.swapScene({name: sceneName, sceneTemplate: sceneName}, args);
}
}
};
StageAssistant.prototype.handleCommand = function(event) {
var controller = Mojo.Controller.stageController.activeScene().assistant;
if(event.type === Mojo.Event.command) {
Mojo.Log.info("executing menu command: %s", event.command);
var a;
if( a = event.command.match(/^myshow-(.+)/) )
Mojo.Controller.stageController.assistant.showScene(a[1]);
if( a = event.command.match(/reset/) )
controller.resetMe();
if( a = event.command.match(/clear-token/) )
controller.clearToken();
if( a = event.command.match(/^json-gps/) )
if( controller )
controller.controller.serviceRequest("palm://com.palm.applicationManager", {
method: "open",
parameters: {
id: 'com.palm.app.browser',
params: { target: "http://db.JGPS.me/user" }
}
});
}
};
StageAssistant.prototype.menuSetup = function() {
this.appMenuModel = {
visible: true,
items: [
Mojo.Menu.editItem,
{ label: "JGPS.me", command: 'json-gps' },
{ label: "Help", command: 'myshow-Help' },
{ label: "About", command: 'myshow-About' },
{ label: "ChangeLog", command: 'myshow-ChangeLog' }
]
};
if( this.resetMe )
this.appMenuModel.items.push({ label: "Reset all Settings", command: 'factory-reset' });
if( this.clearToken )
this.appMenuModel.items.push({ label: "Clear Token", command: 'clear-token' });
this.controller.setupWidget(Mojo.Menu.appMenu, {omitDefaultItems: true}, this.appMenuModel);
};
Mojo.Log.info('loaded(stage-assistant.js)');