-
Notifications
You must be signed in to change notification settings - Fork 2
/
cordova-stub.js
187 lines (135 loc) · 4.56 KB
/
cordova-stub.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
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
/*global cordova, alert, confirm, prompt */
(function () {
"use strict";
if (!window.cordova) {
window.cordova = {plugins: {}};
window.plugins = window.plugins || {};
// deviceready
var m_document_addEventListener = document.addEventListener,
m_window_open = window.open;
document.addEventListener = function (evt, handler, capture) {
var e = evt.toLowerCase();
if (e === 'deviceready') {
handler();
} else {
m_document_addEventListener.call(document, evt, handler, capture);
}
};
window.setTimeout(function () {
var e = document.createEvent('Events');
e.initEvent("deviceready");
document.dispatchEvent(e);
}, 50);
// DEVICE
window.device = {
name: "",
model: "",
phonegap: "",
cordova: "",
platform: "",
uuid: "b54adc00-67f9-11d9-9669-0800200c9a66",
version: 0
};
// NETWORK INFO
navigator.network = {
connection: {
type: "WIFI"
}
};
// NOTIFICATIONS
navigator.notification = {
alert: function (message, callback, title, buttonName) {
alert("[" + title + "] " + message);
},
confirm: function (message, callback, title, buttonName) {
var buttonIndex = confirm("[" + title + "] " + message) ? 1 : 2;
callback(buttonIndex);
},
prompt: function (message, promptCallback, title, buttonLabels, defaultText) {
promptCallback({
input1: prompt(),
buttonIndex: 1
});
},
beep: function (times) {
alert("[BEEP] times:" + times);
}
};
// SPLASH SCREEN
navigator.splashscreen = {
show: function () {
},
hide: function () {
}
};
// SPINNER DIALOG
window.plugins.spinnerDialog = {
show: function (title, message) {
//alert("[SPINNER SHOW] [" + title + "] " + message);
},
hide: function () {
//alert("[SPINNER HIDE]");
}
};
// PUSH NOTIFICATION
window.plugins.pushNotification = {
register: function (success, error, config) {
error("Not supported!");
}
};
// PIN DIALOG
window.plugins.pinDialog = {
prompt: function (message, promptCallback, title, buttonLabels, defaultText) {
promptCallback({
input1: prompt(),
buttonIndex: 1
});
}
};
// GA PLUGIN
window.plugins.gaPlugin = {
init: function (success, fail, init, mingap) {
fail("Not supported!");
},
trackEvent: function (success, fail, category, eventAction, eventLabel, eventValue) {
fail("Not supported!");
},
trackPage: function (success, fail, pageURL) {
fail("Not supported!");
},
setVariable: function (success, fail, index, value) {
fail("Not supported!");
},
exit: function (success, fail) {
fail("Not supported!");
}
};
// BARCODE SCANNER
cordova.plugins.barcodeScanner = {
scan: function (success, fail) {
fail("Not supported!");
},
encode: function (type, data, success, fail) {
fail("Not supported!");
}
};
// UUID - UNIQUE DEVICE ID PLUGIN
window.plugins.uniqueDeviceID = {
get: function (success, fail) {
success(window.device.uuid);
}
};
// IN APP BROWSER PLUGIN
window.open = function (URL, name, specs, replace) {
m_window_open(URL, name, specs, replace);
return {
addEventListener: function () {},
removeEventListener: function () {},
show: function () {},
close: function () {},
executeScript: function () {},
insertCss: function () {}
};
};
}
}());