1/* 2* Page Cache powered by Jpresta (jpresta . com) 3* 4* @author Jpresta 5* @copyright Jpresta 6* @license You are just allowed to modify this copy for your own use. You must not redistribute it. License 7* is permitted for one Prestashop instance only but you can install it on your test instances. 8*/ 9 10function pcGetParameterValue(e) { 11 var t = "[\\?&]" + e + "=([^&#]*)"; 12 var n = new RegExp(t); 13 var r = n.exec(window.location.href); 14 if (r == null) return ""; 15 else return r[1] 16} 17 18function pcSplitUri(uri) { 19 var splitRegExp = new RegExp('^' + '(?:' + '([^:/?#.]+)' + ':)?' + '(?://' + '(?:([^/?#]*)@)?' + '([\\w\\d\\-\\u0100-\\uffff.%]*)' + '(?:(:[0-9]+))?' + ')?' + '([^?#]+)?' + '(?:(\\?[^#]*))?' + '(?:(#.*))?' + '$'); 20 var split = uri.match(splitRegExp); 21 for (var i = 1; i < 8; i++) { 22 if (typeof split[i] == 'undefined') { 23 split[i] = ''; 24 } 25 } 26 return { 27 'scheme': split[1], 28 'user_info': split[2], 29 'domain': split[3], 30 'port': split[4], 31 'path': split[5], 32 'query_data': split[6], 33 'fragment': split[7] 34 } 35} 36 37$(document).ready(function () { 38 /* Refresh dynamic modules */ 39 try { 40 if (typeof processDynamicModules == 'function') { 41 var hooks = ''; 42 $('.dynhook').each(function(index, domhook){ 43 hooks = hooks + '&hook_' + index + '=' + $(this).data('hook') + '%7C' + $(this).data('module'); 44 }); 45 if (hooks.length > 0) { 46 var urlparts = pcSplitUri(document.URL); 47 var url = urlparts['scheme'] + '://' + urlparts['domain'] + urlparts['port'] + urlparts['path'] + urlparts['query_data']; 48 var indexEnd = url.indexOf('?'); 49 if (indexEnd >= 0 && indexEnd < url.length) { url += '&ajax=true';} 50 else { url += '?ajax=true';} 51 url += hooks; 52 url += urlparts['fragment']; 53 url += '&nocache=' + new Date().getTime(); 54 $.getJSON(url, processDynamicModules).fail(function(jqXHR, textStatus, errorThrown) { 55 try { 56 dyndatas = $.parseJSON(jqXHR.responseText); 57 if (dyndatas != null) { 58 processDynamicModules(dyndatas); 59 return; 60 } 61 } 62 catch(err) { 63 console.error("PageCache cannot parse data of error=" + err, err); 64 } 65 console.error("PageCache cannot display dynamic modules: error=" + textStatus + " exception=" + errorThrown); 66 console.log("PageCache dynamic module URL: " + url); 67 }); 68 } 69 else { 70 processDynamicModules(new Array()); 71 } 72 } 73 } catch (e) { 74 console.error("PageCache cannot display dynamic modules: " + e.message, e); 75 } 76 77 /* Forward dbgpagecache parameter */ 78 try { 79 if (typeof baseDir == 'undefined') { 80 baseDir = prestashop.urls.base_url; 81 } 82 if (window.location.href.indexOf("dbgpagecache=") > 0) { 83 $("a:not(.pagecache)").each(function () { 84 var e = $(this).attr("href"); 85 var t = this.search; 86 var n = "dbgpagecache=" + pcGetParameterValue("dbgpagecache"); 87 var r = baseDir.replace("https", "http"); 88 if (typeof e != "undefined" && e.substr(0, 1) != "#" && e.replace("https", "http").substr(0, r.length) == r) { 89 if (t.length == 0) this.search = n; 90 else this.search += "&" + n 91 } 92 }) 93 } 94 } catch (e) { 95 console.warn("Cannot forward dbgpagecache parameter on all links: " + e.message, e) 96 } 97 98});
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.