<?php
require_once('config.php');
require_once('inc/header.php');
?>
<main id="main" class="main">
  <div class="row">
    <div class="col-6 align-items-center">
      <div class="pagetitle mb-2">
        <h1><?php echo $page_title ?></h1>
      </div>
    </div>
  </div>
  <section class="section mt-4">
    <div class="row">
      <div class="col-lg-12">
        <div class="row mb-3">
          <div class="col-lg-3 col-md-4">
            <label class="d-block mb-0" for="GLOBAL_SCHEMA">Sitemap Index</label>
          </div>
          <div class="col-md-8">
            <div class="form-group">
            <div class="input-group">
                <a target="_blank" href="<?php echo $site_domain ?>sitemaps/sitemap.xml" class="form-control text-muted overflow-hidden"><?php echo $site_domain ?>sitemaps/sitemap.xml</a>
                <span data-tt-link="<?php echo $site_domain ?>sitemaps/sitemap.xml" class="copy_tt_link input-group-text cursor-pointer" id="basic-addon1">
                    <i class="bi bi-clipboard"></i>
                </span>
              </div>
            </div>
          </div>
        </div>
        <div class="row mb-3">
          <div class="col-lg-3 col-md-4">
            <label class="d-block mb-0" for="GLOBAL_SCHEMA">Page Sitemap</label>
          </div>
          <div class="col-md-8">
            <div class="form-group">
            <div class="input-group">
                <a target="_blank" href="<?php echo $site_domain ?>sitemaps/page-sitemap.xml" class="form-control text-muted overflow-hidden"><?php echo $site_domain ?>sitemaps/page-sitemap.xml</a>
                <span data-tt-link="<?php echo $site_domain ?>sitemaps/page-sitemap.xml" class="copy_tt_link input-group-text cursor-pointer" id="basic-addon1">
                    <i class="bi bi-clipboard"></i>
                </span>
              </div>
            </div>
          </div>
        </div>
        <div class="row mb-3">
          <div class="col-lg-3 col-md-4">
            <label class="d-block mb-0" for="GLOBAL_SCHEMA">Post Sitemap</label>
          </div>
          <div class="col-md-8">
            <div class="form-group">
            <div class="input-group">
                <a target="_blank" href="<?php echo $site_domain ?>sitemaps/post-sitemap.xml" class="form-control text-muted overflow-hidden"><?php echo $site_domain ?>sitemaps/post-sitemap.xml</a>
                <span data-tt-link="<?php echo $site_domain ?>sitemaps/post-sitemap.xml" class="copy_tt_link input-group-text cursor-pointer" id="basic-addon1">
                    <i class="bi bi-clipboard"></i>
                </span>
              </div>
            </div>
          </div>
        </div>
        <div class="row mb-3">
          <div class="col-lg-3 col-md-4">
            <label class="d-block mb-0" for="GLOBAL_SCHEMA">Author Sitemap</label>
          </div>
          <div class="col-md-8">
            <div class="form-group">
            <div class="input-group">
                <a target="_blank" href="<?php echo $site_domain ?>sitemaps/author-sitemap.xml" class="form-control text-muted overflow-hidden"><?php echo $site_domain ?>sitemaps/author-sitemap.xml</a>
                <span data-tt-link="<?php echo $site_domain ?>sitemaps/author-sitemap.xml" class="copy_tt_link input-group-text cursor-pointer" id="basic-addon1">
                    <i class="bi bi-clipboard"></i>
                </span>
              </div>
            </div>
          </div>
        </div>
        <div class="row mb-3">
          <div class="col-lg-3 col-md-4">
            <label class="d-block mb-0" for="GLOBAL_SCHEMA">Gallery Sitemap</label>
          </div>
          <div class="col-md-8">
            <div class="form-group">
            <div class="input-group">
                <a target="_blank" href="<?php echo $site_domain ?>sitemaps/gallery-sitemap.xml" class="form-control text-muted overflow-hidden"><?php echo $site_domain ?>sitemaps/gallery-sitemap.xml</a>
                <span data-tt-link="<?php echo $site_domain ?>sitemaps/gallery-sitemap.xml" class="copy_tt_link input-group-text cursor-pointer" id="basic-addon1">
                    <i class="bi bi-clipboard"></i>
                </span>
              </div>
            </div>
          </div>
        </div>
        <div class="row mb-3">
          <div class="col-lg-3 col-md-4">
            <label class="d-block mb-0" for="GLOBAL_SCHEMA">Websotry Sitemap</label>
          </div>
          <div class="col-md-8">
            <div class="form-group">
            <div class="input-group">
                <a target="_blank" href="<?php echo $site_domain ?>sitemaps/websotry-sitemap.xml" class="form-control text-muted overflow-hidden"><?php echo $site_domain ?>sitemaps/websotry-sitemap.xml</a>
                <span data-tt-link="<?php echo $site_domain ?>sitemaps/websotry-sitemap.xml" class="copy_tt_link input-group-text cursor-pointer" id="basic-addon1">
                    <i class="bi bi-clipboard"></i>
                </span>
              </div>
            </div>
          </div>
        </div>
        <div class="row mb-3">
          <div class="col-lg-3 col-md-4">
            <label class="d-block mb-0" for="GLOBAL_SCHEMA">Topic/Tag Sitemap</label>
          </div>
          <div class="col-md-8">
            <div class="form-group">
            <div class="input-group">
                <a target="_blank" href="<?php echo $site_domain ?>sitemaps/tag-sitemap.xml" class="form-control text-muted overflow-hidden"><?php echo $site_domain ?>sitemaps/tag-sitemap.xml</a>
                <span data-tt-link="<?php echo $site_domain ?>sitemaps/tag-sitemap.xml" class="copy_tt_link input-group-text cursor-pointer" id="basic-addon1">
                    <i class="bi bi-clipboard"></i>
                </span>
              </div>
            </div>
          </div>
        </div>
        <form action="" method="post" enctype="multipart/form-data">
          <?php
          $args = array(
              'fields' => array(
                array(
                    'field_type'     => 'separetor',
                    'field_title'     => 'Custom Schema',
                    'field_desc'  => 'Add Custom Schema For Pages',
                    'field_required' => true,
                ),
                array(
                  'field_id'       => 'GLOBAL_SCHEMA',
                  'field_type'     => 'code',
                  'field_desc'  => 'Global Schema.',
                  'field_title'  => 'Schema for All Page',
                  'field_data' => $_POST['GLOBAL_SCHEMA'],
                ),
                array(
                  'field_id'       => 'HOME_SCHEMA',
                  'field_type'     => 'code',
                  'field_desc'  => 'Homepage Schema.',
                  'field_title'  => 'Schema for Homepage',
                  'field_data' => $_POST['HOME_SCHEMA'],
                ),
                array(
                    'field_id'     => 'update',
                    'field_type'   => 'button',
                    'btn_theme' => 'success',
                    'field_title'   => 'Save Changes',
                )
              )
          );
          AdvanceNews($args);
          ?>
          </form>

       </div>
    </div>
  </section>
</main>
<script>
    document.addEventListener("DOMContentLoaded", function () {
        document.querySelectorAll(".copy_tt_link").forEach(function (btn) {
            btn.addEventListener("click", function () {
                let ttLink = this.getAttribute("data-tt-link"); // Get data-tt-link value
                let icon = this.querySelector("i"); // Find the <i> tag inside the button

                // Copy to clipboard
                navigator.clipboard.writeText(ttLink).then(() => {
                    // Change the icon to clipboard-check
                    icon.classList.replace("bi-clipboard", "bi-clipboard-check");

                    // Revert back to clipboard after 2 seconds
                    setTimeout(() => {
                        icon.classList.replace("bi-clipboard-check", "bi-clipboard");
                    }, 2000);
                }).catch(err => {
                    console.error("Failed to copy:", err);
                });
            });
        });
    });
</script>
<?php require_once('inc/footer.php'); ?>
