You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cordova.apache.org by pu...@apache.org on 2012/04/10 00:40:29 UTC
[7/34] wp7 commit: removed unused resources
removed unused resources
Project: http://git-wip-us.apache.org/repos/asf/incubator-cordova-wp7/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-cordova-wp7/commit/49b5d3b4
Tree: http://git-wip-us.apache.org/repos/asf/incubator-cordova-wp7/tree/49b5d3b4
Diff: http://git-wip-us.apache.org/repos/asf/incubator-cordova-wp7/diff/49b5d3b4
Branch: refs/heads/master
Commit: 49b5d3b406783de8cd3d1c8428f6fd8ec045ab58
Parents: 96d9fb1
Author: Jesse MacFadyen <pu...@gmail.com>
Authored: Mon Apr 9 15:18:03 2012 -0700
Committer: Jesse MacFadyen <pu...@gmail.com>
Committed: Mon Apr 9 15:18:03 2012 -0700
----------------------------------------------------------------------
Cordova-1.4.1-Custom.zip | Bin 126410 -> 0 bytes
Cordova-1.4.1-Starter.zip | Bin 187245 -> 0 bytes
Cordova-1.5.0-Custom.zip | Bin 126462 -> 0 bytes
Cordova-1.5.0-Starter.zip | Bin 186775 -> 0 bytes
VERSION | 2 +-
framework/js/BuildJSConcat.js | 71 -
framework/js/DOMStorage.js | 220 --
framework/js/PGXHR.js | 205 --
framework/js/accelerometer.js | 149 --
framework/js/battery.js | 81 -
framework/js/camera.js | 151 --
framework/js/capture.js | 235 --
framework/js/compass.js | 177 --
framework/js/contact.js | 317 ---
framework/js/cordova-1.6.0-core.js | 2598 ---------------------
framework/js/cordova-1.6.0.js | 3865 -------------------------------
framework/js/cordova.js.base | 641 -----
framework/js/debugConsole.js | 61 -
framework/js/device.js | 80 -
framework/js/disclaimer.txt | 5 -
framework/js/file.js | 1046 ---------
framework/js/filetransfer.js | 101 -
framework/js/media.js | 232 --
framework/js/network.js | 96 -
framework/js/notification.js | 133 --
framework/js/readme.txt | 4 -
26 files changed, 1 insertions(+), 10469 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-cordova-wp7/blob/49b5d3b4/Cordova-1.4.1-Custom.zip
----------------------------------------------------------------------
diff --git a/Cordova-1.4.1-Custom.zip b/Cordova-1.4.1-Custom.zip
deleted file mode 100644
index 2e91728..0000000
Binary files a/Cordova-1.4.1-Custom.zip and /dev/null differ
http://git-wip-us.apache.org/repos/asf/incubator-cordova-wp7/blob/49b5d3b4/Cordova-1.4.1-Starter.zip
----------------------------------------------------------------------
diff --git a/Cordova-1.4.1-Starter.zip b/Cordova-1.4.1-Starter.zip
deleted file mode 100644
index 026bb9a..0000000
Binary files a/Cordova-1.4.1-Starter.zip and /dev/null differ
http://git-wip-us.apache.org/repos/asf/incubator-cordova-wp7/blob/49b5d3b4/Cordova-1.5.0-Custom.zip
----------------------------------------------------------------------
diff --git a/Cordova-1.5.0-Custom.zip b/Cordova-1.5.0-Custom.zip
deleted file mode 100644
index 34434f9..0000000
Binary files a/Cordova-1.5.0-Custom.zip and /dev/null differ
http://git-wip-us.apache.org/repos/asf/incubator-cordova-wp7/blob/49b5d3b4/Cordova-1.5.0-Starter.zip
----------------------------------------------------------------------
diff --git a/Cordova-1.5.0-Starter.zip b/Cordova-1.5.0-Starter.zip
deleted file mode 100644
index 943e4a2..0000000
Binary files a/Cordova-1.5.0-Starter.zip and /dev/null differ
http://git-wip-us.apache.org/repos/asf/incubator-cordova-wp7/blob/49b5d3b4/VERSION
----------------------------------------------------------------------
diff --git a/VERSION b/VERSION
index 3e1ad72..ce6a70b 100644
--- a/VERSION
+++ b/VERSION
@@ -1 +1 @@
-1.5.0
\ No newline at end of file
+1.6.0
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/incubator-cordova-wp7/blob/49b5d3b4/framework/js/BuildJSConcat.js
----------------------------------------------------------------------
diff --git a/framework/js/BuildJSConcat.js b/framework/js/BuildJSConcat.js
deleted file mode 100644
index 9eee50a..0000000
--- a/framework/js/BuildJSConcat.js
+++ /dev/null
@@ -1,71 +0,0 @@
-// JSConcat
-
-var versionStr = "1.4.1";
-var allSourceFiles = [
- "disclaimer.txt",
- "cordova.js.base",
- "accelerometer.js",
- "camera.js",
- "capture.js",
- "compass.js",
- "contact.js",
- "debugConsole.js",
- "device.js",
- "DOMStorage.js",
- "file.js",
- "filetransfer.js",
- "media.js",
- "network.js",
- "notification.js",
- "PGXHR.js"
-];
-
-var coreSourceFiles = [
- "disclaimer.txt",
- "cordova.js.base",
- "debugConsole.js",
- "device.js",
- "DOMStorage.js",
- "file.js",
- "filetransfer.js",
- "network.js",
- "notification.js",
- "PGXHR.js"
-];
-
-var objArgs = WScript.Arguments;
-if(objArgs && objArgs.length > 0)
-{
- versionStr = objArgs(0);
-}
-
-var fso = WScript.CreateObject("Scripting.FileSystemObject");
-
-var folder = fso.GetFolder(".");
-
-var outFile = fso.CreateTextFile("cordova-" + versionStr + ".js", true);
-
-for(var n = 0; n < allSourceFiles.length; n++)
-{
- var srcFile = fso.OpenTextFile(allSourceFiles[n]);
- while(!srcFile.AtEndOfStream)
- {
- outFile.WriteLine(srcFile.ReadLine());
- }
- outFile.WriteLine("");
-}
-
-var outFile = fso.CreateTextFile("cordova-" + versionStr + "-core.js", true);
-for(var n = 0; n < coreSourceFiles.length; n++)
-{
- var srcFile = fso.OpenTextFile(coreSourceFiles[n]);
- while(!srcFile.AtEndOfStream)
- {
- outFile.WriteLine(srcFile.ReadLine());
- }
- outFile.WriteLine("");
-}
-
-
-
-
http://git-wip-us.apache.org/repos/asf/incubator-cordova-wp7/blob/49b5d3b4/framework/js/DOMStorage.js
----------------------------------------------------------------------
diff --git a/framework/js/DOMStorage.js b/framework/js/DOMStorage.js
deleted file mode 100644
index 1a05ace..0000000
--- a/framework/js/DOMStorage.js
+++ /dev/null
@@ -1,220 +0,0 @@
-/*
- Licensed under the Apache License, Version 2.0 (the "License");
- you may not use this file except in compliance with the License.
- You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
- Unless required by applicable law or agreed to in writing, software
- distributed under the License is distributed on an "AS IS" BASIS,
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- See the License for the specific language governing permissions and
- limitations under the License.
-*/
-
-// this is a WP7 Only implementation of the Storage API for use in webpages loaded from the local file system
-// inside cordova application.
-// there is a native implementation which is backing this and providing the persistance of values.
-// webpages loaded from a domain will not need to use this as IE9 has support for WebStorage
-// Javascript Interface is as defined here : http://dev.w3.org/html5/webstorage/#storage-0
-//
-
-if(!window.localStorage)
-{(function()
-{
- "use strict";
-
- var DOMStorage = function(type)
- {
- // default type is local
- if(type == "sessionStorage")
- {
- this._type = type;
- }
- Object.defineProperty( this, "length",
- {
- configurable: true,
- get: function(){ return this.getLength() }
- });
-
- };
-
- DOMStorage.prototype =
- {
- _type:"localStorage",
- _result:null,
- keys:null,
-
- onResult:function(key,valueStr)
- {
- if(!this.keys)
- {
- this.keys = [];
- }
- this._result = valueStr;
- },
-
- onKeysChanged:function(jsonKeys)
- {
- this.keys = JSON.parse(jsonKeys);
-
- var key;
- for(var n = 0,len =this.keys.length; n < len; n++)
- {
- key = this.keys[n];
- if(!this.hasOwnProperty(key))
- {
- Object.defineProperty( this, key,
- {
-
- configurable: true,
- get: function(){ return this.getItem(key); },
- set: function(val){ return this.setItem(key,val); }
- });
- }
- }
-
- },
-
- initialize:function()
- {
- window.external.Notify("DOMStorage/" + this._type + "/load/keys");
- },
-
- /*
- The length attribute must return the number of key/value pairs currently present in the list associated with the object.
- */
- getLength:function()
- {
- if(!this.keys)
- {
- this.initialize();
- }
- return this.keys.length;
- },
-
- /*
- The key(n) method must return the name of the nth key in the list.
- The order of keys is user-agent defined, but must be consistent within an object so long as the number of keys doesn't change.
- (Thus, adding or removing a key may change the order of the keys, but merely changing the value of an existing key must not.)
- If n is greater than or equal to the number of key/value pairs in the object, then this method must return null.
- */
- key:function(n)
- {
- if(!this.keys)
- {
- this.initialize();
- }
-
- if(n >= this.keys.length)
- {
- return null;
- }
- else
- {
- return this.keys[n];
- }
- },
-
- /*
- The getItem(key) method must return the current value associated with the given key.
- If the given key does not exist in the list associated with the object then this method must return null.
- */
- getItem:function(key)
- {
- if(!this.keys)
- {
- this.initialize();
- }
-
- var retVal = null;
- if(this.keys.indexOf(key) > -1)
- {
- window.external.Notify("DOMStorage/" + this._type + "/get/" + key);
- retVal = this._result;
- this._result = null;
- }
- return retVal;
- },
- /*
- The setItem(key, value) method must first check if a key/value pair with the given key already exists
- in the list associated with the object.
- If it does not, then a new key/value pair must be added to the list, with the given key and with its value set to value.
- If the given key does exist in the list, then it must have its value updated to value.
- If it couldn't set the new value, the method must raise an QUOTA_EXCEEDED_ERR exception.
- (Setting could fail if, e.g., the user has disabled storage for the site, or if the quota has been exceeded.)
- */
- setItem:function(key,value)
- {
- if(!this.keys)
- {
- this.initialize();
- }
- window.external.Notify("DOMStorage/" + this._type + "/set/" + key + "/" + value);
- },
-
- /*
- The removeItem(key) method must cause the key/value pair with the given key to be removed from the list
- associated with the object, if it exists.
- If no item with that key exists, the method must do nothing.
- */
- removeItem:function(key)
- {
- if(!this.keys)
- {
- this.initialize();
- }
- var index = this.keys.indexOf(key);
- if(index > -1)
- {
- this.keys.splice(index,1);
- // TODO: need sanity check for keys ? like 'clear','setItem', ...
- window.external.Notify("DOMStorage/" + this._type + "/remove/" + key);
- delete this[key];
- }
-
- },
-
- /*
- The clear() method must atomically cause the list associated with the object to be emptied of all
- key/value pairs, if there are any.
- If there are none, then the method must do nothing.
- */
- clear:function()
- {
- if(!this.keys)
- {
- this.initialize();
- }
-
- for(var n=0,len=this.keys.length; n < len;n++)
- {
- // TODO: do we need a sanity check for keys ? like 'clear','setItem', ...
- delete this[this.keys[n]];
- }
- this.keys = [];
- window.external.Notify("DOMStorage/" + this._type + "/clear/");
- }
- };
-
- // initialize DOMStorage
-
- Object.defineProperty( window, "localStorage",
- {
- writable: false,
- configurable: false,
- value:new DOMStorage("localStorage")
- });
- window.localStorage.initialize();
-
- Object.defineProperty( window, "sessionStorage",
- {
- writable: false,
- configurable: false,
- value:new DOMStorage("sessionStorage")
- });
- window.sessionStorage.initialize();
-
-
-})();};
-
http://git-wip-us.apache.org/repos/asf/incubator-cordova-wp7/blob/49b5d3b4/framework/js/PGXHR.js
----------------------------------------------------------------------
diff --git a/framework/js/PGXHR.js b/framework/js/PGXHR.js
deleted file mode 100644
index f1f86a4..0000000
--- a/framework/js/PGXHR.js
+++ /dev/null
@@ -1,205 +0,0 @@
-
-/**
- * @author purplecabbage
- */
-
-(function(win,doc){
-
-
- doc.addEventListener("DOMContentLoaded",function()
- {
- var docDomain = null;
- try
- {
- docDomain = doc.domain;
- }
- catch(err)
- {
- //console.log("caught exception trying to access document.domain");
- }
-
- if(!docDomain || docDomain.length == 0)
- {
- //console.log("adding our own Local XHR shim ");
- var aliasXHR = win.XMLHttpRequest;
-
- win.XMLHttpRequest = function(){};
- win.XMLHttpRequest.noConflict = aliasXHR;
- win.XMLHttpRequest.UNSENT = 0;
- win.XMLHttpRequest.OPENED = 1;
- win.XMLHttpRequest.HEADERS_RECEIVED = 2;
- win.XMLHttpRequest.LOADING = 3;
- win.XMLHttpRequest.DONE = 4;
-
- win.XMLHttpRequest.prototype =
- {
- UNSENT:0,
- OPENED:1,
- HEADERS_RECEIVED:2,
- LOADING:3,
- DONE:4,
-
- isAsync:false,
- onreadystatechange:null,
- readyState:0,
- _url:"",
- timeout:0,
- withCredentials:false,
- _requestHeaders:null,
- open:function(reqType,uri,isAsync,user,password)
- {
- console.log("XMLHttpRequest.open ::: " + uri);
-
- if(uri && uri.indexOf("http") == 0)
- {
- if(!this.wrappedXHR)
- {
- this.wrappedXHR = new aliasXHR();
- var self = this;
-
- // timeout
- if(this.timeout > 0)
- {
- this.wrappedXHR.timeout = this.timeout;
- }
- Object.defineProperty( this, "timeout", {
- set: function(val) {
- this.wrappedXHR.timeout = val;
- },
- get:function() {
- return this.wrappedXHR.timeout;
- }});
-
-
-
- if(this.withCredentials)
- {
- this.wrappedXHR.withCredentials = this.withCredentials;
- }
- Object.defineProperty( this, "withCredentials", {
- set: function(val) {
- this.wrappedXHR.withCredentials = val;
- },
- get:function() {
- return this.wrappedXHR.withCredentials;
- }});
-
-
- Object.defineProperty( this, "status", { get: function() {
- return this.wrappedXHR.status;
- }});
- Object.defineProperty( this, "responseText", { get: function() {
- return this.wrappedXHR.responseText;
- }});
- Object.defineProperty( this, "statusText", { get: function() {
- return this.wrappedXHR.statusText;
- }});
-
- Object.defineProperty( this, "responseXML", { get: function() {
- return this.wrappedXHR.responseXML;
- }});
-
- this.getResponseHeader = function(header) {
- return this.wrappedXHR.getResponseHeader(header);
- };
- this.getAllResponseHeaders = function() {
- return this.wrappedXHR.getAllResponseHeaders();
- };
-
- this.wrappedXHR.onreadystatechange = function()
- {
- self.changeReadyState(self.wrappedXHR.readyState);
- };
- }
- return this.wrappedXHR.open(reqType,uri,isAsync,user,password);
- }
- else
- {
- // x-wmapp1://app/www/page2.html
- // need to work some magic on the actual url/filepath
- var newUrl = uri;
- if(newUrl.indexOf(":/") > -1)
- {
- newUrl = newUrl.split(":/")[1];
- }
-
- if(newUrl.lastIndexOf("/") === newUrl.length - 1)
- {
- newUrl += "index.html"; // default page is index.html, when call is to a dir/ ( why not ...? )
- }
- this._url = newUrl;
- }
- },
- statusText:"",
- changeReadyState:function(newState)
- {
- this.readyState = newState;
- if(this.onreadystatechange)
- {
- this.onreadystatechange();
- }
- },
- setRequestHeader:function(header,value)
- {
- if(this.wrappedXHR)
- {
- this.wrappedXHR.setRequestHeader(header,value);
- }
- },
- getResponseHeader:function(header)
- {
- return this.wrappedXHR ? this.wrappedXHR.getResponseHeader(header) : "";
- },
- getAllResponseHeaders:function()
- {
- return this.wrappedXHR ? this.wrappedXHR.getAllResponseHeaders() : "";
- },
- responseText:"",
- responseXML:"",
- onResult:function(res)
- {
- this.status = 200;
- this.responseText = res;
-
- Object.defineProperty( this, "responseXML", { get: function() {
- var parser = new DOMParser();
- return parser.parseFromString(this.responseText,"text/xml");
- }});
- this.changeReadyState(this.DONE);
- },
- onError:function(err)
- {
- console.log("Wrapped XHR received Error from FileAPI :: " + err);
- this.status = 404;
- this.changeReadyState(this.DONE);
- },
-
- abort:function()
- {
- if(this.wrappedXHR)
- {
- return this.wrappedXHR.abort();
- }
- },
-
- send:function(data)
- {
- if(this.wrappedXHR)
- {
- return this.wrappedXHR.send(data);
- }
- else
- {
- this.changeReadyState(this.OPENED);
- navigator.fileMgr.readAsText(this._url,"UTF-8",this.onResult.bind(this),this.onError.bind(this));
- }
- },
- status:404
- };
- } // if doc domain
-
- },false);// addEventListener
-
-
-})(window,document);
-
http://git-wip-us.apache.org/repos/asf/incubator-cordova-wp7/blob/49b5d3b4/framework/js/accelerometer.js
----------------------------------------------------------------------
diff --git a/framework/js/accelerometer.js b/framework/js/accelerometer.js
deleted file mode 100644
index 930d5ce..0000000
--- a/framework/js/accelerometer.js
+++ /dev/null
@@ -1,149 +0,0 @@
-/*
- Licensed under the Apache License, Version 2.0 (the "License");
- you may not use this file except in compliance with the License.
- You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
- Unless required by applicable law or agreed to in writing, software
- distributed under the License is distributed on an "AS IS" BASIS,
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- See the License for the specific language governing permissions and
- limitations under the License.
-*/
-
-if (!Cordova.hasResource("accelerometer"))
-{
-Cordova.addResource("accelerometer");
-
-/** @constructor */
-var Acceleration = function(x, y, z) {
- this.x = x;
- this.y = y;
- this.z = z;
- this.timestamp = new Date().getTime();
-};
-
-/**
- * This class provides access to device accelerometer data.
- * @constructor
- */
-var Accelerometer = function() {
-
- /**
- * The last known acceleration. type=Acceleration()
- */
- this.lastAcceleration = null;
-
- /**
- * List of accelerometer watch timers
- */
- this.timers = {};
-};
-
-Accelerometer.ERROR_MSG = ["Not running", "Starting", "", "Failed to start"];
-
-/**
- * Asynchronously aquires the current acceleration.
- *
- * @param {Function} successCallback The function to call when the acceleration data is available
- * @param {Function} errorCallback The function to call when there is an error getting the acceleration data. (OPTIONAL)
- * @param {AccelerationOptions} options The options for getting the accelerometer data such as timeout. (OPTIONAL)
- */
-Accelerometer.prototype.getCurrentAcceleration = function(successCallback, errorCallback, options) {
-
- // successCallback required
- if (typeof successCallback !== "function") {
- console.log("Accelerometer Error: successCallback is not a function");
- return;
- }
-
- // errorCallback optional
- if (errorCallback && (typeof errorCallback !== "function")) {
- console.log("Accelerometer Error: errorCallback is not a function");
- return;
- }
-
- var self = this;
-
- var onSuccess = function(result)
- {
- var accResult = JSON.parse(result);
- self.lastAcceleration = new Acceleration(accResult.x,accResult.y,accResult.z);
- successCallback(self.lastAcceleration);
- }
-
- var onError = function(err)
- {
- errorCallback(err);
- }
-
- // Get acceleration
- Cordova.exec(onSuccess, onError, "Accelerometer", "getAcceleration",options);
-};
-
-
-/**
- * Asynchronously aquires the acceleration repeatedly at a given interval.
- *
- * @param {Function} successCallback The function to call each time the acceleration data is available
- * @param {Function} errorCallback The function to call when there is an error getting the acceleration data. (OPTIONAL)
- * @param {AccelerationOptions} options The options for getting the accelerometer data such as timeout. (OPTIONAL)
- * @return String The watch id that must be passed to #clearWatch to stop watching.
- */
-Accelerometer.prototype.watchAcceleration = function(successCallback, errorCallback, options)
-{
- var self = this;
- // successCallback required
- if (typeof successCallback !== "function") {
- console.log("Accelerometer Error: successCallback is not a function");
- return;
- }
-
- // errorCallback optional
- if (errorCallback && (typeof errorCallback !== "function")) {
- console.log("Accelerometer Error: errorCallback is not a function");
- return;
- }
-
- var onSuccess = function (result) {
- var accResult = JSON.parse(result);
- self.lastAcceleration = new Acceleration(accResult.x, accResult.y, accResult.z);
- successCallback(self.lastAcceleration);
- }
-
- var onError = function (err) {
- errorCallback(err);
- }
-
- var id = Cordova.createUUID();
-
- var params = new Object();
- params.id = id;
- // Default interval (10 sec)
- params.frequency = (options && options.frequency) ? options.frequency : 10000;
-
- Cordova.exec(onSuccess, onError, "Accelerometer", "startWatch", params);
-
- return id;
-};
-
-/**
- * Clears the specified accelerometer watch.
- *
- * @param {String} id The id of the watch returned from #watchAcceleration.
- */
-Accelerometer.prototype.clearWatch = function(id) {
-
- Cordova.exec(null, null, "Accelerometer", "stopWatch", { id: id });
-};
-
-Cordova.onCordovaInit.subscribeOnce(
-function()
-{
- if (!navigator.accelerometer)
- {
- navigator.accelerometer = new Accelerometer();
- }
-});
-}
http://git-wip-us.apache.org/repos/asf/incubator-cordova-wp7/blob/49b5d3b4/framework/js/battery.js
----------------------------------------------------------------------
diff --git a/framework/js/battery.js b/framework/js/battery.js
deleted file mode 100644
index 0285101..0000000
--- a/framework/js/battery.js
+++ /dev/null
@@ -1,81 +0,0 @@
-/*
- Licensed under the Apache License, Version 2.0 (the "License");
- you may not use this file except in compliance with the License.
- You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
- Unless required by applicable law or agreed to in writing, software
- distributed under the License is distributed on an "AS IS" BASIS,
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- See the License for the specific language governing permissions and
- limitations under the License.
-*/
-
-if (!Cordova.hasResource("battery")) {
-
-Cordova.addResource("battery");
-
-Cordova.onCordovaInit.subscribeOnce(function() {
-
- navigator.battery = navigator.battery ||
- {
-
-
- _events:{},
- _isAttached:false,
-
- _onBatteryStatusChanged:function(eventName,result)
- {
-
- },
-
- addEventListener: function(eventName, funk)
- {
- this._events[eventName] = this._events[eventName] || [];
- this._events[eventName].push(funk);
- if(!this._isAttached)
- {
- // exec start
- }
- },
-
- removeEventListener: function(eventName, funk)
- {
- if( eventName in this._events === false )
- return;
-
- this._events[eventName].splice(this._events[eventName].indexOf(funk), 1);
- if(this._isAttached)
- {
- var hasListeners = false;
- for(var v in this._events)
- {
- if(this._events[v].length)
- {
- hasListeners = true;
- break;
- }
- }
- if(!hasListeners)
- {
- // exec stop
- }
- }
- },
-
- dispatchEvent: function(eventName /* , args... */)
- {
- if( eventName in this._events === false )
- return;
- for(var i = 0; i < this._events[event].length; i++)
- {
- this._events[eventName][i].apply(this, Array.prototype.slice.call(arguments, 1))
- }
- }
-
- };
-
-});
-
-}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/incubator-cordova-wp7/blob/49b5d3b4/framework/js/camera.js
----------------------------------------------------------------------
diff --git a/framework/js/camera.js b/framework/js/camera.js
deleted file mode 100644
index f11e1ea..0000000
--- a/framework/js/camera.js
+++ /dev/null
@@ -1,151 +0,0 @@
-/*
- Licensed under the Apache License, Version 2.0 (the "License");
- you may not use this file except in compliance with the License.
- You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
- Unless required by applicable law or agreed to in writing, software
- distributed under the License is distributed on an "AS IS" BASIS,
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- See the License for the specific language governing permissions and
- limitations under the License.
-*/
-
-if (!Cordova.hasResource("camera")) {
-Cordova.addResource("camera");
-
-/**
- * This class provides access to the device camera.
- *
- * @constructor
- */
-var Camera = function() {
- this.successCallback = null;
- this.errorCallback = null;
- this.options = null;
-};
-
-/**
- * Format of image that returned from getPicture.
- *
- * Example: navigator.camera.getPicture(success, fail,
- * { quality: 80,
- * destinationType: Camera.DestinationType.DATA_URL,
- * sourceType: Camera.PictureSourceType.PHOTOLIBRARY})
- */
-Camera.DestinationType = {
- DATA_URL: 0, // Return base64 encoded string
- FILE_URI: 1 // Return file uri (content://media/external/images/media/2 for Android)
-};
-Camera.prototype.DestinationType = Camera.DestinationType;
-
-/**
- * Encoding of image returned from getPicture.
- *
- * Example: navigator.camera.getPicture(success, fail,
- * { quality: 80,
- * destinationType: Camera.DestinationType.DATA_URL,
- * sourceType: Camera.PictureSourceType.CAMERA,
- * encodingType: Camera.EncodingType.PNG})
-*/
-Camera.EncodingType = {
- JPEG: 0, // Return JPEG encoded image
- PNG: 1 // Return PNG encoded image
-};
-Camera.prototype.EncodingType = Camera.EncodingType;
-
-/**
- * Source to getPicture from.
- *
- * Example: navigator.camera.getPicture(success, fail,
- * { quality: 80,
- * destinationType: Camera.DestinationType.DATA_URL,
- * sourceType: Camera.PictureSourceType.PHOTOLIBRARY})
- */
-Camera.PictureSourceType = {
- PHOTOLIBRARY : 0, // Choose image from picture library (same as SAVEDPHOTOALBUM for Android)
- CAMERA : 1, // Take picture from camera
- SAVEDPHOTOALBUM : 2 // Choose image from picture library (same as PHOTOLIBRARY for Android)
-};
-Camera.prototype.PictureSourceType = Camera.PictureSourceType;
-
-/**
- * Gets a picture from source defined by "options.sourceType", and returns the
- * image as defined by the "options.destinationType" option.
-
- * The defaults are sourceType=CAMERA and destinationType=DATA_URL.
- *
- * @param {Function} successCallback
- * @param {Function} errorCallback
- * @param {Object} options
- */
-Camera.prototype.getPicture = function(successCallback, errorCallback, options) {
- console.log("Camera.prototype.getPicture");
- // successCallback required
- if (typeof successCallback !== "function") {
- console.log("Camera Error: successCallback is not a function");
- return;
- }
-
- // errorCallback optional
- if (errorCallback && (typeof errorCallback !== "function")) {
- console.log("Camera Error: errorCallback is not a function");
- return;
- }
-
- this.options = options;
-
-// TODO: This is duplicate - default values initialization exists in native C# code
-// var quality = 80;
-// if (options.quality) {
-// quality = this.options.quality;
-// }
-//
-// var maxResolution = 0;
-// if (options.maxResolution) {
-// maxResolution = this.options.maxResolution;
-// }
-//
-// var destinationType = Camera.DestinationType.DATA_URL;
-// if (this.options.destinationType) {
-// destinationType = this.options.destinationType;
-// }
-// var sourceType = Camera.PictureSourceType.CAMERA;
-// if (typeof this.options.sourceType === "number") {
-// sourceType = this.options.sourceType;
-// }
-// var encodingType = Camera.EncodingType.JPEG;
-// if (typeof options.encodingType == "number") {
-// encodingType = this.options.encodingType;
-// }
-//
-// var targetWidth = -1;
-// if (typeof options.targetWidth == "number") {
-// targetWidth = options.targetWidth;
-// } else if (typeof options.targetWidth == "string") {
-// var width = new Number(options.targetWidth);
-// if (isNaN(width) === false) {
-// targetWidth = width.valueOf();
-// }
-// }
-
-// var targetHeight = -1;
-// if (typeof options.targetHeight == "number") {
-// targetHeight = options.targetHeight;
-// } else if (typeof options.targetHeight == "string") {
-// var height = new Number(options.targetHeight);
-// if (isNaN(height) === false) {
-// targetHeight = height.valueOf();
-// }
-// }
-
- Cordova.exec(successCallback, errorCallback, "Camera", "getPicture", this.options);
-};
-
-Cordova.onCordovaInit.subscribeOnce(function() {
- if (typeof navigator.camera === "undefined") {
- navigator.camera = new Camera();
- }
-});
-}
http://git-wip-us.apache.org/repos/asf/incubator-cordova-wp7/blob/49b5d3b4/framework/js/capture.js
----------------------------------------------------------------------
diff --git a/framework/js/capture.js b/framework/js/capture.js
deleted file mode 100644
index 13291f3..0000000
--- a/framework/js/capture.js
+++ /dev/null
@@ -1,235 +0,0 @@
-/*
- Licensed under the Apache License, Version 2.0 (the "License");
- you may not use this file except in compliance with the License.
- You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
- Unless required by applicable law or agreed to in writing, software
- distributed under the License is distributed on an "AS IS" BASIS,
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- See the License for the specific language governing permissions and
- limitations under the License.
-*/
-
-if (!Cordova.hasResource("capture")) {
-Cordova.addResource("capture");
-
-/**
- * Represents a single file.
- *
- * name {DOMString} name of the file, without path information
- * fullPath {DOMString} the full path of the file, including the name
- * type {DOMString} mime type
- * lastModifiedDate {Date} last modified date
- * size {Number} size of the file in bytes
- */
-var MediaFile = function(name, fullPath, type, lastModifiedDate, size){
- this.name = name || null;
- this.fullPath = fullPath || null;
- this.type = type || null;
- this.lastModifiedDate = lastModifiedDate || null;
- this.size = size || 0;
-};
-
-/**
- * Get file meta information
- *
- * @param {Function} successCB
- * @param {Function} errorCB
- */
-MediaFile.prototype.getFormatData = function(successCallback, errorCallback){
- Cordova.exec(successCallback, errorCallback, "Capture", "getFormatData", {fullPath: this.fullPath, type: this.type});
-};
-
-
-/**
- * Open file in device media player
- *
- * @param {Function} successCB
- * @param {Function} errorCB
- */
-MediaFile.prototype.play = function(successCallback, errorCallback){
- Cordova.exec(successCallback, errorCallback, "Capture", "play", this);
-};
-
-
-/**
- * MediaFileData encapsulates format information of a media file.
- *
- * @param {DOMString} codecs
- * @param {long} bitrate
- * @param {long} height
- * @param {long} width
- * @param {float} duration
- */
-var MediaFileData = function(codecs, bitrate, height, width, duration){
- this.codecs = codecs || null;
- this.bitrate = bitrate || 0;
- this.height = height || 0;
- this.width = width || 0;
- this.duration = duration || 0;
-};
-
-/**
- * The CaptureError interface encapsulates all errors in the Capture API.
- */
-var CaptureError = function(){
- this.code = null;
-};
-
-// Capture error codes
-CaptureError.CAPTURE_INTERNAL_ERR = 0;
-CaptureError.CAPTURE_APPLICATION_BUSY = 1;
-CaptureError.CAPTURE_INVALID_ARGUMENT = 2;
-CaptureError.CAPTURE_NO_MEDIA_FILES = 3;
-CaptureError.CAPTURE_NOT_SUPPORTED = 20;
-
-/**
- * The Capture interface exposes an interface to the camera and microphone of the hosting device.
- */
-var Capture = function(){
- this.supportedAudioModes = [];
- this.supportedImageModes = [];
- this.supportedVideoModes = [];
-};
-
-function _capture(type, successCallback, errorCallback, options)
-{
- var win = function (pluginResult)
- {
- var mediaFiles = [];
- var i;
- for (i = 0; i < pluginResult.length; i++) {
- var mediaFile = new MediaFile();
- mediaFile.name = pluginResult[i].name;
- mediaFile.fullPath = pluginResult[i].fullPath;
- mediaFile.type = pluginResult[i].type;
- mediaFile.lastModifiedDate = pluginResult[i].lastModifiedDate;
- mediaFile.size = pluginResult[i].size;
- mediaFiles.push(mediaFile);
- }
- successCallback(mediaFiles);
- };
- Cordova.exec(win, errorCallback, "Capture", type, [options]);
-}
-
-/**
- * Launch audio recorder application for recording audio clip(s).
- *
- * @param {Function} successCB
- * @param {Function} errorCB
- * @param {CaptureAudioOptions} options
- */
-Capture.prototype.captureAudio = function (successCallback, errorCallback, options)
-{
- _capture("captureAudio", successCallback, errorCallback, options);
- //Cordova.exec(successCallback, errorCallback, "Capture", "captureAudio", options);
-};
-
-/**
- * Launch camera application for taking image(s).
- *
- * @param {Function} successCB
- * @param {Function} errorCB
- * @param {CaptureImageOptions} options
- */
-Capture.prototype.captureImage = function (successCallback, errorCallback, options)
-{
- _capture("captureImage", successCallback, errorCallback, options);
- //Cordova.exec(successCallback, errorCallback, "Capture", "captureImage", options);
-};
-
-/**
- * Launch device camera application for recording video(s).
- *
- * @param {Function} successCB
- * @param {Function} errorCB
- * @param {CaptureVideoOptions} options
- */
-Capture.prototype.captureVideo = function (successCallback, errorCallback, options)
-{
- _capture("captureVideo", successCallback, errorCallback, options);
- //Cordova.exec(successCallback, errorCallback, "Capture", "captureVideo", options);
-};
-
-
-
-
-/**
-* This function returns and array of MediaFiles. It is required as we need to convert raw
-* JSON objects into MediaFile objects.
-*/
-//Capture.prototype._castMediaFile = function(pluginResult){
-// var mediaFiles = [];
-// var i;
-// for (i = 0; i < pluginResult.message.length; i++) {
-// var mediaFile = new MediaFile();
-// mediaFile.name = pluginResult.message[i].name;
-// mediaFile.fullPath = pluginResult.message[i].fullPath;
-// mediaFile.type = pluginResult.message[i].type;
-// mediaFile.lastModifiedDate = pluginResult.message[i].lastModifiedDate;
-// mediaFile.size = pluginResult.message[i].size;
-// mediaFiles.push(mediaFile);
-// }
-// pluginResult.message = mediaFiles;
-// return pluginResult;
-//};
-
-/**
- * Encapsulates a set of parameters that the capture device supports.
- */
-var ConfigurationData = function(){
- // The ASCII-encoded string in lower case representing the media type.
- this.type = null;
- // The height attribute represents height of the image or video in pixels.
- // In the case of a sound clip this attribute has value 0.
- this.height = 0;
- // The width attribute represents width of the image or video in pixels.
- // In the case of a sound clip this attribute has value 0
- this.width = 0;
-};
-
-/**
- * Encapsulates all image capture operation configuration options.
- */
-var CaptureImageOptions = function(){
- // Upper limit of images user can take. Value must be equal or greater than 1.
- this.limit = 1;
- // The selected image mode. Must match with one of the elements in supportedImageModes array.
- this.mode = null;
-};
-
-/**
- * Encapsulates all video capture operation configuration options.
- */
-var CaptureVideoOptions = function(){
- // Upper limit of videos user can record. Value must be equal or greater than 1.
- this.limit = 1;
- // Maximum duration of a single video clip in seconds.
- this.duration = 0;
- // The selected video mode. Must match with one of the elements in supportedVideoModes array.
- this.mode = null;
-};
-
-/**
- * Encapsulates all audio capture operation configuration options.
- */
-var CaptureAudioOptions = function(){
- // Upper limit of sound clips user can record. Value must be equal or greater than 1.
- this.limit = 1;
- // Maximum duration of a single sound clip in seconds.
- this.duration = 0;
- // The selected audio mode. Must match with one of the elements in supportedAudioModes array.
- this.mode = null;
-};
-Cordova.onCordovaInit.subscribeOnce(function () {
- if (typeof navigator.device === "undefined") {
- navigator.device = window.device = new Device();
- }
- if (typeof navigator.device.capture === "undefined") {
- console.log("Installing capture");
- navigator.device.capture = window.device.capture = new Capture();
- }
-});
-}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/incubator-cordova-wp7/blob/49b5d3b4/framework/js/compass.js
----------------------------------------------------------------------
diff --git a/framework/js/compass.js b/framework/js/compass.js
deleted file mode 100644
index 9e583d4..0000000
--- a/framework/js/compass.js
+++ /dev/null
@@ -1,177 +0,0 @@
-/*
- Licensed under the Apache License, Version 2.0 (the "License");
- you may not use this file except in compliance with the License.
- You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
- Unless required by applicable law or agreed to in writing, software
- distributed under the License is distributed on an "AS IS" BASIS,
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- See the License for the specific language governing permissions and
- limitations under the License.
-*/
-
-if (!Cordova.hasResource("compass")) {
-Cordova.addResource("compass");
-
-/**
- * This class provides access to device Compass data.
- * @constructor
- */
-var Compass = function() {
- /**
- * The last known Compass position.
- */
- this.lastHeading = null;
- this.isCompassSupported = true; // default assumption
-};
-
-// Capture error codes
-CompassError = {
- COMPASS_INTERNAL_ERR:0,
- COMPASS_NOT_SUPPORTED:20
-}
-
-/**
- * Asynchronously aquires the current heading.
- *
- * @param {Function} successCallback The function to call when the heading data is available
- * @param {Function} errorCallback The function to call when there is an error getting the heading data. (OPTIONAL)
- * @param {PositionOptions} options The options for getting the heading data such as timeout. (OPTIONAL)
- */
-Compass.prototype.getCurrentHeading = function(successCallback, errorCallback, options) {
-
- // successCallback required
- if (typeof successCallback !== "function") {
- console.log("Compass Error: successCallback is not a function");
- return;
- }
-
- // errorCallback optional
- if (errorCallback && (typeof errorCallback !== "function")) {
- console.log("Compass Error: errorCallback is not a function");
- //return;
-
- errorCallback = function(){};
- }
-
- if(this.isCompassSupported)
- {
- var self = this;
- var onSuccess = function(result)
- {
- var compassResult = JSON.parse(result);
- //console.log("compassResult = " + result);
- self.lastHeading = compassResult;
- successCallback(self.lastHeading);
- }
-
- var onError = function(res)
- {
- var err = JSON.parse(res);
- if(err.code == CompassError.COMPASS_NOT_SUPPORTED)
- {
- self.isCompassSupported = false;
- }
- errorCallback(err);
- }
-
- // Get heading
- Cordova.exec(onSuccess, onError, "Compass", "getHeading", []);
- }
- else
- {
- var funk = function()
- {
- errorCallback({code:CompassError.COMPASS_NOT_SUPPORTED});
- };
- window.setTimeout(funk,0); // async
- }
-};
-
-/**
- * Asynchronously aquires the heading repeatedly at a given interval.
- *
- * @param {Function} successCallback The function to call each time the heading data is available
- * @param {Function} errorCallback The function to call when there is an error getting the heading data. (OPTIONAL)
- * @param {HeadingOptions} options The options for getting the heading data such as timeout and the frequency of the watch. (OPTIONAL)
- * @return String The watch id that must be passed to #clearWatch to stop watching.
- */
-Compass.prototype.watchHeading= function(successCallback, errorCallback, options) {
-
- // Default interval (100 msec)
-
- var self = this;
-
- // successCallback required
- if (typeof successCallback !== "function") {
- console.log("Compass Error: successCallback is not a function");
- return -1; // in case caller later calls clearWatch with this id
- }
-
- // errorCallback optional
- if (errorCallback && (typeof errorCallback !== "function")) {
- console.log("Compass Error: errorCallback is not a function");
- return -1; // in case caller later calls clearWatch with this id
- }
-
- if(this.isCompassSupported)
- {
- var onSuccess = function (result) {
- var compassResult = JSON.parse(result);
- self.lastHeading = compassResult;
- successCallback(self.lastHeading);
- }
-
- var onError = function (res) {
- var err = JSON.parse(res);
- if(err.code == CompassError.COMPASS_NOT_SUPPORTED)
- {
- self.isCompassSupported = false;
- }
-
- errorCallback(err);
- }
-
- var id = Cordova.createUUID();
-
- var params = {id:id,frequency:((options && options.frequency) ? options.frequency : 100)};
-
- Cordova.exec(onSuccess, onError, "Compass", "startWatch", params);
-
- return id;
- }
- else
- {
- var funk = function()
- {
- errorCallback({code:CompassError.COMPASS_NOT_SUPPORTED});
- };
- window.setTimeout(funk,0); // async
- return -1;
- }
-
-};
-
-
-/**
- * Clears the specified heading watch.
- *
- * @param {String} id The ID of the watch returned from #watchHeading.
- */
-Compass.prototype.clearWatch = function(id) {
-
- Cordova.exec(null, null, "Compass", "stopWatch", { id: id });
-
-};
-
-Cordova.onCordovaInit.subscribeOnce(
-function()
-{
- if (!navigator.compass)
- {
- navigator.compass = new Compass();
- }
-});
-}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/incubator-cordova-wp7/blob/49b5d3b4/framework/js/contact.js
----------------------------------------------------------------------
diff --git a/framework/js/contact.js b/framework/js/contact.js
deleted file mode 100644
index 5f19c50..0000000
--- a/framework/js/contact.js
+++ /dev/null
@@ -1,317 +0,0 @@
-/*
- Licensed under the Apache License, Version 2.0 (the "License");
- you may not use this file except in compliance with the License.
- You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
- Unless required by applicable law or agreed to in writing, software
- distributed under the License is distributed on an "AS IS" BASIS,
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- See the License for the specific language governing permissions and
- limitations under the License.
-*/
-
-if (!Cordova.hasResource("contact")) {
-Cordova.addResource("contact");
-
-/**
-* Contains information about a single contact.
-* @constructor
-* @param {DOMString} id unique identifier
-* @param {DOMString} displayName
-* @param {ContactName} name
-* @param {DOMString} nickname
-* @param {Array.<ContactField>} phoneNumbers array of phone numbers
-* @param {Array.<ContactField>} emails array of email addresses
-* @param {Array.<ContactAddress>} addresses array of addresses
-* @param {Array.<ContactField>} ims instant messaging user ids
-* @param {Array.<ContactOrganization>} organizations
-* @param {DOMString} birthday contact's birthday
-* @param {DOMString} note user notes about contact
-* @param {Array.<ContactField>} photos
-* @param {Array.<ContactField>} categories
-* @param {Array.<ContactField>} urls contact's web sites
-*/
-var Contact = function (id, displayName, name, nickname, phoneNumbers, emails, addresses,
- ims, organizations, birthday, note, photos, categories, urls) {
- this.id = id || null;
- this.rawId = null;
- this.displayName = displayName || null;
- this.name = name || null; // ContactName
- this.nickname = nickname || null;
- this.phoneNumbers = phoneNumbers || null; // ContactField[]
- this.emails = emails || null; // ContactField[]
- this.addresses = addresses || null; // ContactAddress[]
- this.ims = ims || null; // ContactField[]
- this.organizations = organizations || null; // ContactOrganization[]
- this.birthday = birthday || null;
- this.note = note || null;
- this.photos = photos || null; // ContactField[]
- this.categories = categories || null; // ContactField[]
- this.urls = urls || null; // ContactField[]
-};
-
-/**
- * ContactError.
- * An error code assigned by an implementation when an error has occurreds
- * @constructor
- */
-var ContactError = function(errCode) {
- this.code=errCode;
-};
-
-/**
- * Error codes
- */
-ContactError.UNKNOWN_ERROR = 0;
-ContactError.INVALID_ARGUMENT_ERROR = 1;
-ContactError.TIMEOUT_ERROR = 2;
-ContactError.PENDING_OPERATION_ERROR = 3;
-ContactError.IO_ERROR = 4;
-ContactError.NOT_SUPPORTED_ERROR = 5;
-ContactError.PERMISSION_DENIED_ERROR = 20;
-
-/**
-* Removes contact from device storage.
-* @param successCB success callback
-* @param errorCB error callback
-*/
-Contact.prototype.remove = function(successCB, errorCB)
-{
- if (!this.id)
- {
- var errorObj = new ContactError(ContactError.UNKNOWN_ERROR);
- setTimeout(function(){
- errorCB(errorObj);
- },0);
- return ContactError.UNKNOWN_ERROR;
- }
- else
- {
- Cordova.exec(successCB, errorCB, "Contacts", "remove",this.id);
- }
-};
-
-/**
-* Creates a deep copy of this Contact.
-* With the contact ID set to null.
-* @return copy of this Contact
-*/
-Contact.prototype.clone = function() {
- var clonedContact = Cordova.safeClone(this);
- var i;
- clonedContact.id = null;
- clonedContact.rawId = null;
- // Loop through and clear out any id's in phones, emails, etc.
- var myArrayProps = ["phoneNumbers","emails","addresses","ims","organizations","tags","photos","urls"];
-
- for(var n=0, pLen=myArrayProps.length;n < pLen; n++)
- {
- var arr = clonedContact[myArrayProps[n]];
- if (arr && arr.length)
- {
- for(var i=0,len=arr.length; i<len;i++)
- {
- arr[i].id = null;
- }
- }
- }
- return clonedContact;
-};
-
-/**
-* Persists contact to device storage.
-* @param successCB success callback
-* @param errorCB error callback
-*/
-Contact.prototype.save = function(successCB, errorCB)
-{
- var self = this;
- function onSuccess(res)
- {
- setTimeout(function()
- {
- successCB(self);
- },0);
- }
- Cordova.exec(onSuccess, errorCB, "Contacts", "save", this);
-};
-
-/**
-* Contact name.
-* @constructor
-* @param formatted
-* @param familyName
-* @param givenName
-* @param middle
-* @param prefix
-* @param suffix
-*/
-var ContactName = function(formatted, familyName, givenName, middle, prefix, suffix) {
- this.formatted = formatted || null;
- this.familyName = familyName || null;
- this.givenName = givenName || null;
- this.middleName = middle || null;
- this.honorificPrefix = prefix || null;
- this.honorificSuffix = suffix || null;
-};
-
-/**
-* Generic contact field.
-* @constructor
-* @param {DOMString} id unique identifier, should only be set by native code
-* @param type
-* @param value
-* @param pref
-*/
-var ContactField = function(type, value, pref) {
- this.id = null;
- this.type = type || null;
- this.value = value || null;
- this.pref = pref || null;
-};
-
-/**
-* Contact address.
-* @constructor
-* @param {DOMString} id unique identifier, should only be set by native code
-* @param formatted
-* @param streetAddress
-* @param locality
-* @param region
-* @param postalCode
-* @param country
-*/
-var ContactAddress = function(pref, type, formatted, streetAddress, locality, region, postalCode, country) {
- this.id = null;
- this.pref = pref || null;
- this.type = type || null;
- this.formatted = formatted || null;
- this.streetAddress = streetAddress || null;
- this.locality = locality || null;
- this.region = region || null;
- this.postalCode = postalCode || null;
- this.country = country || null;
-};
-
-/**
-* Contact organization.
-* @constructor
-* @param {DOMString} id unique identifier, should only be set by native code
-* @param name
-* @param dept
-* @param title
-* @param startDate
-* @param endDate
-* @param location
-* @param desc
-*/
-var ContactOrganization = function(pref, type, name, dept, title) {
- this.id = null;
- this.pref = pref || null;
- this.type = type || null;
- this.name = name || null;
- this.department = dept || null;
- this.title = title || null;
-};
-
-/**
-* Represents a group of Contacts.
-* @constructor
-*/
-var Contacts = function() {
- this.inProgress = false;
- this.records = [];
-};
-/**
-* Returns an array of Contacts matching the search criteria.
-* @param fields that should be searched
-* @param successCB success callback
-* @param errorCB error callback
-* @param {ContactFindOptions} options that can be applied to contact searching
-* @return array of Contacts matching search criteria
-*/
-Contacts.prototype.find = function(fields, successCB, errorCB, options) {
- if (successCB === null) {
- throw new TypeError("You must specify a success callback for the find command.");
- }
- if (fields === null || fields === "undefined" || fields.length === "undefined" || fields.length <= 0) {
- if (typeof errorCB === "function")
- {
- // escape this scope before we call the errorCB
- setTimeout(function() {
- errorCB({"code": ContactError.INVALID_ARGUMENT_ERROR});
- },0);
- }
- console.log("Contacts.find::ContactError::INVALID_ARGUMENT_ERROR");
- }
- else
- {
- var onSuccess = function(res)
- {
- setTimeout(function()
- {
- successCB(res);
- },0);
- }
- Cordova.exec(onSuccess, errorCB, "Contacts", "search", {"fields":fields,"options":options});
- }
-};
-
-/**
-* This function creates a new contact, but it does not persist the contact
-* to device storage. To persist the contact to device storage, invoke
-* contact.save().
-* @param properties an object who's properties will be examined to create a new Contact
-* @returns new Contact object
-*/
-Contacts.prototype.create = function(properties) {
- var i;
- var contact = new Contact();
- for (i in properties) {
- if (contact[i] !== 'undefined') {
- contact[i] = properties[i];
- }
- }
- return contact;
-};
-
-/**
-* This function returns and array of contacts. It is required as we need to convert raw
-* JSON objects into concrete Contact objects. Currently this method is called after
-* navigator.contacts.find but before the find methods success call back.
-*
-* @param jsonArray an array of JSON Objects that need to be converted to Contact objects.
-* @returns an array of Contact objects
-*/
-Contacts.prototype.cast = function(pluginResult) {
- var contacts = [];
- var i;
- for (i=0; i<pluginResult.message.length; i++) {
- contacts.push(navigator.contacts.create(pluginResult.message[i]));
- }
- pluginResult.message = contacts;
- return pluginResult;
-};
-
-/**
- * ContactFindOptions.
- * @constructor
- * @param filter used to match contacts against
- * @param multiple boolean used to determine if more than one contact should be returned
- */
-var ContactFindOptions = function(filter, multiple) {
- this.filter = filter || '';
- this.multiple = multiple || false;
-};
-
-/**
- * Add the contact interface into the browser.
- */
-Cordova.onCordovaInit.subscribeOnce(function() {
- if(typeof navigator.contacts === "undefined") {
- navigator.contacts = new Contacts();
- }
-});
-}