PageSourceSearch

https://hansschmidt.org/wp-content/plugins/rootspersona/js/rootsUtilities.js?ver=7.0.4

js hansschmidt.org collected 2026-10-10 02:16:52 UTC 24,071 bytes, 615 lines download raw bytes

1function rootsConfirm(winText, trueAction) {
2    var r = confirm(winText);
3    if (r == true) {
4        window.location = trueAction;
5    } else {
6        window.location = "#";
7    }
8}
9
10function findPersonaPage(site_url) {
11    var e = document.getElementById("persona_page");
12    var page = e.options[e.selectedIndex].value;
13    window.location=site_url + '?page_id=' + page;
14}
15
16function gotoPersonaPage(site_url) {
17    var e = document.getElementById("persona_page");
18    var page = e.value;
19    window.location=site_url + '?page_id=' + page;
20}
21
22function updatePersona() {
23    var postData = jQuery('#editPersonaForm').serialize();
24    var data = {
25        action: 'rp_action',
26        datastr: postData,
27        form_action: 'updatePersona'
28    };
29    document.body.style.cursor = "wait";
30    var msgs = jQuery('.persona_msg');
31    jQuery.each(msgs, function(index, item){
32        item.innerHTML = '';
33    });
34    // since 2.8 ajaxurl is always defined in the admin header and points to admin-ajax.php
35    jQuery.post(ajaxurl, data, function(data) {
36        document.body.style.cursor = "default";
37        try {
38            var obj = jQuery.parseJSON(data);
39            var isErr = false;
40            jQuery.each(obj, function(key, value){
41                  if(key == 'error') {
42                      var msgs = jQuery('.persona_msg');
43                        jQuery.each(msgs, function(index, item){
44                            item.innerHTML = value;
45                            jQuery(item).css('color','red');
46                        });
47                        isErr = true;
48                  } else if (key == 'rp_id') {
49                      jQuery("#rp_id").text(value);
50                      jQuery('#personId').val(value);
51                  } else if (key == 'rp_page') {
52                      jQuery("#rp_page").text(value);
53                      jQuery('#persona_page').val(value);
54                  } else if (key == 'rp_famc') {
55                      jQuery("#rp_famc").val(value);
56                  } else if (key == 'rp_fams') {
57                      var fams = jQuery('.rp_fams');
58                      jQuery.each(fams, function(index, item){
59                        if(jQuery(item).val() == '-1') {
60                            jQuery(item).val(value);
61                        }
62                      });
63                  }
64            });
65
66            jQuery("#rp_father_id").val('');
67            jQuery("#rp_mother_id").val('');
68            jQuery('#spousal_link').css('display','inline');
69
70            if(!isErr) {
71                var msgs = jQuery('.persona_msg');
72                jQuery.each(msgs, function(index, item){
73                    item.innerHTML = 'Saved.';
74                    jQuery(item).css('color','green');
75                });
76                var cancels = jQuery('[name="cancel"]');
77                jQuery.each(cancels, function(index, item){
78                    jQuery(item).val('View');
79                });
80            }
81        } catch (err) {
82            if (data == null) data = err;
83            alert(data);
84        }
85
86    });
87}
88
89function unlinkparents(fid) {
90    jQuery('#' + fid).val('');
91    jQuery('#rp_father').html('');
92    jQuery('#rp_mother').html('');
93    jQuery('#rp_unlink_parents').css('display','none');
94    jQuery('#rp_link_parents1').css('display','inline');
95    jQuery('#rp_link_parents2').css('display','inline');
96    jQuery('#parental_text').val('');
97    jQuery('#parental_text').css('display','none');
98    jQuery('#rp_father_id').val('');
99    jQuery('#rp_mother_id').val('');
100    jQuery('#parental_gender').val('');
101}
102
103function linkparents(seq) {
104    if(jQuery('#parental_text').is(':visible')) {
105        jQuery('#parental_text').css('display','none');
106        jQuery('#parental_text').val('');
107        jQuery('#parental_gender').val('');
108    } else {
109        jQuery('#parental_text').css('display','inline');
110        jQuery('#parental_gender').css('display','inline');
111        jQuery('#parental_gender').val(seq);
112    }
113}
114
115function unlinkspouse(fid) {
116    jQuery('#' + fid).val('');
117    famid = fid.replace('rp_fams_','');
118    jQuery('#rp_group_' + famid).remove();
119    jQuery('#spousal_text').css('display','none');
120    jQuery('#spousal_link').css('display','inline');
121}
122
123function linkspouse() {
124    if(jQuery('#spousal_text').is(':visible')) {
125        jQuery('#spousal_text').css('display','none');
126        jQuery('#spousal_text').val('');
127    } else {
128        jQuery('#spousal_text').css('display','inline');
129    }
130}
131
132
133function processBatchSpan( event ) {
134    var myUrl = event.data.url
135                + '/tools.php?page=rootsPersona&rootspage=';
136    var action = event.data.action;
137    if (action == 'include') {
138        myUrl += action + '&batch_id=' + jQuery('#batch_id').val();
139    } else {
140        myUrl += 'util&utilityAction='
141            + action + '&batch_id=' + jQuery('#batch_id').val();
142    }
143
144    jQuery('#process_button').unbind('click', processBatchSpan);
145    window.location = myUrl;
146    return false;
147}
148
149function revealBatchSpan(obj, url) {
150    var action = '';
151    if (obj.id == 'evidence') {
152        action = 'evidence';
153    } else if(obj.id == 'delete') {
154        action = 'delete'
155    } else if(obj.id == 'validate') {
156        action = 'validatePages';
157    } else if(obj.id == 'review') {
158        action='include';
159    }
160    var b = jQuery('#batch_ids option')
161    if ( b.size() < 2 ) {
162        batch_id = b.val();
163        var event = {};
164        event.data = {};
165        event.data.url = url + '/tools.php?page=rootsPersona&rootspage=';
166        event.data.action = action;
167        processBatchSpan(event);
168    } else {
169        var spanpos = jQuery('#' + obj.id).parent().next().children('span:first');
170
171        if( jQuery('#batchspan').is(":visible") ) {
172            jQuery('#batchspan').hide();
173        } else {
174            jQuery('#process_button').bind('click',{url: url, action: action}, processBatchSpan);
175
176            var caller = spanpos.offset();
177            jQuery('#batchspan').show();
178            jQuery('#batchspan').offset({top: (caller.top - 25), left: (caller.left - 10)});
179        }
180    }
181}
182
183function synchBatchText() {
184    var value = jQuery('#batch_ids option:selected').val();
185    jQuery('#batch_id').val(value);
186    return false;
187}
188
189function refreshAddPerson() {
190    var b = jQuery('#batch_ids option:selected').val();
191    jQuery("#persons").contents().remove();
192	var data = {
193        action: 'rp_action',
194        refresh: 1,
195        batch_id: b
196	};
197    document.body.style.cursor = "wait";
198	// since 2.8 ajaxurl is always defined in the admin header and points to admin-ajax.php
199	jQuery.get(ajaxurl, data, function(response) {
200        document.body.style.cursor = "default";
201        var res = jQuery.parseJSON(response);
202        jQuery.each(res, function(index, p) {
203                  if(index == 'error') {
204                      alert(p);
205                  } else {
206                    // add items to List box
207                    jQuery("#persons").append("<option id='" + p.id + "'>"
208                        + p.surname + ", " + p.given + "</option>");
209                }
210            } // end of function
211        );  // each
212	});
213
214    return false;
215}
216
217jQuery(document).ready(function() {
218
219    var rpformfield;
220
221    rp_send_to_editor = function(html) {
222        //imgurl = jQuery('img',html).attr('src');
223        var imgurl = jQuery(html);
224        imgurl = imgurl.prop('src');
225        jQuery('#' + rpformfield).val(imgurl);
226        imgid = rpformfield.replace('_path','');
227        jQuery('#' + imgid).attr('src',imgurl);
228        jQuery('#' + imgid).parent().attr('href',imgurl);
229        tb_remove();
230    }
231
232    jQuery('#img_1_upload_button').click(function() {
233        window.send_to_editor = rp_send_to_editor;
234        rpformfield = jQuery('#img_path_1').attr('name');
235        tb_show('', 'media-upload.php?type=image&amp;post_id=0&amp;TB_iframe=true');
236        return false;
237    });
238
239    jQuery('#img_2_upload_button').click(function() {
240        window.send_to_editor = rp_send_to_editor;
241        rpformfield = jQuery('#img_path_2').attr('name');
242        tb_show('', 'media-upload.php?type=image&amp;post_id=0&amp;TB_iframe=true');
243        return false;
244    });
245
246    jQuery('#img_3_upload_button').click(function() {
247        window.send_to_editor = rp_send_to_editor;
248        rpformfield = jQuery('#img_path_3').attr('name');
249        tb_show('', 'media-upload.php?type=image&amp;post_id=0&amp;TB_iframe=true');
250        return false;
251    });
252
253    jQuery('#img_4_upload_button').click(function() {
254        window.send_to_editor = rp_send_to_editor;
255        rpformfield = jQuery('#img_path_4').attr('name');
256        tb_show('', 'media-upload.php?type=image&amp;post_id=0&amp;TB_iframe=true');
257        return false;
258    });
259
260    jQuery('#img_5_upload_button').click(function() {
261        window.send_to_editor = rp_send_to_editor;
262        rpformfield = jQuery('#img_path_5').attr('name');
263        tb_show('', 'media-upload.php?type=image&amp;post_id=0&amp;TB_iframe=true');
264        return false;
265    });
266
267    jQuery('#img_6_upload_button').click(function() {
268        window.send_to_editor = rp_send_to_editor;
269        rpformfield = jQuery('#img_path_6').attr('name');
270        tb_show('', 'media-upload.php?type=image&amp;post_id=0&amp;TB_iframe=true');
271        return false;
272    });
273
274    jQuery('#img_7_upload_button').click(function() {
275        window.send_to_editor = rp_send_to_editor;
276        rpformfield = jQuery('#img_path_7').attr('name');
277        tb_show('', 'media-upload.php?type=image&amp;post_id=0&amp;TB_iframe=true');
278        return false;
279    });
280
281    var claimTypes = [
282        "Adoption",
283        "Adult Christening",
284        "Annulment",
285        "Baptism",
286        "Bar Mitzvah",
287        "Bas Mitzvah",
288        "Birth",
289        "Blessing",
290        "Burial",
291        "Caste",
292        "Census",
293        "Christening",
294        "Confirmation",
295        "Cremation",
296        "Death",
297        "Divorce",
298        "Divorce Filed",
299        "Education",
300        "Emmigration",
301        "Engagement",
302        "Event",
303        "Fact",
304        "First Communion",
305        "Graduation",
306        "Head of House",
307        "Immigration",
308        "Marriage",
309        "Marriage Bann",
310        "Marriage Contract",
311        "Marriage License",
312        "Marriage Settlement",
313        "Nationality",
314        "Naturalization",
315        "Nobility Title",
316        "Occupation",
317        "Ordnance",
318        "Possessions",
319        "Probate",
320        "Religion",
321        "Residence",
322        "Retirement",
323        "Social Security Nbr",
324        "Will"
325	];
326
327    jQuery('.claimType').each(function(index) {
328            jQuery(this).autocomplete({
329                source: claimTypes
330            });
331    });
332
333    function addFactsRow() {
334        var claim = jQuery('#newclaim').val();
335        if(claim != null && claim != "") {
336            var newRow = '<tr><td><input id="newclaim" type="text" class="claimType" value=""></td>'
337                        + '<td><input id="newdate" type="text" value=""></td>'
338                        + '<td><input id="newplace" type="text" value=""></td>'
339                        + '<td><textarea id="newclassification" type="text" cols="30" rows="1"></textarea>'
340                        + '<td id="newbutton"></td></tr>';
341            var delPath = jQuery('#imgPath').val() + 'delete-icon.png';
342
343            var claimfield = jQuery('#newclaim');
344            var datefield  = jQuery('#newdate');
345            var placefield  = jQuery('#newplace');
346            var classfield  = jQuery('#newclassification');
347            var buttoncell = jQuery('#newbutton');
348
349            buttoncell.append('<img alt="Delete" src="' + delPath + '" class="delFacts"/>');
350            buttoncell.children().each(function(index) {
351                jQuery(this).click(deleteFactsRow);
352                jQuery(this).mouseover(function() {
353                    var imgPath = jQuery('#imgPath').val() + 'delete-icon-hover.png';
354                    jQuery(this).attr('src',imgPath);
355                });
356                jQuery(this).mouseout(function() {
357                    var imgPath = jQuery('#imgPath').val() + 'delete-icon.png';
358                    jQuery(this).attr('src',imgPath);
359                });
360                jQuery(this).mousedown(function() {
361                    var imgPath = jQuery('#imgPath').val() + 'delete-icon-click.png';
362                    jQuery(this).attr('src',imgPath);
363                });
364            });
365            var tbody = jQuery('#facts');
366            tbody.append(newRow);
367
368            var rowCnt = tbody.children().length - 2;
369            claimfield.removeAttr('id');
370            datefield.removeAttr('id');
371            placefield.removeAttr('id');
372            classfield.removeAttr('id');
373            buttoncell.removeAttr('id');
374            claimfield.attr('name', 'rp_claimtype_' + rowCnt);
375            datefield.attr('name', 'rp_claimdate_' + rowCnt);
376            placefield.attr('name', 'rp_claimplace_' + rowCnt);
377            classfield.attr('name', 'rp_classification_' + rowCnt);
378            classfield.unbind('blur');
379
380            jQuery('#facts > tbody').each(function(index) {
381                jQuery(this).append(newRow);
382            });
383            jQuery('#newclaim').autocomplete({
384                source: claimTypes
385            });
386            jQuery('#newclaim').focus();
387            jQuery('#newclassification').blur(addFactsRow);
388        }
389    }
390
391    jQuery('#newclassification').blur(addFactsRow);
392
393    function deleteFactsRow() {
394        // img > cell > row
395        jQuery(this).parent().parent().remove();
396        var tbody = jQuery('#facts');
397        var cnt = tbody.children().length - 1;
398        tbody.children().each(function(index) {
399            var trow = jQuery(this);
400            var cells = trow.children("td");
401            var inp = cells.eq(0).children().eq(0);
402            if(inp.attr("id") == "newclaim" ) return;
403
404            inp.attr("name","rp_claimtype_" + index);
405            inp = cells.eq(1).children().eq(0);
406            inp.attr("name","rp_claimdate_" + index);
407            inp = cells.eq(2).children().eq(0);
408            inp.attr("name","rp_claimplace_" + index);
409            inp = cells.eq(3).children().eq(0);
410            inp.attr("name","rp_classification_" + index);
411        });
412    }
413
414    jQuery('.delFacts').each(function(index) {
415        jQuery(this).click(deleteFactsRow);
416        jQuery(this).mouseover(function() {
417           var imgPath = jQuery('#imgPath').val() + 'delete-icon-hover.png';
418           jQuery(this).attr('src',imgPath);
419        });
420        jQuery(this).mouseout(function() {
421           var imgPath = jQuery('#imgPath').val() + 'delete-icon.png';
422           jQuery(this).attr('src',imgPath);
423        });
424        jQuery(this).mousedown(function() {
425           var imgPath = jQuery('#imgPath').val() + 'delete-icon-click.png';
426           jQuery(this).attr('src',imgPath);
427        });
428    });
429
430    jQuery('.submitPersonForm').each(function(index) {
431        jQuery(this).mouseover(function() {
432           jQuery(this).removeClass('submitPersonForm').addClass('submitPersonFormHover');
433        });
434        jQuery(this).mouseout(function() {
435
436           jQuery(this).removeClass('submitPersonFormHover').addClass('submitPersonForm');
437        });
438        jQuery(this).mousedown(function() {
439           jQuery(this).removeClass('submitPersonFormHover').addClass('submitPersonFormClick');
440        });
441       jQuery(this).mouseup(function() {
442           jQuery(this).removeClass('submitPersonFormClick').addClass('submitPersonFormHover');
443        });
444    });
445
446    function rp_autoSelectPerson (event, ui) {
447            var seq;
448            var el;
449            var nameParm;
450            var ssid;
451            var block;
452            var name;
453            var type = this.id.replace('_text','');
454            var end = ui.item.value.indexOf(')');
455            var idParm = ui.item.value.substr(1, (end-1)).split('-');
456            if(type == 'parental' && idParm[0] == 'F') {
457                jQuery('#rp_famc').val(idParm[1]);
458                nameParm = ui.item.value.substr(end+2).split('&')
459                jQuery('#rp_father').html(nameParm[0]);
460                jQuery('#rp_mother').html(nameParm[1]);
461                jQuery('#rp_unlink_parents').css('display','inline');
462                jQuery('#rp_link_parents1').css('display','none');
463                jQuery('#rp_link_parents2').css('display','none');
464                jQuery('#rp_father_id').val('');
465                jQuery('#rp_mother_id').val('');
466                jQuery('#parental_text').val('');
467                jQuery('#parental_gender').val('');
468                jQuery('#parental_text').css('display','none');
469            } else if(type == 'parental' && idParm[0] == 'I') {
470                el = jQuery('#rp_famc')
471                var id = el.val();
472                if ( id == '') id = '-1';
473                el.val(id);
474                nameParm = ui.item.value.split(')');
475                name = nameParm[1].substr(1);
476                if(jQuery('#parental_gender').val() == '1') {
477                    jQuery('#rp_father').html(name);
478                    jQuery('#rp_father_id').val(idParm[1]);
479                    jQuery('#rp_link_parents1').css('display','none');
480                } else {
481                    jQuery('#rp_mother').html(name);
482                    jQuery('#rp_mother_id').val(idParm[1]);
483                    jQuery('#rp_link_parents2').css('display','none');
484                }
485                jQuery('#rp_unlink_parents').css('display','inline');
486                jQuery('#parental_text').css('display','none');
487                jQuery('#parental_text').val('');
488            } else if (idParm[0] == 'F1' || idParm[0] == 'F2') {
489                seq = 0;
490                el = jQuery('#rp_sseq_' + seq);
491                while (el.length > 0) {
492                    seq++;
493                    el = jQuery('#rp_sseq_' + seq);
494                }
495                nameParm = ui.item.value.substr(end+2).split('&');
496                ssid = nameParm[1].substr(9, nameParm[1].indexOf(']')-9);
497                block = '<div id="rp_group_' + seq + '" name="rp_group_' + seq + '">'
498                    + '<div style="margin-left:10px;"><span style="display:inline-block;width:23.5em;">Family ' + idParm[1] + '</span>'
499                    + '<input type="hidden" id="rp_sseq_'
500                    + seq + '" name="rp_sseq_'+ seq + '" value="' + (idParm[0]=='F2'?'2':'1') + '">'
501                    + '<input type="hidden" id="rp_sid_'+ seq + '" name="rp_sid_'+ seq + '" value="' + ssid + '">'
502                    + '<input type="hidden" class="rp_fams" id="rp_fams_'+ seq + '" name="rp_fams_'+ seq + '" value="' + idParm[1] + '">'
503                    + '<input id="rp_fams_unlink_'+ seq + '" name="rp_fams_unlink_'+ seq + '" class="submitPersonForm" type="button" onclick="unlinkspouse(\'rp_fams_'+ seq + '\');"  value="'
504                    + 'Unlink from this Family Group"></div>'
505                    + '<div style="margin-left:20px;"><span style="font-weight:bold;font-style:italic;display:inline-block;width:5em;">Spouse: </span>'
506                    + nameParm[0] + '</div></div>';
507                jQuery('#spousal_text').parent().prepend(block);
508                jQuery('#spousal_text').val('');
509                jQuery('#spousal_text').css('display','none');
510            } else if (idParm[0] == 'I') {
511                seq = 0;
512                el = jQuery('#rp_sseq_' + seq);
513                while (el.length > 0) {
514                    seq++;
515                    el = jQuery('#rp_sseq_' + seq);
516                }
517                nameParm = ui.item.value.split(')');
518                name = nameParm[1].substr(1);
519                block = '<div id="rp_group_' + seq + '" name="rp_group_' + seq + '">'
520                    + '<div style="margin-left:10px;"><span style="display:inline-block;width:23.5em;">Family</span>'
521                    + '<input type="hidden" id="rp_sseq_' + seq + '" name="rp_sseq_'+ seq + '">'
522                    + '<input type="hidden" id="rp_sid_'+ seq + '" name="rp_sid_'+ seq + '" value="' + idParm[1] + '">'
523                    + '<input type="hidden" class="rp_fams" id="rp_fams_'+ seq + '" name="rp_fams_'+ seq + '" value="-1">'
524                    + '<input id="rp_fams_unlink_'+ seq + '" name="rp_fams_unlink_'+ seq + '" class="submitPersonForm" type="button" onclick="unlinkspouse(\'rp_fams_'+ seq + '\');"  value="'
525                    + 'Unlink from this Family Group"></div>'
526                    + '<div style="margin-left:20px;"><span style="font-weight:bold;font-style:italic;display:inline-block;width:5em;">Spouse: </span>'
527                    + name + '</div></div>';
528                jQuery('#spousal_text').parent().prepend(block);
529                jQuery('#spousal_text').val('');
530                jQuery('#spousal_text').css('display','none');
531                jQuery('#spousal_link').css('display','none');
532            }
533    }
534
535    function rp_autoCompleteParental(req, add){
536        document.body.style.cursor = "wait";
537        jQuery('#parental_text').css('cursor','wait');
538        var data = {
539            action: 'rp_action',
540            datastr: req,
541            form_action: 'getFamilies'
542        };
543        // since 2.8 ajaxurl is always defined in the admin header and points to admin-ajax.php
544        jQuery.post(ajaxurl, data, function(data) {
545            //create array for response objects
546            var suggestions = [];
547
548            //process response
549            rows = jQuery.parseJSON(data);
550            if( rows !== undefined && rows != null ) {
551                jQuery.each(rows, function(idx, row){
552                  if(idx == 'error') {
553                      alert(row);
554                  } else {
555                    suggestions.push(row.name);
556                  }
557                });
558            }
559
560            //pass array to callback
561            add(suggestions);
562
563            document.body.style.cursor = "default";
564            jQuery('#parental_text').css('cursor','default');
565        });
566    }
567
568    function rp_autoCompleteSpousal(req, add){
569        document.body.style.cursor = "wait";
570        jQuery('#spousal_text').css('cursor','wait');
571        var data = {
572            action: 'rp_action',
573            datastr: req,
574            form_action: 'getSpouses'
575        };
576        // since 2.8 ajaxurl is always defined in the admin header and points to admin-ajax.php
577        jQuery.post(ajaxurl, data, function(data) {
578            //create array for response objects
579            var suggestions = [];
580
581            //process response
582            rows = jQuery.parseJSON(data);
583            if( rows !== undefined && rows != null ) {
584                jQuery.each(rows, function(idx, row){
585                  if(idx == 'error') {
586                      alert(row);
587                  } else {
588                    suggestions.push(row.name);
589                  }
590                });
591            }
592
593            //pass array to callback
594            add(suggestions);
595
596            document.body.style.cursor = "default";
597            jQuery('#spousal_text').css('cursor','default');
598        });
599    }
600
601    jQuery('#parental_text').autocomplete({
602        source: rp_autoCompleteParental,
603        select: rp_autoSelectPerson,
604        minLength: 1
605    });
606
607    jQuery('#spousal_text').autocomplete({
608        source: rp_autoCompleteSpousal,
609        select: rp_autoSelectPerson,
610        minLength: 1
611    });
612
613    document.body.style.cursor = "default";
614
615});

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.