← Back to team overview

dhis2-devs team mailing list archive

[Branch ~dhis2-devs-core/dhis2/trunk] Rev 12720: (PT, DV) Plugin fixes.

 

Merge authors:
  Jan Henrik Øverland (janhenrik-overland)
------------------------------------------------------------
revno: 12720 [merge]
committer: Jan Henrik Overland <janhenrik.overland@xxxxxxxxx>
branch nick: dhis2
timestamp: Wed 2013-10-16 14:12:18 +0200
message:
  (PT, DV) Plugin fixes.
modified:
  dhis-2/dhis-web/dhis-web-commons-resources/src/main/webapp/dhis-web-commons/javascripts/plugin/chart.js
  dhis-2/dhis-web/dhis-web-commons-resources/src/main/webapp/dhis-web-commons/javascripts/plugin/table.js
  dhis-2/dhis-web/dhis-web-pivot/src/main/webapp/dhis-web-pivot/app/plugin.html
  dhis-2/dhis-web/dhis-web-pivot/src/main/webapp/dhis-web-pivot/app/scripts/core.js
  dhis-2/dhis-web/dhis-web-visualizer/src/main/webapp/dhis-web-visualizer/app/plugin.html
  dhis-2/dhis-web/dhis-web-visualizer/src/main/webapp/dhis-web-visualizer/app/scripts/core.js


--
lp:dhis2
https://code.launchpad.net/~dhis2-devs-core/dhis2/trunk

