Issue with retrieving contact details - iphone

I have tried to get all my iphone Contacts using cordova-plugin-contacts.
It works on iPhone 5S but i cannot retrieve contacts in iPhone6+. This the code i am using
function onErrorContact(contactError) {
alert('onError!');
};
function onSuccessContact(contacts) {
alert('Found ' + contacts.length + ' contacts.');
}
var options = new ContactFindOptions();
options.filter = "";
options.multiple = true;
var filter = ['displayName', 'name'];
navigator.contacts.find(filter, onSuccessContact, onErrorContact, options);
What is wrong?

Related

doGet failed on google addon script file

I am trying to trace email status with using inline image in an email.
For getting response i am using following code.
// handles the get request to the server
function doGet(e) {
Logger.log(e.parameter);
var method = e.parameter['method'];
switch (method) {
case 'track':
var email = e.parameter['email'];
updateEmailStatus(email);
default:
break;
}
}
function updateEmailStatus(emailToTrack) {
// get the active spreadsheet and data in it
var id = SpreadsheetApp.getActiveSpreadsheet().getId();
var sheet = SpreadsheetApp.openById(id).getActiveSheet();
var data = sheet.getDataRange().getValues();
// get headers
var headers = data[0];
var emailOpened = headers.indexOf('status') + 1;
// declare the variable for the correct row number
var currentRow = 2;
// iterate through the data, starting at index 1
for (var i = 1; i < data.length; i++) {
var row = data[i];
var email = row[0];
if (emailToTrack === email) {
// update the value in sheet
sheet.getRange(currentRow, emailOpened).setValue('opened');
break;
}
currentRow++;
}
}
Here is the sheet
it works in a stand alone file but not working in a addon script project. Is there any way to trace out the send email using apps script ?
Any help on this issue will be highly appreciated. Thank you
I have solved the issue. I have change the code little bit and create a new draft as more than one inline image was added to the existing draft.
The change is here
var ss = SpreadsheetApp.getActiveSpreadsheet();
var sheet = ss.getSheetByName('Email_Status');
After this few changes i deployed as new webapp and it started working. Thank you for contribution
Try this:
//var id = SpreadsheetApp.getActiveSpreadsheet().getId(); remove this
var sheet = SpreadsheetApp.openById(id);//change this by hardcoding the id

Google maps downloadUrl does not return 200

