JAVASCRIPT 47
Admin-wordpress.js Guest on 24th July 2020 12:54:09 PM
  1. //this file has functions to read from the wp-config setting textbox
  2.  
  3. window.defineAdminYetience = function () {
  4.     yetience.loadApp(yetience.path + "/admin-interface", function () {
  5.         //console.log('Scripts and styles loaded in ' + (Date.now() - autience_initiated_at) + ' milliseconds')
  6.         angular.element(document).ready(function () {
  7.             angular.bootstrap(document, ['yetienceApp'])
  8.  
  9.             document.getElementById('footer-thankyou').innerHTML += " Thank you for using <a href='http://www.yeloni.com' target='_blank'>Yeloni.</a>";
  10.         })
  11.     })
  12.  
  13.     yetience.platform = 'wordpress'
  14.  
  15.     yetience.website_saved = false
  16.     yetience.readFromPlatform = function () {
  17.         var encoded_setup = yetience.encoded_setup //document.getElementById('yetience_setup').value
  18.         if (encoded_setup && encoded_setup.length > 1) {
  19.             //decode and return
  20.             var setup = decodeURIComponent(window.atob(encoded_setup))
  21.             yetience.website_saved = true
  22.             return JSON.parse(setup)
  23.         } else {
  24.             return {
  25.                 need_api_key: true,
  26.                 widgets: []
  27.             }
  28.         }
  29.     }
  30.  
  31.  
  32.     yetience.saveToPlatform = function (setup, message, label, disable_undo) {
  33.         //if (!yetience.isCyclic(setup)) {
  34.         document.getElementById('yetience_setup').value = window.btoa(encodeURIComponent(JSON.stringify(setup)))
  35.  
  36.         document.getElementById('autience-save-message').innerHTML = message
  37.         if (!disable_undo) {
  38.             document.getElementById('autience-undo-message').style.display = 'block'
  39.         } else {
  40.             document.getElementById('autience-undo-message').style.display = 'none'
  41.         }
  42.         document.getElementById('yetience_submit_button').getElementsByTagName('input')[0].value = label
  43.         yetience.readyToSave()
  44.         //}
  45.  
  46.     }
  47.  
  48.     yetience.readyToSave = function () {
  49.         document.getElementById("yetience_submit_button").style.display = 'block'
  50.  
  51.         //scroll to top
  52.         document.body.scrollTop = document.documentElement.scrollTop = 0;
  53.     }
  54.  
  55.     yetience.isCyclic = function (obj) {
  56.         var seenObjects = [];
  57.  
  58.         function detect(obj) {
  59.             if (obj && typeof obj === 'object') {
  60.                 if (seenObjects.indexOf(obj) !== -1) {
  61.                     return true;
  62.                 }
  63.                 seenObjects.push(obj);
  64.                 for (var key in obj) {
  65.                     if (obj.hasOwnProperty(key) && detect(obj[key])) {
  66.                         console.log(obj, 'cycle at ' + key);
  67.                         return true;
  68.                     }
  69.                 }
  70.             }
  71.             return false;
  72.         }
  73.  
  74.         return detect(obj);
  75.     }
  76. }

Paste is for source code and general debugging text.

Login or Register to edit, delete and keep track of your pastes and more.

Raw Paste

Login or Register to edit or fork this paste. It's free.