function update_token() { // var xmlHttp = new XMLHttpRequest(); // xmlHttp.open( "GET", "update.php", false ); // false for synchronous request // xmlHttp.send( null ); // alert('test ' + xmlHttp.responseText); return true; } // handles drawing an error message function drawError() { } // handles the response, adds the html function drawOutput(responseText) { } // helper function for cross-browser request object function getRequest(url, success, error) { var req = false; try{ // most browsers req = new XMLHttpRequest(); } catch (e){ // IE try{ req = new ActiveXObject("Msxml2.XMLHTTP"); } catch(e) { // try an older version try{ req = new ActiveXObject("Microsoft.XMLHTTP"); } catch(e) { return false; } } } if (!req) return false; if (typeof success != 'function') success = function () {}; if (typeof error!= 'function') error = function () {}; req.onreadystatechange = function(){ if(req.readyState == 4) { return req.status === 200 ? success(req.responseText) : error(req.status); } } req.open("GET", url, true); req.send(null); return req; } function init() { tabbify(); nameinit(getParameter('name')); sexinit(getParameter('sex')); var id = getParameter('id'); var cid = getParameter('cid'); var sex = getParameter('sex'); var fid = getParameter('fid'); var mid = getParameter('mid'); var hid = getParameter('hid'); var wid = getParameter('wid'); var mar = getParameter('mar'); var state = getParameter('state'); //alert("test "+hid+" "+wid); // document.getElementById('parentButtons').style.display= 'none'; // document.getElementById('mreturnButtons').style.display= 'none'; // document.getElementById('spouseButtons').style.display = 'none'; // document.getElementById('searchLink').style.display = 'none'; document.bgColor='#FFFFFF'; if (cid != '') { document.getElementById('parentButtons').style.display = 'inline'; document.getElementsByName('clear')[0].onclick = function () {window.location.assign('index.php?cid='+cid+'&sex='+sex)}; if (sex == "M") document.bgColor='#E0F0FF'; else document.bgColor='#FFE8F4'; } else if ( state == 'mc') { // called from marriage add child document.getElementById('childButtons').style.display = 'inline'; // (potentially do-nothing) update that chains a redirect to marriage page // does not go through until a previously inserted individual is selected // or a new individual has been inserted (to avoid a phantom child) document.getElementsByName('addChild')[0].onclick = function() { if(document.getElementsByName('ID')[0]) changeDB('update','Update',updateAction); } document.getElementsByName('exitChild')[0].onclick= function() {window.location.assign('mindex.php?tab=chil&id='+mar)}; document.bgColor='#E8FFE8'; // green updateParents(''); queryDB(0,'sibling',siblingAction); } else if (state == 'pc') { // called from person add child document.getElementById('childButtons').style.display = 'inline'; document.getElementsByName('addChild')[0].onclick = function() { if(document.getElementsByName('ID')[0]) changeDB('update','Update',updateAction); } document.getElementsByName('exitChild')[0].onclick = function () {window.location.assign('index.php?id='+tid)}; document.bgColor='#E8FFE8'; // green document.getElementById('searchLink').style.display = 'none'; updateParents(''); } else if (state == 'pcs') { // called from person add child add spouse document.getElementById('spouseButtons').style.display = 'inline'; if (hid != '') { document.getElementsByName('exitSpouse')[0].onclick = function () {window.location.assign('index.php?state=pc&fid='+hid)}; } else { document.getElementsByName('exitSpouse')[0].onclick = function () {window.location.assign('index.php?state=pc&mid='+wid)}; } if (sex == "M") document.bgColor='#E0F0FF'; else document.bgColor='#FFE8F4'; } else if (state == 'ms') { //called from marriage add spouse document.getElementById('spouseButtons').style.display = 'inline'; document.getElementById('childLink').style.display = 'none'; var urlstring = 'index.php?sex='+sex; if (sex == "M") urlstring += '&hid='+hid; if (sex == "F") urlstring += '&wid='+wid; document.getElementsByName('clear')[0].onclick = function () {window.location.assign(urlstring)}; if (sex == "M") document.bgColor='#E0F0FF'; else document.bgColor='#FFE8F4'; } else { document.getElementById('searchLink').style.display = 'none'; } if (id != '') { // populate field if called with ID queryDB(id,'read',queryAction); if (state == 'mcu' || state == 'pcu') return; queryDB(id,'child',childAction); queryDB(id,'mquery', marrAction); queryDB(id,'sibling', siblingAction); } // also sort of a ### HACK ### var wideness = document.getElementsByName('AGE')[0].style.width; for(var i=0; i 0) var ret = confirm(localize("strAddMarriage")); if (ret == true) marryDB(fath,moth,name); } // update father and mother fields if (fath != '' && fath != null && fath != 0) { queryDB(fath,'read',parentAction); } else { // document.getElementById("fatherdata").innerHTML = ' 
 '; v/*ar http = '';*/ //http += localize("strQuery") + '/' + localize("strInsert") + ''; // document.getElementById("fatherlink").style.display = 'inline-block'; document.getElementById("fatherlink").innerHTML = ""; } if (moth != '' && moth != null && moth != 0) { queryDB(moth,'read',parentAction); } else { // document.getElementById("motherdata").innerHTML = ' 
 '; // var http = ''; //http += localize("strQuery") + '/' + localize("strInsert") + ''; // document.getElementById("motherlink").style.display = 'inline-block'; document.getElementById("motherlink").innerHTML = ""; } // alert(fath + " " + moth); if (fath == 0 || moth == 0) { if (fath != 0) queryDB(fath,'mquery', spouseAction); if (moth != 0) queryDB(moth,'mquery', spouseAction); } else { queryDB(id,'pmquery', pmarrAction); } } function updateMarriage(id) { field = document.getElementsByName("SEX"); var addMhttp = ' ' + localize("strAddMarriage") + ''; document.getElementById("mlink").innerHTML = ""; } function updateSpouse(key) { var id = document.getElementsByName('ID')[0].value; var sel = document.getElementsByName(key)[0]; var opts = sel.options; var opts_sel = sel.selectedIndex; var state = getParameter('state'); //alert("test " + state ); if (key == "fathSelectbox") { field = "FATH"; if (state == 'pc') { urlstring = 'index.php?state=pcs&sex=M&wid='+getParameter('mid'); } else { urlstring = 'index.php?&sex=M&cid='+id; } } if (key == "mothSelectbox") { field = "MOTH"; if (state == 'pc') { urlstring = 'index.php?state=pcs&sex=F&hid='+getParameter('fid'); } else { urlstring = 'index.php?&sex=F&cid='+id; } } //alert("test1 " + urlstring ); if (sel.value > 0) { idfield = document.getElementsByName(field)[0]; idfield.value = sel.value; modify(field); } else if (sel.value == 0) { window.location.assign(urlstring) } } function queryAction(http_request) { if (document.getElementById("done") == null) { setTimeout(queryAction,40,http_request); return; } var result = http_request.responseText; //document.getElementById('zone').innerHTML = result; // No results from search var rind = result.indexOf('Nichts.') + result.indexOf('Nothing.') + result.indexOf('false'); if (rind > -3) { document.getElementById('zone').innerHTML = localize("strNothing"); return; } // if (result.indexOf('Nichts') > 0) { // document.getElementById('zone').innerHTML = localize("strNothing"); // return; // } // More than 1 result from search if (result.indexOf('Results') >0 ) { var begin = result.indexOf('Results'); var back = '

'; document.getElementById('zone').innerHTML = back + result.substring(begin); document.getElementById('person').style.visibility = 'hidden'; document.getElementById('parentButtons').style.display= 'none'; return; } // exactly one person (data in JSON format); update data in forms var person = JSON.parse(result); for (var key in person) { var val = person[key]; if (!val) val = ''; elements = document.getElementsByName(key); // lengthen NOTES field to fit all lines plus an extra if (key == "NOTE" && val != null) { var lines = val.split('\n').length; elements[0].rows = lines+1; } if (elements[0] != null && val !=" NULL") { elements[0].value = val; elements[0].style.color = 'black'; } } var pinfo = get_pinfo(person); // set reference fields for birth/christening/death/burial var fields = { 'b': { 'bd': pinfo.birth, 'bp': pinfo.birtloc, 'br': pinfo.birtrel }, 'c': { 'cd': pinfo.chris, 'cp': pinfo.chrloc, 'cr': pinfo.chrrel }, 'd': { 'dd': pinfo.death, 'dp':pinfo.deatloc, 'dr': pinfo.deatrel }, 'u': { 'ud': pinfo.burial, 'up':pinfo.buriloc, 'ur': pinfo.burirel } }; for (var prefix in fields) { var pairs = fields[prefix]; var date = pairs[prefix + 'd']; if (date != '' && date != null) { for (var field in pairs) { document.getElementById(field).innerHTML = pairs[field]; } } else { for (var field in pairs) { document.getElementById(field).innerHTML = ""; } } } // // called from marriage insert child with update request // if ( getParameter('state') == "mcu" || getParameter('state') == "pcu" ) { // if (getParameter('fid')) { // document.getElementsByName("FATH")[0].value = getParameter('fid'); // } // if (getParameter('mid')) { // document.getElementsByName("MOTH")[0].value = getParameter('mid'); // } // // changeDB('update','Update',updateAction); // } // // if ( getParameter('state') == "mcu") return; updateParents(' '); updateMarriage(pinfo.id); clearHighlight(); if (!getParameter('id')) { //not called from page load action queryDB(pinfo.id,'child',childAction); queryDB(pinfo.id,'mquery', marrAction); queryDB(pinfo.id,'sibling',siblingAction); } // make insert Child link visible (Lothar Schmitt request); // but don't confuse things when we're already inserting a // child (from the marriage page)!! if (!getParameter('cid') && getParameter('state') != 'mc') { //get last name var name = pinfo.name.split(' '); name = name[name.length-1].replace(/\//g,'').toUpperCase(); var http = "           "; http += 'Kind einfügen'; } else { http = ''; } // document.getElementById('childLink').innerHTML = http; // document.getElementById('zone').innerHTML = "Done ..."; } function insertAction(http_request) { var result = http_request.responseText; // document.getElementById("zone").innerHTML = result; var begin = result.indexOf('ID-Nummer')+2; var end = result.indexOf('
',begin)-1; var splitresult = result.substring(begin,end).split(' '); var id = splitresult[splitresult.length-1]; document.getElementsByName('ID')[0].value = id; document.getElementsByName('REV')[0].value = 0; document.getElementById("zone").innerHTML = localize('strInserted'); clearHighlight(); // add marriage and update parent data if necessary updateParents(result); // update add Marriage Link updateMarriage(id); } function updateAction(http_request) { var fid = getParameter('fid'); var mid = getParameter('mid'); var id = document.getElementsByName('ID')[0].value; var result = http_request.responseText; //document.getElementById("zone").innerHTML = result; // if not successful return if (result.indexOf('nicht') > 0) { document.getElementById("zone").innerHTML = result; return; } // called from marriage insert child with update request: redirect if (getParameter('mar') && getParameter('state') == "mc" ) { window.location.assign('mindex.php?tab=chil&id='+getParameter('mar')); return; } // called from marriage insert child with update request if (getParameter('state') == "pc" ) { if (getParameter('fid')) { window.location.assign('index.php?tab=chil&id='+getParameter('fid')); } if (getParameter('mid')) { window.location.assign('index.php?tab=chil&id='+getParameter('mid')); } return; } var begin = result.indexOf('ID'); var end = result.indexOf('Marr',begin); document.getElementById("zone").innerHTML = "Done " + result.substring(begin,end); // add marriage and update parent data if necessary updateParents(result); // update add Marriage Link updateMarriage(id); clearHighlight(); // update revision var rev = parseInt(document.getElementsByName('REV')[0].value) + 1; document.getElementsByName('REV')[0].value = rev.toString(); // change length of NOTES box to correct length var elements = document.getElementsByName('NOTE'); var lines = elements[0].value.split('\n').length; elements[0].rows = lines+1; // Update display fields on tabs to correct values var tabs = { 'b': 'BIRT', 'c': 'CHR', 'd': 'DEAT', 'u': 'BURI' }; var fields = { 'd': 'DATE', 'p': 'PLAC', 'r': 'RELI' }; for (var tab in tabs) { var date = document.getElementsByName(tabs[tab]+"_DATE")[0].value; if (date != null && date != '') { for (var field in fields) { document.getElementById(tab+field).innerHTML = document.getElementsByName(tabs[tab] + "_" + fields[field])[0].value; } } else { for (var field in fields) { document.getElementById(tab+field).innerHTML = ""; } } } } function deleteAction(http_request) { result = http_request.responseText; document.getElementById('zone').innerHTML = result; begin = result.indexOf('ID #')+4; end = result.indexOf(' ' + localize("strOpen") + ''; var parhttp = pinfo.name; if (pinfo.birth != '') parhttp += ' ' + localize("strBirth") + ': ' + pinfo.birth; else if (pinfo.chris != '') parhttp += ' ' + localize("strChristening") + ': ' + pinfo.chris; if (pinfo.death != '') parhttp += ' ' + localize("strDeath") + ': ' + pinfo.death; if (pinfo.sex == "M") { document.getElementById("fatherlink").innerHTML = linkhttp; document.getElementById("fatherdata").innerHTML = parhttp; } if (pinfo.sex == "F") { document.getElementById("motherlink").innerHTML = linkhttp; document.getElementById("motherdata").innerHTML = parhttp; } } // function childAction(http_request) { in chiltab.js // function childMarryAction(http_request) { in chiltab.js // function siblingAction(http_request) { in chiltab.js function marrAction(http_request) { // wait for document loaded enough to insert data if (document.getElementById("marriages") == null) { setTimeout(marrAction,50,http_request); return; } // alert("test" + http_request.responseText); var marriages = JSON.parse(http_request.responseText); if (marriages.length > 0) { document.getElementById("marrcount").innerHTML = localize("strMarriages") + " (" + marriages.length + ") :
"; } var marrhttp = ''; for (var id in marriages) { var minfo = get_minfo(marriages[id]); if (minfo.husb != minfo.sid && minfo.wife != minfo.sid) { return }; var spouse = ''; if (minfo.husb == minfo.sid) spouse = minfo.wife; else if (minfo.wife == minfo.sid) spouse = minfo.husb; marrhttp += '"; // date first if (minfo.rdate != '') marrhttp += ""; if (minfo.cdate != '') marrhttp += ""; // spouse information marrhttp += ""; if (minfo.sname != '') marrhttp += ""; if (minfo.sbirt != '') { marrhttp += "'; } marrhttp += ''; } marrhttp += '
'; marrhttp += "ID " + minfo.mid +"" + minfo.rdate + "" + minfo.cdate + "" + localize("strSpouse") + " " + " "; marrhttp += "(ID " + spouse+")" + minfo.sname + "" + localize("strBirth")+ ": " + minfo.sbirt; } else if (minfo.schri != '') { marrhttp += "" + localize("strChristening")+ ": " + minfo.schri; } if (minfo.sdeat != '') { marrhttp += '  ' + localize("strDeath") + ": " + minfo.sdeat + '
'; document.getElementById("marriages").innerHTML = marrhttp; } function pmarrAction(http_request) { // wait for document loaded enough to insert data if (document.getElementById("pmarrid") == null) { setTimeout(pmarrAction,50,http_request); return; } //document.getElementById("zone").innerHTML = http_request.responseText; if (http_request.responseText.length == 0) return; var minfo = get_minfo(JSON.parse(http_request.responseText)); var marrid = ''; var marrdate = ''; if (minfo.mid != 0) { marrid = "(ID " + minfo.mid +") "; if (minfo.cdate != "") { marrdate = localize("strMarriageDate") + ": " + minfo.cdate; } else if (minfo.rdate != "") { marrdate = localize("strMarriageDate") + ": " + minfo.rdate; } } document.getElementById("pmarrid").innerHTML = marrid; document.getElementById("pmarrdate").innerHTML = marrdate; } function spouseAction(http_request) { // wait for document loaded enough to insert data if (document.getElementById("marriage") == null) { setTimeout(marrAction,50,http_request); return; } var snames = new Array(); var sids = new Array(); var i=0; marriages = JSON.parse(http_request.responseText); for (var id in marriages) { marriage = marriages[id]; var minfo = get_minfo(marriages[id]); if (minfo.sid == husb) sids[i] = minfo.wife; if (minfo.sid == wife) sids[i] = minfo.husb; snames[i] = minfo.sname; i += 1; } if (minfo.sid == minfo.husb) { spouseFieldId = "motherlink"; spouseSelect = "mothSelectbox"; } if (minfo.sid == minfo.wife) { spouseFieldId = "fatherlink"; spouseSelect = "fathSelectbox"; } var http = ' '; document.getElementById(spouseFieldId).innerHTML = http; } var persid = 0; var db_select = "select.php"; var db_mselect = "mselect.php"; function queryDB(id,cmd,action) { //alert('query : ' + id + " " + cmd); if (id == null || id == '' || id == 0) { if (cmd == 'query') { // PostRequest data var poststr = cmd + "=" + cmd; for (i=4; i