1/** 2 * Created by Krzysztof Smolicz on 2017-03-31. 3 */ 4 5(function ( $ ) { 6 "use strict"; 7 8 $.fn.route = function( url, callback, resource ) { 9 10 var storageSupported = typeof(Storage) !== 'undefined'; 11 var putResource = function(url, resource) { 12 if(typeof url !== 'undefined') { 13 if (typeof resource === 'undefined') { 14 resource = ''; 15 } 16 return url.replace(/\{.*?\}/g, resource); 17 } 18 }; 19 20 if (storageSupported) { 21 var storedRoutes = sessionStorage.getItem("routes"); 22 if( storedRoutes !== null && storedRoutes !== '') { 23 return callback(putResource(JSON.parse(storedRoutes)[url], resource)); 24 } 25 } 26 $.ajax({ 27 url: $.fn.handleWebmatrixHost('/system/routes'), 28 type: 'get', 29 success: function (data) { 30 if(typeof data !== 'undefined' && typeof data[url] !== 'undefined'){ 31 if (storageSupported){ 32 sessionStorage.setItem("routes", JSON.stringify(data)); 33 } 34 return callback(putResource(data[url], resource)); 35 } 36 }, 37 error: function(jqXHR, status){ 38 $.log.error('Request failed with status: ' + status); 39 return callback('/404'); 40 } 41 }); 42 }; 43 44 $.fn.handleWebmatrixHost = function(url) { 45 if(typeof xmediaHost !== 'undefined' && xmediaHost !== '') { 46 return xmediaHost + url; 47 } else { 48 return url; 49 } 50 } 51 52}( 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.