@@ -53,6 +53,9 @@ $('#cd-file-path').on('change', function() {
5353 else collectionConfig [ 'CrashdayPath' ] = p
5454
5555 SaveConfig ( )
56+
57+ $ . toast ( { title : 'CD Path saved!' ,
58+ type : 'success' , delay : 5000 , container : $ ( '#toaster' ) } )
5659} )
5760
5861LoadWorkshop ( )
@@ -133,10 +136,18 @@ function PrepareMissingModsModal(){
133136 Http . open ( 'GET' , url )
134137 Http . send ( )
135138
139+ console . groupCollapsed ( 'Sent a request to Steam' )
140+ console . log ( url )
141+ console . groupEnd ( )
142+
136143 Http . onreadystatechange = function ( ) {
137144 if ( this . readyState == 4 && this . status == 200 ) {
138145 var answer = JSON . parse ( Http . responseText ) [ 'response' ]
139146
147+ console . groupCollapsed ( 'Steam answer' )
148+ console . log ( answer )
149+ console . groupEnd ( )
150+
140151 $ ( '#missing-mods-modal-list' ) . html ( '' )
141152 for ( i in answer [ 'publishedfiledetails' ] ) {
142153 $ ( '#missing-mods-modal-list' ) . append (
@@ -189,12 +200,18 @@ function LoadWorkshop(){
189200 Http . open ( 'GET' , url )
190201 Http . send ( )
191202
203+ console . groupCollapsed ( 'Sent a request to Steam' )
192204 console . log ( url )
205+ console . groupEnd ( )
193206
194207 Http . onreadystatechange = function ( ) {
195208 if ( this . readyState == 4 && this . status == 200 ) {
196209 steamAnswer = JSON . parse ( Http . responseText ) [ 'response' ]
197210
211+ console . groupCollapsed ( 'Steam answer' )
212+ console . log ( steamAnswer )
213+ console . groupEnd ( )
214+
198215 const table = { }
199216 table [ 'search' ] = true
200217 table [ 'clickToSelect' ] = true
@@ -493,10 +510,18 @@ function GetCollectionFromLink(){
493510 Http . open ( 'GET' , url )
494511 Http . send ( )
495512
513+ console . groupCollapsed ( 'Sent a request to Steam' )
514+ console . log ( url )
515+ console . groupEnd ( )
516+
496517 Http . onreadystatechange = function ( ) {
497518 if ( this . readyState == 4 && this . status == 200 ) {
498519 var response = JSON . parse ( Http . responseText ) [ 'response' ]
499520
521+ console . groupCollapsed ( 'Steam answer' )
522+ console . log ( response )
523+ console . groupEnd ( )
524+
500525 if ( response [ 'publishedfiledetails' ] [ 0 ] [ 'result' ] != 1 ) {
501526 $ . toast ( { title : 'Collection import error' ,
502527 content : 'Steam could not find collection with id ' + collectionUrl ,
@@ -767,31 +792,52 @@ function LoadConfig(){
767792
768793 //check for new mods in the workshop folder
769794 var p = path . join ( colls [ 'CrashdayPath' ] , '../../workshop/content/508980' )
770- var foundNewMods = 0
795+ var unlistedMods = 0
796+ var listedMods = 0
797+ var emptyFolders = 0
798+ var otherFiles = 0
771799 if ( fs . existsSync ( p ) ) {
772800 fs . readdirSync ( p ) . forEach ( file => {
773801 var foundFile = false
774802 var name = parseInt ( file , 10 )
775- //skip not numbered .cpk's
776- if ( name == NaN ) return
803+ //skip not numbered folder names
804+ if ( name == NaN ) {
805+ otherFiles ++
806+ return
807+ }
808+
809+ folder = fs . statSync ( path . join ( p , file ) )
810+ if ( ! folder . isDirectory ( ) ) {
811+ otherFiles ++
812+ return
813+ }
814+ //check there is a mod file in mod folder
815+ files = fs . readdirSync ( path . join ( p , file ) )
816+ if ( files . length == 0 ) {
817+ emptyFolders ++
818+ return
819+ }
777820
778821 for ( n in cfg [ 'WorkshopItems' ] )
779822 {
780823 if ( cfg [ 'WorkshopItems' ] [ n ] [ 0 ] == name )
781824 {
825+ listedMods ++
782826 foundFile = true
783827 }
784828 }
785829 if ( ! foundFile ) {
786830 cfg [ 'WorkshopItems' ] . push ( [ name , false ] )
787- foundNewMods += 1
831+ unlistedMods ++
788832 }
789833 } )
790834 }
791835
792- if ( foundNewMods > 0 ) {
836+ console . log ( `Found ${ listedMods } listed mods, ${ unlistedMods } unlisted mods, ${ emptyFolders } empty folders and ${ otherFiles } other files in Workshop folder` )
837+
838+ if ( unlistedMods > 0 ) {
793839 $ . toast ( { title : 'New mods found' ,
794- content : 'Launcher found and added ' + foundNewMods + ' new mods.' ,
840+ content : 'Launcher found and added ' + unlistedMods + ' new mods.' ,
795841 type : 'info' , delay : 5000 , container : $ ( '#toaster' ) } )
796842 }
797843
0 commit comments