This shows you the differences between two versions of the page.
Next revision | Previous revision | ||
sample_code:folder_picker [2014/11/26 12:25] stevegarman created |
sample_code:folder_picker [2015/02/19 23:17] (current) |
||
---|---|---|---|
Line 4: | Line 4: | ||
See also [[sample_code: | See also [[sample_code: | ||
===== The code ===== | ===== The code ===== | ||
- | |||
<code javascript folderpicker.js> | <code javascript folderpicker.js> | ||
Line 19: | Line 18: | ||
// | // | ||
app.AddLayout( lay ); | app.AddLayout( lay ); | ||
+ | pick = new FolderPicker(mycallback); | ||
+ | // | ||
+ | pick.SetHideFiles(true); | ||
}// | }// | ||
function btn_OnTouch(){ | function btn_OnTouch(){ | ||
- | pick = new FolderPicker(mycallback); | ||
pick.SetFolder("/ | pick.SetFolder("/ | ||
pick.Show(); | pick.Show(); | ||
Line 37: | Line 38: | ||
this.callback = Callback || function(){}; | this.callback = Callback || function(){}; | ||
this.FolderPath = this.basePath; | this.FolderPath = this.basePath; | ||
+ | this.hideHiddenFiles = false; | ||
this.dlg = app.CreateDialog(this.basePath); | this.dlg = app.CreateDialog(this.basePath); | ||
this.lay = app.CreateLayout( " | this.lay = app.CreateLayout( " | ||
Line 61: | Line 63: | ||
this.Show = function(){ | this.Show = function(){ | ||
self.dlg.Show(); | self.dlg.Show(); | ||
+ | } | ||
+ | this.SetHideFiles=function(val){ | ||
+ | if(val == undefined) val = true; | ||
+ | self.hideHiddenFiles = val; | ||
} | } | ||
this.Hide = function(){ | this.Hide = function(){ | ||
Line 74: | Line 80: | ||
var lst = app.ListFolder(folderPath); | var lst = app.ListFolder(folderPath); | ||
lst.sort(function(x, | lst.sort(function(x, | ||
- | var dirlist=[]; | + | self.lstFolds.SetList("" |
- | if( self.FolderPath != self.basePath ) dirlist = [" | + | if( self.FolderPath != self.basePath ) |
+ | self.lstFolds.AddItem(" | ||
var ths = lst.shift(); | var ths = lst.shift(); | ||
while (undefined != ths) { | while (undefined != ths) { | ||
- | var pth = folderPath + "/" | + | if ((! self.hideHiddenFiles) || (ths.indexOf(" |
- | if (app.IsFolder(pth))dirlist.push(ths); | + | var pth = folderPath + "/" |
+ | if (app.IsFolder(pth)) | ||
+ | self.lstFolds.AddItem(ths, | ||
+ | } | ||
ths = lst.shift(); | ths = lst.shift(); | ||
} | } | ||
- | self.lstFolds.SetList(dirlist.join("," | ||
app.HideProgress(); | app.HideProgress(); | ||
} | } |