1. Shlomi Fish
  2. shlomi-fish-homepage

Commits

Shlomi Fish  committed c758c81

Add support for the IDs in _data/nav.json to to-jqtree.

  • Participants
  • Parent commits f18614c
  • Branches default

Comments (0)

Files changed (2)

File Tests/js/jqtree-from-h-w-json-nav-menu-test.js

View file
  • Ignore whitespace
         {
             var input = [
             {
+                id: 1,
                 "text": 'Shlomi Fish',
                 "url": "",
                 "subs": [
                     {
+                        id: 2,
                         "text": "About Myself",
                         "url": "me/"
                     },
                     {
+                        id: 3,
                         "text": "Humour",
                         "title": "Stories and Aphorisms I wrote",
                         "url": "humour/"
         {
             var input = [
             {
+                id: 1,
                 "text": 'Shlomi Fish',
                 "url": "",
                 "subs": [
                     {
+                        id: 2,
                         "text": "About Myself",
                         "url": "me/"
                     },
                     {
+                        id: 3,
                         "text": "Humour",
                         "title": "Stories and Aphorisms I wrote",
                         "url": "humour/",
                         "subs": [
                             {
+                                id: 4,
                                 "text": "The One With The Fountainhead",
                                 "title": "Parody of The Fountainhead",
                                 "url": "humour/TOWTF/"
                             },
                             {
+                                id: 5,
                                 "text": "HHFG",
                                 "title": "The Human Hacking Field Guide",
                                 "url": "humour/human-hacking/",
                                 "subs": [
                                     {
+                                        id: 6,
                                         "text": "Hebrew Translation",
                                         "url": "humour/human-hacking/heb.html"
                                     }

File common/js/to-jqtree.js

View file
  • Ignore whitespace
 
     // TODO : XSS - cross site scripting.
     var _recurse;
-    var _next_id = 0;
 
     _recurse = function(sub_tree) {
         if ($.isArray(sub_tree)) {
             title_attr = ' title="' + sub_tree['title'] + '"'
         }
         var ret = {
+            id: parseInt(sub_tree['id']),
             label: ("<a href=\"" +
                 escape_html(_get_rel(sub_tree['url'])) + "\"" + title_attr +
                 ">" + sub_tree['text'] + "</a>"
-                ),
-            id: (++_next_id),
+                )
         };
 
         if ('subs' in sub_tree) {