Your team DHIS 2 developers is subscribed to branch lp:dhis2.
To unsubscribe from this branch go to https://code.launchpad.net/~dhis2-devs-core/dhis2/trunk/+edit-subscription
=== modified file 'dhis-2/dhis-web/dhis-web-commons-resources/src/main/webapp/dhis-web-commons/javascripts/plugin/chart.js'
--- dhis-2/dhis-web/dhis-web-commons-resources/src/main/webapp/dhis-web-commons/javascripts/plugin/chart.js	2013-10-15 17:37:29 +0000
+++ dhis-2/dhis-web/dhis-web-commons-resources/src/main/webapp/dhis-web-commons/javascripts/plugin/chart.js	2013-10-16 12:10:40 +0000
@@ -2237,70 +2237,80 @@
 				};
 
                 initialize = function() {
-                    var url,
-                        xLayout,
-                        xResponse,
-                        chart;
-
-					// Extended layout
-                    xLayout = engine.getExtendedLayout(layout);
-
-                    dv.paramString = engine.getParamString(xLayout, true);
-                    url = init.contextPath + '/api/analytics.json' + dv.paramString;
+                    var xLayout = engine.getExtendedLayout(layout),
+                        paramString = engine.getParamString(xLayout, true),
+						method = 'GET',
+						success;
+
+					success = function(response) {
+						var xResponse,
+							chart,
+							html,
+							response = dv.api.response.Response(response);
+
+						if (!response) {
+							dv.util.mask.hideMask(dv.viewport.centerRegion);
+							return;
+						}
+
+						// Synchronize xLayout
+						xLayout = getSyncronizedXLayout(xLayout, response);
+
+						if (!xLayout) {
+							dv.util.mask.hideMask(dv.viewport.centerRegion);
+							return;
+						}
+
+						// Extended response
+						xResponse = getExtendedResponse(response, xLayout);
+
+						// Create chart
+						chart = generator[xLayout.type](xResponse, xLayout);
+
+						// Update viewport
+						dv.viewport.centerRegion.removeAll(true);
+						dv.viewport.centerRegion.add(chart);
+
+						dv.paramString = paramString;
+
+						afterLoad(layout, xLayout, xResponse);
+					};
 
 					// Validate request size
-                    if (!validateUrl(url)) {
+                    if (!validateUrl(init.contextPath + '/api/analytics.jsonp' + paramString)) {
                         return;
                     }
 
 					// Show load mask
                     util.mask.showMask(dv.viewport.centerRegion);
 
-                    Ext.Ajax.request({
-                        method: 'GET',
-                        url: url,
-                        callbackName: 'analytics',
-                        timeout: 60000,
-                        headers: {
-                            'Content-Type': 'application/json',
-                            'Accept': 'application/json'
-                        },
-                        disableCaching: false,
-                        failure: function(r) {
-                            util.mask.hideMask(dv.viewport.centerRegion);
-                            alert(r.responseText);
-                        },
-                        success: function(r) {
-                            var html,
-								response = dv.api.response.Response(Ext.decode(r.responseText));
-
-							if (!response) {
-								dv.util.mask.hideMask(dv.viewport.centerRegion);
-								return;
+                    if (dv.isPlugin) {
+						Ext.data.JsonP.request({
+							method: method,
+							url: init.contextPath + '/api/analytics.jsonp' + paramString,
+							disableCaching: false,
+							success: success
+						});
+					}
+					else {
+						Ext.Ajax.request({
+							method: method,
+							url: init.contextPath + '/api/analytics.json' + paramString,
+							timeout: 60000,
+							headers: {
+								'Content-Type': 'application/json',
+								'Accept': 'application/json'
+							},
+							disableCaching: false,
+							failure: function(r) {
+								util.mask.hideMask(dv.viewport.centerRegion);
+								alert(r.responseText);
+							},
+							success: function(r) {
+								success(Ext.decode(r.responseText));
 							}
-
-							// Synchronize xLayout
-                            xLayout = getSyncronizedXLayout(xLayout, response);
-
-                            if (!xLayout) {
-                                dv.util.mask.hideMask(dv.viewport.centerRegion);
-                                return;
-                            }
-
-							// Extended response
-                            xResponse = getExtendedResponse(response, xLayout);
-
-							// Create chart
-                            chart = generator[xLayout.type](xResponse, xLayout);
-
-							// Update viewport
-                            dv.viewport.centerRegion.removeAll(true);
-                            dv.viewport.centerRegion.add(chart);
-
-                            afterLoad(layout, xLayout, xResponse);
-                        }
-                    });
-
+						});
+					}
                 }();
             };
 

=== modified file 'dhis-2/dhis-web/dhis-web-commons-resources/src/main/webapp/dhis-web-commons/javascripts/plugin/table.js'
--- dhis-2/dhis-web/dhis-web-commons-resources/src/main/webapp/dhis-web-commons/javascripts/plugin/table.js	2013-10-15 17:37:29 +0000
+++ dhis-2/dhis-web/dhis-web-commons-resources/src/main/webapp/dhis-web-commons/javascripts/plugin/table.js	2013-10-16 12:10:40 +0000
@@ -2481,78 +2481,86 @@
 					}
 				};
 
