@ -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,6 +36,7 @@ module.exports = () => {
let conf = document . createElement ( 'button' ) ;
let conf = document . createElement ( 'button' ) ;
conf . innerHTML = 'Create' ;
conf . innerHTML = 'Create' ;
conf . onclick = ( ) => {
conf . onclick = ( ) => {
try {
input . value . trim ( ) ;
input . value . trim ( ) ;
if ( fs . existsSync ( path . join ( window . kade . cpath , input . value ) ) ) {
if ( fs . existsSync ( path . join ( window . kade . cpath , input . value ) ) ) {
if ( ! input . value . match ( /^.+\(\d\)$/gm ) ) { input . value += ' (1)' ; }
if ( ! input . value . match ( /^.+\(\d\)$/gm ) ) { input . value += ' (1)' ; }
@ -42,6 +50,11 @@ module.exports = () => {
fs . mkdirSync ( path . join ( window . kade . cpath , input . value ) ) ;
fs . mkdirSync ( path . join ( window . kade . cpath , input . value ) ) ;
lightRefresh ( ) ;
lightRefresh ( ) ;
modal . remove ( ) ;
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." ) ;
}
} ;
} ;
cont . appendChild ( conf ) ;
cont . appendChild ( conf ) ;
}
}