Re:Show HN: JsonTree, a 3.53kb JavaScript tool for generatin...
by brockwhittaker on Friday February 24, 2017 @07:28PM
(#13729233)
You should consider removing all the other functions from the global scope, especially because they have relatively generic names like "generateTree", "toArray", "depth", and "toggleClass".
Consider using an actual class or a closure perhaps?
Re:Show HN: JsonTree, a 3.53kb JavaScript tool for generatin...
by MaxLeiter on Saturday February 25, 2017 @01:18AM
(#13730344)
Yours is much cleaner code though; this was my first venture in javascript (and really programming) when I wrote it and am planning on refactoring it soon(tm). Great work with Kapok, the demo page is well done.
Re:Show HN: JsonTree, a 3.53kb JavaScript tool for generatin...
by EdSharkey on Friday February 24, 2017 @07:57PM
(#13729364)
I'm not a fan of javascript being used for the clicky handlers, even if the element being clicked is a natural clicky element like an anchor tag.
It's much better to rely on a toggle like input type=checkbox and CSS to visualize tree expand and collapse based on checkbox states than to install click handlers in javascript. I suspect you could make such an arrangement more accessible and keyboard navigable as well (via grouping.)
Javascript should only be used to dynamically load/unload subtrees on click in the case of especially huge or costly trees.
Re:Show HN: JsonTree, a 3.53kb JavaScript tool for generatin...
by recklessplayer on Sunday February 26, 2017 @03:09AM
(#13736224)
As a blind screen reader user, I rely on keyboard accessibility for navigating any type of tree.
Now I know not to checkout your project as it would be of no use to me.
Consider using an actual class or a closure perhaps?
https://github.com/cheezmeister/kapok
[I think it does most of what yours does](https://github.com/Cheezmeister/kapok/blob/master/tst/kapok....) (EDIT: Nope, missing URL loading and XSS cleaning!)
https://developer.mozilla.org/en/docs/Web/CSS/cursor
Here's an example of a tree widget that can be navigated by keyboard: https://www.jstree.com/docs/html/
It's much better to rely on a toggle like input type=checkbox and CSS to visualize tree expand and collapse based on checkbox states than to install click handlers in javascript. I suspect you could make such an arrangement more accessible and keyboard navigable as well (via grouping.)
Javascript should only be used to dynamically load/unload subtrees on click in the case of especially huge or costly trees.