13361336 }
13371337 if ( type === "boolean" && ! value ) {
13381338 return false ;
1339+ } else if ( type === "number" ) {
1340+ if ( typeof value === "number" ) {
1341+ return value . toString ( ) ;
1342+ } else if ( ! value ) {
1343+ return "0" ;
1344+ } else {
1345+ return value ;
1346+ }
13391347 } else {
13401348 return value ;
13411349 }
13791387 title : "File server port" ,
13801388 type : "text" ,
13811389 valid_pattern : / [ 0 - 9 ] * / ,
1382- description : "Other peers will use this port to reach your served sites. (default: 15441 )"
1390+ description : "Other peers will use this port to reach your served sites. (default: randomize )"
13831391 } ) ;
13841392 section . items . push ( {
13851393 key : "ip_external" ,
16161624
16171625} ) . call ( this ) ;
16181626
1619-
16201627/* ---- ConfigView.coffee ---- */
16211628
16221629
19341941 } ;
19351942
19361943 UiConfig . prototype . saveValues = function ( cb ) {
1937- var base , changed_values , i , item , j , last , len , match , message , results , value , value_same_as_default ;
1944+ var base , changed_values , default_value , i , item , j , last , len , match , message , results , value , value_same_as_default ;
19381945 changed_values = this . getValuesChanged ( ) ;
19391946 results = [ ] ;
19401947 for ( i = j = 0 , len = changed_values . length ; j < len ; i = ++ j ) {
19411948 item = changed_values [ i ] ;
19421949 last = i === changed_values . length - 1 ;
19431950 value = this . config_storage . deformatValue ( item . value , typeof this . config [ item . key ] [ "default" ] ) ;
1944- value_same_as_default = JSON . stringify ( this . config [ item . key ] [ "default" ] ) === JSON . stringify ( value ) ;
1945- if ( value_same_as_default ) {
1946- value = null ;
1947- }
1951+ default_value = this . config_storage . deformatValue ( this . config [ item . key ] [ "default" ] , typeof this . config [ item . key ] [ "default" ] ) ;
1952+ this . log ( "default check:" , JSON . stringify ( default_value ) , "==" , JSON . stringify ( value ) ) ;
1953+ value_same_as_default = JSON . stringify ( default_value ) === JSON . stringify ( value ) ;
19481954 if ( this . config [ item . key ] . item . valid_pattern && ! ( typeof ( base = this . config [ item . key ] . item ) . isHidden === "function" ? base . isHidden ( ) : void 0 ) ) {
19491955 match = value . match ( this . config [ item . key ] . item . valid_pattern ) ;
19501956 if ( ! match || match [ 0 ] !== value ) {
19541960 break ;
19551961 }
19561962 }
1963+ if ( value_same_as_default ) {
1964+ value = null ;
1965+ }
19571966 results . push ( this . saveValue ( item . key , value , last ? cb : null ) ) ;
19581967 }
19591968 return results ;
20542063
20552064 window . Page . createProjector ( ) ;
20562065
2057- } ) . call ( this ) ;
2066+ } ) . call ( this ) ;
0 commit comments