/*************************************************************** * Copyright notice * * (c) 2005 Georg Hennecke (Hennecke@Enigma-Software.de) * All rights reserved * * This script is part of the TYPO3 project. The TYPO3 project is * free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * The GNU General Public License can be found at * http://www.gnu.org/copyleft/gpl.html. * * This script is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * This copyright notice MUST APPEAR in all copies of the script! ***************************************************************/ /// Page-tracking object var user_pagetracker_pi1_obj; /** * Page-tracking class * * @param in_MaximumNumberOfEntries maximal number of tracked pages */ function user_pagetracker_pi1(in_MaximumNumberOfEntries) { this.m_MaximumNumberOfEntries = in_MaximumNumberOfEntries; this.m_CookieName = 'user_pagetracker_pi1_ptc'; } /** * Track page with typo3 page-id * * @param in_PageId typo3 page id for page to track * @param in_PageTitle title of web page * @param in_URL URL of web page * */ user_pagetracker_pi1.prototype.trackPage = function(in_PageId, in_PageTitle, in_URL) { // read cooke with visited pages var visitedPages = this.readCookie(); // if the current page id is in the visited page array, delete it for (var i=0; i this.m_MaximumNumberOfEntries+1) { visitedPages.splice(this.m_MaximumNumberOfEntries+1, visitedPages.length); } // write back cookie this.writeCookie(visitedPages); } /** * write HTML for visited pages * * @param in_siteURL URL of website */ user_pagetracker_pi1.prototype.writeHTML = function() { // read cooke with visited page ids var visitedPages = this.readCookie(); var theHTML = '"; document.write(theHTML); } /** * read visited pages from cookie * * @return array with visited pages data */ user_pagetracker_pi1.prototype.readCookie = function() { var allCookies = document.cookie; if (allCookies) { // look for the start of our cookie var pos = allCookies.indexOf(this.m_CookieName+'='); if (pos != -1) { var start = pos + this.m_CookieName.length + 1; var end = allCookies.indexOf(';', start); var value = unescape(allCookies.substring(start, (end != -1) ? end : allCookies.length)); return value.split(','); } } return new Array(); } /** * write visited pages to cookie * * @param in_VisitedPages array with visited pages data */ user_pagetracker_pi1.prototype.writeCookie = function(in_VisitedPages) { document.cookie = this.m_CookieName+'='+in_VisitedPages.join(",")+'; path=/'; }