org.symbian.tools.wrttools/libraries/phonegap.js
changeset 442 980aaebb8022
parent 340 740921999de7
equal deleted inserted replaced
441:85f06000ab13 442:980aaebb8022
  1045 };
  1045 };
  1046 
  1046 
  1047 Contacts.prototype.success_callback = function(contacts_iterator) {
  1047 Contacts.prototype.success_callback = function(contacts_iterator) {
  1048 	try {
  1048 	try {
  1049 	var gapContacts = new Array();
  1049 	var gapContacts = new Array();
  1050 	contacts_iterator.reset();
  1050 	if (contacts_iterator) {
  1051     var contact;
  1051 		contacts_iterator.reset();
  1052 	var i = 0;
  1052 		var contact;
  1053 	var end = this.options.page * this.options.limit;
  1053 		var i = 0;
  1054 	var start = end - this.options.limit;
  1054 		var end = this.options.page * this.options.limit;
  1055 	while ((contact = contacts_iterator.getNext()) != undefined && i < end) {
  1055 		var start = end - this.options.limit;
  1056 		try {
  1056 		while ((contact = contacts_iterator.getNext()) != undefined && i < end) {
  1057 			if (i >= start) {
  1057 			try {
  1058 				var gapContact = new Contact();
  1058 				if (i >= start) {
  1059 				gapContact.name.givenName = Contacts.GetValue(contact, "FirstName");
  1059 					var gapContact = new Contact();
  1060 				gapContact.name.familyName = Contacts.GetValue(contact, "LastName");
  1060 					gapContact.name.givenName = Contacts.GetValue(contact, "FirstName");
  1061 				gapContact.name.formatted = gapContact.name.givenName + " " + gapContact.name.familyName;
  1061 					gapContact.name.familyName = Contacts.GetValue(contact, "LastName");
  1062 				gapContact.emails = Contacts.getEmailsList(contact);
  1062 					gapContact.name.formatted = gapContact.name.givenName + " " + gapContact.name.familyName;
  1063 				gapContact.phones = Contacts.getPhonesList(contact);
  1063 					gapContact.emails = Contacts.getEmailsList(contact);
  1064 				gapContact.address = Contacts.getAddress(contact);
  1064 					gapContact.phones = Contacts.getPhonesList(contact);
  1065 				gapContact.id = Contacts.GetValue(contact, "id");
  1065 					gapContact.address = Contacts.getAddress(contact);
  1066 				gapContacts.push(gapContact);
  1066 					gapContact.id = Contacts.GetValue(contact, "id");
       
  1067 					gapContacts.push(gapContact);
       
  1068 				}
       
  1069 				i++;
       
  1070 			} catch (e) {
       
  1071 				alert("ContactsError (" + e.name + ": " + e.message + ")");
  1067 			}
  1072 			}
  1068 			i++;
       
  1069 		} catch (e) {
       
  1070 			alert("ContactsError (" + e.name + ": " + e.message + ")");
       
  1071 		}
  1073 		}
  1072 	}
  1074 	}
  1073 	this.contacts = gapContacts;
  1075 	this.contacts = gapContacts;
  1074 	this.global_success(gapContacts);
  1076 	this.global_success(gapContacts);
  1075 	} catch (ex) { alert(ex.name + ": " + ex.message); }
  1077 	} catch (ex) { alert(ex.name + ": " + ex.message); }
  1142 /**
  1144 /**
  1143  * Print a warning message to the console
  1145  * Print a warning message to the console
  1144  * @param {Object|String} message Message or object to print to the console
  1146  * @param {Object|String} message Message or object to print to the console
  1145  */
  1147  */
  1146 DebugConsole.prototype.warn = function(message) {
  1148 DebugConsole.prototype.warn = function(message) {
       
  1149 	console.log(message);
  1147 };
  1150 };
  1148 
  1151 
  1149 /**
  1152 /**
  1150  * Print an error message to the console
  1153  * Print an error message to the console
  1151  * @param {Object|String} message Message or object to print to the console
  1154  * @param {Object|String} message Message or object to print to the console
  1152  */
  1155  */
  1153 DebugConsole.prototype.error = function(message) {
  1156 DebugConsole.prototype.error = function(message) {
       
  1157 	console.log(message);
  1154 };
  1158 };
  1155 
  1159 
  1156 if (typeof window.debug == "undefined") window.debug = new DebugConsole();
  1160 if (typeof window.debug == "undefined") window.debug = new DebugConsole();
  1157 PhoneGap.ExtendWrtDeviceObj = function(){
  1161 PhoneGap.ExtendWrtDeviceObj = function(){
  1158 	
  1162 	
  1361 	return { name: "MapError", message: err };
  1365 	return { name: "MapError", message: err };
  1362 
  1366 
  1363 };
  1367 };
  1364 
  1368 
  1365 if (typeof navigator.map == "undefined") navigator.map = new Map();
  1369 if (typeof navigator.map == "undefined") navigator.map = new Map();
  1366 
  1370 function Network() {
       
  1371     /**
       
  1372      * The last known Network status.
       
  1373      */
       
  1374 	this.lastReachability = null;
       
  1375 };
       
  1376 
       
  1377 Network.prototype.isReachable = function(hostName, successCallback, options) {
       
  1378 	var req = new XMLHttpRequest();  
       
  1379    	req.open('GET', hostName, true);  
       
  1380    	req.onreadystatechange = function (aEvt) {  
       
  1381      	if (req.readyState == 4) {  
       
  1382         	if(req.status == 200)  
       
  1383         		successCallback(NetworkStatus.REACHABLE_VIA_CARRIER_DATA_NETWORK);
       
  1384          	else  
       
  1385           		successCallback(NetworkStatus.NOT_REACHABLE);
       
  1386  		}  
       
  1387   	};  
       
  1388   	req.send(null);
       
  1389 
       
  1390 };
       
  1391 
       
  1392 /**
       
  1393  * This class contains information about any NetworkStatus.
       
  1394  * @constructor
       
  1395  */
       
  1396 function NetworkStatus() {
       
  1397 	this.code = null;
       
  1398 	this.message = "";
       
  1399 }
       
  1400 
       
  1401 NetworkStatus.NOT_REACHABLE = 0;
       
  1402 NetworkStatus.REACHABLE_VIA_CARRIER_DATA_NETWORK = 1;
       
  1403 NetworkStatus.REACHABLE_VIA_WIFI_NETWORK = 2;
       
  1404 
       
  1405 if (typeof navigator.network == "undefined") navigator.network = new Network();
  1367 /**
  1406 /**
  1368  * This class provides access to notifications on the device.
  1407  * This class provides access to notifications on the device.
  1369  */
  1408  */
  1370 function Notification() {
  1409 function Notification() {
  1371 	
  1410