1function trainParsely() { 2 var maxHistory = 50; 3 var base = location.protocol + "//" + location.hostname + "/api/parselyrecommendations"; 4 var endpoint = "/profile"; 5 var params = { 6 apikey: "thestar.com.my", 7 uuid: PARSELY.config.parsely_site_uuid, 8 url: [location.protocol, '//', location.host, location.pathname].join('') 9 }; 10 var localStorID = "Trendinghistory"; 11 var queryStr = $.param(params); 12 var apiUrl = base + endpoint + "/?" + queryStr; 13 14 //train parsley 15 //$.getJSON(apiUrl, function (data) { }); 16 17 //track history url into localStorage 18 var historyItemString = window.localStorage[localStorID]; 19 if (historyItemString) { 20 var historyItem = JSON.parse(historyItemString) 21 22 var index = historyItem.indexOf(params.url); 23 while (index > -1) { 24 historyItem.splice(index, 1); 25 index = historyItem.indexOf(params.url); 26 } 27 historyItem.push(params.url); 28 //get last n of history 29 historyItem = historyItem.slice(Math.max(historyItem.length - maxHistory, 0)); 30 window.localStorage[localStorID] = JSON.stringify(historyItem); 31 } 32 else { 33 var newHistoryItem = []; 34 newHistoryItem.push(params.url); 35 window.localStorage.setItem(localStorID, JSON.stringify(newHistoryItem)); 36 } 37}; 38function trainParselyStar2Stories(star2URL) { 39 var maxHistory = 50; 40 var base = location.protocol + "//" + location.hostname + "/api/parselyrecommendations"; 41 var endpoint = "/profile"; 42 var params = { 43 apikey: "thestar.com.my", 44 uuid: PARSELY.config.parsely_site_uuid, 45 url: star2URL 46 }; 47 var localStorID = "Trendinghistory"; 48 var queryStr = $.param(params); 49 var apiUrl = base + endpoint + "/?" + queryStr; 50 51 //train parsley 52 //$.getJSON(apiUrl, function (data) { }); 53 54 //track history url into localStorage 55 var historyItemString = window.localStorage[localStorID]; 56 if (historyItemString) { 57 var historyItem = JSON.parse(historyItemString) 58 59 var index = historyItem.indexOf(params.url); 60 while (index > -1) { 61 historyItem.splice(index, 1); 62 index = historyItem.indexOf(params.url); 63 } 64 historyItem.push(params.url); 65 //get last n of history 66 historyItem = historyItem.slice(Math.max(historyItem.length - maxHistory, 0)); 67 window.localStorage[localStorID] = JSON.stringify(historyItem); 68 } 69 else { 70 var newHistoryItem = []; 71 newHistoryItem.push(params.url); 72 window.localStorage.setItem(localStorID, JSON.stringify(newHistoryItem)); 73 } 74};
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.