From 5adf77a193ed63e6ca6740ce7bcd660a453053a2 Mon Sep 17 00:00:00 2001 From: Cristina Date: Mon, 30 Jul 2018 13:09:27 +0200 Subject: [PATCH] Use getPath in onEvent --- examples/16_on_event_api.html | 34 +++++++++++++++------------------- src/js/Node.js | 23 +---------------------- 2 files changed, 16 insertions(+), 41 deletions(-) diff --git a/examples/16_on_event_api.html b/examples/16_on_event_api.html index ab99240..25c4f77 100644 --- a/examples/16_on_event_api.html +++ b/examples/16_on_event_api.html @@ -51,7 +51,7 @@ onEvent: function(node, event) { if (event.type === 'click') { var message = 'click on <' + node.field + - '> under path <' + printPath(node.path) + + '> under path <' + node.path + '> with pretty path: <' + prettyPrintPath(node.path) + '>'; if (node.value) message += ' with value <' + node.value + '>'; console.log(message); @@ -60,37 +60,33 @@ var str = ''; for (var i=0; i0 && (path[i-1].type === 'array')) { - str += '[' + element.name + ']' + if (typeof element === 'number') { + str += '[' + element + ']' } else { - str += (str.length > 0) ? ','+element.name : element.name; + if (str.length > 0) str += ','; + str += element; } } return str; } - function printPath(path) { - var str = ''; - for (var i=0; i