-				initialize = function() {
-					var url,
-						xLayout,
-						xResponse,
-						xColAxis,
-						xRowAxis;
-
-					// Extended layout
-					xLayout = engine.getExtendedLayout(layout);
-
-					// Param string
-					pt.paramString = engine.getParamString(xLayout, true);
-					url = pt.init.contextPath + '/api/analytics.json' + pt.paramString;
+                initialize = function() {
+                    var xLayout = engine.getExtendedLayout(layout),
+                        paramString = engine.getParamString(xLayout, true),
+						method = 'GET',
+						success;
+
+					success = function(response) {
+						var xResponse,
+							chart,
+							html,
+							response = pt.api.response.Response(response);
+
+						if (!response) {
+							pt.util.mask.hideMask(pt.viewport.centerRegion);
+							return;
+						}
+
+						// Synchronize xLayout
+						xLayout = getSyncronizedXLayout(xLayout, response);
+
+						if (!xLayout) {
+							pt.util.mask.hideMask(pt.viewport.centerRegion);
+							return;
+						}
+
+						// Extended response
+						xResponse = getExtendedResponse(response, xLayout);
+
+						// Extended axes
+						xColAxis = getExtendedAxis('col', xLayout.columnDimensionNames, xResponse);
+						xRowAxis = getExtendedAxis('row', xLayout.rowDimensionNames, xResponse);
+
+						// Create html
+						html = getTableHtml(xColAxis, xRowAxis, xResponse);
+
+						// Update viewport
+						pt.viewport.centerRegion.removeAll(true);
+						pt.viewport.centerRegion.update(html);
+
+						pt.paramString = paramString;
+
+						afterLoad(layout, xLayout, xResponse);
+					};
 
 					// Validate request size
-					if (!validateUrl(url)) {
-						return;
-					}
+                    if (!validateUrl(init.contextPath + '/api/analytics.jsonp' + paramString)) {
+                        return;
+                    }
 
 					// Show load mask
-					pt.util.mask.showMask(pt.viewport.centerRegion);
-
-					Ext.Ajax.request({
-						method: 'GET',
-						url: url,
-						callbackName: 'analytics',
-						timeout: 60000,
-						headers: {
-							'Content-Type': 'application/json',
-							'Accept': 'application/json'
-						},
-						disableCaching: false,
-						failure: function(r) {
-							pt.util.mask.hideMask(pt.viewport.centerRegion);
-							alert(r.responseText);
-						},
-						success: function(r) {
-							var html,
-								response = pt.api.response.Response(Ext.decode(r.responseText));
-
-							if (!response) {
-								pt.util.mask.hideMask(pt.viewport.centerRegion);
-								return;
-							}
-
-							// Synchronize xLayout
-							xLayout = getSyncronizedXLayout(xLayout, response);
-
-							if (!xLayout) {
-								pt.util.mask.hideMask(pt.viewport.centerRegion);
-								return;
-							}
-
-							// Extended response
-							xResponse = getExtendedResponse(response, xLayout);
-
-							// Extended axes
-							xColAxis = getExtendedAxis('col', xLayout.columnDimensionNames, xResponse);
-							xRowAxis = getExtendedAxis('row', xLayout.rowDimensionNames, xResponse);
-
-							// Create html
-							html = getTableHtml(xColAxis, xRowAxis, xResponse);
-
-							// Update viewport
-							pt.viewport.centerRegion.removeAll(true);
-							pt.viewport.centerRegion.update(html);
-
-							afterLoad(layout, xLayout, xResponse);
-						}
-					});
-
-				}();
+                    util.mask.showMask(pt.viewport.centerRegion);
+
+                    if (pt.isPlugin) {
+						Ext.data.JsonP.request({
+							method: method,
+							url: init.contextPath + '/api/analytics.jsonp' + paramString,
+							disableCaching: false,
+							success: success
+						});
+					}
+					else {
+						Ext.Ajax.request({
+							method: method,
+							url: init.contextPath + '/api/analytics.json' + paramString,
+							timeout: 60000,
+							headers: {
+								'Content-Type': 'application/json',
+								'Accept': 'application/json'
+							},
+							disableCaching: false,
+							failure: function(r) {
+								util.mask.hideMask(pt.viewport.centerRegion);
+								alert(r.responseText);
+							},
+							success: function(r) {
+								success(Ext.decode(r.responseText));
+							}
+						});
+					}
+                }();
 			};
 
 			engine.loadTable = function(id, pt, updateGui, isFavorite) {

=== modified file 'dhis-2/dhis-web/dhis-web-pivot/src/main/webapp/dhis-web-pivot/app/plugin.html'
--- dhis-2/dhis-web/dhis-web-pivot/src/main/webapp/dhis-web-pivot/app/plugin.html	2013-10-14 11:39:50 +0000
+++ dhis-2/dhis-web/dhis-web-pivot/src/main/webapp/dhis-web-pivot/app/plugin.html	2013-10-16 12:10:40 +0000
@@ -5,6 +5,10 @@
 	<link rel="stylesheet" type="text/css" href="http://localhost:8080/dhis-web-commons/javascripts/ext/resources/css/ext-plugin-gray.css"; />
 	<script src="http://localhost:8080/dhis-web-commons/javascripts/ext/ext-all.js";></script>
 	<script src="http://localhost:8080/dhis-web-commons/javascripts/plugin/table.js";></script>
+<!--
+	<script src="http://localhost:8080/dhis-web-pivot/app/scripts/core.js";></script>
+	<script src="http://localhost:8080/dhis-web-pivot/app/scripts/plugin.js";></script>
+-->
 
     <style type="text/css">
 		body {font-family:sans-serif; margin:0 0 0 60px;}

=== modified file 'dhis-2/dhis-web/dhis-web-pivot/src/main/webapp/dhis-web-pivot/app/scripts/core.js'
--- dhis-2/dhis-web/dhis-web-pivot/src/main/webapp/dhis-web-pivot/app/scripts/core.js	2013-10-13 12:41:41 +0000
+++ dhis-2/dhis-web/dhis-web-pivot/src/main/webapp/dhis-web-pivot/app/scripts/core.js	2013-10-16 12:10:40 +0000
@@ -2,14 +2,14 @@
 
 	// ext config
 	Ext.Ajax.method = 'GET';
-	
-	// pt	
+
+	// pt
 	PT = {
 		core: {
 			instances: []
-		},		
-		i18n: {},		
-		isDebug: false,		
+		},
+		i18n: {},
+		isDebug: false,
 		isSessionStorage: 'sessionStorage' in window && window['sessionStorage'] !== null
 	};
 
