This repository has been archived by the owner on Sep 19, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathapp.js
131 lines (92 loc) · 2.66 KB
/
app.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
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
/*
TODO:
INITIALIZATION OF THE APP. EXPECTING TO USE AN API AND AN LOCAL STORAGE:
use the storage plugin to see if the db already exists -> ok
if not:
create all the relevant tables: -> ok
use the connexion plug in -> ok
if connexion -> ok:
MEMO:
$( document ).on("pageshow", "#myStopsPage", function() {
dispMyStops();
});
$( document ).on( "swipeleft", "#myStopsPage", function() {
$.mobile.changePage('#busPage');
});
$( document ).on( "tap", "#cancelDialogButton", function() {
resetDialogPage();
});
*/
/*DEV -> test code in a desktop browser //*/
$(document).on("pagecreate","#indexPage",function(){
// GET request parameters definition
var param ={};
param.name = 'userId';
param.value = '1';
// And now, we fetch all data from the contrefort server !
var api = new Api();
api.post({}).done(function(recipList){
console.log(JSON.stringify(recipList));
}).fail(function(error){
console.log(error.message);
});
});
//*/
/**
* This is where everything happens. A kind of a controller in a MVC representation
*/
function App(){
//this.init();
}
/**
* initiate the application
* @return {integer} always 0
*/
App.prototype.init = function(){
this.bindEvents();
return 0;
}
/**
* bind all required event to the DOM (see MEMO to have examples)
* @return {integer} always 0;
*/
App.prototype.bindEvents = function(){
document.addEventListener("deviceready", this.onDeviceReady, false);
return 0;
}
/**
* when the mobile application is ready to go, fill all required attributes and set the environement for the user
* @return {integer} always 0
*/
App.prototype.onDeviceReady = function(){
/****************************************
IF THIS IS THE FIRST EXECUTION:
we have to create the database, its tables, and
insert a default line in the parameter table */
var db = new Db();
db.init().done(function(){
var param = new Parameters();
param.init().done(function(res){
/* end of things to do for a first execution
********************************************/
/****************************************
NORMAL PREPARATION:
now we are sure that the database is ready. The recipients in the relevant table
are updated from the contrefort server. Then, every action which has to be updated
with the contrefort server must be saved
*/
/* end of things to do at normal startup
********************************************/
/****************************************
DISPLAY THE FIRST PAGE OF APPLICATION
*/
var index = new IndexView();
index.display();
});
});
return 0;
}
// TODO:
App.prototype.onPause = function(){return 0;}
// TODO:
App.prototype.onResume = function(){return 0;}