function childAction(http_request) {
// wait for document loaded enough to insert data
if (document.getElementById("strChildren") == null) {
setTimeout(childAction,50,http_request);
return;
}
if (http_request.responseText.length==0 || http_request.responseText == "[]")
return; // no children, show default message
//alert(http_request.responseText);
var resp = JSON.parse(http_request.responseText);
document.getElementById("childcount").innerHTML = localize("strChildren") + " (" + resp.length + ") :
";
document.getElementById("children").innerHTML = parseChildren(resp);
}
function siblingAction(http_request) {
// wait for document loaded enough to insert data
if (document.getElementById("siblings") == null) {
setTimeout(siblingAction,50,http_request);
return;
}
if (http_request.responseText.length==0 || http_request.responseText == "[]")
return; // no siblings, show default message
var resp = JSON.parse(http_request.responseText);
document.getElementById("sibcount").innerHTML = localize("strSiblings") + " (" + resp.length + ") :
";
document.getElementById("siblings").innerHTML = parseChildren(resp);
}
function parseChildren(children) {
var chilhttp = '
';
for (var cid in children) {
var pinfo = get_pinfo(children[cid]);
chilhttp += ' ';
chilhttp += 'ID ' + pinfo.id +' | ';
chilhttp += ' ' ;
chilhttp += pinfo.name + " | ";
if (pinfo.birth != '') {
chilhttp += ' ' + localize("strBirth") + ": " + pinfo.birth;
} else if (pinfo.chris != '') {
chilhttp += ' | ' + localize("strChristening") + ": " + pinfo.chris;
}
chilhttp += ' | ';
if (pinfo.death != '') {
chilhttp += ' ' + localize("strDeath") + ": " + pinfo.death + ' | ';
}
chilhttp += '
';
chilhttp += '';
chilhttp += ' ';
chilhttp += ' |
';
queryDB(pinfo.id,'mquery',childMarryAction);
}
chilhttp += '
';
return chilhttp;
}
function childMarryAction(http_request) {
var marriages = JSON.parse(http_request.responseText);
if (marriages.length == 0) return; // no marriages
var sid = 0;
var http = '';
for (var id in marriages) {
var minfo = get_minfo(marriages[id]);
var spouse = '';
sid = minfo.sid;
if (minfo.husb == sid) spouse = minfo.wife;
else if (minfo.wife == sid) spouse = minfo.husb;
http += ' | ';
http += localize("strMarriage") + ": ";
http += "(ID " + minfo.mid +")";
if (minfo.rdate != '') {
http += " | " + minfo.rdate;
} else if (minfo.cdate != '') {
http += " | " + minfo.cdate;
}
http += ' |
| ';
http += ' ' + localize("strSpouse") + " " + " ";
http += "(ID " + spouse+") | ";
if (minfo.sname != '') http += " " + minfo.sname + " | ";
if (minfo.sbirt != '') {
http += "" + localize("strBirth") + ": " + minfo.sbirt;
} else if (minfo.schri != '') {
http += " | " + localize("strChristening") + ": " + minfo.schri;
}
http += ' |
';
}
http += '
';
document.getElementById("chilmarr" + sid).style.display = 'inline';
document.getElementById("chilmarr" + sid).innerHTML = http;
}