@@ -767,7 +767,7 @@
 					layout.showTotals = Ext.isBoolean(config.totals) ? config.totals : (Ext.isBoolean(config.showTotals) ? config.showTotals : true);
 					layout.showSubTotals = Ext.isBoolean(config.subtotals) ? config.subtotals : (Ext.isBoolean(config.showSubTotals) ? config.showSubTotals : true);
 					layout.hideEmptyRows = Ext.isBoolean(config.hideEmptyRows) ? config.hideEmptyRows : false;
-					
+
 					layout.showHierarchy = Ext.isBoolean(config.showHierarchy) ? config.showHierarchy : false;
 
 					layout.displayDensity = Ext.isString(config.displayDensity) && !Ext.isEmpty(config.displayDensity) ? config.displayDensity : 'normal';
@@ -799,7 +799,7 @@
 			};
 
 			api.response = {};
-			
+
 			api.response.Header = function(config) {
 				var header = {};
 
@@ -883,43 +883,43 @@
 				}();
 			};
 		}());
-		
+
 		// service
 		(function() {
 			service.layout = {};
-			
+
 			service.layout.getObjectNameDimensionMap = function(dimensionArray) {
 				var map = {};
-				
-				if (Ext.isArray(dimensionArray) && dimensionArray.length) {					
+
+				if (Ext.isArray(dimensionArray) && dimensionArray.length) {
 					for (var i = 0, dim; i < dimensionArray.length; i++) {
 						dim = api.layout.Dimension(dimensionArray[i]);
-						
+
 						if (dim) {
 							map[dim.dimension] = dim;
 						}
 					}
 				}
-				
+
 				return map;
-			};				
-			
+			};
+
 			service.layout.getObjectNameDimensionItemsMap = function(dimensionArray) {
 				var map = {};
-				
-				if (Ext.isArray(dimensionArray) && dimensionArray.length) {					
+
+				if (Ext.isArray(dimensionArray) && dimensionArray.length) {
 					for (var i = 0, dim; i < dimensionArray.length; i++) {
 						dim = api.layout.Dimension(dimensionArray[i]);
-						
+
 						if (dim) {
 							map[dim.dimension] = dim.items;
 						}
 					}
 				}
-				
+
 				return map;
 			};
-							
+
 			service.response = {};
 		}());
 
@@ -1169,7 +1169,7 @@
 						paramString += '&filter=' + dim.dimensionName + ':' + dim.ids.join(';');
 					}
 				}
-				
+
 				if (xLayout.showHierarchy) {
 					paramString += '&hierarchyMeta=true';
 				}
