<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-6 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>Footer Content<span style="color:#ff0000;"></span></label>
		<textarea name="footer_content" id="footer_content" class="form-control" rows="15"><?php echo !empty($edit[0]->footer_content) ? $edit[0]->footer_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($footerimagedetails)){ ?>
	<h5>Uploaded Images</h5>
	<?php foreach($footerimagedetails 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-12 mb-3">
		<label>External JS<span style="color:#ff0000;"></span></label>
		<textarea name="external_js" id="external_js" class="form-control" rows="15"><?php echo !empty($edit[0]->external_js) ? $edit[0]->external_js : "";?></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">
		<!{1}**<div id="preview" style="margin-top:10px;"></div>**{1}>
		<?php if(!empty($edit[0]->favicon)){?>
		<h5>Current Favicon</h5>
		<div id="preview1" style="margin-top:10px;"><img src="<?php echo base_url().$edit[0]->favicon; ?>" width="100" height="auto"></div>
		<?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-8 mb-3">
		<label>Upload JS Files<span style="color:#ff0000;"></span></label>
		<input type="file" name="js[]" id="js" class="form-control" multiple >
	</div>
	<?php if(!empty($footerdetails)){ ?>
	<h5>Uploaded JS</h5>
	<?php foreach($footerdetails as $hd){
	// Original string
	$string = $hd->js;
	$js_text = str_replace('pages/'.$edit[0]->page_slug.'/js/',"",$string);
	?>
	<p id="js_<?php echo $hd->id; ?>"><?php echo $js_text; ?><span style="margin-left:10px;"><button type="button" class="btn btn-danger" onclick="deleteJS('<?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>
