You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@openoffice.apache.org by ro...@apache.org on 2012/04/24 22:33:15 UTC

svn commit: r1329995 - /incubator/ooo/ooo-site/trunk/content/scripts/entourage.js

Author: robweir
Date: Tue Apr 24 20:33:15 2012
New Revision: 1329995

URL: http://svn.apache.org/viewvc?rev=1329995&view=rev
Log: (empty)

Added:
    incubator/ooo/ooo-site/trunk/content/scripts/entourage.js   (with props)

Added: incubator/ooo/ooo-site/trunk/content/scripts/entourage.js
URL: http://svn.apache.org/viewvc/incubator/ooo/ooo-site/trunk/content/scripts/entourage.js?rev=1329995&view=auto
==============================================================================
--- incubator/ooo/ooo-site/trunk/content/scripts/entourage.js (added)
+++ incubator/ooo/ooo-site/trunk/content/scripts/entourage.js Tue Apr 24 20:33:15 2012
@@ -0,0 +1,72 @@
+/*!
+ * Entourage 1.1.2 - Automatic Download Tracking for Asynchronous Google Analytics
+ *
+ * Copyright (c) 2011 by Tian Valdemar Davis (http://techoctave.com/c7)
+ * Licensed under the MIT (http://en.wikipedia.org/wiki/MIT_License) license.
+ *
+ * Learn More: http://techoctave.com/c7/posts/58-entourage-js-automatic-download-tracking-for-asynchronous-google-analytics
+ * 
+ * 2012-04-24 Mod by robweir to whitelist additional file extensions as used in AOO project
+ */
+
+/*jshint strict:false */
+
+(function() {
+var entourage = new (function() {
+	var version = "1.1.2";
+	var whitelist = /\.pdf$|\.zip$|\.gz$|\.bz2$|\.od*|\.doc*|\.xls*|\.ppt*|\.exe$|\.dmg$|\.mov$|\.avi$|\.mp3$/i;
+	
+	//Get true FileName from link pathname
+	var getFileName = function(pathname) {
+		//Remove the anchor at the end (if one exists)
+		pathname = pathname.substring(0, (pathname.indexOf("#") === -1) ? pathname.length : pathname.indexOf("#"));
+
+		//Removes the query after the file pathname (if one exists)
+		pathname = pathname.substring(0, (pathname.indexOf("?") === -1) ? pathname.length : pathname.indexOf("?"));
+
+		//Removes everything before the last slash in the path
+		pathname = pathname.substring(pathname.lastIndexOf("/") + 1, pathname.length);
+
+		return pathname;
+	};
+
+	var autograph = function() {
+		var fileName, associate;
+
+		//Get the file name
+		fileName = getFileName(this.pathname); //The link object is now available in "this"
+
+		//Add file to the Google Analytics Queue
+		associate = '/download/' + fileName;
+		
+		//Track download using Asynchronous Google Analytics
+		_gaq.push(['_trackPageview', associate]);
+    };
+
+	var initialize = function() {
+		var links = document.links;
+		
+		for (var i = 0, l = links.length; i < l; i++) {
+			//Compare the fileType to the whitelist
+			var match = links[i].pathname.match(whitelist);
+			
+			//If the link is for a file download . . .
+			if (typeof match !== "undefined" && match !== null) {
+				//Call Entourage whenever the link is clicked
+				links[i].onclick = autograph;
+			}
+		}
+    };
+
+	return {
+		version: version,
+		initialize: initialize
+	};
+})(); //Entourage.js
+
+//Add entourage to the global namespace
+window.entourage = entourage;
+
+//Execute entourage onload - ensuring links are present in the DOM
+window.onload = entourage.initialize;
+})();
\ No newline at end of file

Propchange: incubator/ooo/ooo-site/trunk/content/scripts/entourage.js
------------------------------------------------------------------------------
    svn:eol-style = native