@@ -1207,26 +1207,26 @@
 
 				isHierarchy = function(id, response) {
 					return layout.showHierarchy && Ext.isObject(response.metaData.ouHierarchy) && response.metaData.ouHierarchy.hasOwnProperty(id);
-				};						
-					
+				};
+
 				getItemName = function(id, response, isHtml) {
 					var metaData = response.metaData,
 						name = '';
-					
+
 					if (isHierarchy(id, response)) {
 						var a = Ext.clean(metaData.ouHierarchy[id].split('/'));
 						a.shift();
-						
+
 						for (var i = 0; i < a.length; i++) {
 							name += (isHtml ? '<span class="text-weak">' : '') + metaData.names[a[i]] + (isHtml ? '</span>' : '') + ' / ';
 						}
 					}
-					
+
 					name += metaData.names[id];
-					
+
 					return name;
 				};
-				
+
 				getSyncronizedXLayout = function(xLayout, response) {
 					var removeDimensionFromXLayout,
 						getHeaderNames,
@@ -1341,10 +1341,10 @@
 											responseOu = response.metaData[ou];
 
 										userOugc = [];
-										
+
 										for (var j = 0, id; j < responseOu.length; j++) {
 											id = responseOu[j];
-											
+
 											if (!Ext.Array.contains(userOuOuc, id)) {
 												userOugc.push({
 													id: id,
@@ -1361,7 +1361,7 @@
 								else if (isLevel || isGroup) {
 									for (var j = 0, responseOu = response.metaData[ou], id; j < responseOu.length; j++) {
 										id = responseOu[j];
-										
+
 										dim.items.push({
 											id: id,
 											name: getItemName(id, response)
@@ -2436,9 +2436,9 @@
 				};
 
 				afterLoad = function(layout, xLayout, xResponse) {
-					
+
 					if (pt.isPlugin) {
-						
+
 						// Resize render elements
 						var baseEl = Ext.get(pt.init.el),
 							baseElBorderW = parseInt(baseEl.getStyle('border-left-width')) + parseInt(baseEl.getStyle('border-right-width')),
@@ -2457,7 +2457,7 @@
 							setMouseHandlers();
 							engine.setSessionStorage('table', layout);
 						}
-						
+
 						if (updateGui) {
 							pt.viewport.setGui(layout, xLayout, updateGui, isFavorite);
 						}
@@ -2479,80 +2479,88 @@
 						console.log("xResponse", xResponse);
 						console.log("xLayout", xLayout);
 					}
-				};					
-
-				initialize = function() {
-					var url,
-						xLayout,
-						xResponse,
-						xColAxis,
-						xRowAxis;
-
-					// Extended layout
-					xLayout = engine.getExtendedLayout(layout);
-
-					// Param string
-					pt.paramString = engine.getParamString(xLayout, true);
-					url = pt.init.contextPath + '/api/analytics.json' + pt.paramString;
+				};
+
+                initialize = function() {
+                    var xLayout = engine.getExtendedLayout(layout),
+                        paramString = engine.getParamString(xLayout, true),
+						method = 'GET',
+						success;
+
+					success = function(response) {
+						var xResponse,
+							chart,
+							html,
+							response = pt.api.response.Response(response);
+
+						if (!response) {
+							pt.util.mask.hideMask(pt.viewport.centerRegion);
+							return;
+						}
+
+						// Synchronize xLayout
+						xLayout = getSyncronizedXLayout(xLayout, response);
+
+						if (!xLayout) {
+							pt.util.mask.hideMask(pt.viewport.centerRegion);
+							return;
+						}
+
+						// Extended response
+						xResponse = getExtendedResponse(response, xLayout);
+
+						// Extended axes
+						xColAxis = getExtendedAxis('col', xLayout.columnDimensionNames, xResponse);
+						xRowAxis = getExtendedAxis('row', xLayout.rowDimensionNames, xResponse);
+
+						// Create html
+						html = getTableHtml(xColAxis, xRowAxis, xResponse);
+
+						// Update viewport
+						pt.viewport.centerRegion.removeAll(true);
+						pt.viewport.centerRegion.update(html);
+
+						pt.paramString = paramString;
+
+						afterLoad(layout, xLayout, xResponse);
+					};
 
 					// Validate request size
-					if (!validateUrl(url)) {
-						return;
-					}
+                    if (!validateUrl(init.contextPath + '/api/analytics.jsonp' + paramString)) {
+                        return;
+                    }
 
 					// Show load mask
-					pt.util.mask.showMask(pt.viewport.centerRegion);
-
-					Ext.Ajax.request({
-						method: 'GET',
-						url: url,
-						callbackName: 'analytics',
-						timeout: 60000,
-						headers: {
-							'Content-Type': 'application/json',
-							'Accept': 'application/json'
-						},
-						disableCaching: false,
-						failure: function(r) {
-							pt.util.mask.hideMask(pt.viewport.centerRegion);
-							alert(r.responseText);
-						},
-						success: function(r) {
-							var html,
-								response = pt.api.response.Response(Ext.decode(r.responseText));
-
-							if (!response) {
-								pt.util.mask.hideMask(pt.viewport.centerRegion);
-								return;
-							}
-
-							// Synchronize xLayout
-							xLayout = getSyncronizedXLayout(xLayout, response);
-
-							if (!xLayout) {
-								pt.util.mask.hideMask(pt.viewport.centerRegion);
-								return;
-							}
-
-							// Extended response
-							xResponse = getExtendedResponse(response, xLayout);
-
-							// Extended axes
-							xColAxis = getExtendedAxis('col', xLayout.columnDimensionNames, xResponse);
-							xRowAxis = getExtendedAxis('row', xLayout.rowDimensionNames, xResponse);
-
-							// Create html
-							html = getTableHtml(xColAxis, xRowAxis, xResponse);
-
-							// Update viewport
-							pt.viewport.centerRegion.removeAll(true);
-							pt.viewport.centerRegion.update(html);
-							
-							afterLoad(layout, xLayout, xResponse);
-						}
-					});
-
-				}();
+                    util.mask.showMask(pt.viewport.centerRegion);
+
+                    if (pt.isPlugin) {
+						Ext.data.JsonP.request({
+							method: method,
+							url: init.contextPath + '/api/analytics.jsonp' + paramString,
+							disableCaching: false,
+							success: success
+						});
+					}
+					else {
+						Ext.Ajax.request({
+							method: method,
+							url: init.contextPath + '/api/analytics.json' + paramString,
+							timeout: 60000,
+							headers: {
+								'Content-Type': 'application/json',
+								'Accept': 'application/json'
+							},
+							disableCaching: false,
+							failure: function(r) {
+								util.mask.hideMask(pt.viewport.centerRegion);
+								alert(r.responseText);
+							},
+							success: function(r) {
+								success(Ext.decode(r.responseText));
+							}
+						});
+					}
+                }();
 			};
 
 			engine.loadTable = function(id, pt, updateGui, isFavorite) {

=== modified file 'dhis-2/dhis-web/dhis-web-visualizer/src/main/webapp/dhis-web-visualizer/app/plugin.html'
--- dhis-2/dhis-web/dhis-web-visualizer/src/main/webapp/dhis-web-visualizer/app/plugin.html	2013-10-08 17:07:19 +0000
+++ dhis-2/dhis-web/dhis-web-visualizer/src/main/webapp/dhis-web-visualizer/app/plugin.html	2013-10-16 12:10:40 +0000
@@ -5,8 +5,7 @@
 
     <script src="../../dhis-web-commons/javascripts/ext/ext-all.js"></script>
     <script src="../../dhis-web-commons/javascripts/simpleRegression.js"></script>
-	<script src="scripts/core.js"></script>
-	<script src="scripts/plugin.js"></script>
+    <script src="../../dhis-web-commons/javascripts/plugin/chart.js"></script>
 
     <style type="text/css">
 		body {font-family: sans-serif; margin: 0 0 0 60px;}

=== modified file 'dhis-2/dhis-web/dhis-web-visualizer/src/main/webapp/dhis-web-visualizer/app/scripts/core.js'
--- dhis-2/dhis-web/dhis-web-visualizer/src/main/webapp/dhis-web-visualizer/app/scripts/core.js	2013-10-08 09:53:16 +0000
+++ dhis-2/dhis-web/dhis-web-visualizer/src/main/webapp/dhis-web-visualizer/app/scripts/core.js	2013-10-16 12:10:40 +0000
@@ -2235,70 +2235,80 @@
 				};
 
                 initialize = function() {
-                    var url,
-                        xLayout,
-                        xResponse,
-                        chart;
-
-					// Extended layout
-                    xLayout = engine.getExtendedLayout(layout);
-
-                    dv.paramString = engine.getParamString(xLayout, true);
-                    url = init.contextPath + '/api/analytics.json' + dv.paramString;
+                    var xLayout = engine.getExtendedLayout(layout),
+                        paramString = engine.getParamString(xLayout, true),
+						method = 'GET',
+						success;
+
+					success = function(response) {
+						var xResponse,
+							chart,
+							html,
+							response = dv.api.response.Response(response);
+
+						if (!response) {
+							dv.util.mask.hideMask(dv.viewport.centerRegion);
+							return;
+						}
+
+						// Synchronize xLayout
+						xLayout = getSyncronizedXLayout(xLayout, response);
+
+						if (!xLayout) {
+							dv.util.mask.hideMask(dv.viewport.centerRegion);
+							return;
+						}
+
+						// Extended response
+						xResponse = getExtendedResponse(response, xLayout);
+
+						// Create chart
+						chart = generator[xLayout.type](xResponse, xLayout);
+
+						// Update viewport
+						dv.viewport.centerRegion.removeAll(true);
+						dv.viewport.centerRegion.add(chart);
+
+						dv.paramString = paramString;
+
+						afterLoad(layout, xLayout, xResponse);
+					};
 
 					// Validate request size
-                    if (!validateUrl(url)) {
+                    if (!validateUrl(init.contextPath + '/api/analytics.jsonp' + paramString)) {
                         return;
                     }
 
 					// Show load mask
                     util.mask.showMask(dv.viewport.centerRegion);
 
-                    Ext.Ajax.request({
-                        method: 'GET',
-                        url: url,
-                        callbackName: 'analytics',
-                        timeout: 60000,
-                        headers: {
-                            'Content-Type': 'application/json',
-                            'Accept': 'application/json'
-                        },
-                        disableCaching: false,
-                        failure: function(r) {
-                            util.mask.hideMask(dv.viewport.centerRegion);
-                            alert(r.responseText);
-                        },
-                        success: function(r) {
-                            var html,
-								response = dv.api.response.Response(Ext.decode(r.responseText));
-
-							if (!response) {
-								dv.util.mask.hideMask(dv.viewport.centerRegion);
-								return;
+                    if (dv.isPlugin) {
+						Ext.data.JsonP.request({
+							method: method,
+							url: init.contextPath + '/api/analytics.jsonp' + paramString,
+							disableCaching: false,
+							success: success
+						});
+					}
+					else {
+						Ext.Ajax.request({
+							method: method,
+							url: init.contextPath + '/api/analytics.json' + paramString,
+							timeout: 60000,
+							headers: {
+								'Content-Type': 'application/json',
+								'Accept': 'application/json'
+							},
+							disableCaching: false,
+							failure: function(r) {
+								util.mask.hideMask(dv.viewport.centerRegion);
+								alert(r.responseText);
+							},
+							success: function(r) {
+								success(Ext.decode(r.responseText));
 							}
-
-							// Synchronize xLayout
-                            xLayout = getSyncronizedXLayout(xLayout, response);
-
-                            if (!xLayout) {
-                                dv.util.mask.hideMask(dv.viewport.centerRegion);
-                                return;
-                            }
-
-							// Extended response
-                            xResponse = getExtendedResponse(response, xLayout);
-
-							// Create chart
-                            chart = generator[xLayout.type](xResponse, xLayout);
-
-							// Update viewport
-                            dv.viewport.centerRegion.removeAll(true);
-                            dv.viewport.centerRegion.add(chart);
-
-                            afterLoad(layout, xLayout, xResponse);
-                        }
-                    });
-
+						});
+					}
                 }();
             };