@@ -250,7 +250,7 @@ function parseStaticDHCPLine(line) {
250250 } ;
251251
252252 // Advanced if contains id:, set:, tag:, ignore
253- if ( / i d : | s e t : | t a g : | i g n o r e | l e a s e _ t i m e | , \s * , / . test ( line ) ) return "advanced" ;
253+ if ( / i d : | s e t : | t a g : | i g n o r e | l e a s e _ t i m e | , \s * , / v . test ( line ) ) return "advanced" ;
254254
255255 // Split the line by commas and trim whitespace
256256 const parts = line . split ( "," ) . map ( s => s . trim ( ) ) ;
@@ -307,7 +307,7 @@ $(document).on("click", ".save-static-row:not(.disabled)", function () {
307307 return ;
308308 }
309309
310- const lines = $ ( "#dhcp-hosts" ) . val ( ) . split ( / \r ? \n / ) ;
310+ const lines = $ ( "#dhcp-hosts" ) . val ( ) . split ( / \r ? \n / v ) ;
311311 // Only update if at least one field is non-empty
312312 lines [ rowIdx ] =
313313 hwaddr || ipaddr || hostname ? [ hwaddr , ipaddr , hostname ] . filter ( Boolean ) . join ( "," ) : "" ;
@@ -319,7 +319,7 @@ $(document).on("click", ".save-static-row:not(.disabled)", function () {
319319// Delete button for each row removes that line from the textarea and updates the table
320320$ ( document ) . on ( "click" , ".delete-static-row" , function ( ) {
321321 const rowIdx = Number . parseInt ( $ ( this ) . data ( "row" ) , 10 ) ;
322- const lines = $ ( "#dhcp-hosts" ) . val ( ) . split ( / \r ? \n / ) ;
322+ const lines = $ ( "#dhcp-hosts" ) . val ( ) . split ( / \r ? \n / v ) ;
323323 lines . splice ( rowIdx , 1 ) ;
324324 $ ( "#dhcp-hosts" ) . val ( lines . join ( "\n" ) ) ;
325325 renderStaticDHCPTable ( ) ;
@@ -328,7 +328,7 @@ $(document).on("click", ".delete-static-row", function () {
328328// Add button for each row inserts a new empty line after this row
329329$ ( document ) . on ( "click" , ".add-static-row" , function ( ) {
330330 const rowIdx = Number . parseInt ( $ ( this ) . data ( "row" ) , 10 ) ;
331- const lines = $ ( "#dhcp-hosts" ) . val ( ) . split ( / \r ? \n / ) ;
331+ const lines = $ ( "#dhcp-hosts" ) . val ( ) . split ( / \r ? \n / v ) ;
332332 lines . splice ( rowIdx + 1 , 0 , "" ) ;
333333 $ ( "#dhcp-hosts" ) . val ( lines . join ( "\n" ) ) ;
334334 renderStaticDHCPTable ( ) ;
@@ -378,7 +378,7 @@ $(document).on("click", ".save-static-row", function () {
378378function renderStaticDHCPTable ( ) {
379379 const tbody = $ ( "#StaticDHCPTable tbody" ) ;
380380 tbody . empty ( ) ;
381- const lines = $ ( "#dhcp-hosts" ) . val ( ) . split ( / \r ? \n / ) ;
381+ const lines = $ ( "#dhcp-hosts" ) . val ( ) . split ( / \r ? \n / v ) ;
382382 for ( const [ idx , line ] of lines . entries ( ) ) {
383383 const parsed = parseStaticDHCPLine ( line ) ;
384384
@@ -403,31 +403,26 @@ function renderStaticDHCPTable() {
403403 . attr ( "title" , "Add new line after this" )
404404 . attr ( "data-toggle" , "tooltip" ) ;
405405
406- const tr = $ ( "<tr></tr>" )
406+ const tr = $ ( "<tr></tr>" ) ;
407407
408408 if ( parsed === "advanced" ) {
409- tr . addClass ( "table-warning" )
410- . append (
411- '<td colspan="3" class="text-muted"><em>Advanced settings present in line</em> ' +
412- ( idx + 1 ) +
413- "</td>" ,
414- )
409+ tr . addClass ( "table-warning" ) . append (
410+ '<td colspan="3" class="text-muted"><em>Advanced settings present in line</em> ' +
411+ ( idx + 1 ) +
412+ "</td>"
413+ ) ;
415414
416415 // Keep the original data
417416 tr . data ( "original-line" , line ) ;
418417
419418 // Disable the save button on advanced rows
420- saveBtn
421- . addClass ( "disabled" )
422- . prop ( "disabled" , true )
423- . attr ( "title" , "Disabled" ) ;
424-
419+ saveBtn . addClass ( "disabled" ) . prop ( "disabled" , true ) . attr ( "title" , "Disabled" ) ;
425420 } else {
426421 // Append 3 cells containing parsed values, with placeholder for empty hwaddr
427422 tr . append ( $ ( '<td contenteditable="true" class="static-hwaddr"></td>' ) . text ( parsed . hwaddr ) )
428423 . append ( $ ( '<td contenteditable="true" class="static-ipaddr"></td>' ) . text ( parsed . ipaddr ) )
429424 . append (
430- $ ( '<td contenteditable="true" class="static-hostname"></td>' ) . text ( parsed . hostname ) ,
425+ $ ( '<td contenteditable="true" class="static-hostname"></td>' ) . text ( parsed . hostname )
431426 ) ;
432427 }
433428
@@ -529,7 +524,8 @@ $(document).on("input blur paste", "#StaticDHCPTable td.static-ipaddr", function
529524$ ( document ) . on ( "input blur paste" , "#StaticDHCPTable td.static-hostname" , function ( ) {
530525 const val = $ ( this ) . text ( ) . trim ( ) ;
531526 // Hostnames must not contain spaces, commas, or characters invalid in DNS names
532- const hostnameValidator = / ^ [ a - z A - Z 0 - 9 ] ( [ a - z A - Z 0 - 9 \- ] * [ a - z A - Z 0 - 9 ] ) ? ( \. [ a - z A - Z 0 - 9 ] ( [ a - z A - Z 0 - 9 \- ] * [ a - z A - Z 0 - 9 ] ) ? ) * $ / v;
527+ const hostnameValidator =
528+ / ^ [ a - z A - Z 0 - 9 ] ( [ a - z A - Z 0 - 9 \- ] * [ a - z A - Z 0 - 9 ] ) ? ( \. [ a - z A - Z 0 - 9 ] ( [ a - z A - Z 0 - 9 \- ] * [ a - z A - Z 0 - 9 ] ) ? ) * $ / v;
533529 if ( val && ! hostnameValidator . test ( val ) ) {
534530 $ ( this ) . addClass ( "table-danger" ) ;
535531 $ ( this ) . removeClass ( "table-success" ) ;
0 commit comments