My code is based on the example of google code:
https://developers.google.com/maps/articles/phpsqlinfo_v3
and was working fine.
I need to change a former 'gid' (Integer) field to 'id' (String) to get saved to the database and used to display a new labeled symbol on the map.
The strange thing is, that the url, that is build in the code to call the addrow.php file is OK. When I capture this string with alert(url), and I manually use this string, the new data is added to the database.
In my script, the call seems to fail (responseCode == 200 && data.length <=1), since no data is written to the database and the alert from the 'else-clause' is displayed as short pop-up.
Here's the code I use in my project (to save data from a form):
//save new marker to Postgis-database and add new markerwithlabel on the fly
function saveData(){
var gender = escape(document.getElementById("gender").value);
var hoehe = InZahl(document.getElementById("hoehe").value);
var breite = InZahl(document.getElementById("breite").value);
var id = escape(document.getElementById("id").value);
var vital = document.getElementById("vital").value;
var typ = document.getElementById("typ").value;
var ein_mehr = document.getElementById("ein_mehr").value;
var st_durchm = document.getElementById("st_durchm").value;
var frucht = document.getElementById("frucht").value;
var anmerk = document.getElementById("anmerk").value;
var latlng = marker.getPosition();
var url = "./mapdata/addrow.php?gender=" + gender +
"&hoehe=" + hoehe + "&lat=" + latlng.lat() + "&lng=" + latlng.lng() +
"&breite=" + breite + "&id=" + id + "&typ=" + typ + "&ein_mehr=" +ein_mehr + "&st_durchm=" + st_durchm +
"&frucht=" + frucht +
"&vital=" + vital + "&anmerk=" + anmerk;
downloadUrl(url, function (data, responseCode) {
if (responseCode == 200 && data.length <=1) {
infowindow.close();
marker.setDraggable(false);
marker.setIcon('./images/mm_purple.png');
marker.labelContent = id;
marker.setMap(map);
downloadUrl("./mapdata/getxml_get_last.php", function (data1) {
var xml = parseXml(data1);
var ms = xml.documentElement.getElementsByTagName("m");
var gid = ms[0].getAttribute("gid");
var html_n = "<div id='InfoWindow'><p style='font-weight:bold;'>" + id + "</p> \n\<p>Höhe:" + hoehe + " Breite: "+ breite +
"<br />\n\Typ: "+typ+" Stämme: "+ein_mehr+" St-Durchm: "+ st_durchm + "<br />\n\Vitalität: "+vital+" Fruchtbehang: "+frucht+
"<p/>\n\<p style='text-align:right;'><a href='sm_juniperus.php?operation=ssearch&ResetFilter=0&SearchField=gid&FilterType=%3D&FilterText="+ gid +
"' target='_blank'> Daten editieren </a></p></div>";
infowindow.setContent(html_n);
bindInfoWindow(marker, map, infowindow, html_n);
(function(i, marker, gid) {
var origIcon = marker.getIcon();
new LongPress(marker, 1000);
google.maps.event.addListener(marker, 'longpress', function(e) {
marker.setDraggable(true);
marker.setIcon(mmcross);
});
google.maps.event.addListener(marker, 'dragend', function(){
updatePosition(marker, gid);
marker.setIcon(origIcon);
});
})(i,marker,gid);
//add new marker to markerCluster-Array and to markerArray
markerCluster.addMarker(marker,false);
markerArray.push(marker);
i++;
}); // End add new marker
}
else {
alert("Your data couldn't be saved!");
}
}); // End downloadUrl
}; // END saveData()
As I said, my code worked fine, but after 3 evenings passed to solve this, I thought it would be time to ask for help.
If anybody has an idea, where the mistake lies, I would apreciate any hint.
Just to confirm, you're aware that you by doing
if (responseCode == 200 && data.length <=1) {
you are saying 'if the request is successful and the data it returns is only one character or below in length'? I am unsure if this is intended or not, because this way the code inside the if statement is only ran if the response is successful but contains only 1 or 0 characters.

global mongodb cursor in Meteor App

I'm trying to build an app with Meteor and I'm new to the framework.
What I want to do is have the Mongocursor that get returned in the tablets functions with the search parameter to be used in colors functions. Currently in colors I'm just getting the reactive variable again and running the Tablets.find(). But I'm going to have many other functions like this so I want to use the same Mongo cursor. Is it possible to create a global Mongo cursor from the tablets functions that will also be reactive.
The code below is my setup:
Template.tabletsList.helpers({
tablets: function() {
// read the user's last search (if any)
var query = Template.instance().query.get();
// sort options
var options = {sort: {manufacturer: 1}};
if ($.isEmptyObject(query)) {
// if the user didn't input a search just find all tablets
var tabletCursor = Tablets.find({}, options);
return tabletCursor;
}
else {
// find all tablets matching the search expression
return Tablets.find(query, options);
}
},
colors: function() {
var query = Template.instance().query.get();
if ($.isEmptyObject(query))
var allTablets = Tablets.find().fetch();
else
var allTablets = Tablets.find(query).fetch();
var color = '';
var colors = [];
allTablets.forEach(function (tablet) {
for (var i=0; i<tablet.specs.color.length; i++) {
color = tablet.specs.color[i];
if ($.inArray(color, colors) === -1) {
colors.push(color);
}
}
});
return colors.sort();
}
You can create a global helper:
Template.registerHelper('tablets',function(query){
var options = {sort: {manufacturer: 1}};
if ($.isEmptyObject(query)) query = {};
return = Tablets.find(query, options);
});
Then from anywhere in your code you can access this with:
var tabletCursor = UI._globalHelpers.tablets(query);
If you don't have access to query everwhere you can add it to Session or create a new reactive variable to hold it.

Get Child name (relation) out of Contacts App

I'm extracting contacts with ContactsApp and can get email and namnes, but can not find out how to get "Child"-namne out of the contacts.
I tried with "CustomField". I can create a custom field and read it, but there is no "Child"-field.
How do I get "Child"-namne out of the contacts?
Test code for Google Apps script
function doGet(e) {
var GroupObject = ContactsApp.getContactGroup('TestGrupp');
var ContactsTestGrupp = GroupObject.getContacts();
var nrContacts = ContactsTestGrupp.length;
var objectContact;
var emailString;
var GivenNameString;
var FamilyNameString;
for(var i = 0; i < nrContacts; i++) {
objectContact = ContactsTestGrupp[i].getEmails();
emailString = objectContact[0].getAddress();
Logger.log(emailString);
GivenNameString = ContactsTestGrupp[i].getGivenName();
FamilyNameString = ContactsTestGrupp[i].getFamilyName();
Logger.log(GivenNameString + ' ' + FamilyNameString);
}
}
I don't think Google Contacts has a field for child name, at least not that I can find.

YUI 3 Autocomplete Textbox Value Change

The question I have is how I would be able to change the value that is set in the text box that the autocomplete is linked to. The task I am attempting to do is to convert from YUI 2 to YUI 3. Please don't say that I shouldn't do that... because It isn't my choice. I am aware... The code below is what was used before. I already have the autocomplete functionality doing most of what it needs to do. It's just when it gets to the field.itemSelectEvent.subscribe(myHandler) part that I can no longer get anything else to work. The list comes up with the persons information but when selected it just puts [object Object] in the text box instead of their name that automatically forwards to another page. Thank you for your help!!!
var field = new YAHOO.widget.AutoComplete("webUserSearch",
"webUserSearchContainer", oDS);
field.highlightClassName = "autoCompleteHighlight";
field.useShadow = true;
field.queryMatchContains = true;
field.maxResultsDisplayed = 20;
field.resultTypeList = false;
field.formatResult = function(oResultData, sQuery) {
return "<div class=\"result\"><u style=\"cursor:pointer\">"
+ oResultData['Last Name'] + ", " + oResultData['First Name']
+ "</u> (" + oResultData['User Name'] + ")</div>";
};
var myHandler = function(sType, aArgs) {
var theField = aArgs[0];
var selectedElement = aArgs[1];
var repObject = aArgs[2];
theField.getInputEl().value = repObject['Last Name'] + ", "
+ repObject['First Name'];
var newTabURL = <URL Removed for Stack Overflow>;
window.location.href = newTabURL;
};
field.itemSelectEvent.subscribe(myHandler);
Listen for the select event, then in the handler for that you'll get a result object. The structure of that is described in the docs for the result event (a little up from the select event).
I usually take a value out of the raw property on the result object to stick into the field.
resultTextLocator was the ticket. All I had to do was to return the value I wanted to display in the box.
resultTextLocator : function (result) {
return result["Last Name"] +
', ' +
result["First Name"];
}