1+ function createDirectory ( link ) {
2+ let dname = prompt ( 'Enter the name of the directory (only ASCII):' ) ;
3+ if ( dname != null )
4+ location . href = '?link=' + encodeURIComponent ( link ) +
5+ '&cDir=' + encodeURIComponent ( dname ) ;
6+ }
7+
8+ function createFile ( link ) {
9+ let dname = prompt ( 'Enter the name of the file (only ASCII):' ) ;
10+ if ( dname != null )
11+ location . href = '?link=' + encodeURIComponent ( link ) +
12+ '&cFile=' + encodeURIComponent ( dname ) ;
13+ }
14+
15+ function deleteFile ( link , fileName ) {
16+ if ( confirm ( 'Do you really want to delete the ' + fileName + ' file?' ) )
17+ location . href = '?link=' + encodeURIComponent ( link ) +
18+ '&dFileName=' + encodeURIComponent ( fileName ) ;
19+ }
20+
21+ function deleteDirectory ( link , dirName ) {
22+ if ( confirm ( 'Do you really want to delete the ' + dirName + ' directory?' ) )
23+ location . href = '?link=' + encodeURIComponent ( link ) +
24+ '&dDirName=' + encodeURIComponent ( dirName ) ;
25+ }
26+
27+ function dwldDirectory ( link , dirName ) {
28+ location . href = '?link=' + encodeURIComponent ( link ) +
29+ '&dwldDirName=' + encodeURIComponent ( dirName ) ;
30+ }
31+
32+ function getFileText ( link ) {
33+ var xhr = new XMLHttpRequest ( ) ;
34+ xhr . open ( 'GET' , link , false ) ;
35+ xhr . send ( ) ;
36+ if ( xhr . status != 200 ) {
37+ alert ( xhr . status + ': ' + xhr . statusText ) ;
38+ } else {
39+ document . getElementById ( 'taEditor' ) . innerHTML = xhr . responseText ;
40+ }
41+ }
42+
43+ function closeEditor ( ) {
44+ document . getElementById ( 'taEditor' ) . innerHTML = '' ;
45+ document . getElementById ( 'inpEditor' ) . value = '' ;
46+ document . getElementById ( 'divEditor' ) . style . display = 'none' ;
47+ document . getElementById ( 'saveEditorBtn' ) . onclick = function ( ) { } ;
48+ }
49+
50+ function editFile ( link , fileName ) {
51+ closeEditor ( ) ;
52+ getFileText ( '?dwld=/dir' + link + '/' + fileName ) ;
53+ document . getElementById ( 'inpEditor' ) . value = fileName ;
54+ document . getElementById ( 'divEditor' ) . style . display = 'block' ;
55+ document . getElementById ( 'saveEditorBtn' ) . onclick = function ( ) { saveFile ( link , fileName ) ; } ;
56+ }
57+
58+ function saveFile ( link , fileName ) {
59+ var xhr = new XMLHttpRequest ( ) ;
60+ xhr . open ( 'POST' , '/' , true ) ;
61+ xhr . setRequestHeader ( 'Content-type' , 'application/x-www-form-urlencoded' ) ;
62+ xhr . send (
63+ 'link=' + encodeURIComponent ( link ) +
64+ '&sFile=' + encodeURIComponent ( fileName ) +
65+ '&text=' + encodeURIComponent ( document . getElementById ( 'taEditor' ) . value )
66+ ) ;
67+ }
68+
69+ function uploadFile ( link ) {
70+ document . getElementById ( 'uploadFile' ) . style . display = 'block' ;
71+ }
72+
73+ function closeUploader ( link ) {
74+ document . getElementById ( 'uploadFile' ) . style . display = 'none' ;
75+ }
0 commit comments