From 811f8fcb1b049d8808c1d524a894de372da8c822 Mon Sep 17 00:00:00 2001 From: coderaiser Date: Tue, 21 Aug 2012 10:54:01 -0400 Subject: [PATCH] added google analytics --- client.js | 25 +++++++++++++++++++++++-- lib/client/google_analytics.js | 16 ++++++++++++++++ 2 files changed, 39 insertions(+), 2 deletions(-) create mode 100644 lib/client/google_analytics.js diff --git a/client.js b/client.js index 28f3b7c0..dab3e667 100644 --- a/client.js +++ b/client.js @@ -23,6 +23,7 @@ var CloudClient = { Viewer : function(){},/* function loads and shows viewer */ Terminal : function(){},/* function loads and shows terminal*/ Menu : function(){},/* function loads and shows menu */ + GoogleAnalytics : function(){}, _loadDir : function(){}, /* Функция привязываеться ко всем * ссылкам и @@ -284,7 +285,7 @@ CloudClient.Utils = (function(){ ' could not be loaded' }); - if(lFunc.onerror && + if(lFunc && lFunc.onerror && typeof lFunc.onerror === 'function') lFunc.onerror(); }); @@ -681,6 +682,21 @@ CloudClient.Editor = (function(pIsReadOnly) { }); }); +CloudClient.GoogleAnalytics = (function(){ + /* google analytics */ + var lFunc = document.onmousemove; + document.onmousemove = function(){ + setTimeout(function(){ + Util.jsload('lib/client/google_analytics.js'); + },5000); + + if(typeof lFunc === 'function') + lFunc(); + + document.onmousemove = lFunc; + }; +}); + /* function loads and shows viewer */ CloudClient.Viewer = (function(){ Util.jsload(CloudClient.LIBDIRCLIENT + @@ -1296,12 +1312,17 @@ return CloudClient; })(); try{ - window.onload=function(){ + window.onload = function(){ 'use strict'; + /* базовая инициализация*/ CloudCommander.init(); + /* привязываем клавиши к функциям */ CloudCommander.keyBinding(); + + /* загружаем Google Analytics */ + CloudCommander.GoogleAnalytics(); }; } catch(err){} \ No newline at end of file diff --git a/lib/client/google_analytics.js b/lib/client/google_analytics.js new file mode 100644 index 00000000..ea7024f0 --- /dev/null +++ b/lib/client/google_analytics.js @@ -0,0 +1,16 @@ +var CloudCommander, _gaq; +(function(){ + /* setting google analitics tracking code */ + _gaq = [['_setAccount', 'UA-33536569-2'], ['_trackPageview']]; + + window.onerror = function(msg, url, line) { + var preventErrorAlert = true; + _gaq.push(['_trackEvent', + 'JS Error', + msg, + navigator.userAgent + ' -> ' + url + " : " + line]); + return preventErrorAlert; + }; + + CloudCommander.Util.jsload('http://google-analytics.com/ga.js'); +})(); \ No newline at end of file