my running this code, which can not add several key figures in
AppFieldTarefa and then retrieves them and show ...
code:
<?xml version="1.0" encoding="UTF-8" ?>
<Module>
<ModulePrefs title="Tarefas 2 My Teste" >
<Require feature="opensocial-0.7"/>
</ModulePrefs>
<Content type="html">
<![CDATA[
<script type="text/javascript">
gadgets.util.registerOnLoadHandler(requestMyTarefa);
var htmlout = "";
var me = null;
function AddMyTarefa() {
var req = opensocial.newDataRequest();
var json =
gadgets.json.stringify(document.getElementById('input_tarefa').value) ;
req.add(req.newUpdatePersonAppDataRequest("VIEWER",
"AppFieldTarefa", json));
req.send(requestMyTarefa);
}
function requestMyTarefa() {
var req = opensocial.newDataRequest();
var fields = [ "AppFieldTarefa" ];
req.add(req.newFetchPersonRequest(opensocial.DataRequest.PersonId.VIEWER),
"viewer");
req.add(req.newFetchPersonAppDataRequest("VIEWER", fields),
"viewer_data");
req.send(handleRequestMyTarefa);
}
function handleRequestMyTarefa(data) {
var mydata = data.get("viewer_data");
var viewer = data.get("viewer");
me = viewer.getData();
if (mydata.hadError()) {
htmlout += data.getError();
return;
}
// Do something with the returned data - note the getData call
doSomethingWithMyTarefa(mydata.getData());
}
function doSomethingWithMyTarefa(data) {
//Data is indexed by user id, and represents an object where
keys
//correspond with the app data fields.
var mydata = data[me.getId()]["AppFieldTarefa"];
var unescapedmyData = gadgets.util.unescapeString(mydata);
var myObject = gadgets.json.parse(unescapedmyData);
var div = document.getElementById('content_div');
//htmlout += "Minha Tarefa eh: " + mydata["AppFieldTarefa"] +
"<br />";
div.innerHTML = myObject;
}
</script>
<h1>Tarefas do Dia</h1>
<br>
<hr>
Tarefa:<input id="input_tarefa" type="text" />
<a href='javascript:void(0);' onclick='AddMyTarefa();'>Ok!</a>
</form>
<hr>
<div id="content_div"></div>
]]>
</Content>
</Module>
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"Orkut Developer Forum" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at
http://groups.google.com/group/opensocial-orkut?hl=en
-~----------~----~----~----~------~----~------~--~---