lundi 25 juillet 2016

I have file where at start of line tabs are for tree level, how to count tabs in start of lines

I want to count tabs in the start
of lines and create tree levels

$(".importTree").on("change", function(e) {

    var file = this.files[0];
    var reader = new FileReader();
    reader.onload = function(progressEvent){
           var tree = this.result.split('n');
           var tabLvl = [] ;
           for (line in tree) {
                tabLvl.push(tree[line].split(/[^t]/)[0].length)
                console.log(tabLvl);
           };
          //after I split file into lines tabs are disappeared
      };
      reader.readAsText(file);
   };
});

after I split file into lines tabs are disappeared

Aucun commentaire:

Enregistrer un commentaire