You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cordova.apache.org by ak...@apache.org on 2015/08/09 14:43:20 UTC

[4/9] docs commit: Add GA event which will track language changes. Also remove deprecated code

Add GA event which will track language changes.
Also remove deprecated code


Project: http://git-wip-us.apache.org/repos/asf/cordova-docs/repo
Commit: http://git-wip-us.apache.org/repos/asf/cordova-docs/commit/fcfc8693
Tree: http://git-wip-us.apache.org/repos/asf/cordova-docs/tree/fcfc8693
Diff: http://git-wip-us.apache.org/repos/asf/cordova-docs/diff/fcfc8693

Branch: refs/heads/master
Commit: fcfc86932ae42d5d7af475dce9e34c084531ae2f
Parents: a2ee176
Author: Andrey Kurdyumov <ka...@gmail.com>
Authored: Thu Aug 6 19:52:38 2015 +0600
Committer: Andrey Kurdyumov <ka...@gmail.com>
Committed: Thu Aug 6 19:52:38 2015 +0600

----------------------------------------------------------------------
 template/docs/default/index.js | 23 +++--------------------
 1 file changed, 3 insertions(+), 20 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cordova-docs/blob/fcfc8693/template/docs/default/index.js
----------------------------------------------------------------------
diff --git a/template/docs/default/index.js b/template/docs/default/index.js
index 374ec60..d2754fc 100644
--- a/template/docs/default/index.js
+++ b/template/docs/default/index.js
@@ -45,6 +45,7 @@ function changeLanguageOrVersion(language, version, missingVersion) {
     // Uncomment to also jump to the same page. However, the server should handle missing page
     // window.location.href = '../../' + language + '/' + version + currentFile;
     var sameFile = '../../' + language + '/' + version + currentFile;
+    ga('send', 'event', 'navigation', 'lang-ver-change', { 'page': currentFile, lang: language, version: version });
     var testForSameVersion = true;
     if (testForSameVersion && window.location.protocol !== "file:") {
         var xmlhttp = new XMLHttpRequest()
@@ -54,6 +55,7 @@ function changeLanguageOrVersion(language, version, missingVersion) {
         if(xmlhttp.status == 200) {
             window.location.href = sameFile;
         } else {
+            ga('send', 'event', 'navigation', 'lang-ver-fallback', { 'page': currentFile, lang: language, version: version });
             window.location.href = '../../' + language + '/' + version + '/index.html';
         }
     } else {
@@ -84,7 +86,7 @@ function setupLanguageSelect() {
 
 function setupVersionSelect() {
     var versionElement = document.getElementById('version');
-    var languageVersions = versions[settings.lang];
+    var languageVersions = versions[settings.lang] || [];
     languageVersions.reverse().forEach(function (version) {
         var optionElement = document.createElement("option");
         optionElement.value = version;
@@ -102,25 +104,6 @@ function setupVersionSelect() {
 }
 
 //
-// Version and Language <select>
-//
-(function() {
-    
-    window.addEventListener('load', function() {
-        document.getElementById('header').getElementsByTagName('select')[0].addEventListener('change', function(e) {
-            var $select     = this.options[this.selectedIndex];
-            var version     = $select.value;
-            var language    = $select.parentElement.getAttribute('value');
-            var currentFile = (window.location.href.match(/\/[^\/]*$/) || ['/index.html'])[0];
-
-            // Uncomment to also jump to the same page. However, the server should handle missing page
-            // window.location.href = '../../' + language + '/' + version + currentFile;
-            //window.location.href = '../../' + language + '/' + version + '/index.html';
-        }, false);
-    }, false);
-})();
-
-//
 // API <select>
 //
 (function() {


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@cordova.apache.org
For additional commands, e-mail: commits-help@cordova.apache.org