PageSourceSearch

https://stoscarromeroparish.org.uk/wp-content/plugins/wd-facebook-feed/js/ffwd_cache.js?ver=1.2.4

js stoscarromeroparish.org.uk collected 2026-10-10 02:13:52 UTC 7,319 bytes, 214 lines download raw bytes

1jQuery(window).load(function() {
2  var feed_ids = {};
3  jQuery(".ffwd_container1").each(function (key) {
4    feed_ids[key] = jQuery(this).attr("data-feed_id");
5  });
6  if (Object.keys(feed_ids).length === 0) {
7    feed_ids = 0;
8  }
9  var datas;
10  /* Case when need update all feeds data */
11  if(ffwd_cache.need_update === 'true') {
12    if( ffwd_cache.update_data === '' ) {
13      wdi_hide_loading();
14      return;
15    }
16    datas = JSON.parse(ffwd_cache.update_data);
17    jQuery.each( datas, function( key, value ) {
18      var data = value;
19      update_cache_data(data['id'], 0, '', data['page_access_token'], data['from'], data['content_type']);
20    });
21  }
22  /* Case when request from admin part and no need to run cron */
23  else if( ffwd_cache.need_update === 'false' && feed_ids === 0) { // need to remove
24    wdi_hide_loading();
25  }
26  /* case frontend when media data count is 0 */
27  else if( ffwd_cache.need_update === 'false' && feed_ids !== 0 ) {
28    datas = JSON.parse(ffwd_cache.update_data);
29    var zeroDataCount = 0;
30    jQuery.each( datas, function( key, value ) {
31      var data = value;
32      if( parseInt(data['data_count']) === 0 && Object.values(feed_ids).includes(data['id']) ) {
33        zeroDataCount++;
34        set_cache_data(data['id'], 0, '', data['page_access_token'], data['from'], data['content_type']);
35      }
36    });
37    if( zeroDataCount === 0 ) {
38      wdi_hide_loading();
39    }
40  }
41
42});
43
44/* Using for frontend hide loading and show hidden container */
45function wdi_hide_loading() {
46  jQuery(".ffwd_container2").removeClass("ffwd-hidden"); // create function for this
47  jQuery(".ffwd-loading-layout").remove();
48}
49
50function set_cache_data( fb_id, iter, fb_graph_url, page_access_token, user_id, content_type, non_public_share_count ) {
51  var data = {
52    'action' : 'set_cache_data',
53    'fb_id' : fb_id,
54    'user_id' : user_id,
55    'content_type': content_type,
56    'graph_url': fb_graph_url,
57    'iter': iter,
58    'page_access_token' : page_access_token,
59    'non_public_share_count' : non_public_share_count,
60  };
61  jQuery.ajax({
62    method: "POST",
63    url: ffwd_cache.ajax_url,
64    data: data,
65    success: function (result) {
66      result = JSON.parse(result);
67      var return_json = '';
68      if( result['status'] === 'success' && result['next_page'] !== '') {
69        iter = parseInt(result['iter']) + 1;
70        set_cache_data( fb_id, iter, result['next_page'], page_access_token, user_id, content_type, result['non_public_share_count'] );
71      }
72      else if( result['status'] === 'error' ) {
73        return_json = {
74          0 : result['status'],
75          1 : result['msg'],
76        };
77        apply_save_ajax_message( return_json );
78      } else {
79        return_json = {
80          0:'success',
81          1: fb_id,
82          2: result['non_public_share_count'],
83        };
84        apply_save_ajax_message( return_json );
85        get_shortcode_html(fb_id);
86      }
87    },
88    error: function (xhr, ajaxOptions, thrownError) {
89      console.log(xhr.status);
90      console.log(thrownError);
91    }
92  });
93}
94
95function get_shortcode_html( fb_id ) {
96  var frontend = 0;
97  jQuery(".ffwd_container1").each(function (key) {
98    if(jQuery(this).attr("data-feed_id") === fb_id) {
99      frontend = 1;
100    }
101  });
102  if( frontend === 0 ) {
103    return;
104  }
105
106  var data = {
107    'action' : 'ffwd_ajax_front_end',
108    'fb_id' : fb_id
109  };
110  jQuery.ajax({
111    method: "POST",
112    url: ffwd_cache.ajax_url,
113    data: data,
114   // dataType: 'html',
115    success: function (result) {
116      var html = jQuery(result).find(".ffwd_container1[data-feed_id='" + fb_id + "']").html();
117      jQuery(document).find(".ffwd_container1[data-feed_id='" + fb_id + "']").html(html);
118      jQuery(document).find(".ffwd_container1[data-feed_id='" + fb_id + "'] .ffwd-loading-layout").remove();
119      jQuery(document).find(".ffwd_container1[data-feed_id='" + fb_id + "'] .ffwd_container2").removeClass('ffwd-hidden');
120
121      /* Using to reset click action after content replace (problem in album click) */
122      jQuery(".ffwd_container1").each(function () {
123        var id = jQuery(this).attr("id");
124        if( typeof id !== 'undefined' ) {
125          var ind = id.replace('ffwd_container1_', '');
126          window["ffwd_document_ready_" + ind]();
127        }
128      });
129    },
130    error: function (xhr, ajaxOptions, thrownError) {
131      console.log(xhr.status);
132      console.log(thrownError);
133    }
134  });
135}
136
137function update_cache_data( fb_id, iter, fb_graph_url, page_access_token, user_id, content_type, non_public_share_count ) {
138  var data = {
139    'action' : 'update_cache_data',
140    'fb_id' : fb_id,
141    'user_id' : user_id,
142    'content_type': content_type,
143    'graph_url': fb_graph_url,
144    'iter': iter,
145    'page_access_token' : page_access_token,
146    'non_public_share_count' : non_public_share_count,
147  };
148  jQuery.ajax({
149    method: "POST",
150    url: ffwd_cache.ajax_url,
151    data: data,
152    success: function (result) {
153      result = JSON.parse(result);
154      var return_json = '';
155      fb_id = result['fb_id'];
156      if( result['status'] === 'success' && result['next_page'] !== '') {
157        iter = parseInt(result['iter'])+1;
158        update_cache_data( fb_id, iter, result['next_page'], page_access_token, user_id, content_type, result['non_public_share_count'] );
159      }
160      else if( result['status'] === 'error' ) {
161        return_json = {
162          0 : result['status'],
163          1 : result['msg'],
164        };
165        apply_save_ajax_message( return_json );
166      } else {
167        return_json = {
168          0:'success',
169          1: fb_id,
170          2: result['non_public_share_count'],
171        };
172        get_shortcode_html(fb_id);
173        apply_save_ajax_message( return_json );
174      }
175    },
176    error: function (xhr, ajaxOptions, thrownError) {
177      console.log(xhr.status);
178      console.log(thrownError);
179    }
180  });
181}
182/* Save feed ajax message printing in success */
183function apply_save_ajax_message( result ) {
184  var task = jQuery("#task").val();
185  jQuery(".ffwd_notice").html("");
186  if (result[1] !== 0) {
187    jQuery("#current_id").val(result[1]);
188  }
189  switch (task) {
190    case "apply":
191      var non_visible_post_msg = '';
192      if( typeof result[2] !== "undefined" && 0 !== parseInt(result[2])) {
193        non_visible_post_msg = "<p>"+parseInt(result[2])+" posts are not available, probably they are not public.</p>";
194        non_visible_post_msg = "<p>The data of "+parseInt(result[2])+" posts will not be displayed on your site. This is because, most likely the owner of the post did n
194ot set the post to public and/or shared the post to a specific page, or has deleted the post.</p>";
195      }
196      jQuery("#task").val("");
197      jQuery('#message_div').html("<strong><p>Items Succesfully Saved.</p>"+non_visible_post_msg+"</strong>");
198      jQuery('#message_div').show();
199      jQuery('#ffwd_page_url,#page_access_token,#name').removeAttr("style");
200      break;
201    case "save":
202      if( typeof result[2] !== "undefined" && 0 !== parseInt(result[2])) {
203        jQuery("#ffwd_info_form").append("<input type='hidden' name='non_public_posts_count' value='"+parseInt(result[2])+"'>")
204      }
205
206      jQuery("#ffwd_info_form").submit();
207      break;
208    default:
209      jQuery("#task").val("");
210      break;
211  }
212  jQuery('#opacity_div').hide();
213  jQuery('#loading_div').hide();
214}

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.