Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/sualko/cloud_piwik.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/js
diff options
context:
space:
mode:
authorKlaus Herberth <github@spam.herberth.eu>2015-09-06 12:58:14 +0300
committerKlaus Herberth <github@spam.herberth.eu>2015-09-06 12:58:14 +0300
commitf11c7cbc5795fc6d8c5aa32d6d67f74584bcf534 (patch)
tree1bf00eefc2b1407e81dda93e3e3eead884fa8633 /js
parent5d65492ca2f49b20eb01e595c0b9c5235b2a5d66 (diff)
multiple fixes
- fix undefined variables - fix get settings
Diffstat (limited to 'js')
-rw-r--r--js/settings-admin.js6
-rw-r--r--js/track.js12
2 files changed, 11 insertions, 7 deletions
diff --git a/js/settings-admin.js b/js/settings-admin.js
index c174b30..9988408 100644
--- a/js/settings-admin.js
+++ b/js/settings-admin.js
@@ -10,13 +10,13 @@
$(function() {
OC.AppConfig.getValue('piwik', 'piwik', {}, function(piwik){
- piwik = JSON.parse(piwik);
+ piwik = JSON.parse(piwik) || {};
$('#piwikSiteId').val(piwik.siteId);
$('#piwikUrl').val(piwik.url);
-
- $('#piwikUrl').attr('placeholder', 'e.g. //' + window.location.host + '/piwik/');
});
+
+ $('#piwikUrl').attr('placeholder', 'e.g. //' + window.location.host + '/piwik/');
$('#piwikSettings input[type="text"]').change(function() {
var piwik = {}, value;
diff --git a/js/track.js b/js/track.js
index 0261785..718df24 100644
--- a/js/track.js
+++ b/js/track.js
@@ -14,12 +14,16 @@ var _paq = _paq || [];
"use strict";
var piwik = (typeof localStorage !== 'undefined') ? OC.localStorage.getItem('piwik') : null;
-
+
if (piwik && (piwik.validUntil || 0) > (new Date()).getTime() / 1000 && !oc_debug) {
track(piwik.siteId, piwik.url);
} else {
- OC.AppConfig.getValue('piwik', 'piwik', {}, function(piwik) {
- piwik = JSON.parse(piwik);
+ $.ajax({
+ url: OC.filePath('piwik', 'ajax', 'getPiwikSettings.php'),
+ })
+ .done(function(data) {
+ data = data || {};
+ piwik = JSON.parse(data.data) || {};
if (piwik.siteId && piwik.url) {
piwik.validUntil = (new Date()).getTime() + (piwik.validity * 1000);
@@ -34,7 +38,7 @@ var _paq = _paq || [];
function track(siteId, url) {
var app = null;
var path = window.location.pathname;
- var pathparts = path.match(/index\.php\/apps\/([a-z0-9]+)\/?/i) || path.match(/index\.php\/([a-z0-9]+)(\/([a-z0-9]+))?/i);
+ var pathparts = path.match(/index\.php\/apps\/([a-z0-9]+)\/?/i) || path.match(/index\.php\/([a-z0-9]+)(\/([a-z0-9]+))?/i) || [];
if(pathparts.length >= 2) {
app = pathparts[1];