Search the Community
Showing results for tags 'directory structure'.
-
Hello, I started a little script to create a html page with links from a local directory structure. At the end I want to have a html page which cotains tags like (div, span, ul, li, ...) to use it with Javascript. The script works, but now the requirements have changed The user wants to have a foldertree like here: Example can be seen here: http://www.soa-bpm-integration.com/2009-07-12-dateibaeume-drupal-jquery-darstellen So, that is why the html tags need to be set correctly, because my thought was to use Javascript which can also be written into the page which extends the functionality. With JQuery and some plugins. (see example) Anybody who can help with this (only the Autoit part) or anybody who has already a piece of code which does the job? Opt('MustDeclareVars', 1) Global $GUI _main() Func _main() #region ### START Koda GUI section ### Form=C:\Users\xf01145\Documents\GUI.kxf $GUI = GUICreate("Linkseitengenerator", 615, 204, 192, 124) GUICtrlCreateGroup("Einstellungen", 5, 10, 605, 190) GUICtrlCreateLabel("Titel der Seite", 15, 30, 69, 17) Local $title_I = GUICtrlCreateInput("Linksammlung", 145, 25, 456, 21) GUICtrlCreateLabel("Überschrift", 15, 55, 55, 17) Local $headline_I = GUICtrlCreateInput("Überschrift", 145, 50, 456, 21) Local $selectFolder_B = GUICtrlCreateButton("Startordner auswählen", 10, 120, 120, 25) Local $symbol_I = GUICtrlCreateInput("-", 145, 75, 456, 21) GUICtrlCreateLabel("Einrücksymbol", 15, 80, 72, 17) Local $startDir_I = GUICtrlCreateInput("c:\Autoit\GAD\Startseite-MI\", 145, 125, 456, 21) ;~ Local $startDir_I = GUICtrlCreateInput("", 145, 125, 456, 21) GUICtrlCreateGroup("Start", 5, 150, 605, 50) Local $start_B = GUICtrlCreateButton("Linkseite generieren", 15, 165, 590, 25) GUICtrlCreateGroup("", -99, -99, 1, 1) GUICtrlCreateLabel("Dateiname (index.html)", 15, 100, 111, 17) Local $filename_I = GUICtrlCreateInput("index.html", 145, 100, 456, 21) GUICtrlCreateGroup("", -99, -99, 1, 1) GUISetState(@SW_SHOW) #endregion ### END Koda GUI section ### Local $nMsg = 0 While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE Exit (0) Case $selectFolder_B GUICtrlSetData($startDir_I, _selectStartFolder()) Case $start_B FileDelete(GUICtrlRead($filename_I)) _writeHTML(GUICtrlRead($title_I), GUICtrlRead($headline_I), GUICtrlRead($symbol_I), GUICtrlRead($filename_I), GUICtrlRead($startDir_I)) ShellExecute(GUICtrlRead($filename_I)) EndSwitch WEnd EndFunc ;==>_main Func _selectStartFolder() Local $startDir = FileSelectFolder('Hallo Frau Wahrendorf, bitte wählen Sie den Startordner aus:', '', 7, @ScriptDir, $GUI) If @error = 1 Then Exit (0) Return $startDir EndFunc ;==>_selectStartFolder Func _writeHTML($title, $headline, $symbol, $filename, $startDir) Local $szDrive, $szDir, $szFName, $szExt, $TestPath, $dir Local $startLevel = 0 Local $currentLevel = 0 Local $priviousLevel = 0 Local $count = 0 Local $splitted_A = 0 Local $links = '' Local $ID = 0 Local $level = 0 Local $re = _RecFileListToArray($startDir, '*', 0, 1, 1, 2) StringReplace($startDir, '\', '\') ; startDir $startLevel = @extended For $i = 1 To UBound($re) - 1 $currentLevel = 0 StringReplace($re[$i], '\', '\') ; relativeDir $currentLevel = @extended $count = $currentLevel - $startLevel ; Verzeichnis If FileGetAttrib($re[$i]) = 'D' Then If $count = 0 Then $links &= '</br>' & @CRLF $links &= '<div id="' & $ID & '" style="font-size:16px;padding-left:' & $count * 15 & 'px;" onClick="javascript:toggle(' & $ID & ');"><b>' & $re[$i] & '</b></div>' & @CRLF ConsoleWrite($re[$i] & ' ' & $count & @CRLF) $ID += 1 Else ; Link / Datei $splitted_A = _PathSplit($re[$i], $szDrive, $szDir, $szFName, $szExt) $re[$i] = StringReplace($re[$i], '\', '/') $links &= '<a style="padding-left:' & $count * 15 & 'px;" href = "file:///' & $re[$i] & '" > ' & _ ; Linkadresse _fill($count, $symbol) & ' ' & $splitted_A[3] & $splitted_A[4] & ' </a> ' & _ ; Name des Link '' & '<br>' & @CRLF ; Freitext EndIf $priviousLevel = $currentLevel Next Local $html = _ '<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN"' & @CRLF & _ ' "http://www.w3.org/TR/html4/strict.dtd">' & @CRLF & _ '<html>' & @CRLF & _ '<head>' & @CRLF & _ '<title>' & $title & '</title>' & @CRLF & _ '</head>' & @CRLF & _ '<body>' & @CRLF & _ '' & @CRLF & _ '<h3>' & $headline & '</h1>' & @CRLF & _ '' & @CRLF & _ '<p>' & @CRLF & _ $links & @CRLF & _ '</p>' & @CRLF & _ '' & @CRLF & _ '' & @CRLF & _ '<script>' & @CRLF & _ 'function toggle(id) {' & @CRLF & _ ' if (document.getElementById(id).style.display == "none") {' & @CRLF & _ ' document.getElementById(id).style.display = "";' & @CRLF & _ ' }' & @CRLF & _ ' else {' & @CRLF & _ ' document.getElementById(id).style.display = "none";' & @CRLF & _ ' }' & @CRLF & _ '}' & @CRLF & _ '</script>' & @CRLF & _ '</body>' & @CRLF & _ '</html>' ConsoleWrite($html & @CRLF) FileWrite($filename, $html) Return 1 EndFunc ;==>_writeHTML Func _fill($count, $symbol) Local $str = '' For $i = 0 To $count $str &= $symbol Next Return $str EndFunc ;==>_fill Edit : Another requirement is: Sorting the files by name or date. Thanks for any help. Mega