Source: site.view [edit]
Function name: footer
Arguments:
Description:
Page type: text
Render function:  
Module: demavu

Page source:

          <!-- content-wrapper ends -->
          <!-- partial:partials/_footer.html -->
          <footer class="footer">
            <div class="d-sm-flex justify-content-center justify-content-sm-between">
              <span class="text-muted d-block text-center text-sm-right d-sm-inline-block">Copyright (c) 2024, 52 Productions, Inc.</span>
            </div>
          </footer>
          <!-- partial -->
        </div>
        <!-- main-panel ends -->
      </div>
      <!-- page-body-wrapper ends -->
    </div>
    <!-- container-scroller -->
    <!-- plugins:js -->
    <script src="/assets/vendors/js/vendor.bundle.base.js"></script>
    <!-- endinject -->
    <!-- Plugin js for this page -->
    <script src="/assets/vendors/chart.js/Chart.min.js"></script>
    <script src="/assets/vendors/progressbar.js/progressbar.min.js"></script>
    <script src="/assets/vendors/jvectormap/jquery-jvectormap.min.js"></script>
    <script src="/assets/vendors/jvectormap/jquery-jvectormap-world-mill-en.js"></script>
    <script src="/assets/vendors/owl-carousel-2/owl.carousel.min.js"></script>
    <!-- End plugin js for this page -->
    <!-- inject:js -->
    <script src="/assets/js/off-canvas.js"></script>
    <script src="/assets/js/hoverable-collapse.js"></script>
    <script src="/assets/js/misc.js"></script>
    <script src="/assets/js/settings.js"></script>
    <script src="/assets/js/todolist.js"></script>
    <!-- endinject -->
    <!-- Custom js for this page -->
    <script src="/assets/js/dashboard.js"></script>

    <script>


        // Wrap the code inside the window.onload function
        window.onload = function() {

           // For each field of class editable, when it changes, enable the saveButton
          const editableFields = document.querySelectorAll('.editable');
          editableFields.forEach(field => {
             // Get the source input and target field elements
             const sourceInput = document.getElementById(field.id);
             const saveBtn = document.getElementById("saveChangesButton");

             // Listen for changes in the source input
             sourceInput.addEventListener('input', function() {
               saveBtn.disabled = false;
             });
           });

          // For each field of class "imgtext", changing it will update the src of an image with the same id, but txtIDNAME --> imgIDNAME
          const imageTexts = document.querySelectorAll('.imgtext');
          imageTexts.forEach(field => {
             // Get the source input and target field elements
             const sourceInput = document.getElementById(field.id);
             const targetField = document.getElementById(field.id.replace("txt","img"));

             // Listen for changes in the source input
             sourceInput.addEventListener('input', function() {
               // Update the attribute of the target field based on the input's value
               const newValue = sourceInput.value;
               targetField.setAttribute('src', newValue);
             });
           });
        };

        function addHtmlBefore(id, html) {
            // Get the button element by its ID
            var addBeforeElement = document.getElementById(id);
            
            // Insert the new HTML content before the button
            addBeforeElement.insertAdjacentHTML('beforebegin', html);
            const saveBtn = document.getElementById("saveChangesButton");
            saveBtn.disabled = false;
        }

        // Function to call the web service
        // Data returned as a json object
        async function callWebService(url) {
           try {
             // Make the network request
             const response = await fetch(url);

             // Check if the request was successful
             if (!response.ok) {
                throw new Error(`HTTP error! status: ${response.status}`);
             }

             // Get the response
             const data = await response.text();

             // Return the data
             return  data;
           } catch (error) {
              console.error('Error fetching data: ', error);
           }
        }

        function addObject(category) {
           var name = prompt("New " + category.slice(0, -1) + "'s name:", "");

           // Check if the user clicked "OK" and entered something
           if (name !== null) {
              var server = "staging";
              const url = '/site/addRecord(' + server + "," + category + ',' + btoa(removeNonAsciiCharacters(name)) + ')';

              callWebService(url)
                .then(data => {
                  // Handle the data from the web service
                  console.log('Received data:', data);
                  location.reload();
                })
                .catch(error => {
                  // Handle errors
                  console.error('Error calling web service:', error);
                });
           }
        }

        function removeNonAsciiCharacters(inputString) {
          // Replace non-ASCII characters with an empty string
          const asciiString = inputString.replace(/[^\x00-\x7F]/g, '');

          return asciiString;
        }

       function pushToProduction() {
          if (confirm("Are you sure?  This may take a minute or two...")) {
             const url = '/site/copyDB:staging,production';

              callWebService(url)
                .then(data => {
                  // Handle the data from the web service
                  console.log('Received data:', data);
                  alert("Staging has been pushed to production.");
                })
                .catch(error => {
                  // Handle errors
                  console.error('Error calling web service:', error);
                });
          }
       }

       function saveEditableFields() {
          const editableFields = document.querySelectorAll('.editable');

          // Iterate over each field
          editableFields.forEach(field => {
            // Get the ID of the field
            const fieldId = field.id;

            const metaData = field.title;

            // Get the content of the field
            const fieldValue = field.value;
            const server = "staging";

            const url = '/site/updateRecord(' + server + "," + btoa(removeNonAsciiCharacters(metaData)) + "," + btoa(removeNonAsciiCharacters(fieldValue)) + ')';

            callWebService(url)
              .then(data => {
                // Handle the data from the web service
                console.log('title: ', metaData);
                console.log('Value: ', fieldValue);
                console.log('Received data:', data);
                const saveBtn = document.getElementById("saveChangesButton");
                saveBtn.disabled = true;
                location.reload();
              })
              .catch(error => {
                // Handle errors
                console.error('Error calling web service:', error);
              });
        
          });
       }
    </script>

    <!-- End custom js for this page -->
  </body>
</html>