Skip to content

Commit

Permalink
feat(plugin): full text of JSON results
Browse files Browse the repository at this point in the history
Relates #5729
  • Loading branch information
alyec committed Apr 20, 2015
1 parent 88deeec commit 00718b8
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 6 deletions.
2 changes: 1 addition & 1 deletion src/js/RAMP/Modules/mapClickHandler.js
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,7 @@ define([

var strings = dojoArray.map(results, function (response, index) {
var res = "<h5 class='margin-top-none'>" + visibleLayers[index].layerConfig.displayName + "</h5>" +
RAMP.plugins.featureInfoParser[visibleLayers[index].layerConfig.featureInfo.parser](response);
RAMP.plugins.featureInfoParser[visibleLayers[index].layerConfig.featureInfo.parser](response,visibleLayers[index].wmsLayer.id);
return res;
});

Expand Down
14 changes: 9 additions & 5 deletions src/js/plugins/jsonParse.js
Original file line number Diff line number Diff line change
@@ -1,13 +1,17 @@
/* global RAMP, console */

console.log('loading jsonParse');
RAMP.plugins.featureInfoParser.jsonParse = function (data) {
RAMP.plugins.featureInfoParser.jsonParse = function (data, layerId) {
'use strict';
var summary;
var summary, txArea;

data = { a: 1, b: '2', c: true, d: [1, 2, 3], e: { f: 1, g: 2 }, h: null };
data = { a: 1, b: '2', c: true, d: [1, 2, 3], e: { f: 1, g: 2 }, h: layerId };
if (typeof data === 'string') {
data = JSON.parse(data);
}

summary = Object.keys(data).filter(function (e) { return typeof data[e] !== 'object' && typeof data[e] !== 'undefined'; }).map(function (e) { return '<tr><th>{0}</th><td>{1}</td></tr>'.format(e, data[e]); }).join('');
summary = Object.keys(data).filter(function (e) { return typeof data[e] !== 'object' && typeof data[e] !== 'undefined'; }).map(function (e) { return '<tr><th>{0}</th><td style="padding-left: 1em">{1}</td></tr>'.format(e, data[e]); }).join('');
txArea = '<textarea style="display: none">{0}</textarea>'.format(JSON.stringify(data));

return "<table>{0}</table>".format(summary);
return '<table>{0}</table>{1}'.format(summary,txArea);
};

0 comments on commit 00718b8

Please sign in to comment.