mobile_template 0.0.1
Sign up to get free protection for your applications and to get access to all the features.
- data/.gitignore +17 -0
- data/Gemfile +4 -0
- data/LICENSE +22 -0
- data/README.md +28 -0
- data/Rakefile +3 -0
- data/bin/mobile_template +71 -0
- data/lib/mobile_template/version.rb +4 -0
- data/lib/mobile_template.rb +5 -0
- data/mobile_template.gemspec +21 -0
- data/templates/assets/Gemfile +4 -0
- data/templates/assets/config.rb +96 -0
- data/templates/assets/config.ru +4 -0
- data/templates/assets/source/images/vendor/ajax-loader.gif +0 -0
- data/templates/assets/source/images/vendor/ajax-loader.png +0 -0
- data/templates/assets/source/images/vendor/icons-18-black.png +0 -0
- data/templates/assets/source/images/vendor/icons-18-white.png +0 -0
- data/templates/assets/source/images/vendor/icons-36-black.png +0 -0
- data/templates/assets/source/images/vendor/icons-36-white.png +0 -0
- data/templates/assets/source/index.html.erb +2 -0
- data/templates/assets/source/javascripts/app/index.js.coffee +2 -0
- data/templates/assets/source/javascripts/application.js.coffee +5 -0
- data/templates/assets/source/javascripts/vendor/cordova.js +4841 -0
- data/templates/assets/source/javascripts/vendor/jquery.js +9267 -0
- data/templates/assets/source/javascripts/vendor/jquery.mobile.js +7410 -0
- data/templates/assets/source/layout.erb +24 -0
- data/templates/assets/source/stylesheets/application.css.scss +2 -0
- data/templates/assets/source/stylesheets/vendor/jquery.mobile.css.scss +1872 -0
- data/templates/cordova_android/.gitignore +18 -0
- data/templates/cordova_android/LICENSE +202 -0
- data/templates/cordova_android/NOTICE +5 -0
- data/templates/cordova_android/README.md +95 -0
- data/templates/cordova_android/VERSION +1 -0
- data/templates/cordova_android/bin/BOOM +4 -0
- data/templates/cordova_android/bin/autotest +2 -0
- data/templates/cordova_android/bin/bench +29 -0
- data/templates/cordova_android/bin/create +46 -0
- data/templates/cordova_android/bin/create.bat +1 -0
- data/templates/cordova_android/bin/create.js +88 -0
- data/templates/cordova_android/bin/create.xml +79 -0
- data/templates/cordova_android/bin/node_modules/.bin/cake +7 -0
- data/templates/cordova_android/bin/node_modules/.bin/coffee +7 -0
- data/templates/cordova_android/bin/node_modules/.bin/nodeunit +120 -0
- data/templates/cordova_android/bin/node_modules/coffee-script/.npmignore +11 -0
- data/templates/cordova_android/bin/node_modules/coffee-script/LICENSE +22 -0
- data/templates/cordova_android/bin/node_modules/coffee-script/README +48 -0
- data/templates/cordova_android/bin/node_modules/coffee-script/Rakefile +78 -0
- data/templates/cordova_android/bin/node_modules/coffee-script/bin/cake +7 -0
- data/templates/cordova_android/bin/node_modules/coffee-script/bin/coffee +7 -0
- data/templates/cordova_android/bin/node_modules/coffee-script/extras/jsl.conf +44 -0
- data/templates/cordova_android/bin/node_modules/coffee-script/lib/browser.js +75 -0
- data/templates/cordova_android/bin/node_modules/coffee-script/lib/cake.js +76 -0
- data/templates/cordova_android/bin/node_modules/coffee-script/lib/coffee-script.js +135 -0
- data/templates/cordova_android/bin/node_modules/coffee-script/lib/command.js +301 -0
- data/templates/cordova_android/bin/node_modules/coffee-script/lib/grammar.js +591 -0
- data/templates/cordova_android/bin/node_modules/coffee-script/lib/helpers.js +66 -0
- data/templates/cordova_android/bin/node_modules/coffee-script/lib/index.js +8 -0
- data/templates/cordova_android/bin/node_modules/coffee-script/lib/lexer.js +656 -0
- data/templates/cordova_android/bin/node_modules/coffee-script/lib/nodes.js +2289 -0
- data/templates/cordova_android/bin/node_modules/coffee-script/lib/optparse.js +111 -0
- data/templates/cordova_android/bin/node_modules/coffee-script/lib/parser.js +676 -0
- data/templates/cordova_android/bin/node_modules/coffee-script/lib/repl.js +123 -0
- data/templates/cordova_android/bin/node_modules/coffee-script/lib/rewriter.js +363 -0
- data/templates/cordova_android/bin/node_modules/coffee-script/lib/scope.js +120 -0
- data/templates/cordova_android/bin/node_modules/coffee-script/package.json +27 -0
- data/templates/cordova_android/bin/node_modules/nodeunit/.gitignore +5 -0
- data/templates/cordova_android/bin/node_modules/nodeunit/.npmignore +3 -0
- data/templates/cordova_android/bin/node_modules/nodeunit/CONTRIBUTORS.md +60 -0
- data/templates/cordova_android/bin/node_modules/nodeunit/LICENSE +19 -0
- data/templates/cordova_android/bin/node_modules/nodeunit/Makefile +126 -0
- data/templates/cordova_android/bin/node_modules/nodeunit/README.md +432 -0
- data/templates/cordova_android/bin/node_modules/nodeunit/bin/nodeunit +120 -0
- data/templates/cordova_android/bin/node_modules/nodeunit/bin/nodeunit.json +10 -0
- data/templates/cordova_android/bin/node_modules/nodeunit/deps/async.js +623 -0
- data/templates/cordova_android/bin/node_modules/nodeunit/deps/console.log.js +55 -0
- data/templates/cordova_android/bin/node_modules/nodeunit/deps/ejs.js +125 -0
- data/templates/cordova_android/bin/node_modules/nodeunit/deps/json2.js +483 -0
- data/templates/cordova_android/bin/node_modules/nodeunit/examples/browser/nodeunit.js +1757 -0
- data/templates/cordova_android/bin/node_modules/nodeunit/examples/browser/suite1.js +12 -0
- data/templates/cordova_android/bin/node_modules/nodeunit/examples/browser/suite2.js +13 -0
- data/templates/cordova_android/bin/node_modules/nodeunit/examples/browser/test.html +16 -0
- data/templates/cordova_android/bin/node_modules/nodeunit/img/example_fail.png +0 -0
- data/templates/cordova_android/bin/node_modules/nodeunit/img/example_pass.png +0 -0
- data/templates/cordova_android/bin/node_modules/nodeunit/index.js +3 -0
- data/templates/cordova_android/bin/node_modules/nodeunit/lib/assert.js +316 -0
- data/templates/cordova_android/bin/node_modules/nodeunit/lib/core.js +260 -0
- data/templates/cordova_android/bin/node_modules/nodeunit/lib/nodeunit.js +82 -0
- data/templates/cordova_android/bin/node_modules/nodeunit/lib/reporters/browser.js +119 -0
- data/templates/cordova_android/bin/node_modules/nodeunit/lib/reporters/default.js +123 -0
- data/templates/cordova_android/bin/node_modules/nodeunit/lib/reporters/html.js +107 -0
- data/templates/cordova_android/bin/node_modules/nodeunit/lib/reporters/index.js +9 -0
- data/templates/cordova_android/bin/node_modules/nodeunit/lib/reporters/junit.js +183 -0
- data/templates/cordova_android/bin/node_modules/nodeunit/lib/reporters/minimal.js +112 -0
- data/templates/cordova_android/bin/node_modules/nodeunit/lib/reporters/skip_passed.js +105 -0
- data/templates/cordova_android/bin/node_modules/nodeunit/lib/track.js +48 -0
- data/templates/cordova_android/bin/node_modules/nodeunit/lib/types.js +187 -0
- data/templates/cordova_android/bin/node_modules/nodeunit/lib/utils.js +209 -0
- data/templates/cordova_android/bin/node_modules/nodeunit/man1/nodeunit.1 +95 -0
- data/templates/cordova_android/bin/node_modules/nodeunit/nodelint.cfg +4 -0
- data/templates/cordova_android/bin/node_modules/nodeunit/package.json +56 -0
- data/templates/cordova_android/bin/node_modules/nodeunit/share/junit.xml.ejs +19 -0
- data/templates/cordova_android/bin/node_modules/nodeunit/share/license.js +11 -0
- data/templates/cordova_android/bin/node_modules/nodeunit/share/nodeunit.css +70 -0
- data/templates/cordova_android/bin/templates/project/.cordova/android/readme.md +1 -0
- data/templates/cordova_android/bin/templates/project/.cordova/readme.md +3 -0
- data/templates/cordova_android/bin/templates/project/cordova/create +36 -0
- data/templates/cordova_android/bin/templates/project/cordova/debug +9 -0
- data/templates/cordova_android/bin/templates/project/cordova/emulate +12 -0
- data/templates/cordova_android/bin/templates/project/cordova/log +3 -0
- data/templates/cordova_android/bin/templates/project/cordova/templates/Activity.java +16 -0
- data/templates/cordova_android/bin/templates/project/cordova/templates/project/AndroidManifest.xml +50 -0
- data/templates/cordova_android/bin/templates/project/cordova/templates/project/assets/www/index.html +42 -0
- data/templates/cordova_android/bin/templates/project/cordova/templates/project/assets/www/main.js +146 -0
- data/templates/cordova_android/bin/templates/project/cordova/templates/project/assets/www/master.css +96 -0
- data/templates/cordova_android/bin/templates/project/cordova/templates/project/res/drawable/icon.png +0 -0
- data/templates/cordova_android/bin/templates/project/cordova/templates/project/res/xml/cordova.xml +5 -0
- data/templates/cordova_android/bin/templates/project/cordova/templates/project/res/xml/plugins.xml +19 -0
- data/templates/cordova_android/bin/test +26 -0
- data/templates/cordova_android/bin/tests/autotest.coffee +4 -0
- data/templates/cordova_android/bin/tests/create.coffee +21 -0
- data/templates/cordova_android/bin/tests/debug.coffee +0 -0
- data/templates/cordova_android/bin/tests/test.coffee +0 -0
- data/templates/cordova_android/framework/.classpath +8 -0
- data/templates/cordova_android/framework/.project +33 -0
- data/templates/cordova_android/framework/AndroidManifest.xml +68 -0
- data/templates/cordova_android/framework/ant.properties +34 -0
- data/templates/cordova_android/framework/assets/js/accelerometer.js +137 -0
- data/templates/cordova_android/framework/assets/js/app.js +89 -0
- data/templates/cordova_android/framework/assets/js/battery.js +134 -0
- data/templates/cordova_android/framework/assets/js/camera.js +168 -0
- data/templates/cordova_android/framework/assets/js/capture.js +203 -0
- data/templates/cordova_android/framework/assets/js/compass.js +168 -0
- data/templates/cordova_android/framework/assets/js/contact.js +310 -0
- data/templates/cordova_android/framework/assets/js/cordova.android.js +4841 -0
- data/templates/cordova_android/framework/assets/js/cordova.js.base +924 -0
- data/templates/cordova_android/framework/assets/js/crypto.js +54 -0
- data/templates/cordova_android/framework/assets/js/device.js +83 -0
- data/templates/cordova_android/framework/assets/js/file.js +1082 -0
- data/templates/cordova_android/framework/assets/js/filetransfer.js +125 -0
- data/templates/cordova_android/framework/assets/js/geolocation.js +209 -0
- data/templates/cordova_android/framework/assets/js/header.txt +19 -0
- data/templates/cordova_android/framework/assets/js/media.js +233 -0
- data/templates/cordova_android/framework/assets/js/network.js +100 -0
- data/templates/cordova_android/framework/assets/js/notification.js +133 -0
- data/templates/cordova_android/framework/assets/js/position.js +100 -0
- data/templates/cordova_android/framework/assets/js/storage.js +439 -0
- data/templates/cordova_android/framework/assets/www/index.html +27 -0
- data/templates/cordova_android/framework/build.xml +216 -0
- data/templates/cordova_android/framework/libs/commons-codec-1.3.jar +0 -0
- data/templates/cordova_android/framework/proguard-project.txt +20 -0
- data/templates/cordova_android/framework/project.properties +14 -0
- data/templates/cordova_android/framework/res/drawable/icon.png +0 -0
- data/templates/cordova_android/framework/res/drawable/splash.png +0 -0
- data/templates/cordova_android/framework/res/layout/main.xml +29 -0
- data/templates/cordova_android/framework/res/values/strings.xml +23 -0
- data/templates/cordova_android/framework/res/xml/cordova.xml +37 -0
- data/templates/cordova_android/framework/res/xml/plugins.xml +37 -0
- data/templates/cordova_android/framework/src/com/phonegap/api/IPlugin.java +27 -0
- data/templates/cordova_android/framework/src/com/phonegap/api/LOG.java +28 -0
- data/templates/cordova_android/framework/src/com/phonegap/api/PhonegapActivity.java +28 -0
- data/templates/cordova_android/framework/src/com/phonegap/api/Plugin.java +27 -0
- data/templates/cordova_android/framework/src/com/phonegap/api/PluginManager.java +35 -0
- data/templates/cordova_android/framework/src/com/phonegap/api/PluginResult.java +53 -0
- data/templates/cordova_android/framework/src/org/apache/cordova/AccelListener.java +311 -0
- data/templates/cordova_android/framework/src/org/apache/cordova/App.java +198 -0
- data/templates/cordova_android/framework/src/org/apache/cordova/AudioHandler.java +364 -0
- data/templates/cordova_android/framework/src/org/apache/cordova/AudioPlayer.java +450 -0
- data/templates/cordova_android/framework/src/org/apache/cordova/AuthenticationToken.java +69 -0
- data/templates/cordova_android/framework/src/org/apache/cordova/BatteryListener.java +156 -0
- data/templates/cordova_android/framework/src/org/apache/cordova/CallbackServer.java +431 -0
- data/templates/cordova_android/framework/src/org/apache/cordova/CameraLauncher.java +500 -0
- data/templates/cordova_android/framework/src/org/apache/cordova/Capture.java +400 -0
- data/templates/cordova_android/framework/src/org/apache/cordova/CompassListener.java +308 -0
- data/templates/cordova_android/framework/src/org/apache/cordova/ContactAccessor.java +198 -0
- data/templates/cordova_android/framework/src/org/apache/cordova/ContactAccessorSdk5.java +1934 -0
- data/templates/cordova_android/framework/src/org/apache/cordova/ContactManager.java +113 -0
- data/templates/cordova_android/framework/src/org/apache/cordova/CordovaChromeClient.java +314 -0
- data/templates/cordova_android/framework/src/org/apache/cordova/CordovaWebViewClient.java +306 -0
- data/templates/cordova_android/framework/src/org/apache/cordova/Device.java +219 -0
- data/templates/cordova_android/framework/src/org/apache/cordova/DirectoryManager.java +161 -0
- data/templates/cordova_android/framework/src/org/apache/cordova/DroidGap.java +1417 -0
- data/templates/cordova_android/framework/src/org/apache/cordova/ExifHelper.java +165 -0
- data/templates/cordova_android/framework/src/org/apache/cordova/FileTransfer.java +458 -0
- data/templates/cordova_android/framework/src/org/apache/cordova/FileUploadResult.java +63 -0
- data/templates/cordova_android/framework/src/org/apache/cordova/FileUtils.java +1048 -0
- data/templates/cordova_android/framework/src/org/apache/cordova/GeoBroker.java +165 -0
- data/templates/cordova_android/framework/src/org/apache/cordova/GeoListener.java +133 -0
- data/templates/cordova_android/framework/src/org/apache/cordova/GpsListener.java +163 -0
- data/templates/cordova_android/framework/src/org/apache/cordova/HttpHandler.java +80 -0
- data/templates/cordova_android/framework/src/org/apache/cordova/LinearLayoutSoftKeyboardDetect.java +104 -0
- data/templates/cordova_android/framework/src/org/apache/cordova/NetworkListener.java +153 -0
- data/templates/cordova_android/framework/src/org/apache/cordova/NetworkManager.java +248 -0
- data/templates/cordova_android/framework/src/org/apache/cordova/Notification.java +366 -0
- data/templates/cordova_android/framework/src/org/apache/cordova/PreferenceNode.java +34 -0
- data/templates/cordova_android/framework/src/org/apache/cordova/PreferenceSet.java +62 -0
- data/templates/cordova_android/framework/src/org/apache/cordova/StandAlone.java +35 -0
- data/templates/cordova_android/framework/src/org/apache/cordova/Storage.java +239 -0
- data/templates/cordova_android/framework/src/org/apache/cordova/TempListener.java +112 -0
- data/templates/cordova_android/framework/src/org/apache/cordova/api/CordovaInterface.java +145 -0
- data/templates/cordova_android/framework/src/org/apache/cordova/api/IPlugin.java +116 -0
- data/templates/cordova_android/framework/src/org/apache/cordova/api/LOG.java +234 -0
- data/templates/cordova_android/framework/src/org/apache/cordova/api/Plugin.java +210 -0
- data/templates/cordova_android/framework/src/org/apache/cordova/api/PluginManager.java +359 -0
- data/templates/cordova_android/framework/src/org/apache/cordova/api/PluginResult.java +119 -0
- data/templates/cordova_android/framework/src/org/apache/cordova/file/EncodingException.java +28 -0
- data/templates/cordova_android/framework/src/org/apache/cordova/file/FileExistsException.java +28 -0
- data/templates/cordova_android/framework/src/org/apache/cordova/file/InvalidModificationException.java +29 -0
- data/templates/cordova_android/framework/src/org/apache/cordova/file/NoModificationAllowedException.java +28 -0
- data/templates/cordova_android/framework/src/org/apache/cordova/file/TypeMismatchException.java +29 -0
- data/templates/cordova_android/framework/test/org/apache/cordova/PreferenceNodeTest.java +53 -0
- data/templates/cordova_android/framework/test/org/apache/cordova/PreferenceSetTest.java +73 -0
- metadata +279 -0
@@ -0,0 +1,134 @@
|
|
1
|
+
/*
|
2
|
+
* Licensed to the Apache Software Foundation (ASF) under one
|
3
|
+
* or more contributor license agreements. See the NOTICE file
|
4
|
+
* distributed with this work for additional information
|
5
|
+
* regarding copyright ownership. The ASF licenses this file
|
6
|
+
* to you under the Apache License, Version 2.0 (the
|
7
|
+
* "License"); you may not use this file except in compliance
|
8
|
+
* with the License. You may obtain a copy of the License at
|
9
|
+
*
|
10
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
11
|
+
*
|
12
|
+
* Unless required by applicable law or agreed to in writing,
|
13
|
+
* software distributed under the License is distributed on an
|
14
|
+
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
15
|
+
* KIND, either express or implied. See the License for the
|
16
|
+
* specific language governing permissions and limitations
|
17
|
+
* under the License.
|
18
|
+
*/
|
19
|
+
|
20
|
+
if (!Cordova.hasResource("battery")) {
|
21
|
+
Cordova.addResource("battery");
|
22
|
+
|
23
|
+
/**
|
24
|
+
* This class contains information about the current battery status.
|
25
|
+
* @constructor
|
26
|
+
*/
|
27
|
+
var Battery = function() {
|
28
|
+
this._level = null;
|
29
|
+
this._isPlugged = null;
|
30
|
+
this._batteryListener = [];
|
31
|
+
this._lowListener = [];
|
32
|
+
this._criticalListener = [];
|
33
|
+
};
|
34
|
+
|
35
|
+
/**
|
36
|
+
* Registers as an event producer for battery events.
|
37
|
+
*
|
38
|
+
* @param {Object} eventType
|
39
|
+
* @param {Object} handler
|
40
|
+
* @param {Object} add
|
41
|
+
*/
|
42
|
+
Battery.prototype.eventHandler = function(eventType, handler, add) {
|
43
|
+
var me = navigator.battery;
|
44
|
+
if (add) {
|
45
|
+
// If there are no current registered event listeners start the battery listener on native side.
|
46
|
+
if (me._batteryListener.length === 0 && me._lowListener.length === 0 && me._criticalListener.length === 0) {
|
47
|
+
Cordova.exec(me._status, me._error, "Battery", "start", []);
|
48
|
+
}
|
49
|
+
|
50
|
+
// Register the event listener in the proper array
|
51
|
+
if (eventType === "batterystatus") {
|
52
|
+
if (me._batteryListener.indexOf(handler) === -1) {
|
53
|
+
me._batteryListener.push(handler);
|
54
|
+
}
|
55
|
+
} else if (eventType === "batterylow") {
|
56
|
+
if (me._lowListener.indexOf(handler) === -1) {
|
57
|
+
me._lowListener.push(handler);
|
58
|
+
}
|
59
|
+
} else if (eventType === "batterycritical") {
|
60
|
+
if (me._criticalListener.indexOf(handler) === -1) {
|
61
|
+
me._criticalListener.push(handler);
|
62
|
+
}
|
63
|
+
}
|
64
|
+
} else {
|
65
|
+
var pos = -1;
|
66
|
+
// Remove the event listener from the proper array
|
67
|
+
if (eventType === "batterystatus") {
|
68
|
+
pos = me._batteryListener.indexOf(handler);
|
69
|
+
if (pos > -1) {
|
70
|
+
me._batteryListener.splice(pos, 1);
|
71
|
+
}
|
72
|
+
} else if (eventType === "batterylow") {
|
73
|
+
pos = me._lowListener.indexOf(handler);
|
74
|
+
if (pos > -1) {
|
75
|
+
me._lowListener.splice(pos, 1);
|
76
|
+
}
|
77
|
+
} else if (eventType === "batterycritical") {
|
78
|
+
pos = me._criticalListener.indexOf(handler);
|
79
|
+
if (pos > -1) {
|
80
|
+
me._criticalListener.splice(pos, 1);
|
81
|
+
}
|
82
|
+
}
|
83
|
+
|
84
|
+
// If there are no more registered event listeners stop the battery listener on native side.
|
85
|
+
if (me._batteryListener.length === 0 && me._lowListener.length === 0 && me._criticalListener.length === 0) {
|
86
|
+
Cordova.exec(null, null, "Battery", "stop", []);
|
87
|
+
}
|
88
|
+
}
|
89
|
+
};
|
90
|
+
|
91
|
+
/**
|
92
|
+
* Callback for battery status
|
93
|
+
*
|
94
|
+
* @param {Object} info keys: level, isPlugged
|
95
|
+
*/
|
96
|
+
Battery.prototype._status = function(info) {
|
97
|
+
if (info) {
|
98
|
+
var me = this;
|
99
|
+
var level = info.level;
|
100
|
+
if (me._level !== level || me._isPlugged !== info.isPlugged) {
|
101
|
+
// Fire batterystatus event
|
102
|
+
Cordova.fireWindowEvent("batterystatus", info);
|
103
|
+
|
104
|
+
// Fire low battery event
|
105
|
+
if (level === 20 || level === 5) {
|
106
|
+
if (level === 20) {
|
107
|
+
Cordova.fireWindowEvent("batterylow", info);
|
108
|
+
}
|
109
|
+
else {
|
110
|
+
Cordova.fireWindowEvent("batterycritical", info);
|
111
|
+
}
|
112
|
+
}
|
113
|
+
}
|
114
|
+
me._level = level;
|
115
|
+
me._isPlugged = info.isPlugged;
|
116
|
+
}
|
117
|
+
};
|
118
|
+
|
119
|
+
/**
|
120
|
+
* Error callback for battery start
|
121
|
+
*/
|
122
|
+
Battery.prototype._error = function(e) {
|
123
|
+
console.log("Error initializing Battery: " + e);
|
124
|
+
};
|
125
|
+
|
126
|
+
Cordova.addConstructor(function() {
|
127
|
+
if (typeof navigator.battery === "undefined") {
|
128
|
+
navigator.battery = new Battery();
|
129
|
+
Cordova.addWindowEventHandler("batterystatus", navigator.battery.eventHandler);
|
130
|
+
Cordova.addWindowEventHandler("batterylow", navigator.battery.eventHandler);
|
131
|
+
Cordova.addWindowEventHandler("batterycritical", navigator.battery.eventHandler);
|
132
|
+
}
|
133
|
+
});
|
134
|
+
}
|
@@ -0,0 +1,168 @@
|
|
1
|
+
/*
|
2
|
+
* Licensed to the Apache Software Foundation (ASF) under one
|
3
|
+
* or more contributor license agreements. See the NOTICE file
|
4
|
+
* distributed with this work for additional information
|
5
|
+
* regarding copyright ownership. The ASF licenses this file
|
6
|
+
* to you under the Apache License, Version 2.0 (the
|
7
|
+
* "License"); you may not use this file except in compliance
|
8
|
+
* with the License. You may obtain a copy of the License at
|
9
|
+
*
|
10
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
11
|
+
*
|
12
|
+
* Unless required by applicable law or agreed to in writing,
|
13
|
+
* software distributed under the License is distributed on an
|
14
|
+
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
15
|
+
* KIND, either express or implied. See the License for the
|
16
|
+
* specific language governing permissions and limitations
|
17
|
+
* under the License.
|
18
|
+
*/
|
19
|
+
|
20
|
+
if (!Cordova.hasResource("camera")) {
|
21
|
+
Cordova.addResource("camera");
|
22
|
+
|
23
|
+
/**
|
24
|
+
* This class provides access to the device camera.
|
25
|
+
*
|
26
|
+
* @constructor
|
27
|
+
*/
|
28
|
+
var Camera = function() {
|
29
|
+
this.successCallback = null;
|
30
|
+
this.errorCallback = null;
|
31
|
+
this.options = null;
|
32
|
+
};
|
33
|
+
|
34
|
+
/**
|
35
|
+
* Format of image that returned from getPicture.
|
36
|
+
*
|
37
|
+
* Example: navigator.camera.getPicture(success, fail,
|
38
|
+
* { quality: 80,
|
39
|
+
* destinationType: Camera.DestinationType.DATA_URL,
|
40
|
+
* sourceType: Camera.PictureSourceType.PHOTOLIBRARY})
|
41
|
+
*/
|
42
|
+
Camera.DestinationType = {
|
43
|
+
DATA_URL: 0, // Return base64 encoded string
|
44
|
+
FILE_URI: 1 // Return file uri (content://media/external/images/media/2 for Android)
|
45
|
+
};
|
46
|
+
Camera.prototype.DestinationType = Camera.DestinationType;
|
47
|
+
|
48
|
+
/**
|
49
|
+
* Encoding of image returned from getPicture.
|
50
|
+
*
|
51
|
+
* Example: navigator.camera.getPicture(success, fail,
|
52
|
+
* { quality: 80,
|
53
|
+
* destinationType: Camera.DestinationType.DATA_URL,
|
54
|
+
* sourceType: Camera.PictureSourceType.CAMERA,
|
55
|
+
* encodingType: Camera.EncodingType.PNG})
|
56
|
+
*/
|
57
|
+
Camera.EncodingType = {
|
58
|
+
JPEG: 0, // Return JPEG encoded image
|
59
|
+
PNG: 1 // Return PNG encoded image
|
60
|
+
};
|
61
|
+
Camera.prototype.EncodingType = Camera.EncodingType;
|
62
|
+
|
63
|
+
/**
|
64
|
+
* Type of pictures to select from. Only applicable when
|
65
|
+
* PictureSourceType is PHOTOLIBRARY or SAVEDPHOTOALBUM
|
66
|
+
*
|
67
|
+
* Example: navigator.camera.getPicture(success, fail,
|
68
|
+
* { quality: 80,
|
69
|
+
* destinationType: Camera.DestinationType.DATA_URL,
|
70
|
+
* sourceType: Camera.PictureSourceType.PHOTOLIBRARY,
|
71
|
+
* mediaType: Camera.MediaType.PICTURE})
|
72
|
+
*/
|
73
|
+
Camera.MediaType = {
|
74
|
+
PICTURE: 0, // allow selection of still pictures only. DEFAULT. Will return format specified via DestinationType
|
75
|
+
VIDEO: 1, // allow selection of video only, ONLY RETURNS URL
|
76
|
+
ALLMEDIA : 2 // allow selection from all media types
|
77
|
+
};
|
78
|
+
Camera.prototype.MediaType = Camera.MediaType;
|
79
|
+
|
80
|
+
|
81
|
+
/**
|
82
|
+
* Source to getPicture from.
|
83
|
+
*
|
84
|
+
* Example: navigator.camera.getPicture(success, fail,
|
85
|
+
* { quality: 80,
|
86
|
+
* destinationType: Camera.DestinationType.DATA_URL,
|
87
|
+
* sourceType: Camera.PictureSourceType.PHOTOLIBRARY})
|
88
|
+
*/
|
89
|
+
Camera.PictureSourceType = {
|
90
|
+
PHOTOLIBRARY : 0, // Choose image from picture library (same as SAVEDPHOTOALBUM for Android)
|
91
|
+
CAMERA : 1, // Take picture from camera
|
92
|
+
SAVEDPHOTOALBUM : 2 // Choose image from picture library (same as PHOTOLIBRARY for Android)
|
93
|
+
};
|
94
|
+
Camera.prototype.PictureSourceType = Camera.PictureSourceType;
|
95
|
+
|
96
|
+
/**
|
97
|
+
* Gets a picture from source defined by "options.sourceType", and returns the
|
98
|
+
* image as defined by the "options.destinationType" option.
|
99
|
+
|
100
|
+
* The defaults are sourceType=CAMERA and destinationType=DATA_URL.
|
101
|
+
*
|
102
|
+
* @param {Function} successCallback
|
103
|
+
* @param {Function} errorCallback
|
104
|
+
* @param {Object} options
|
105
|
+
*/
|
106
|
+
Camera.prototype.getPicture = function(successCallback, errorCallback, options) {
|
107
|
+
|
108
|
+
// successCallback required
|
109
|
+
if (typeof successCallback !== "function") {
|
110
|
+
console.log("Camera Error: successCallback is not a function");
|
111
|
+
return;
|
112
|
+
}
|
113
|
+
|
114
|
+
// errorCallback optional
|
115
|
+
if (errorCallback && (typeof errorCallback !== "function")) {
|
116
|
+
console.log("Camera Error: errorCallback is not a function");
|
117
|
+
return;
|
118
|
+
}
|
119
|
+
|
120
|
+
if (options === null || typeof options === "undefined") {
|
121
|
+
options = {};
|
122
|
+
}
|
123
|
+
if (options.quality === null || typeof options.quality === "undefined") {
|
124
|
+
options.quality = 80;
|
125
|
+
}
|
126
|
+
if (options.maxResolution === null || typeof options.maxResolution === "undefined") {
|
127
|
+
options.maxResolution = 0;
|
128
|
+
}
|
129
|
+
if (options.destinationType === null || typeof options.destinationType === "undefined") {
|
130
|
+
options.destinationType = Camera.DestinationType.FILE_URI;
|
131
|
+
}
|
132
|
+
if (options.sourceType === null || typeof options.sourceType === "undefined") {
|
133
|
+
options.sourceType = Camera.PictureSourceType.CAMERA;
|
134
|
+
}
|
135
|
+
if (options.encodingType === null || typeof options.encodingType === "undefined") {
|
136
|
+
options.encodingType = Camera.EncodingType.JPEG;
|
137
|
+
}
|
138
|
+
if (options.mediaType === null || typeof options.mediaType === "undefined") {
|
139
|
+
options.mediaType = Camera.MediaType.PICTURE;
|
140
|
+
}
|
141
|
+
if (options.targetWidth === null || typeof options.targetWidth === "undefined") {
|
142
|
+
options.targetWidth = -1;
|
143
|
+
}
|
144
|
+
else if (typeof options.targetWidth === "string") {
|
145
|
+
var width = new Number(options.targetWidth);
|
146
|
+
if (isNaN(width) === false) {
|
147
|
+
options.targetWidth = width.valueOf();
|
148
|
+
}
|
149
|
+
}
|
150
|
+
if (options.targetHeight === null || typeof options.targetHeight === "undefined") {
|
151
|
+
options.targetHeight = -1;
|
152
|
+
}
|
153
|
+
else if (typeof options.targetHeight === "string") {
|
154
|
+
var height = new Number(options.targetHeight);
|
155
|
+
if (isNaN(height) === false) {
|
156
|
+
options.targetHeight = height.valueOf();
|
157
|
+
}
|
158
|
+
}
|
159
|
+
|
160
|
+
Cordova.exec(successCallback, errorCallback, "Camera", "takePicture", [options]);
|
161
|
+
};
|
162
|
+
|
163
|
+
Cordova.addConstructor(function() {
|
164
|
+
if (typeof navigator.camera === "undefined") {
|
165
|
+
navigator.camera = new Camera();
|
166
|
+
}
|
167
|
+
});
|
168
|
+
}
|
@@ -0,0 +1,203 @@
|
|
1
|
+
/*
|
2
|
+
* Licensed to the Apache Software Foundation (ASF) under one
|
3
|
+
* or more contributor license agreements. See the NOTICE file
|
4
|
+
* distributed with this work for additional information
|
5
|
+
* regarding copyright ownership. The ASF licenses this file
|
6
|
+
* to you under the Apache License, Version 2.0 (the
|
7
|
+
* "License"); you may not use this file except in compliance
|
8
|
+
* with the License. You may obtain a copy of the License at
|
9
|
+
*
|
10
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
11
|
+
*
|
12
|
+
* Unless required by applicable law or agreed to in writing,
|
13
|
+
* software distributed under the License is distributed on an
|
14
|
+
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
15
|
+
* KIND, either express or implied. See the License for the
|
16
|
+
* specific language governing permissions and limitations
|
17
|
+
* under the License.
|
18
|
+
*/
|
19
|
+
|
20
|
+
if (!Cordova.hasResource("capture")) {
|
21
|
+
Cordova.addResource("capture");
|
22
|
+
|
23
|
+
/**
|
24
|
+
* Represents a single file.
|
25
|
+
*
|
26
|
+
* name {DOMString} name of the file, without path information
|
27
|
+
* fullPath {DOMString} the full path of the file, including the name
|
28
|
+
* type {DOMString} mime type
|
29
|
+
* lastModifiedDate {Date} last modified date
|
30
|
+
* size {Number} size of the file in bytes
|
31
|
+
*/
|
32
|
+
var MediaFile = function(name, fullPath, type, lastModifiedDate, size){
|
33
|
+
this.name = name || null;
|
34
|
+
this.fullPath = fullPath || null;
|
35
|
+
this.type = type || null;
|
36
|
+
this.lastModifiedDate = lastModifiedDate || null;
|
37
|
+
this.size = size || 0;
|
38
|
+
};
|
39
|
+
|
40
|
+
/**
|
41
|
+
* Launch device camera application for recording video(s).
|
42
|
+
*
|
43
|
+
* @param {Function} successCB
|
44
|
+
* @param {Function} errorCB
|
45
|
+
*/
|
46
|
+
MediaFile.prototype.getFormatData = function(successCallback, errorCallback){
|
47
|
+
Cordova.exec(successCallback, errorCallback, "Capture", "getFormatData", [this.fullPath, this.type]);
|
48
|
+
};
|
49
|
+
|
50
|
+
/**
|
51
|
+
* MediaFileData encapsulates format information of a media file.
|
52
|
+
*
|
53
|
+
* @param {DOMString} codecs
|
54
|
+
* @param {long} bitrate
|
55
|
+
* @param {long} height
|
56
|
+
* @param {long} width
|
57
|
+
* @param {float} duration
|
58
|
+
*/
|
59
|
+
var MediaFileData = function(codecs, bitrate, height, width, duration){
|
60
|
+
this.codecs = codecs || null;
|
61
|
+
this.bitrate = bitrate || 0;
|
62
|
+
this.height = height || 0;
|
63
|
+
this.width = width || 0;
|
64
|
+
this.duration = duration || 0;
|
65
|
+
};
|
66
|
+
|
67
|
+
/**
|
68
|
+
* The CaptureError interface encapsulates all errors in the Capture API.
|
69
|
+
*/
|
70
|
+
var CaptureError = function(){
|
71
|
+
this.code = null;
|
72
|
+
};
|
73
|
+
|
74
|
+
// Capture error codes
|
75
|
+
CaptureError.CAPTURE_INTERNAL_ERR = 0;
|
76
|
+
CaptureError.CAPTURE_APPLICATION_BUSY = 1;
|
77
|
+
CaptureError.CAPTURE_INVALID_ARGUMENT = 2;
|
78
|
+
CaptureError.CAPTURE_NO_MEDIA_FILES = 3;
|
79
|
+
CaptureError.CAPTURE_NOT_SUPPORTED = 20;
|
80
|
+
|
81
|
+
/**
|
82
|
+
* The Capture interface exposes an interface to the camera and microphone of the hosting device.
|
83
|
+
*/
|
84
|
+
var Capture = function(){
|
85
|
+
this.supportedAudioModes = [];
|
86
|
+
this.supportedImageModes = [];
|
87
|
+
this.supportedVideoModes = [];
|
88
|
+
};
|
89
|
+
|
90
|
+
/**
|
91
|
+
* Launch audio recorder application for recording audio clip(s).
|
92
|
+
*
|
93
|
+
* @param {Function} successCB
|
94
|
+
* @param {Function} errorCB
|
95
|
+
* @param {CaptureAudioOptions} options
|
96
|
+
*/
|
97
|
+
Capture.prototype.captureAudio = function(successCallback, errorCallback, options){
|
98
|
+
navigator.device.capture._capture("captureAudio", successCallback, errorCallback, options);
|
99
|
+
};
|
100
|
+
|
101
|
+
/**
|
102
|
+
* Launch camera application for taking image(s).
|
103
|
+
*
|
104
|
+
* @param {Function} successCB
|
105
|
+
* @param {Function} errorCB
|
106
|
+
* @param {CaptureImageOptions} options
|
107
|
+
*/
|
108
|
+
Capture.prototype.captureImage = function(successCallback, errorCallback, options){
|
109
|
+
navigator.device.capture._capture("captureImage", successCallback, errorCallback, options);
|
110
|
+
};
|
111
|
+
|
112
|
+
/**
|
113
|
+
* Launch device camera application for recording video(s).
|
114
|
+
*
|
115
|
+
* @param {Function} successCB
|
116
|
+
* @param {Function} errorCB
|
117
|
+
* @param {CaptureVideoOptions} options
|
118
|
+
*/
|
119
|
+
Capture.prototype.captureVideo = function(successCallback, errorCallback, options){
|
120
|
+
navigator.device.capture._capture("captureVideo", successCallback, errorCallback, options);
|
121
|
+
};
|
122
|
+
|
123
|
+
/**
|
124
|
+
* Launches the correct capture.
|
125
|
+
*
|
126
|
+
* @param (DOMString} type
|
127
|
+
* @param {Function} successCB
|
128
|
+
* @param {Function} errorCB
|
129
|
+
* @param {CaptureVideoOptions} options
|
130
|
+
*/
|
131
|
+
Capture.prototype._capture = function(type, successCallback, errorCallback, options){
|
132
|
+
var win = function(result) {
|
133
|
+
var mediaFiles = [];
|
134
|
+
var i;
|
135
|
+
for (i = 0; i < pluginResult.message.length; i++) {
|
136
|
+
var mediaFile = new MediaFile();
|
137
|
+
mediaFile.name = pluginResult.message[i].name;
|
138
|
+
mediaFile.fullPath = pluginResult.message[i].fullPath;
|
139
|
+
mediaFile.type = pluginResult.message[i].type;
|
140
|
+
mediaFile.lastModifiedDate = pluginResult.message[i].lastModifiedDate;
|
141
|
+
mediaFile.size = pluginResult.message[i].size;
|
142
|
+
mediaFiles.push(mediaFile);
|
143
|
+
}
|
144
|
+
successCallback(mediaFiles);
|
145
|
+
};
|
146
|
+
Cordova.exec(win, errorCallback, "Capture", type, [options]);
|
147
|
+
};
|
148
|
+
|
149
|
+
|
150
|
+
/**
|
151
|
+
* Encapsulates a set of parameters that the capture device supports.
|
152
|
+
*/
|
153
|
+
var ConfigurationData = function(){
|
154
|
+
// The ASCII-encoded string in lower case representing the media type.
|
155
|
+
this.type = null;
|
156
|
+
// The height attribute represents height of the image or video in pixels.
|
157
|
+
// In the case of a sound clip this attribute has value 0.
|
158
|
+
this.height = 0;
|
159
|
+
// The width attribute represents width of the image or video in pixels.
|
160
|
+
// In the case of a sound clip this attribute has value 0
|
161
|
+
this.width = 0;
|
162
|
+
};
|
163
|
+
|
164
|
+
/**
|
165
|
+
* Encapsulates all image capture operation configuration options.
|
166
|
+
*/
|
167
|
+
var CaptureImageOptions = function(){
|
168
|
+
// Upper limit of images user can take. Value must be equal or greater than 1.
|
169
|
+
this.limit = 1;
|
170
|
+
// The selected image mode. Must match with one of the elements in supportedImageModes array.
|
171
|
+
this.mode = null;
|
172
|
+
};
|
173
|
+
|
174
|
+
/**
|
175
|
+
* Encapsulates all video capture operation configuration options.
|
176
|
+
*/
|
177
|
+
var CaptureVideoOptions = function(){
|
178
|
+
// Upper limit of videos user can record. Value must be equal or greater than 1.
|
179
|
+
this.limit = 1;
|
180
|
+
// Maximum duration of a single video clip in seconds.
|
181
|
+
this.duration = 0;
|
182
|
+
// The selected video mode. Must match with one of the elements in supportedVideoModes array.
|
183
|
+
this.mode = null;
|
184
|
+
};
|
185
|
+
|
186
|
+
/**
|
187
|
+
* Encapsulates all audio capture operation configuration options.
|
188
|
+
*/
|
189
|
+
var CaptureAudioOptions = function(){
|
190
|
+
// Upper limit of sound clips user can record. Value must be equal or greater than 1.
|
191
|
+
this.limit = 1;
|
192
|
+
// Maximum duration of a single sound clip in seconds.
|
193
|
+
this.duration = 0;
|
194
|
+
// The selected audio mode. Must match with one of the elements in supportedAudioModes array.
|
195
|
+
this.mode = null;
|
196
|
+
};
|
197
|
+
|
198
|
+
Cordova.addConstructor(function(){
|
199
|
+
if (typeof navigator.device.capture === "undefined") {
|
200
|
+
navigator.device.capture = window.device.capture = new Capture();
|
201
|
+
}
|
202
|
+
});
|
203
|
+
}
|
@@ -0,0 +1,168 @@
|
|
1
|
+
/*
|
2
|
+
* Licensed to the Apache Software Foundation (ASF) under one
|
3
|
+
* or more contributor license agreements. See the NOTICE file
|
4
|
+
* distributed with this work for additional information
|
5
|
+
* regarding copyright ownership. The ASF licenses this file
|
6
|
+
* to you under the Apache License, Version 2.0 (the
|
7
|
+
* "License"); you may not use this file except in compliance
|
8
|
+
* with the License. You may obtain a copy of the License at
|
9
|
+
*
|
10
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
11
|
+
*
|
12
|
+
* Unless required by applicable law or agreed to in writing,
|
13
|
+
* software distributed under the License is distributed on an
|
14
|
+
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
15
|
+
* KIND, either express or implied. See the License for the
|
16
|
+
* specific language governing permissions and limitations
|
17
|
+
* under the License.
|
18
|
+
*/
|
19
|
+
|
20
|
+
if (!Cordova.hasResource("compass")) {
|
21
|
+
Cordova.addResource("compass");
|
22
|
+
|
23
|
+
var CompassError = function(){
|
24
|
+
this.code = null;
|
25
|
+
};
|
26
|
+
|
27
|
+
// Capture error codes
|
28
|
+
CompassError.COMPASS_INTERNAL_ERR = 0;
|
29
|
+
CompassError.COMPASS_NOT_SUPPORTED = 20;
|
30
|
+
|
31
|
+
var CompassHeading = function() {
|
32
|
+
this.magneticHeading = null;
|
33
|
+
this.trueHeading = null;
|
34
|
+
this.headingAccuracy = null;
|
35
|
+
this.timestamp = null;
|
36
|
+
};
|
37
|
+
|
38
|
+
/**
|
39
|
+
* This class provides access to device Compass data.
|
40
|
+
* @constructor
|
41
|
+
*/
|
42
|
+
var Compass = function() {
|
43
|
+
/**
|
44
|
+
* The last known Compass position.
|
45
|
+
*/
|
46
|
+
this.lastHeading = null;
|
47
|
+
|
48
|
+
/**
|
49
|
+
* List of compass watch timers
|
50
|
+
*/
|
51
|
+
this.timers = {};
|
52
|
+
};
|
53
|
+
|
54
|
+
Compass.ERROR_MSG = ["Not running", "Starting", "", "Failed to start"];
|
55
|
+
|
56
|
+
/**
|
57
|
+
* Asynchronously aquires the current heading.
|
58
|
+
*
|
59
|
+
* @param {Function} successCallback The function to call when the heading data is available
|
60
|
+
* @param {Function} errorCallback The function to call when there is an error getting the heading data. (OPTIONAL)
|
61
|
+
* @param {PositionOptions} options The options for getting the heading data such as timeout. (OPTIONAL)
|
62
|
+
*/
|
63
|
+
Compass.prototype.getCurrentHeading = function(successCallback, errorCallback, options) {
|
64
|
+
|
65
|
+
// successCallback required
|
66
|
+
if (typeof successCallback !== "function") {
|
67
|
+
console.log("Compass Error: successCallback is not a function");
|
68
|
+
return;
|
69
|
+
}
|
70
|
+
|
71
|
+
// errorCallback optional
|
72
|
+
if (errorCallback && (typeof errorCallback !== "function")) {
|
73
|
+
console.log("Compass Error: errorCallback is not a function");
|
74
|
+
return;
|
75
|
+
}
|
76
|
+
|
77
|
+
var win = function(result) {
|
78
|
+
if (result.timestamp) {
|
79
|
+
var timestamp = new Date(result.timestamp);
|
80
|
+
result.timestamp = timestamp;
|
81
|
+
}
|
82
|
+
successCallback(result);
|
83
|
+
};
|
84
|
+
|
85
|
+
// Get heading
|
86
|
+
Cordova.exec(win, errorCallback, "Compass", "getHeading", []);
|
87
|
+
};
|
88
|
+
|
89
|
+
/**
|
90
|
+
* Asynchronously aquires the heading repeatedly at a given interval.
|
91
|
+
*
|
92
|
+
* @param {Function} successCallback The function to call each time the heading data is available
|
93
|
+
* @param {Function} errorCallback The function to call when there is an error getting the heading data. (OPTIONAL)
|
94
|
+
* @param {HeadingOptions} options The options for getting the heading data such as timeout and the frequency of the watch. (OPTIONAL)
|
95
|
+
* @return String The watch id that must be passed to #clearWatch to stop watching.
|
96
|
+
*/
|
97
|
+
Compass.prototype.watchHeading= function(successCallback, errorCallback, options) {
|
98
|
+
|
99
|
+
// Default interval (100 msec)
|
100
|
+
var frequency = (options !== undefined) ? options.frequency : 100;
|
101
|
+
|
102
|
+
// successCallback required
|
103
|
+
if (typeof successCallback !== "function") {
|
104
|
+
console.log("Compass Error: successCallback is not a function");
|
105
|
+
return;
|
106
|
+
}
|
107
|
+
|
108
|
+
// errorCallback optional
|
109
|
+
if (errorCallback && (typeof errorCallback !== "function")) {
|
110
|
+
console.log("Compass Error: errorCallback is not a function");
|
111
|
+
return;
|
112
|
+
}
|
113
|
+
|
114
|
+
// Make sure compass timeout > frequency + 10 sec
|
115
|
+
Cordova.exec(
|
116
|
+
function(timeout) {
|
117
|
+
if (timeout < (frequency + 10000)) {
|
118
|
+
Cordova.exec(null, null, "Compass", "setTimeout", [frequency + 10000]);
|
119
|
+
}
|
120
|
+
},
|
121
|
+
function(e) { }, "Compass", "getTimeout", []);
|
122
|
+
|
123
|
+
// Start watch timer to get headings
|
124
|
+
var id = Cordova.createUUID();
|
125
|
+
navigator.compass.timers[id] = setInterval(
|
126
|
+
function() {
|
127
|
+
var win = function(result) {
|
128
|
+
if (result.timestamp) {
|
129
|
+
var timestamp = new Date(result.timestamp);
|
130
|
+
result.timestamp = timestamp;
|
131
|
+
}
|
132
|
+
successCallback(result);
|
133
|
+
};
|
134
|
+
Cordova.exec(win, errorCallback, "Compass", "getHeading", []);
|
135
|
+
}, (frequency ? frequency : 1));
|
136
|
+
|
137
|
+
return id;
|
138
|
+
};
|
139
|
+
|
140
|
+
|
141
|
+
/**
|
142
|
+
* Clears the specified heading watch.
|
143
|
+
*
|
144
|
+
* @param {String} id The ID of the watch returned from #watchHeading.
|
145
|
+
*/
|
146
|
+
Compass.prototype.clearWatch = function(id) {
|
147
|
+
|
148
|
+
// Stop javascript timer & remove from timer list
|
149
|
+
if (id && navigator.compass.timers[id]) {
|
150
|
+
clearInterval(navigator.compass.timers[id]);
|
151
|
+
delete navigator.compass.timers[id];
|
152
|
+
}
|
153
|
+
};
|
154
|
+
|
155
|
+
Compass.prototype._castDate = function(pluginResult) {
|
156
|
+
if (pluginResult.message.timestamp) {
|
157
|
+
var timestamp = new Date(pluginResult.message.timestamp);
|
158
|
+
pluginResult.message.timestamp = timestamp;
|
159
|
+
}
|
160
|
+
return pluginResult;
|
161
|
+
};
|
162
|
+
|
163
|
+
Cordova.addConstructor(function() {
|
164
|
+
if (typeof navigator.compass === "undefined") {
|
165
|
+
navigator.compass = new Compass();
|
166
|
+
}
|
167
|
+
});
|
168
|
+
}
|