@ -2,8 +2,15 @@ const fs = require('fs');
const path = require ( 'path' ) ;
const path = require ( 'path' ) ;
const lightRefresh = require ( '../fileview/lightrefresh' ) ;
const lightRefresh = require ( '../fileview/lightrefresh' ) ;
const preModal = require ( '../modal/pre' ) ;
const postModal = require ( '../modal/post' ) ;
const showError = require ( '../modal/common/error' ) ;
const clearModals = require ( '../modal/clearmodals' ) ;
module . exports = ( ) => {
module . exports = ( ) => {
console . log ( 'e' ) ;
if ( window . kade . modal ) { console . log ( 'hboonk' ) ; return ; }
preModal ( 'new-folder-modal-container' ) ;
let modal = document . createElement ( 'div' ) ;
let modal = document . createElement ( 'div' ) ;
modal . className = 'modal' ;
modal . className = 'modal' ;
modal . id = 'new-folder-modal-container' ;
modal . id = 'new-folder-modal-container' ;
@ -29,19 +36,25 @@ module.exports = () => {
let conf = document . createElement ( 'button' ) ;
let conf = document . createElement ( 'button' ) ;
conf . innerHTML = 'Create' ;
conf . innerHTML = 'Create' ;
conf . onclick = ( ) => {
conf . onclick = ( ) => {
input . value . trim ( ) ;
try {
if ( fs . existsSync ( path . join ( window . kade . cpath , input . value ) ) ) {
input . value . trim ( ) ;
if ( ! input . value . match ( /^.+\(\d\)$/gm ) ) { input . value += ' (1)' ; }
if ( fs . existsSync ( path . join ( window . kade . cpath , input . value ) ) ) {
else {
if ( ! input . value . match ( /^.+\(\d\)$/gm ) ) { input . value += ' (1)' ; }
let tempstr = input . value . split ( '' ) ;
else {
tempstr [ input . value . length - 2 ] = ` ${ Number ( input . value . charAt ( input . value . length - 2 ) ) + 1 } ` ;
let tempstr = input . value . split ( '' ) ;
input . value = tempstr . join ( '' ) ;
tempstr [ input . value . length - 2 ] = ` ${ Number ( input . value . charAt ( input . value . length - 2 ) ) + 1 } ` ;
input . value = tempstr . join ( '' ) ;
}
return ;
}
}
return ;
fs . mkdirSync ( path . join ( window . kade . cpath , input . value ) ) ;
lightRefresh ( ) ;
modal . remove ( ) ;
postModal ( modal . id ) ;
} catch {
clearModals ( ) ;
showError ( "Folder Creation" , "There was an unknown error while trying to create that folder. It may be a permissions issue, or the host folder doesn't exist anymore." ) ;
}
}
fs . mkdirSync ( path . join ( window . kade . cpath , input . value ) ) ;
lightRefresh ( ) ;
modal . remove ( ) ;
} ;
} ;
cont . appendChild ( conf ) ;
cont . appendChild ( conf ) ;
}
}