PageSourceSearch

https://www.hotac.org.tw/modules/civicrm/js/Common.js?tlhygj

js hotac.org.tw collected 2026-09-24 20:10:21 UTC 30,555 bytes, 899 lines download raw bytes

1/*
2 +--------------------------------------------------------------------+
3 | CiviCRM version 3.3                                                |
4 +--------------------------------------------------------------------+
5 | Copyright CiviCRM LLC (c) 2004-2010                                |
6 +--------------------------------------------------------------------+
7 | This file is a part of CiviCRM.                                    |
8 |                                                                    |
9 | CiviCRM is free software; you can copy, modify, and distribute it  |
10 | under the terms of the GNU Affero General Public License           |
11 | Version 3, 19 November 2007 and the CiviCRM Licensing Exception.   |
12 |                                                                    |
13 | CiviCRM is distributed in the hope that it will be useful, but     |
14 | WITHOUT ANY WARRANTY; without even the implied warranty of         |
15 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.               |
16 | See the GNU Affero General Public License for more details.        |
17 |                                                                    |
18 | You should have received a copy of the GNU Affero General Public   |
19 | License and the CiviCRM Licensing Exception along                  |
20 | with this program; if not, contact CiviCRM LLC                     |
21 | at info[AT]civicrm[DOT]org. If you have questions about the        |
22 | GNU Affero General Public License or the licensing of CiviCRM,     |
23 | see the CiviCRM license FAQ at http://civicrm.org/licensing        |
24 +--------------------------------------------------------------------+
25*/
26
27/**
28 *
29 * @package CRM
30 * @copyright CiviCRM LLC (c) 2004-2010
31 * $Id$
32 *
33 */
34
35/**
36 * IE 8 support of trim
37 **/
38if(typeof String.prototype.trim !== 'function') {
39  String.prototype.trim = function() {
40    return this.replace(/^\s+|\s+$/g, ''); 
41  }
42}
43
44/** 
45 *  This function can be used to clear default 'suggestive text' from an input field
46 *  When the cursor is moved into the field.
47 *  
48 *  It is generally invoked by the input field's onFocus event. Use the reserved
49 *  word 'this' to pass this object. EX: onFocus="clearFldVal(this);"
50 * 
51 * @access public
52 * @param  fld The form field object whose value is to be cleared
53 * @param  hideBlocks Array of element Id's to be hidden
54 * @return none 
55 */
56function clearFldVal(fld) {
57    if (fld.value == fld.defaultValue) {
58        fld.value = "";
59    }
60}
61
62/** 
63 *  This function is called by default at the bottom of template files which have forms that have
64 *  conditionally displayed/hidden sections and elements. The PHP is responsible for generating
65 *  a list of 'blocks to show' and 'blocks to hide' and the template passes these parameters to
66 *  this function.
67 * 
68 * @access public
69 * @param  showBlocks Array of element Id's to be displayed
70 * @param  hideBlocks Array of element Id's to be hidden
71 * @param elementType Value to set display style to for showBlocks (e.g. 'block' or 'table-row' or ...)
72 * @return none 
73 */
74function on_load_init_blocks(showBlocks, hideBlocks, elementType)
75{   
76    if ( elementType == null ) {
77        var elementType = 'block';
78    }
79    
80    /* This loop is used to display the blocks whose IDs are present within the showBlocks array */ 
81    for ( var i = 0; i < showBlocks.length; i++ ) {
82        var myElement = document.getElementById(showBlocks[i]);
83        /* getElementById returns null if element id doesn't exist in the document */
84        if (myElement != null) {
85            myElement.style.display = elementType;
86        } else {
87	  alert('showBlocks array item not in .tpl = ' + showBlocks[i]);
88        }
89    }
90    
91    /* This loop is used to hide the blocks whose IDs are present within the hideBlocks array */ 
92    for ( var i = 0; i < hideBlocks.length; i++ ) { 
93        var myElement = document.getElementById(hideBlocks[i]);
94        /* getElementById returns null if element id doesn't exist in the document */
95        if (myElement != null) {
96            myElement.style.display = 'none';
97        } else {
98	  alert('showBlocks array item not in .tpl = ' + hideBlocks[i]);
99        }
100    }
101    
102}
103
104/**
105 *  This function is called when we need to show or hide a related form element (target_element)
106 *  based on the value (trigger_value) of another form field (trigger_field).
107 *
108 * @deprecated
109 * @param  trigger_field_id     HTML id of field whose onchange is the trigger
110 * @param  trigger_value        List of integers - option value(s) which trigger show-element action for target_field
111 * @param  target_element_id    HTML id of element to be shown or hidden
112 * @param  target_element_type  Type of element to be shown or hidden ('block' or 'table-row')
113 * @param  field_type           Type of element radio/select
114 * @param  invert               Boolean - if true, we HIDE target on value match; if false, we SHOW target on value match
115 */
116function showHideByValue(trigger_field_id, trigger_value, target_element_id, target_element_type, field_type, invert) {
117  var target, j;
118
119  if (field_type == 'select') {
120    var trigger = trigger_value.split("|");
121    var selectedOptionValue = cj('#' + trigger_field_id).val();
122
123    target = target_element_id.split("|");
124    for (j = 0; j < target.length; j++) {
125      if (invert) {
126        cj('#' + target[j]).show();
127      }
128      else {
129        cj('#' + target[j]).hide();
130      }
131      for (var i = 0; i < trigger.length; i++) {
132        if (selectedOptionValue == trigger[i]) {
133          if (invert) {
134            cj('#' + target[j]).hide();
135          }
136          else {
137            cj('#' + target[j]).show();
138          }
139        }
140      }
141    }
142
143  }
144  else {
145    if (field_type == 'radio') {
146      target = target_element_id.split("|");
147      for (j = 0; j < target.length; j++) {
148        if (cj('[name="' + trigger_field_id + '"]:first').is(':checked')) {
149          if (invert) {
150            cj('#' + target[j]).hide();
151          }
152          else {
153            cj('#' + target[j]).show();
154          }
155        }
156        else {
157          if (invert) {
158            cj('#' + target[j]).show();
159          }
160          else {
161            cj('#' + target[j]).hide();
162          }
163        }
164      }
165    }
166  }
167}
168
169
170/** 
171 *  This function is called when we need to enable or disable a related form element (target_element)
172 *  based on the value (trigger_value) of another form field (trigger_field).
173 * 
174 * @access public
175 * @param  trigger_field_id     HTML id of field whose onchange is the trigger
176 * @param  trigger_value        List of integers - option value(s) which trigger enable-element action for target_field
177 * @param  target_element_id    HTML id of element to be enabled or disabled
178 * @param  target_element_type  Type of element to be enabled or disabled ('block' or 'table-row')
179 * @param  field_type           Type of element radio/select
180 * @param  invert               Boolean - if true, we DISABLE target on value match; if false, we ENABLE target on value match
181 * @return none 
182*/
183function enableDisableByValue(trigger_field_id, trigger_value, target_element_id, target_element_type, field_type, invert ) {
184    if ( target_element_type == null ) {
185        var target_element_type = 'block';
186    } else if ( target_element_type == 'table-row' ) {
187	var target_element_type = '';
188    }
189    
190    if (field_type == 'select') {
191        var trigger = trigger_value.split("|");
192        var selectedOptionValue = document.getElementById(trigger_field_id).options[document.getElementById(trigger_field_id).selectedIndex].value;	
193        
194        var target = target_element_id.split("|");
195        for(var j = 0; j < target.length; j++) {
196  	    if (document.getElementById(target[j])) {
197              if ( invert ) {  
198                 document.getElementById(target[j]).disabled = false;
199              } else {
200                 document.getElementById(target[j]).disabled = true;
201              }
202	    }
203            for(var i = 0; i < trigger.length; i++) {
204                if (selectedOptionValue == trigger[i]) {
205    	            if (document.getElementById(target[j])) {
206                       if ( invert ) {  
207			  document.getElementById(target[j]).disabled = true;
208	               } else {
209			  document.getElementById(target[j]).disabled = false;
210	               }	
211		    }
212                }
213            }
214        }
215 
216    } else if (field_type == 'radio') {
217        var target = target_element_id.split("|");
218        for(var j = 0; j < target.length; j++) {
219	    if (document.getElementsByName(trigger_field_id)[0].checked) {
220	       if (document.getElementById(target[j])) {
221		   if ( invert ) {  
222			document.getElementById(target[j]).disabled = true;
223		   } else {
224			document.getElementById(target[j]).disabled = false;
225		   }
226		}
227	    } else {
228	       if (document.getElementById(target[j])) {
229		   if ( invert ) {  
230			document.getElementById(target[j]).disabled = false;
231 		   } else {
232			document.getElementById(target[j]).disabled = true;
233	    	   }
234		}
235	    }
236	}
237    }
238}
239
240/** 
241 *  This function is called when we need to Reset a related form element (target_element)
242 *  based on the value (trigger_value) of another form field (trigger_field).
243 * 
244 * @access public
245 * @param  trigger_field_id     HTML id of field whose onchange is the trigger
246 * @param  trigger_value        List of integers - option value(s) which trigger reset action for target_field
247 * @param  target_element_id    HTML id of element to be reset
248 * @param  target_field_type    Field-Type of element to be reset ('radio' or 'text')
249 * @param  field_type           Type of element radio/select
250 * @param  invert               Boolean - if true, we RESET target on value-match; if false, we RESET target on No-value-match
251 * @return none 
252*/
253function resetByValue(trigger_field_id, trigger_value, target_element_id, target_field_type, field_type, invert) {
254    
255    if (field_type == 'select') {
256        var trigger = trigger_value.split("|");
257        var selectedOptionValue = document.getElementById(trigger_field_id).options[document.getElementById(trigger_field_id).selectedIndex].value;	
258        
259        var target = target_element_id.split("|");
260        for(var j = 0; j < target.length; j++) {
261            for(var i = 0; i < trigger.length; i++) {
262		if ( invert ) {
263                  if (selectedOptionValue == trigger[i]) {
264		       if (target_field_type == 'radio') {	
265			   if (document.getElementsByName(target[j])) {
266				for (var i=0; i<document.getElementsByName(target[j]).length; i++) {
267				   if (document.getElementsByName(target[j])[i].checked) {
268 				       document.getElementsByName(target[j])[i].checked = null;
269				   }
270				}
271			   }
272		       } else {	
273	    	           if (document.getElementById(target[j])) {
274			       document.getElementById(target[j]).value = "";
275			   }
276		       }
277                  }
278		} else {
279		    if (selectedOptionValue != trigger[i]) {
280		       if (target_field_type == 'radio') {	
281			   if (document.getElementsByName(target[j])) {
282				for (var i=0; i<document.getElementsByName(target[j]).length; i++) {
283				   if (document.getElementsByName(target[j])[i].checked) {
284 				       document.getElementsByName(target[j])[i].checked = null;
285				   }
286				}
287			   }
288		       } else {	
289	    	           if (document.getElementById(target[j])) {
290			       document.getElementById(target[j]).value = "";
291			   }
292		       }
293		    }
294		}
295            }
296        }
297
298     } else if (field_type == 'radio') {
299        var target = target_element_id.split("|");
300        for(var j = 0; j < target.length; j++) {
301	      if ( invert ) {
302		   if (document.getElementsByName(trigger_field_id)[0].checked) {
303		       if (target_field_type == 'radio') {	
304			   if (document.getElementsByName(target[j])) {
305				for (var i=0; i<document.getElementsByName(target[j]).length; i++) {
306				   if (document.getElementsByName(target[j])[i].checked) {
307 				       document.getElementsByName(target[j])[i].checked = null;
308				   }
309				}
310			   }
311		       } else {	
312			       if (document.getElementById(target[j])) {
313		  		   document.getElementById(target[j]).value = "";
314			      }
315		       }
316		   }
317	      } else {
318		   if (!document.getElementsByName(trigger_field_id)[0].checked) {
319		       if (target_field_type == 'radio') {	
320			   if (document.getElementsByName(target[j])) {
321				for (var i=0; i<document.getElementsByName(target[j]).length; i++) {
322				   if (document.getElementsByName(target[j])[i].checked) {
323 				       document.getElementsByName(target[j])[i].checked = null;
324				   }
325				}
326			   }
327		       } else {	
328			       if (document.getElementById(target[j])) {
329		  		   document.getElementById(target[j]).value = "";
330			      }
331		       }
332		   }
333	      }
334	}
335    }
336}
337
338/** 
339 * This function is used to display a page element  (e.g. block or table row or...). 
340 * 
341 * This function is called by various links which handle requests to display the hidden blocks.
342 * An example is the <code>[+] another phone</code>
342 link which expands an additional phone block.
343 * The parameter block_id must have the id of the block which has to be displayed.
344 *
345 * 
346 * @access public
347 * @param block_id Id value of the block (or row) to be displayed.
348 * @param elementType Value to set display style to when showing the element (e.g. 'block' or 'table-row' or ...)
349 * @return none
350 */
351function show(block_id,elementType)
352{
353    if ( elementType == null ) {
354        var elementType = 'block';
355    } else if ( elementType == "table-row" && navigator.appName == 'Microsoft Internet Explorer' ) {
356 	var elementType = "block";
357    }
358    var myElement = document.getElementById(block_id);
359    if (myElement != null) {
360        myElement.style.display = elementType;
361    } else {
362        alert('Request to show() function failed. Element id undefined = '+ block_id);
363    }
364}
365
366
367/** 
368 * This function is used to hide a block. 
369 * 
370 * This function is called by various links which handle requests to hide the visible blocks.
371 * An example is the <code>[-] hide phone</code> link which hides the phone block.
372 * The parameter block_id must have the id of the block which has to be hidden.
373 *
374 * @access public
375 * @param block_id Id value of the block to be hidden.
376 * @return none
377 */
378function hide(block_id) 
379{
380    var myElement = document.getElementById(block_id);
381    if (myElement != null) {
382        myElement.style.display = 'none';
383    } else {
384        alert('Request to hide() function failed. Element id undefined = ' + block_id);
385    }
386    
387    //    document.getElementById(block_id).style.display = 'none';
388}
389
390/**
391 *
392 * Function for checking ALL or unchecking ALL check boxes in a resultset page.
393 *
394 * @access public
395 * @param fldPrefix - common string which precedes unique checkbox ID and identifies field as
396 *                    belonging to the resultset's checkbox collection
397 * @param action - 'select' = set all to checked; 'deselect' = set all to unchecked
398 * @param form - name of form that checkboxes are part of
399 * Sample usage: onClick="javascript:changeCheckboxValues('chk_', 'select', myForm );"
400 *
401 * @return
402 */
403function toggleCheckboxVals(fldPrefix,object) {
404  if (object.id === 'toggleSelect' && cj(object).is(':checked')) {
405    cj('input[id*="' + fldPrefix + '"],Input[id*="toggleSelect"]').prop('checked', true);
406    cj('input[name=radio_ts][value=ts_all]').prop('checked', false);
407    cj('input[name=radio_ts][value=ts_sel]').trigger('click');
408  } else {
409    cj('input[id*="' + fldPrefix + '"],Input[id*="toggleSelect"]').prop('checked', false);
410  }
411}
412
413function countSelectedCheckboxes(fldPrefix, form) {
414    fieldCount = 0;
415    for( i=0; i < form.elements.length; i++) {
416        fpLen = fldPrefix.length;
417        if (form.elements[i].type == 'checkbox' && form.elements[i].name.slice(0,fpLen) == fldPrefix && form.elements[i].checked == true) {
418            fieldCount++;
419        }
420    }
421    return fieldCount;
422}
423
424/**
425 * Function to enable task action select
426 */
427function toggleTaskAction( status ) {
428  var $radio_ts_all = cj("input[name=radio_ts][value=ts_all]");
429  var $radio_ts_sel = cj("input[name=radio_ts][value=ts_sel]");
430
431  if (!$radio_ts_sel.length) {
432    $radio_ts_all.prop("checked", true);
433  }
434
435  if ($radio_ts_all.prop("checked") === true || $radio_ts_sel.prop("checked") === true) {
436    status = true;
437  }
438
439  var formElements = ['task', 'Go', 'Print'];
440  for (var i = 0; i < formElements.length; i++) {
441    var $ele = cj('#' + formElements[i]);
442    if ($ele.length) {
443      if (status) {
444        $ele.removeAttr('disabled');
445      } else {
446        $ele.attr('disabled', 'disabled');
447      }
448    }
449  }
450}
451
452/**
453 * This function is used to check if any actio is selected and also to check if any contacts are checked.
454 *
455 * @access public
456 * @param fldPrefix - common string which precedes unique checkbox ID and identifies field as
457 *                    belonging to the resultset's checkbox collection
458 * @param form - name of form that checkboxes are part of
459 * Sample usage: onClick="javascript:checkPerformAction('chk_', myForm );"
460 *
461 */
462function checkPerformAction (fldPrefix, form, taskButton) {
463    var cnt;
464    var gotTask = 0;
465    
466    // taskButton TRUE means we don't need to check the 'task' field - it's a button-driven task
467    if (taskButton == 1) {
468        gotTask = 1;
469    } else if (document.forms[form].task.selectedIndex) {
470	//force user to select all search contacts, CRM-3711
471	if ( document.forms[form].task.value == 13 || document.forms[form].task.value == 14 || document.forms[form].task.value == 20 ) {
472	    var toggleSelect = document.getElementsByName('toggleSelect');
473	    if ( toggleSelect[0].checked || document.forms[form].radio_ts[0].checked ) {
474		return true;
475	    } else {
476		alert( "Please select all contacts for this action.\n\nTo use the entire set of search results, click the 'all records' radio button." );
477		return false;
478	    }
479	}
480	gotTask = 1; 
481    }
482    
483    if (gotTask == 1) {
484        // If user wants to perform action on ALL records and we have a task, return (no need to check further)
485        if (document.forms[form].radio_ts[0].checked) {
486            return true;
487        }
488	
489        cnt = countSelectedCheckboxes(fldPrefix, document.forms[form]);
490        if (!cnt) {
491            alert ("Please select one or more contacts for this action.\n\nTo use the entire set of search results, click the 'all records' radio button.");
492            return false;
493        }
494    } else {
495        alert ("Please select an action from the drop-down menu.");
496        return false;
497    }
498}
499
500/**
501 * This function changes the style for a checkbox block when it is selected.
502 *
503 * @access public
504 * @param chkName - it is name of the checkbox
505 * @param form - name of form that checkboxes are part of
506 * @return null
507 */
508function checkSelectedBox (chkName, form) 
509{
510    var ss = document.forms[form].elements[chkName].name.substring(7,document.forms[form].elements[chkName].name.length);
511    
512    var row = 'rowid' + ss;
513  
514    if (document.forms[form].elements[chkName].checked == true) {
515        // change 'all records' radio to 'selected' if any row is checked
516        document.forms[form].radio_ts[1].checked = true;
517        
518        if (document.getElementById(row).className == 'even-row') {
519            document.getElementById(row).className = 'row-selected even-row';
520        } else {
521            document.getElementById(row).className = 'row-selected odd-row';
522        }
523	
524    } else {
525        if (document.getElementById(row).className == 'row-selected even-row') {
526            document.getElementById(row).className = 'even-row';
527        } else if (document.getElementById(row).className == 'row-selected odd-row') {
528            document.getElementById(row).className = 'odd-row';
529        }
530    }
531}
532
533
534/**
535 * This function is to show the row with  selected checkbox in different color
536 * @param form - name of form that checkboxes are part of
537 *
538 * @access public
539 * @return null
540 */
541
542function on_load_init_checkboxes(form) 
543{
544    var formName = form;
545    var fldPrefix = 'mark_x';
546    for( i=0; i < document.forms[formName].elements.length; i++) {
547	fpLen = fldPrefix.length;
548	if (document.forms[formName].elements[i].type == 'checkbox' && document.forms[formName].elements[i].name.slice(0,fpLen) == fldPrefix ) {
549	    checkSelectedBox (document.forms[formName].elements[i].name, formName); 
550	}
551    }
552    
553}
554
555/**
556 * Function to change the color of the class
557 * 
558 * @param form - name of the form
559 * @param rowid - id of the <tr>, <div> you want to change
560 *
561 * @access public
562 * @return null
563 */
564
565function changeRowColor (rowid, form) {
566
567    switch (document.getElementById(rowid).className) 	{
568    case 'even-row'          : 	document.getElementById(rowid).className = 'selected even-row';
569	break;
570    case 'odd-row'           : 	document.getElementById(rowid).className = 'selected odd-row';
571	break;
572    case 'selected even-row' : 	document.getElementById(rowid).className = 'even-row';
573	break;
574    case 'selected odd-row'  : 	document.getElementById(rowid).className = 'odd-row';
575	break;
576    case 'form-item'         : 	document.getElementById(rowid).className = 'selected';
577	break;
578    case 'selected'          : 	document.getElementById(rowid).className = 'form-item';
579	
580    }
581}
582
583/**
584 * This function is to show the row with  selected checkbox in different color
585 * @param form - name of form that checkboxes are part of
586 *
587 * @access public
588 * @return null
589 */
590
591function on_load_init_check(form) 
592{
593    for( i=0; i < document.forms[form].elements.length; i++) {
594	
595      if (
596          ( document.forms[form].elements[i].type == 'checkbox' && document.forms[form].elements[i].checked == true )
597           ||
598          ( document.forms[form].elements[i].type == 'hidden' && document.forms[form].elements[i].value == 1 )
599         ) {
600              var ss = document.forms[form].elements[i].id;
601		      var row = 'rowid' + ss;
602		      changeRowColor(row, form);
603           }
604    }
605}
606
607/**
608 * reset all the radio buttons with a given name
609 *
610 * @param string fieldName
611 * @param object form
612 * @return null
613 */
614function unselectRadio(fieldName, form)
615{
616  if(typeof form !== 'undefined'){
617    for( i=0; i < document.forms[form].elements.length; i++) {
618      if (document.forms[form].elements[i].name == fieldName) {
619        document.forms[form].elements[i].checked = false;
620      }
621    }
622  }
623  else{
624    var fields = document.getElementsByName(fieldName);
625    for( i=0; i < fields.length; i++) {
626      fields[i].checked = false;
627    }
628  }
629  return;
630}
631
632/**
633 * Function to change button text and disable one it is clicked
634 *
635 * @param obj object - the button clicked
636 * @param formID string - the id of the form being submitted
637 * @param string procText - button text after user clicks it
638 * @return null
639 */
640function submitOnce(obj, formId, procText) {
641    // if named button clicked, change text
642    if (obj.value != null) {
643        obj.value = procText + " ...";
644    }
645}
646
647/**
648 * Function submits referenced form on click of wizard nav link.
649 * Populates targetPage hidden field prior to POST.
650 *
651 * @param formID string - the id of the form being submitted
652 * @param targetPage - identifier of wizard section target
653 * @return null
654 */
655function submitCurrentForm(formId,targetPage) {
656    alert(formId + ' ' + targetPage);
657    document.getElementById(formId).targetPage.value = targetPage;
658    document.getElementById(formId).submit();
659}
660
661/**
662 * Function counts and controls maximum word count for textareas.
663 *
664 * @param essay_id string - the id of the essay (textarea) field
665 * @param wc - int - number of words allowed
666 * @return null
667 */
668function countit(essay_id,wc){
669    var text_area       = document.getElementById("essay_" + essay_id);
670    var count_element   = document.getElementById("word_count_" + essay_id);
671    var count           = 0;
672    var text_area_value = text_area.value;
673    var regex           = /\n/g; 
674    var essay           = text_area_value.replace(regex," ");
675    var words           = essay.split(' ');
676    
677    for (z=0; z<words.length; z++){
678        if (words[z].length>0){
679            count++;
680        }
681    }
682    
683    count_element.value     = count;
684    if (count>=wc) {
685        /*text_area.value     = essay;*/
686
687        var dataString = '';
688        for (z=0; z<wc; z++){
689	  if (words[z].length>0) {
690	    dataString = dataString + words[z] + ' '; 
691	  }
692	}
693
694	text_area.value = dataString; 
695        text_area.blur();
696	count = wc;
697        count_element.value = count;
698        alert("You have reached the "+ wc +" word limit.");
699    }
700}
701
702function popUp(URL) {
703  day = new Date();
704  id  = day.getTime();
705  eval("page" + id + " = window.open(URL, '" + id + "', 'toolbar=0,scrollbars=1,location=0,statusbar=0,menubar=0,resizable=0,width=640,height=420,left = 202,top = 184');");
706}
707
708/**
709 * Function to execute javascript that is assigned to element using innerHTML property
710 *
711 * @param elementName element name, that whose innerHTML is set
712 */
713function executeInnerHTML ( elementName ) 
714{
715    var element   = document.getElementById( elementName );
716    var content   = element.getElementsByTagName('script');
717    var tagLength = content.length;
718    
719    for (var x=0; x<tagLength; x++ ) {
720	var newScript = document.createElement('script');
721	newScript.type = "text/javascript";
722	newScript.text = content[x].text;
723	//execute script
724	element.appendChild(newScript);
725    }
726    
727    for ( var y=0; y<tagLength-1; y++ ) {
728	element.removeChild(element.getElementsByTagName('script')[y]);
729    }
730}
731
732function imagePopUp ( path ) 
733{      window.open(path,'popupWindow','toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=no,resizable=yes,copyhistory=no,screenX=150,screenY=150,top=150,left=150');
734}
735
736/**
737 * Function to show / hide the row in optionFields
738 *
739 * @param element name index, that whose innerHTML is to hide else will show the hidden row.
740 */
741function showHideRow( index )
742{
743   if( index) {
744    cj( 'tr#optionField_' + index ).hide( );
745    if( cj( 'table#optionField tr:hidden:first' ).length )  cj( 'div#optionFieldLink' ).show( );
746   } else {
747    cj( 'table#optionField tr:hidden:first' ).show( );
748    if( ! cj( 'table#optionField tr:hidden:last' ).length ) cj( 'div#optionFieldLink' ).hide( );
749   }
750    return false; 
751}
752
753/**
754 * Function to check activity status in relavent to activity date
755 *
756 * @param element message JSON object.
757 */
758function activityStatus( message )
759{
760    var d = new Date(), time = [], i;
761    var currentDateTime = d.getTime()
762    var activityTime    = cj("input#activity_date_time_time").val().replace(":", "");
763    
764    //chunk the time in bunch of 2 (hours,minutes,ampm)
765	for(i=0; i<activityTime.length; i+=2 ) { 
766        time.push( activityTime.slice( i, i+2 ) );
767    }
768    var activityDate = new Date( cj("input#activity_date_time_hidden").val() );
769      
770    d.setFullYear(activityDate.getFullYear());
771    d.setMonth(activityDate.getMonth());
772    d.setDate(activityDate.getDate());
773    var hours = time['0'];
774    var ampm  = time['2'];
775
776    if (ampm == "PM" && hours != 0 && hours != 12) {
777        // force arithmetic instead of string concatenation
778        hours = hours*1 + 12;
779    } else if (ampm == "AM" && hours == 12) {
780        hours = 0;
781    }
782    d.setHours(hours);
783    d.setMinutes(time['1']);
784
785    var activity_date_time = d.getTime();
786
787    var activityStatusId = cj('#status_id').val();
788
789    if ( activityStatusId == 2 && currentDateTime < activity_date_time ) {
790        if (! confirm( message.completed )) {
791            return false;
792        }
793    } else if ( activity_date_time && activityStatusId == 1 && currentDateTime >= activity_date_time ) {
794        if (! confirm( message.scheduled )) {
795            return false;
796        }
797    } 
798}
799
800function setCookie(cname, cvalue, extsec, path) {
801    extsec = typeof extsec !== 'undefined' ? extsec : 86400;
802    var d = new Date();
803    d.setTime(d.getTime() + (extsec*1000));
804    var expires = "expires=" + d.toGMTString();
805    if (path) {
806      document.cookie = cname+"="+cvalue+"; "+expires+'; path='+path;
807    }
808    else {
809      document.cookie = cname+"="+cvalue+"; "+expires;
810    }
811}
812
813function getCookie(cname) {
814    var name = cname + "=";
815    var ca = document.cookie.split(';');
816    for(var i=0; i<ca.length; i++) {
817        var c = ca[i].trim();
818        if (c.indexOf(name) == 0) return c.substring(name.length, c.length);
819    }
820    return "";
821}
822
823function getUrlParams(name) {
824  // This function is anonymous, is executed immediately and 
825  // the return value is assigned to QueryString!
826  var query_string = {};
827  var query = window.location.search.substring(1);
828  var vars = query.split("&");
829  for (var i=0;i<vars.length;i++) {
830    var pair = vars[i].split("=");
831      // If first entry with this name
832    if (typeof query_string[pair[0]] === "undefined") {
833      query_string[pair[0]] = pair[1];
834      // If second entry with this name
835    }
836    else if (typeof query_string[pair[0]] === "string") {
837      var arr = [ query_string[pair[0]], pair[1] ];
838      query_string[pair[0]] = arr;
839      // If third or later entry with this name
840    }
841    else {
842      query_string[pair[0]].push(pair[1]);
843    }
844  }
845  if(name){
846    if(typeof query_string[name] === 'undefined'){
847      return null;
848    }
849    else{
850      return query_string[name];
851    }
852  }
853  else{
854    return query_string;
855  }
856}
857
858function mdFormElement(type, label, attr){
859  var tag = type == 'select' ? 'select' : 'input';
860  var tag_class = ['form-'+type, 'md-'+type+'-'+tag];
861  var wrap_class = ['crm-form-elem', 'crm-form-'+type, 'md-'+type];
862  var label_class = ['elem-label', 'md-'+type+'-label'];
863  var attributes = ['type="'+ type +'"'];
864  var opt = []
865  var id;
866  for(i in attr) {
867    if(type == 'select' && i == 'values') {
868      opt = attr[i];
869      continue;
870    }
871    if(i == 'class') {
872      tag_class.push(attr[i]);
873    }
874    if(i == 'id'){
875      id = attr[i];
876    }
877    attributes.push(i+'="'+attr[i]+'"')
878  }
879  attributes.push('class="'+ tag_class.join(' ') +'"')
880  var ele = '<' + tag + ' ' + attributes.join(' ') + ' >';
881  if(tag == 'select'){
882    for (i in opt) {
883      ele += '<option value="'+i+'">' + opt[i] + '</option>';
884    }
885    ele += '</'+tag+'>';
886  }
887  var text = '<span class="'+ label_class.join(' ') +'">'+ label +'</span>';
888  var label_for = id ? ' for="'+id+'"' : '';
889  return '<label class="'+ wrap_class.join(' ') +'"' + label_for +'>' + ele + text + '</label>';
890}
891
892(function ($) {
893  // CVE-2015-9251 - Prevent auto-execution of scripts when no explicit dataType was provided
894  $.ajaxPrefilter(function(s) {
895    if (s.crossDomain) {
896      s.contents.script = false;
897    }
898  });
899})(jQuery);

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.