PageSourceSearch

https://propertyguardianprotection.com/login/js/portal_editor.js?v=1435934451

js propertyguardianprotection.com collected 2026-09-25 13:04:19 UTC 27,854 bytes, 867 lines download raw bytes

1function Portal_Editor(source_type, source_id, document_id, options=[]) {
2	var table = '<div id="portal_editor_content_holder"><div class="loading" style="padding:20px"><br><i class="fa fa-circle-o-notch fa-spin"></i>&nbsp;Loading</div></div>';
3  	dialog = bootbox.dialog({
4      message: table,
5  	});
6                  
7  	dialog.on('shown.bs.modal', function(e){
8      	$.post('portal_document_editor.php',{source_id:source_id, document_id:document_id, source_type:source_type, params:options}, function(data){
9			$('#portal_editor_content_holder').html(data);
10			start_amc_editor();
11			stop_copy_paste();
12		});
13  	});
14  	
15  	objId = 0;
16	objTxtId = 0;
17	newObjs = 0;
18	idCounter = 0;	
19	toGoto = '';
20	signatureCounter = 0;
21}
22
23var objId = 0;
24var objTxtId = 0;
25var newObjs = 0;
26var idCounter = 0;
27var toGoto = '';
28var signatureCounter = 0;
29/*STOPPING COPY PASTE*/
30
31function stop_copy_paste(){
32	
33	make_editable('set_doc');
34    var ctrlDown = false, ctrlKey = 17, cmdKey = 91, cmdKeyFF = 224, vKey = 86;
35    $(document).keydown(function(e) {
36		if (e.keyCode == ctrlKey || e.keyCode == cmdKey || e.keyCode == cmdKeyFF) ctrlDown = true;
37    }).keyup(function(e) {
38        if (e.keyCode == ctrlKey || e.keyCode == cmdKey || e.keyCode == cmdKeyFF) ctrlDown = false;
39    });
40
41    $('[editable=true]').keydown(function(e) {
42        if (ctrlDown && (e.keyCode == vKey)) {
43            if (e.keyCode == vKey) {
44                console.log('Pasting Disabled');
45
46                bootbox.alert('Copy/Paste has been disabled in edit mode, to paste any content please right-click and select "Paste content" and paste the content in the space provided')
47            }
48            
49            return false;
50        }
51    });
52
53    // Document Ctrl + C/V 
54    $(document).keydown(function(e) {
55        if (ctrlDown && (e.keyCode == cKey)) console.log("Document catch Ctrl+C");
56        if (ctrlDown && (e.keyCode == vKey)) console.log("Document catch Ctrl+V");
57    });
58}
59
60function append_action_box(type, top, left){
61    newObjs++;
62    if(type=='pasteContent'){
63        var html = '<span id="new_obj_'+newObjs+'"></span>';
64        pasteHtmlAtCaret(html);
65        $('.overlay_paste_box').show();
66    	$('.paste_insert_box').html('');
67        
68        $('.save_button_paste_box').attr('object_to_insert',newObjs); 
69        //$('body').append('<div style="top:'+top+'; left:'+left+'" id="content_paste_box_'+newObjs+'" class="content_paste_box"><div class="paste_content" id="content_paste_'+newObjs+'" contenteditable="true"></div> <div class="content_paste_action" ><a href="javascript:;" onclick="add_paste_content('+newObjs+');"><i class="fa fa-save"></i> Save</a> <a href="javascript:;" onclick="cancel_paste_content('+newObjs+');"><i class="fa fa-ban"></i> Cancel</a></div></div>');
70    }
71}	
72	
73function make_editable(elemID){
74
75	$('#'+elemID).addClass('dblclickoption');
76	$('#'+elemID).addClass('editable');
77	$('#'+elemID).addClass('context-menu-one');
78	$('#'+elemID).attr('contenteditable','true');
79	$('.formattingIcons input').bootstrapSwitch();
80	 $.contextMenu({
81		selector: '.context-menu-one', 
82		callback: function(key, opt) {
83			var top = opt.$menu.css('top');
84			var left = opt.$menu.css('left');
85			append_action_box(key, top, left);
86		},
87		items: {
88		 "pasteContent": {name: "Paste content here", icon: ""}
89		}
90	});
91	
92	 
93		/*
94		$('#'+elemID).keyup(function() {
95  			recreate_list_of_merge_fields();
96		});
97		*/
98}
99			
100function pasteHtmlAtCaret(html) {
101    var sel, range;
102    if (window.getSelection) {
103        // IE9 and non-IE
104        sel = window.getSelection();
105        if (sel.getRangeAt && sel.rangeCount) {
106            range = sel.getRangeAt(0);
107            range.deleteContents();
108
109            // Range.createContextualFragment() would be useful here but is
110            // non-standard and not supported in all browsers (IE9, for one)
111            var el = document.createElement("div");
112            el.innerHTML = html;
113            var frag = document.createDocumentFragment(),
114                node, lastNode;
115            while ((node = el.firstChild)) {
116                lastNode = frag.appendChild(node);
117            }
118            range.insertNode(frag);
119
120            // Preserve the selection
121            if (lastNode) {
122                range = range.cloneRange();
123                range.setStartAfter(lastNode);
124                range.collapse(true);
125                sel.removeAllRanges();
126                sel.addRange(range);
127            }
128        }
129    } else if (document.selection && document.selection.type != "Control") {
130        // IE < 9
131        document.selection.createRange().pasteHTML(html);
132    }
133}
134	
135function redo_marking(){
136	remove_highlighting();
137	var regExp = /\[([^)]+)\]/;
138	$("#set_doc").markRegExp(regExp);
139	
140	$('[data-markjs="true"]').each(function(){
141		$(this).addClass($(this).html())
142		$(this).addClass('merge_field');
143		$('#merge_field_list').append('<br>'+$(this).html());	
144	});
145	
146}
147
148function getSelected() {
149	if(window.getSelection) { return window.getSelection(); }
150	else if(document.getSelection) { return document.getSelection(); }
151	else {
152		var selection = document.selection && document.selection.createRange();
153		if(selection.text) { return selection.text; }
154		return false;
155	}
156	return false;
157}
158
159
160function recreate_list_of_merge_fields(){
161	console.log('recreating');
162	idCounter = 0;	
163	$('.marked_text').each(function(){
164		idCounter++;
165		toGoto  = '<p onclick="goTo(\''+idCounter+'\')" id="goToAnchor_'+idCounter+'" class="tags_anchors">'+$(this).html()+'</p>';
166		$(this).addClass($(this).html())
167		$(this).attr('id', idCounter);
168		$(this).addClass('merge_field');
169		
170		$('#merge_field_list').append(toGoto);
171		$(this).bind( "click", function( event ) {
172			$('#goToAnchor_'+$(this).attr('id')).remove(); 
173			//$(this).remove(); 
174		}); 
175	
176	});
177}
178function preset_signee_name(user_id, obj){
179	var search_key = 'id';
180	var val_to_search = user_id;
181	var key_to_val_needed = 'value';
182	$(obj).addClass('signature_selected');
183	var flag_signee = 0;
184	$(known_signees).each(function(index,value){
185	   	if(eval('value.'+search_key) == val_to_search){
186	 		$(obj).html(eval('value.'+key_to_val_needed)) ;
187	   		flag_signee =1;
188	   	}
189	});	
190	if(flag_signee==0){
191		$.post('portal_get_signee_info.php', {user_id:val_to_search}, function(data) {
192			var info = jQuery.parseJSON(data);
193			if(info.success){
194				known_signees.push(info.contact);
195				$(obj).html(info.contact.value) ;
196			}
197	    });
198	}
199}
200
201function start_amc_editor(){
202	
203	$('#set_doc').on("drop", function (e) {
204	 	e.stopPropagation();
205		e.preventDefault();
206		bootbox.alert('Dropping images has been disabled in edit mode');
207    });
208	
209	var options_signing = {};
210	options_signing['className'] = "marked_signature";
211	var regExp_signing = /{signature(.*)}/;
212	$("#set_doc").markRegExp(regExp_signing,options_signing);
213	
214	$('.marked_signature').each(function() {
215		signatureCounter++;
216		var signReg = /\[.*?\]/;
217		var signtag = $(this).html();
218		var userTag = signtag.match(signReg);
219		var userId = '';
220		if(userTag!==null && userTag.length>0){
221			userId = userTag[0];
222			signtag = signtag.replace(userId, '');
223			userId = userId.replace('[','');
224			userId = userId.replace(']','');
225		}
226		else{
227			$(this).html(signtag)
228		}
229		
230		
231		
232	    toGoto = '<p onclick="goTo(\'sign_' + signatureCounter + '\')" id="goToAnchor_sign_' + signatureCounter + '" class="tags_anchors">' + signtag + '</p>';
233	    $(this).addClass(signReg)
234	    
235	    $(this).attr('signee_address_book_id', userId);
236	    $(this).attr('signature_field_id', signtag);
237	    $(this).attr('id', 'sign_' + signatureCounter);
238	    $(this).addClass('merge_field');
239	
240	    $('#merge_field_list').append(toGoto);
241	    
242	    if(subdomain!='pacific'){
243		    $(this).bind("click", function(event) {
244				$('[gotTooltip="yes"]').each(function() {
245		     		$(this).tooltipster('destroy');
246		     		$(this).attr('gotTooltip','no');
247				});
248				
249		        $(this).attr('gotTooltip', 'yes');
250		        var signature_field_id = $(this).attr('id');
251				
252				var signees_select_header = '<p style="padding:7px; background:#FFF;">Please select a signee from the list below<a style="float:right" href="javascript:close_all_tooltipsters();"><i class="fa fa-times" style="color:#60694d;font-size:18px"></i></a></p>';
253				var signees_list_holder = '<div class="list_of_signees_'+signature_field_id+'" style="width:450px; height:200px; padding: 0px 10px; overflow:auto"></div>';
254				var signees_add_footer = '<div style="position:absolute;bottom:0px;left:0px;padding:7px; background:#60694d;color:#FFF;
254cursor:pointer;text-align:center;width:50%" onclick="open_add_signee_box(\''+signature_field_id+'\')">Add new signee</div>';
255				signees_add_footer+='<div style="position:absolute;bottom:0px;right:0px;padding:7px; background:#FF0000;color:#FFF;cursor:pointer;text-align:center;width:50%" onclick="remove_signature_tag(\''+signature_field_id+'\')">Remove</div>';
256				
257				//https://jsfiddle.net/0Lng89tq/2/
258				
259		        $(this).tooltipster({
260		            content: '<div style="position:relative">'+signees_select_header+signees_list_holder+signees_add_footer+'<div>',
261		            contentAsHTML: true,
262		            interactive: true,
263		            trigger: 'custom',
264		            triggerOpen: {
265		                click: true
266		            },
267		            triggerClose: {
268		                click: false,
269		                scroll: false
270		            },
271		            functionReady: function(instance, helper) {
272		            	$('.list_of_signees_'+signature_field_id).html('<i class="fa fa-circle-o-notch fa-spin"></i>&nbsp;Loading');
273						$.post('portal_generate_signees_list.php', {
274		                    users: JSON.stringify(known_signees),
275		                    signature_field: signature_field_id,
276		                    selected_signee : $('#'+signature_field_id).attr('signee_address_book_id')
277		                }, function(data) {
278		                    $('.list_of_signees_'+signature_field_id).html(data);
279		                     
280		                });
281		
282		            }
283		        });
284		        $(this).tooltipster('open');
285		    });
286		    console.log('html : '+$(this).html());
287	    }
288	});
289	
290	var options = {};
291	options['className'] = "marked_text";
292	var regExp = /\[.*?\]/;
293	$("#set_doc").markRegExp(regExp,options);
294
295	$('.marked_text').each(function(){
296	idCounter++;
297	toGoto  = '<p onclick="goTo(\''+idCounter+'\')" id="goToAnchor_'+idCounter+'" class="tags_anchors">'+$(this).html()+'</p>';
298	$(this).addClass($(this).html())
299	$(this).attr('id', idCounter);
300	$(this).addClass('merge_field');
301	
302	$('#merge_field_list').append(toGoto);
303	$(this).bind( "click", function( event ) {
304		$('#goToAnchor_'+$(this).attr('id')).remove(); 
305		$(this).remove(); 
306	}); 
307	
308	});
309		
310	check_esign_package_new();
311	
312	amc_editor_toggle_esign_pref();
313
314}
315
316function amc_editor_toggle_esign_pref(){
317	check_if_doc_ready();
318	if(!$('#send_to_esign').is(':checked')){
319		$('.marked_signature').each(function() {
320			$(this).hide();$(this).html('');
321			$('#goToAnchor_'+$(this).attr('id')).hide();
322		});
323	}
324	else{
325		check_esign_package();
326		$('.marked_signature').each(function() {
327			$(this).show();
328			
329			var userId = $(this).attr('signee_address_book_id');
330			console.log('found : '+userId);
331			if(userId!=""){
332				preset_signee_name(userId, $(this));
333			}
334			else{
335				$(this).html($(this).attr('signature_field_id'));
336			}
337			$('#goToAnchor_'+$(this).attr('id')).show();
338		});	
339		assign_this_signee(landlord_id, 'sign_1');
340	}
341}
342
343function check_esign_package_new(){
344	$.post("portal_check_esign_package.php", function(data) {
345		var info = jQuery.parseJSON(data);
346		if(info.success){
347			$('#send_to_esign').prop('checked', true).change();
348			return false;
349		}else{
350			$('#package_status').html(info.response);
351			$('#send_to_esign').prop('checked', false).change();
352			return false;
353		}
354	});
355}
356
357function check_esign_package(){
358	$.post("portal_check_esign_package.php", function(data) {
359		var info = jQuery.parseJSON(data);
360		if(info.success){
361			//console.log("sss");
362			//$('#send_to_esign').prop('checked', true);
363			//assign_this_signee(landlord_id, 'sign_1');
364			$('#package_status').html('');
365		}else{
366			$('#package_status').html(info.response);
367			$('#send_to_esign').prop('checked', false).change();
368		}
369	});
370}
371
372function check_if_doc_ready(){
373	$('#merge_field_list p').each(function(){
374		//console.log($(this).html() + $(this).css('display'));	
375	});
376}
377
378function open_add_signee_box(signee_field_id){
379 
380	$('.ovelay_box_from_top').show();
381 	$('#new_signee_save').attr('signee_field_id',signee_field_id); 
382}
383
384function get_value_from_object(obj, search_key, val_to_search, key_to_val_needed){
385	$(known_signees).each(function(index,value){
386	   	if(eval('value.'+search_key) == val_to_search)
387	 	return (eval('value.'+key_to_val_needed)) 
388	});	
389}
390
391function assign_this_signee(obj, signature_field){
392	
393	$('#'+signature_field).attr('signee_address_book_id', obj);
394 	
395 	var search_key = 'id';
396	var val_to_search = obj;
397	var key_to_val_needed = 'value';
398	
399	$('#'+signature_field).addClass('signature_selected');
400	
401	$(known_signees).each(function(index,value){
402	   	if(eval('value.'+search_key) == val_to_search){
403	 	$('#'+signature_field).html(eval('value.'+key_to_val_needed)) ;
404	   		close_all_tooltipsters();
405	   	}
406	});	
407	
408}
409
410
411
412function close_all_tooltipsters(){
413	$('[gotTooltip="yes"]').each(function() {
414     		$(this).tooltipster('destroy');
415     		$(this).attr('gotTooltip','no');
416	});
417}
418
419function add_paste_content(){
420	var n = $('.save_button_paste_box').attr('object_to_insert');
421    var html = $('.paste_insert_box').html();
422    $('.hide_while_loading').hide();
423    $('.show_while_loading').show();
424     
425    $.post("portal_clean_html.php", { content: html }, function(data) {
426		$('#new_obj_'+n).replaceWith(data);
427        //$('#content_paste_box_'+n).remove();
428        $('.hide_while_loading').show();
429        $('.show_while_loading').hide();
430        $('.overlay_paste_box').hide();
431	});
432    
433}
434
435function cancel_add_signee(){
436	$('#new_signee_name').val('');
437	$('#new_signee_email').val(''); 
438	$('#new_signee_save').attr('signee_field_id',''); 
439	$('.ovelay_box_from_top').hide();	
440}
441
442function cancel_paste_content(){
443	var n = $('.save_button_paste_box').attr('object_to_insert');
444    $('#new_obj_'+n).replaceWith('');
445    //$('#content_paste_box_'+n).remove();
446    $('.overlay_paste_box').hide();
447}
448
449function remove_highlighting(){
450	$('.marked_text').each(function(){
451		$(this).unmark();
452	});
453	$('.marked_signature').each(function(){
454		signature_field_html = $(this).attr('signature_field_id');
455		if($(this).attr('signee_address_book_id')){
456			signee_address_book_id =  $(this).attr('signee_address_book_id');
457			new_value = signature_field_html.replace("}","["+signee_address_book_id+"]}");
458			$(this).html(new_value);
459		}
460		else{
461			$(this).html(signature_field_html);
462		}
463		$(this).unmark();
464	});
465}
466
467function remove_signature_tag(sign_name){
468	$('#'+sign_name).remove();
469	$('#goToAnchor_'+sign_name).remove();
470}
471
472function add_signees_in_right_field(){
473	var signature_field_html;
474	var new_value;
475	var signee_address_book_id;
476	
477	var all_good=0;
478	
479	$('.marked_signature').each(function(){
480		signature_field_html = $(this).attr('signature_field_id');
481		if($(this).attr('signee_address_book_id')){
482			signee_address_book_id =  $(this).attr('signee_address_book_id');
483			new_value = signature_field_html.replace("}","["+signee_address_book_id+"]}");
484			$(this).html(new_value);
485		}
486		else{
487			all_good = 1;
488		}
489		$(this).unmark();
490	});
491	
492	if(all_good == 0)
493	return true;
494	else
495	return false;
496}
497
498function check_all_fields(){
499	// var all_good=0;
500	// $('.marked_text').each(function(){
501	// 	console.log('Cheking'+ $(this));
502	// 	all_good = 1;	
503	// });
504	// if(all_good == 0)
505	// return true;
506	// else
507	// return false;
508	
509	return true;
510	
511}
512
513function save_new_signee(signee_field_obj){
514	
515	var error = 0;
516	var signee_field_id = $(signee_field_obj).attr('signee_field_id');
517	var new_signee_name = $('#new_signee_name').val();
518	var new_signee_email = $('#new_signee_email').val();
519	
520	if(new_signee_name!=''){
521		$('#new_signee_name').css('border-color','');
522	}else{
523		$('#new_signee_name').css('border-color','#fd0000');
524		error++;
525	}
526	
527	if(new_signee_email!=''){
528		$('#new_signee_email').css('border-color','');
529	}else{
530		$('#new_signee_email').css('border-color','#fd0000');
531		error++;
532	}
533	
534	$('#signee_error').html('<i class="fa fa-circle-o-notch fa-spin"></i>&nbsp;Saving');
535	if(error==0){
536		$.post('portal_save_signees_list.php', {new_signee_name: new_signee_name,new_signee_email: new_signee_email,signee_field_id:signee_field_id}, function(data) {
537			var info = jQuery.parseJSON(data);/**VINOSH : INJECT IN KNOWN SIGNESS**/
538			if(info.success){
539				known_signees.push(info.contact);
540				$('.list_of_signees_'+signee_field_id).append(info.response);
541	    		cancel_add_signee(); 
542			}else{
543				$('#signee_error').html('<label style="color:#ff0000;font-weight:bold;font-size:14px;">'+info.response+'</label>');
544			}
545	    });
546	}
547}
548
549function just_print_pdf(){
550	if($('input[type=radio][name=haveref]').length > 0){
551		var radioValue = $("input[type=radio][name=haveref]:checked").val();
552		if(radioValue == 'No'){
553			$(".haveref_show_hide").remove();
554		}
555	}
556	
557	var attach_how_to_rent = 0;
558	var attach_dps_privacy_notice = 0;
559	var attach_epc=0;
560	var epc_file_names;
561	var epc_property_id;
562	$('.marked_signature').each(function(){
563		$(this).remove();
564	});
565	if($('#attach_how_to_rent').length>0 && $('#attach_how_to_rent').is(':checked')){
566		attach_how_to_rent = 1;
567	}
568	if($('#attach_epc').length>0 && $('#attach_epc').is(':checked')){
569		attach_epc = 1;
570		epc_file_names=$('#epc_file_names').val();
571		epc_property_id=$('#epc_property_id').val();
572	}
573	if($('#attach_dps_privacy_notice').length>0 && $('#attach_dps_privacy_notice').is(':checked') && status==0){
574		attach_dps_privacy_notice = 1;
575	}
576	if($('#attach_how_to_rent_section').length>0){
577		$('#attach_how_to_rent_section').hide();
578	}
579	if($('#attach_dps_private_notice_section').length>0){
580		$('#attach_dps_private_notice_section').hide();
581	}
582	$('.amc_editor_actions').html('<span class="alert alert-warning open">Please wait...while downloading</span>')
583	remove_highlighting(); 
584	var html = $('#set_doc').html();
585	$.post('portal_document_print.php',{ epc_property_id:epc_property_id,epc_file_names:epc_file_names, attach_epc:attach_epc,  html_content:html,document_type:document_type,attach_how_to_rent:attach_how_to_rent,attach_dps_privacy_notice:attach_dps_privacy_notice}, function(data){
586		var info = jQuery.parseJSON(data);
587		if(info.success){
588			$('#amc_editor_status').attr('class', 'alert alert-success');
589			if(status==0){
590				var popup = window.open(info.response);
591				popupBlockerChecker.check(popup, 'Click <a href="'+info.response+'" target="_blank">here</a> to open the generated file', 'amc_editor_status');
592				if(dialog){
593			        dialog.modal('hide');
594			    }
595			}
596			else{
597				$('#amc_editor_status').html('Saved. Closing in 3 seconds');
598			}
599		}
600	})
601}
602
603function submit_html_page(status){
604	if($('input[type=radio][name=haveref]').length > 0){
605		var radioValue = $("input[type=radio][name=haveref]:checked").val();
606		if(radioValue == 'No'){
607			$(".haveref_show_hide").remove();
608		}
609	}
610	
611	$('.gas_supply_pdf[style*="display: none"]').remove();
612	$('.epc_pdf[style*="display: none"]').remove();
613	$('.eicr_pdf[style*="display: none"]').remove();
614	
615	var can_proceed = 0, sendtoesign = 0, attach_how_to_rent = 0, attach_dps_privacy_notice = 0;
616	var attach_epc=0;
617	var epc_file_names;
618	var epc_property_id;
619	var document_subcategory=$("#document_subcategory").val();
620	if($('#send_to_esign').is(':checked')){
621		sendtoesign = 1;
622		if(!add_signees_in_right_field())
623		can_proceed = 1;
624	}else{
625		$('.marked_signature').each(function(){
626			$(this).remove();
627		});
628	}
629	
630	if($('#attach_how_to_rent').length>0 && $('#attach_how_to_rent').is(':checked') && status==0){
631		attach_how_to_rent = 1;
632	}
633	if($('#attach_dps_privacy_notice').length>0 && $('#attach_dps_privacy_notice').is(':checked') && status==0){
634		attach_dps_privacy_notice = 1;
635	}
636	if($('#attach_epc').length>0 && $('#attach_epc').is(':checked')){
637		attach_epc = 1;
638		epc_file_names=$('#epc_file_names').val();
639		epc_property_id=$('#epc_property_id').val();
640	}
641	
642	convertSelectToInput('type_of_landlord');
643	convertSelectToInput('resident');
644	convertSelectToInput('property_hold');
645	convertSelectToInput('furnishing_options');
646	convertSelectToInput('parking');
647	convertSelectToInput('representatives');
648	convertSelectToInput('holding');
649	convertSelectToTd('gas_supply');
650	convertSelectToTd('corgi_certificate');
651	convertSelectToTd('business_term');
652	convertSelectToTd('epc_certificates');
653	convertSelectToTd('business_terms_1');
654	convertSelectToTd('eicr_certificates');
655	convertSelectToTd('business_terms_2');
656	// return false;
657	
658	if(status==1 || (can_proceed == 0 && check_all_fields())){
659		if($('#attach_how_to_rent_section').length>0){
660			$('#attach_how_to_rent_section').hide();
661		}
662		if($('#attach_dps_private_notice_section').length>0){
663			$('#attach_dps_private_notice_section').hide();
664		}
665		remove_highlighting(); 
666		var document_title = $("#doc_title").val();
667		var html = $('#set_doc').html();
668		$('.amc_editor_actions').find('.amc_editor_action_wrapper').hide();
669		$('.amc_editor_actions').append('<div id="amc_editor_status" class="alert alert-warning">Saving...</div>');
670		$.post('portal_document_save.php', {document_subcategory:document_subcategory, epc_property_id:epc_property_id,epc_file_names:epc_file_names, attach_epc:attach_epc,html_content:html, source_id:source_id, source_type:source_type, property_branch_id:property_branch_id, document_id:document_id, document_header:document_header, document_footer:document_footer, draft_id:draft_id, document_title:document_title, document_type:document_type, save_or_publish:status, send_to_sign:sendtoesign,document_editable:document_editable,attach_how_to_rent,attach_dps_privacy_notice:attach_dps_privacy_notice}, function(data){
671			var info = jQuery.parseJSON(data);
672			if(info.success){
673				$('#amc_editor_status').attr('class', 'alert alert-success');
674				if(status==0){
675					//$('#amc_editor_status').html('Saved. Click <a href="'+info.response+'" target="_blank">here</a> to view');
676					//$('<tr><td>Stuff</td></tr>').insertBefore('table > tbody > tr:first');
677					
678					var popup = window.open(info.response);
679					popupBlockerChecker.check(popup, 'Click <a href="'+info.response+'" target="_blank">here</a> to open the generated file', 'amc_editor_status');
680					
681				}
682				else{
683					$('#amc_editor_status').html('Saved. Closing in 3 seconds');
684				
685				}
686				$(".no_doc_list").remove();
687				var recently_added_row = info.recently_added_row;
688				if(recently_added_row!="")
689				add_result_row_to_table('table_list_of_generated_documents', recently_added_row, 'top');
690				else if(document_editable==1)
691				location.reload();
692				close_bootbox_in_few_seconds(3000);
693				
694			
695			}
696			else{
697				bootbox.alert(info.response);
698				setTimeout(function(){
699					$('#amc_editor_status').remove();
700					$('.amc_editor_actions').find('.amc_editor_action_wrapper').show();
701				}, 2000);
702				
703			}
704		})
705	}
706	else{
707		$('.tags_anchors').each(function() {
708     		$(this).css('color', '#FF0000');
709		});
710		 bootbox.alert("Please check the fileds marked in red before generating the PDF");
711	}
712}
713
714
715function format_text(style){
716		//https://developer.mozilla.org/en-US/docs/Web/API/Document/execCommand
717	console.log(style);
718	 
719	if(style=="bold")
720	document.execCommand('bold');
721	
722	else if(style=="italic")
723	document.execCommand('italic');
724	
725	else if(style=="underline")
726	document.execCommand('underline');
727	
728	else if(style=="center")
729	document.execCommand('justifyCenter');
730	
731		else if(style=="left")
732	document.execCommand('justifyLeft');
733	
734	else if(style=="right")
735	document.execCommand('justifyRight');
736	
737	else if(style=="undo")
738	document.execCommand('undo');
739	
740	else if(style=="increaseFontSize"){
741	document.execCommand('increaseFontSize'); 
742	}
743	else if(style=="decreaseFontSize"){
744	document.execCommand('decreaseFontSize'); 
745	}
746}
747
748function goTo(elemID){
749	
750	var container = $('.amc_editor_box');
751	var targetElm = $("#"+elemID);
752	scrollToElm( container, targetElm , 1 );   
753	
754}
755
756function scrollToElm(container, elm, duration){
757  var pos = getRelativePos(elm, container);
758  scrollTo( container, (pos.top)-50 , 2);  // duration in seconds
759}
760
761function getRelativePos(elm, container){
762  var pPos = container[0].getBoundingClientRect(), // parent pos
763      cPos = elm[0].getBoundingClientRect(), // target pos
764      pos = {};
765
766  pos.top    = cPos.top    - pPos.top + container[0].scrollTop,
767  pos.right  = cPos.right  - pPos.right,
768  pos.bottom = cPos.bottom - pPos.bottom,
769  pos.left   = cPos.left   - pPos.left;
770
771  return pos;
772}
773    
774function scrollTo(element, to, duration, onDone) {
775    var start = element[0].scrollTop,
776        change = to - start,
777        startTime = performance.now(),
778        val, now, elapsed, t;
779
780    function animateScroll(){
781        now = performance.now();
782        elapsed = (now - startTime)/1000;
783        t = (elapsed/duration);
784
785        element[0].scrollTop = start + change * easeInOutQuad(t);
786
787        if( t < 1 )
788            window.requestAnimationFrame(animateScroll);
789        else
790            onDone && onDone();
791    };
792
793    animateScroll();
794}
795
796function convertSelectToInput(selectId) {
797      const selectElement = document.getElementById(selectId);
798      if(typeof(selectElement) != 'undefined' && selectElement != null){
799      const inputElement = document.createElement('p');
800      const node = document.createTextNode($("#"+selectId+" option:selected").text());
801	  inputElement.appendChild(node);
802      //inputElement.type = 'text';
803      inputElement.id = selectId;
804
805      // Copy selected option value to the new input field, if an option is selected
806      // inputElement.value = selectElement.value;
807      //inputElement.setAttribute('value',$("#"+selectId+" option:selected").text());
808      inputElement.style.border = '1px solid black';
809      inputElement.style.paddingLeft = '10px';
810      inputElement.style.width = '100%';
811      inputElement.style.height = '25px';
812      inputElement.style.lineHeight = '25px';
813      
814      
815       
816       
817      // Append the new input element after the select element
818      selectElement.insertAdjacentElement('afterend', inputElement);
819
820      // Hide the select element
821      selectElement.remove();
822      }
823     
824}
825
826function convertSelectToTd(selectId) {
827        const selectElement = document.getElementById(selectId);
828        if(typeof(selectElement) != 'undefined' && selectElement != null){
829          const tdElement = document.getElementById(selectId+'_td');
830          tdElement.innerHTML = $("#"+selectId+" option:selected").text();
831          tdElement.id = selectId;
832          // Copy selected option value to the new input field, if an option is selected
833          tdElement.style.verticalAlign = 'top';
834          tdElement.style.borderCollapse = 'collapse';
835          tdElement.style.border = '1px solid #000';
836          tdElement.style.padding = '10px';
837          // Hide the select element
838          selectElement.remove();
839        }
840    }
841
842function easeInOutQuad(t){ return t<.5 ? 2*t*t : -1+(4-2*t)*t };
843
844function delete_propertydocument(doc_id){
845		$.confirm({
846        'title'     : 'Are you sure?',
847        'message'   : 'This document will be deleted permanently',
848        'type'      : 'confirm',
849        'buttons'   : {
850            'OK'   : {
851                'class' : 'ok_btn',
852                'action': function(){
853                    $.post('portal_delete_property_document.php', {cid:doc_id}, function(data){
854						var info = jQuery.parseJSON(data);
855						if(info.success){
856							location.reload();
857						}
858					});
859                }
860            },
861            'CANCEL'    : {
862                'class' : 'cancel_btn',
863                'action': function(){} 
864            }
865        }
866    });
867}

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.