diff --git a/assets/js/scancode.js b/assets/js/scancode.js index 0581aff8..69938a54 100644 --- a/assets/js/scancode.js +++ b/assets/js/scancode.js @@ -249,14 +249,33 @@ $(document).ready(function () { var jstree = $('#jstree').jstree({ "types": { - "folder": { + "directory": { "icon": "glyphicon glyphicon-folder-close" }, "file": { "icon": "glyphicon glyphicon-file" } }, - "plugins": [ "types"] + "plugins": [ "types" , "sort"], + //A sort function to sort the tree so that folders come first + "sort": function(a,b){ + x = this.get_node(a) + y = this.get_node(b) + if(x.type == "directory"){ + if(y.type == "directory"){ + //if both the nodes are directory, alphabetic wise priority is given + return (x.text>y.text) ? 1 : -1 + }else{ + return -1 + } + }else{ + if(y.type == "directory"){ + return 1 + }else{ + return (x.text>y.text) ? 1 : -1 + } + } + } }) .on('open_node.jstree', function (evt, data) { data.instance.set_icon( @@ -289,6 +308,11 @@ $(document).ready(function () { // The xhr.dt event occurs whenever new json data is loaded .on('xhr.dt', function (event, settings, json, xhr) { scanData = new ScanData(json); + //Fixing jsTreeData + for(var i=0;i