Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

[ux][fix] Chose a different ToC order. Also, wrote cleaner, working s…

…ort code.
  • Loading branch information...
commit 5ca328a3a79f691eca83829498ca1ad2f640aa6c 1 parent ea44823
@jfhbrook jfhbrook authored
Showing with 28 additions and 17 deletions.
  1. +28 −17 lib/helpers.js
View
45 lib/helpers.js
@@ -87,41 +87,52 @@ helpers.filesToTree = function(files){
// Function to use with sorting the ToC.
//
helpers.tocSort = function (a, b) {
+ // For future reference, here is the list from the top-level.
+ /*[
+ 'cryptography',
+ 'advanced',
+ 'intermediate',
+ 'errors',
+ 'file-system',
+ 'javascript-conventions',
+ 'child-processes',
+ 'command-line',
+ 'REPL',
+ 'getting-started',
+ 'HTTP' ]
+ */
// These items should be listed *first*.
var first = [
'getting-started',
- 'intermediate',
- 'advanced',
'javascript-conventions'
];
// These items should be listed *last*.
var last = [
+ 'intermediate',
+ 'advanced',
'cryptography'
];
+ //a > b: --> 1
+
// Handles the case where a and/or b is in the "first" list.
if ( -~first.indexOf(a) || -~first.indexOf(b) ) {
- return -~first.indexOf(a) ? (
- -~first.indexOf(b)
- ? first.indexOf(a) - first.indexOf(b)
- : -1
- ) : 1
- };
-
- // Handles the case where a and/or b is in the "last" list.
+
+ return ( -~first.indexOf(a) && -~first.indexOf(b) )
+ ? (first.indexOf(a) - first.indexOf(b))
+ : ( -~first.indexOf(a) ? -1 : 1);
+
+ }
+
if ( -~last.indexOf(a) || -~last.indexOf(b) ) {
- return -~last.indexOf(a) ? (
- -~last.indexOf(b)
- ? last.indexOf(a) - last.indexOf(b)
- : 1
- ) : -1
+ return (-~last.indexOf(a) && -~last.indexOf(b))
+ ? (last.indexOf(a) - last.indexOf(b))
+ : ( -~last.indexOf(a) ? 1 : -1);
}
- // Handles "default" case.
return a > b ? 1 : (a < b ? -1 : 0);
-
};
helpers.treeToHTML = function(values, parent) {
Please sign in to comment.
Something went wrong with that request. Please try again.