Advertisement
Guest User

Untitled

a guest
Aug 22nd, 2019
120
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. jQuery(document).ready(function ($) {
  2.     var target = document.getElementById('search-result');
  3.     var config = {
  4.         childList: true
  5.     };
  6.     //note this observe method
  7.     observer.observe(target, config);
  8.     // console.log("registered");
  9. });
  10.  
  11. var success = function(data) {
  12.     loc = getUrlParameter('search_location').split(', ')[0];
  13.     if (typeof category !== 'undefined' || category !== null) {
  14.         loc.length > 0 ? loc += " közelében" : loc = "";
  15.         title.innerText = data[0] + " magántanár " + loc;
  16.         desc.innerText = data[1];
  17.     }
  18. };
  19.  
  20. var observer = new MutationObserver(function (mutationRecords, observer) {
  21.     mutationRecords.forEach(function (mutation) {
  22.         title = document.getElementById("search-cat-title");
  23.         desc = document.getElementById("search-cat-desc");
  24.         window.category = CASE27_Explore_Settings.ListingTypes.tanarok.filters.job_category;
  25.         Array.isArray(category) ? category = category[0] : category = category;
  26.         get_category_name(category, success);
  27.     });
  28. });
  29.  
  30. function getUrlParameter(name) {
  31.     name = name.replace(/[\[]/, '\\[').replace(/[\]]/, '\\]');
  32.     var regex = new RegExp('[\\?&]' + name + '=([^&#]*)');
  33.     var results = regex.exec(location.search);
  34.     return results === null ? '' : decodeURIComponent(results[1].replace(/\+/g, ' '));
  35. };
  36.  
  37. function get_category_name(category, successCallback, errorCallback) {
  38.     // We'll pass this variable to the PHP function seo_ajax_request
  39.    // This does the ajax request
  40.    jQuery.ajax({
  41.        url: seo_ajax_obj.ajaxurl, // or example_ajax_obj.ajaxurl if using on frontend
  42.        data: {
  43.            'action': 'seo_ajax_request',
  44.            'category' : category
  45.        },
  46.        success:function(data) {
  47.            // This outputs the result of the ajax request
  48.            successCallback(JSON.parse(data));
  49.        },
  50.        error: function(errorThrown){
  51.            errorCallback(errorThrown);
  52.        }
  53.    });              
  54. };
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement