1// ---------------------------------------------------------------------------- 2// FILE 3// template/prototype/track.js 4// DESCRIPTION 5// Javascript for banner template under Prototype, repurposed to track 6// pre-scalable page views. 7// NOTES 8// Identical to template/jquery/track.js except $ replaced with $j 9// COPYRIGHT 10// Copyright Mark Jeffery 2017 11// ---------------------------------------------------------------------------- 12 13// ---------------------------------------------------------------------------- 14// Constants 15// ---------------------------------------------------------------------------- 16 17// Must match thingsmadethinkable.ddl ttEvent.ttEventType 18var ttEventType_0s = 0; 19var ttEventType_7s = 1; 20var ttEventType_49s = 2; 21 22// ---------------------------------------------------------------------------- 23// FUNCTION 24// ttTrackEvent 25// DESCRIPTION 26// Track the specified event. 27// ---------------------------------------------------------------------------- 28 29function ttTrackEvent(aPagePath, aEventType) 30{ 31 $j.ajax 32 ({ 33 type: 'POST', 34 url: '/phpscripts/track.php', 35 dataType: 'text', // track.php returns text 36 data: 37 { 38 page: aPagePath, 39 type: aEventType 40 }, 41 success: function(aResponse) 42 { 43 lResponse = $j.trim(aResponse); // sometimes servers add stray newlines to responses 44 if (lResponse != '0') 45 { 46 console.log('Track failed'); 47 console.log(lResponse); 48 } 49 }, 50 error: function(aRequest, aStatus, aError) 51 { 52 console.log('Track broken'); 53 console.log(aRequest); 54 console.log(aStatus); 55 console.log(aError); 56 } 57 }); 58} 59 60// ---------------------------------------------------------------------------- 61// FUNCTION 62// initialiseTrack 63// DESCRIPTION 64// Initialize tracking of pre-scalable page views. 65// ---------------------------------------------------------------------------- 66 67function initialiseTrack() 68{ 69 var lPageURL = String(window.location); 70 var lPagePath = lPageURL; // so that if the match fails, the path is set to the entire URL, so we'll be able to handle the issue 71 var lMatchArray = lPageURL.match(/thingsmadethinkable.com\/([^\.\?]*)/); 72 if (lMatchArray !== null) 73 lPagePath = lMatchArray[1]; 74 75 ttTrackEvent(lPagePath, ttEventType_0s); 76 setTimeout(new Function("ttTrackEvent('" + lPagePath.replace(/'/g, "\\'") + "', " + ttEventType_7s + ");"), 7000); 77 setTimeout(new Function("ttTrackEvent('" + lPagePath.replace(/'/g, "\\'") + "', " + ttEventType_49s + ");"), 49000); 78}
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.