Guest User

Lunder

a guest
Apr 7th, 2015
284
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. function CheckPath(p, temp) {
  2.     var result = new Array();
  3.     var folders = new Array();
  4.     var res = null;
  5.     folders.push(p);
  6.     var licznik = folders.length;
  7.     while( licznik > 0) {
  8.         res = TestDir(folders[0], temp);
  9.         result.concat(res[0]);
  10.         folders.concat(res[1]);
  11.         folders.shift();
  12.         licznik = folders.length;
  13.     }
  14.     return folders;
  15. }
  16.  
  17. function TestDir(p, temp) {
  18.     var result = new Array(new Array(), new Array());
  19.     var folders = new Array();
  20.    
  21.     return Promise.resolve($.ajax({
  22.         method: "POST",
  23.         url: "testcore.php",
  24.         data: { path: p, template: temp},
  25.         dataType: "json"
  26.     })).then(function(data) {
  27.         result[0] = data[0];
  28.         folders = data[1];
  29.         if(folders.length > 0) {
  30.             for(i = 0; i<folders.length; i++) {
  31.                 zm = folders[i].split("/");
  32.                 zm = zm[zm.length-1];
  33.                 if( zm != "static" && zm != "_products" && zm != "templates" && zm != "") {
  34.                     result[1].push(folders[i]);
  35.                 }
  36.             }
  37.         }
  38.     }).then(function() {
  39.         return result;
  40.     });
  41. }
Advertisement
Add Comment
Please, Sign In to add comment