/******************************************************************** * CreateNewFolder Dialog ===================================================================== * Creation date: 23-01-2015 by octazid * Last update: 23-01-2015 by octazid ===================================================================== * Simple dialog to create a new folder ********************************************************************/ //*** CreateNewFolder Dialog***// function NewFolderDialog(savepath) { var self = this; this.Fdlg = app.CreateDialog("Create a new Folder:"); this.Flay = app.CreateLayout( "Linear", "FillXY" ); this.Ftxtpath = app.CreateText(savepath,0.9,0.02,"Left,Autoscale"); this.Ftxtpath.SetMargins(0,0.01,0,0); this.Ftxtpath.parent = self; this.Flay.AddChild(this.Ftxtpath); this.Fedt = app.CreateTextEdit("",0.9,0.05,"Left"); this.Fedt.SetTextSize(18); this.Fedt.SetHint("Foldername"); this.Fedt.parent = self; this.Flay.AddChild(this.Fedt); this.Fbtnlay = app.CreateLayout( "Linear", "Horizontal,FillXY" ); this.Fdlgbtn = app.CreateButton("OK", 0.45); this.Fdlgbtn.parent = self; this.Fdlgbtn.SetOnTouch(Fdlgbtn_OnTouch); this.Fbtnlay.AddChild(this.Fdlgbtn); this.FdlgbtnCancel = app.CreateButton("Chancel",0.45); this.FdlgbtnCancel.parent = self; this.FdlgbtnCancel.SetOnTouch(Fdlgbtn_OnTouch); this.Fbtnlay.AddChild(this.FdlgbtnCancel); this.Flay.AddChild(this.Fbtnlay) this.Fdlg.AddLayout(this.Flay); this.Show = function(){self.Fdlg.Show();} this.Hide = function(){self.Fdlg.Hide();} }//function NewFolderDialog() // Called if a button is touched function Fdlgbtn_OnTouch() { var par = this.parent; folder = par.Fedt.GetText(); path = par.Ftxtpath.GetText(); if(this.GetText() == "OK") CreateFolder(folder, path); par.Hide(); }//function Fdlgbtn_OnTouch // Called if Button Ok is touched function CreateFolder(foldername, path) { if (foldername != "") { //Replace illegal letters foldername = foldername.replace(/(=|\\|\/|\*|:|,|;|\+|<|>|\"|\[|\]|\?|\|)/g,""); //Replace double Whitespaces foldername = foldername.replace(/(\s+)/g," "); //Replace Whitespaces at the start and at the end foldername = foldername.trim(); //Check if Folder exists. If yes, show a message if (app.FolderExists(path + foldername)) { app.Alert("Please select another Foldername!", "Error - Folder already exists!"); } else { //Create the folder app.MakeFolder(path + foldername); //show a message if creation was ok if (app.FolderExists(path + foldername)) app.ShowPopup("Folder Created!"); } } }//function CreateFolder