Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Updated the Badge plugin for Cordova 1.6.1

Updated the README file to show the versions of everything we use.
  • Loading branch information...
commit 076687b3e22a1564c466e2dc64aa90b2e903ee81 1 parent f87151f
@JStuhr JStuhr authored
View
26 README
@@ -1,3 +1,29 @@
+The Disaster Response application uses the following:
+ - XCode 4.3.2 (for iOS)
+ - App Store: http://itunes.apple.com/us/app/xcode/id497799835?ls=1&mt=12
+
+ - Eclipse
+ - Website: http://www.eclipse.org/
+ - Download: http://www.eclipse.org/downloads/
+
+ - Cordova 1.6.1
+ - Website: http://phonegap.com/
+ - Direct Download: https://github.com/phonegap/phonegap/tags
+
+ - JQuery 1.7.1
+ - Website: http://jquery.com/
+ - Direct Download: http://blog.jquery.com/2011/11/21/jquery-1-7-1-released/
+
+ - JQuery Mobile 1.0.1
+ - Website: http://jquerymobile.com/
+ - Direct Download: http://jquerymobile.com/blog/2012/01/26/jquery-mobile-1-0-1-released/
+
+ - Heatmap.js
+ - Website: http://www.patrick-wied.at/static/heatmapjs/
+ - Our Modified Version: https://github.com/JStuhr/heatmap.js
+
+/* ================================================================================ */
+
For building and running on Android, please consult the Android developer's guide.
"If you are developing in Eclipse, the ADT plugin incrementally builds your project as you make changes to the source code. Eclipse outputs an .apk file automatically to the bin folder of the project, so you do not have to do anything extra to generate the .apk.
View
2  iOS/Disaster Response/Disaster Response/Cordova.plist
@@ -26,6 +26,8 @@
</array>
<key>Plugins</key>
<dict>
+ <key>Badge</key>
+ <string>Badge</string>
<key>Compass</key>
<string>CDVLocation</string>
<key>Accelerometer</key>
View
23 iOS/Disaster Response/Disaster Response/Plugins/Badge/Badge.h
@@ -0,0 +1,23 @@
+/*
+ * This code is adapted from the work of Michael Nachbaur
+ * by Simon Madine of The Angry Robot Zombie Factory
+ * - Converted to Cordova 1.6.1 by Joseph Stuhr.
+ * 2012-04-19
+ * MIT licensed
+ *
+ */
+
+#import <Foundation/Foundation.h>
+
+#ifdef CORDOVA_FRAMEWORK
+ #import <Cordova/CDVPlugin.h>
+#else
+ #import "CDVPlugin.h"
+#endif
+
+@interface Badge : CDVPlugin {
+}
+
+- (void)setBadge:(NSMutableArray*)badgeNumber withDict:(NSMutableDictionary*)options;
+
+@end
View
18 iOS/Disaster Response/Disaster Response/Plugins/Badge/Badge.m
@@ -0,0 +1,18 @@
+/*
+ * This code is adapted from the work of Michael Nachbaur
+ * by Simon Madine of The Angry Robot Zombie Factory
+ * - Converted to Cordova 1.6.1 by Joseph Stuhr.
+ * 2012-04-19
+ * MIT licensed
+ *
+ */
+
+#import "Badge.h"
+
+@implementation Badge
+
+- (void)setBadge:(NSMutableArray*)badgeNumber withDict:(NSMutableDictionary*)options {
+ [[UIApplication sharedApplication] setApplicationIconBadgeNumber:[[ badgeNumber objectAtIndex:0] intValue]];
+}
+
+@end
View
69 iOS/Disaster Response/www/common/PhoneGap-Plugins/Badge.js
@@ -1,39 +1,50 @@
/*
* This code is adapted from the work of Michael Nachbaur
* by Simon Madine of The Angry Robot Zombie Factory
- * 2010-05-04
+ * - Converted to Cordova 1.6.1 by Joseph Stuhr.
+ * 2012-04-19
* MIT licensed
*
- * Converted to Cordova by Joseph Stuhr.
-*/
-
-/**
- * This class exposes the iPhone 'icon badge' functionality to JavaScript
- * to add a number (with a red background) to each icon
- * @constructor
*/
-function Badge() {
-}
-/**
- * Positive integer sets the badge, 0 or negative clears it
+/*
+ * Temporary Scope to contain the plugin.
+ * - More information here:
+ * https://github.com/apache/incubator-cordova-ios/blob/master/guides/Cordova%20Plugin%20Upgrade%20Guide.md
*/
-Badge.prototype.set = function(options) {
- Cordova.exec("Badge.setBadge", options);
-};
+(function(){
-/**
- * Shorthand to set the badge to 0
- */
-Badge.prototype.clear = function() {
- Cordova.exec("Badge.setBadge", 0);
-};
+ /* Get local ref to global PhoneGap/Cordova/cordova object for exec function.
+ - This increases the compatibility of the plugin. */
+ var cordovaRef = window.PhoneGap || window.Cordova || window.cordova; // old to new fallbacks
+
+ /*
+ * This class exposes the iPhone 'icon badge' functionality to JavaScript
+ * to add a number (with a red background) to each icon.
+ */
+ function Badge() { }
+
+ /**
+ * Positive integer sets the badge amount, 0 or negative removes it.
+ */
+ Badge.prototype.set = function(options) {
+ cordovaRef.exec("Badge.setBadge", options);
+ };
+
+ /**
+ * Shorthand to set the badge to 0 and remove it.
+ */
+ Badge.prototype.clear = function() {
+ cordovaRef.exec("Badge.setBadge", 0);
+ };
-Cordova.addConstructor(function() {
- if(!window.plugins) {
- window.plugins = {};
- }
- if(!window.plugins.badge) {
- window.plugins.badge = new Badge();
- }
-});
+ cordovaRef.addConstructor(function() {
+ if(!window.plugins) {
+ window.plugins = {};
+ }
+ if(!window.plugins.badge) {
+ window.plugins.badge = new Badge();
+ }
+ });
+
+})(); /* End of Temporary Scope. */
Please sign in to comment.
Something went wrong with that request. Please try again.