blob: a56320f1c1197fa0b2caf0ab3245f8083a0eaf8c (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
|
function piwikHelper()
{
}
/*
* Returns query string for an object of key,values
* Note: we don't use $.param from jquery as it doesn't return array values the PHP way (returns a=v1&a=v2 instead of a[]=v1&a[]=v2)
* Example:
* piwikHelper.getQueryStringFromParameters({"a":"va","b":["vb","vc"],"c":1})
* Returns:
* a=va&b[]=vb&b[]=vc&c=1
*/
piwikHelper.getQueryStringFromParameters = function(parameters)
{
var queryString = '';
if(parameters.length==0) {
return queryString;
}
for(var name in parameters) {
value = parameters[name];
if(typeof value == 'object') {
for(var i in value) {
queryString += name + '[]=' + value[i] + '&';
}
} else {
queryString += name + '=' + value + '&';
}
}
return queryString.substring(0, queryString.length-1);
}
piwikHelper.findSWFGraph = function(name) {
if (navigator.appName.indexOf("Microsoft")!= -1) {
return window[name];
} else {
return document[name];
}
}
piwikHelper.redirectToUrl = function(url) {
window.location = url;
}
piwikHelper.ajaxHandleError = function()
{
$('#loadingError').show();
setTimeout( function(){
$('#loadingError').fadeOut('slow');
}, 2000);
}
piwikHelper.ajaxShowError = function( string )
{
$('#ajaxError').html(string).show();
}
piwikHelper.ajaxHideError = function()
{
$('#ajaxError').hide();
}
piwikHelper.ajaxHandleResponse = function(response)
{
if(response.result == "error")
{
piwikHelper.ajaxShowError(response.message);
}
else
{
window.location.reload();
}
piwikHelper.toggleAjaxLoading();
}
piwikHelper.toggleAjaxLoading = function()
{
$('#ajaxLoading').toggle();
}
piwikHelper.getStandardAjaxConf = function()
{
var ajaxRequest = new Object;
ajaxRequest.type = 'GET';
ajaxRequest.url = 'index.php';
ajaxRequest.dataType = 'json';
ajaxRequest.error = piwikHelper.ajaxHandleError;
ajaxRequest.success = piwikHelper.ajaxHandleResponse;
return ajaxRequest;
}
// Scrolls the window to the jquery element 'elem' if necessary.
// "time" specifies the duration of the animation in ms
piwikHelper.lazyScrollTo = function(elem, time)
{
var elemTop = $(elem).offset().top;
//only scroll the page if the graph is not visible
if(elemTop < $(window).scrollTop()
|| elemTop > $(window).scrollTop()+$(window).height())
{
//scroll the page smoothly to the graph
$.scrollTo(elem, time);
}
}
String.prototype.trim = function() {
return this.replace(/^\s+|\s+$/g,"");
}
|