1(function ($) { 2 var cachedResponses = [], 3 callsStack = []; 4 5 $.RMP_AJAX = function (actionName, requestData, dontCache) { 6 var actionMethod = 'POST', 7 cachedData = {}, 8 cacheKey = generateCacheKey(actionMethod, actionName, requestData), 9 ajaxConfig = { 10 url: RMP_AJAX_LOCALS.ajaxUrl, 11 type: actionMethod, 12 data: _.extend({}, { 13 action: 'RMP_' + actionName, 14 _nonce: RMP_AJAX_LOCALS._nonce 15 }, requestData) 16 }; 17 18 if (isResponseCached(cacheKey) && !dontCache) { 19 cachedData = cachedResponses[cacheKey]; 20 21 return $.Deferred()[cachedData['type']](cachedData['data']).promise(); 22 } 23 24 return $.ajax(ajaxConfig).always(function(responseData, textStatus) { 25 var cacheData = { 26 'data': responseData, 27 'type': 'resolve' 28 }; 29 30 if (textStatus === 'error') { 31 cacheData['type'] = 'reject'; 32 } 33 34 return cacheResponse.apply(null, [cacheKey, cacheData]); 35 }); 36 }; 37 38 function generateCacheKey(actionMethod, actionName, requestData) { 39 return actionMethod + '_' + actionName + '_' + JSON.stringify(requestData); 40 } 41 42 function isResponseCached(cacheKey) { 43 return ! _.isUndefined(cachedResponses[cacheKey]); 44 } 45 46 function cacheResponse(cacheKey, responseData) { 47 if (! isResponseCached(cacheKey)) { 48 cachedResponses[cacheKey] = responseData; 49 } 50 51 return responseData; 52 } 53 54})(jQuery);
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.