Small tweak to JS from yesterday
In prep for tomorrows post, I made a few tweaks to the Javascript I posted yesterday. I’m posting this now since I think the post tomorrow will be long enough, and I’m not ready to write it up yet. This function is handy in a general sense also, so this way it doesn’t get lost in a longer post.
To get the contacts list I needed to make a few changes to the JS functoin convertViewEntryToJSONObject:
function convertViewEntryToJSONObject(data){
var entry = [];
for( var j=0; j<data.viewentry.length; j++ ){
var obj = {};
obj.noteid = data.viewentry[j]["@noteid"];
for(var i=0;i<data.viewentry[j].entrydata.length;i++){
var prop = data.viewentry[j].entrydata[i]["@name"];
var val = "";
if('undefined'=== typeof data.viewentry[j].entrydata[i].text){
val = data.viewentry[j].entrydata[i].textlist.text[0][0];
}
else{
val = data.viewentry[j].entrydata[i].text[0];
}
obj[prop]=val;
}
entry.push( obj );
}
return entry;
}
The version I needed yesterday worked well when I only got one view entry back. Now it works with views that return multiple entries. This should make the view object I get back a lot easier to work with long term.
-
edtoh likes this
-
notesonmobile posted this