Commit 83706943 authored by Aran Dunkley's avatar Aran Dunkley

make ajax functionality compatible with JSON returned by API calls

parent 69cb695e
......@@ -14,7 +14,7 @@
*/
if( !defined( 'MEDIAWIKI' ) ) die( 'Not an entry point.' );
define( 'TREEANDMENU_VERSION','4.1.1, 2015-04-28' );
define( 'TREEANDMENU_VERSION','4.1.2, 2015-06-08' );
define( 'TREEANDMENU_TREE', 1 );
define( 'TREEANDMENU_MENU', 2 );
......
......@@ -89,6 +89,15 @@
// Otherwise see if it's as a JSON list of node data (need to extract as MediaWiki adds parser info)
else if(m = response.match(/^.*?(\[[\s\S]+\])/i)) data.result = $.parseJSON(m[1]);
// Otherwise see if it's as a JSON list of node data contained in an object (as it is in an API response)
else if(m = response.match(/^\{/)) {
var json = $.parseJSON(response);
data.result = false;
for( var k in json ) {
if( data.result === false && typeof json[k] == 'array' ) data.result = json[k];
}
}
// Otherwise just return an empty node set (should raise an error)
else data.result = [];
};
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment