<div class="row mb-3">
	<div class="col-sm-6 mb-3">
		<label>Select Page<span style="color:#ff0000;">*</span></label>
		<select class="form-control bg-light border-0" id="page" name="page" required>
		<option value="">Select</option>
		<?php foreach($pages as $pg){ ?>
		<option value="<?php echo $pg->page_name;?>" <?php echo !empty($edit[0]->page) ? $edit[0]->page == $pg->page_name ? "selected" : "": "";?>><?php echo $pg->page_name;?></option>
		<?php } ?>
		</select>
		<input type="hidden" name="id" id="id" value="<?php echo !empty($edit[0]->id) ? $edit[0]->id : "";?>"/>											

	</div>
	<div class="clearfix"></div>
	<div class="col-sm-12 mb-3">
		<label>Title<span style="color:#ff0000;">*</span></label>
	    <input type="text" name="header_title" id="header_title" value="<?php echo !empty($edit[0]->header_title) ? $edit[0]->header_title : "";?>" class="form-control" required />											
	</div>
	<div class="clearfix"></div>
	<div class="col-sm-12 mb-3">
		<label>Json Script<span style="color:#ff0000;"></span></label>
		<textarea name="json_script" id="json_script" class="form-control" rows="15"><?php echo !empty($edit[0]->json_script) ? $edit[0]->json_script : "";?></textarea>
	</div>
	<div class="clearfix"></div>
	<div class="col-sm-12 mb-3">
		<label>Cannonical Tag<span style="color:#ff0000;"></span></label>
		<textarea name="cannonical_tag" id="cannonical_tag" class="form-control" rows="15"><?php echo !empty($edit[0]->cannonical_tag) ? $edit[0]->cannonical_tag : "";?></textarea>
	</div>
	<div class="clearfix"></div>
	<div class="col-sm-12 mb-3">
		<label>Meta Content<span style="color:#ff0000;"></span></label>
		<textarea name="meta_content" id="meta_content" class="form-control" rows="15"><?php echo !empty($edit[0]->meta_content) ? $edit[0]->meta_content : "";?></textarea>
	</div>
	<div class="clearfix"></div>
	<div class="col-sm-12 mb-3">
		<label>Social Media Tag<span style="color:#ff0000;"></span></label>
		<textarea name="social_media_tag" id="social_media_tag" class="form-control" rows="15"><?php echo !empty($edit[0]->social_media_tag) ? $edit[0]->social_media_tag : "";?></textarea>
	</div>
	<div class="clearfix"></div>
	<div class="col-sm-12 mb-3">
		<label>Author/Image Attribute<span style="color:#ff0000;"></span></label>
		<textarea name="author_image_attribute" id="author_image_attribute" class="form-control" rows="15"><?php echo !empty($edit[0]->author_image_attribute) ? $edit[0]->author_image_attribute : "";?></textarea>
	</div>
	<div class="clearfix"></div>
	<div class="col-sm-8 mb-3">
		<label>Upload Favicon<span style="color:#ff0000;"></span></label>
		<input type="file" name="favicon" id="favicon" class="form-control">
	</div>
	<div class="clearfix"></div>
	<div class="col-sm-6 mb-3">
		<!--<div id="preview" style="margin-top:10px;"></div>-->
		<?php if(!empty($edit[0]->favicon)){?>
		<h5>Current Favicon</h5>
		<div id="preview1" style="margin-top:10px;margin-bottom:10px;"><img src="<?php echo base_url().$edit[0]->favicon; ?>" width="100" height="auto"></div>
		<?php
		// Original string
		$string1 = $edit[0]->favicon;
		$image_text1 = str_replace('pages/'.$edit[0]->page_slug.'/images/',"",$string1);
		$original_url1=base_url().$string1;
		?>
	    <input type="text" value="<?php echo $original_url1; ?>" id="myInput<?php echo $edit[0]->id; ?>" style="display:none;">
		<p id="image_<?php echo $edit[0]->id; ?>"><?php echo $image_text1; ?><span style="margin-left:10px;"><button type="button" class="btn btn-success" onclick="copyLink('<?php echo $edit[0]->id; ?>');">Copy Link</button></span></p>
		<?php } ?>
		<input type="hidden" name="oldImage" id="oldImage" class="form-control" value="<?php echo empty($edit[0]->favicon) ? "":$edit[0]->favicon; ?>" />											
	</div>
	<div class="clearfix"></div>
	<div class="col-sm-12 mb-3">
		<label>Favicon Content<span style="color:#ff0000;"></span></label>
	    <input type="text" name="favicon_content" id="favicon_content" value='<?php echo !empty($edit[0]->favicon_content) ? $edit[0]->favicon_content : "";?>' class="form-control"/>											
	</div>
	<div class="clearfix"></div>
	<div class="col-sm-12 mb-3">
		<label>External CSS<span style="color:#ff0000;"></span></label>
		<textarea name="external_css" id="external_css" class="form-control" rows="15"><?php echo !empty($edit[0]->external_css) ? $edit[0]->external_css : "";?></textarea>
	</div>
	<div class="col-sm-12 mb-3">
		<label>Header Content<span style="color:#ff0000;"></span></label>
		<textarea name="header_content" id="header_content" class="form-control" rows="15"><?php echo !empty($edit[0]->header_content) ? $edit[0]->header_content : "";?></textarea>
	</div>
	<div class="clearfix"></div>
	<div class="col-sm-8 mb-3">
		<label>Upload Images<span style="color:#ff0000;"></span></label>
		<input type="file" name="image[]" id="image" class="form-control" multiple >
	</div>
	<?php if(!empty($headerimagedetails)){ ?>
	<h5>Uploaded Images</h5>
	<?php foreach($headerimagedetails as $hd){
	
	// Original string
	$string = $hd->image;
	$image_text = str_replace('pages/'.$edit[0]->page_slug.'/images/',"",$string);
	$original_url=base_url().$hd->image;
	//$short_url=get_tiny_url($original_url);
	?>
	<input type="text" value="<?php echo $original_url; ?>" id="myInput<?php echo $hd->id; ?>" style="display:none;">
	<p id="image_<?php echo $hd->id; ?>"><?php echo $image_text; ?><span style="margin-left:10px;"><button type="button" class="btn btn-success" onclick="copyLink('<?php echo $hd->id; ?>');">Copy Link</button>&nbsp;&nbsp;<button type="button" class="btn btn-danger" onclick="deleteImage('<?php echo $hd->id; ?>');">Delete</button></span></p>
	<?php } ?>
	<?php } ?>
	<div class="clearfix"></div>
	<div class="col-sm-8 mb-3">
		<label>Upload CSS Files<span style="color:#ff0000;"></span></label>
		<input type="file" name="css[]" id="css" class="form-control" multiple >
	</div>
	<?php if(!empty($headerdetails)){ ?>
	<h5>Uploaded CSS</h5>
	<?php foreach($headerdetails as $hd){
	// Original string
	$string = $hd->css;
	$css_text = str_replace('pages/'.$edit[0]->page_slug.'/css/',"",$string);
	?>
	<p id="css_<?php echo $hd->id; ?>"><?php echo $css_text; ?><span style="margin-left:10px;"><button type="button" class="btn btn-danger" onclick="deleteCSS('<?php echo $hd->id; ?>');">Delete</button></span></p>
	<?php } ?>
	<?php } ?>
	
</div>
<script>
function copyLink(id) { 
  // Get the text field
  var copyText = document.getElementById("myInput"+id);

  // Select the text field
  copyText.select();
  copyText.setSelectionRange(0, 99999); // For mobile devices

   // Copy the text inside the text field
  navigator.clipboard.writeText(copyText.value);

  // Alert the copied text
  alert("Link Copied: " + copyText.value);
}
</script>
