@ -77,6 +77,7 @@ function _show_extra_template( template_id )
var display _name = template _info . params [ i ] . caption || template _info . params [ i ] . name ;
var display _name = template _info . params [ i ] . caption || template _info . params [ i ] . name ;
buf . push ( "<td class='caption'>" , escapeHTML ( display _name ) + ":" ) ;
buf . push ( "<td class='caption'>" , escapeHTML ( display _name ) + ":" ) ;
buf . push ( "<td class='value'>" ) ;
buf . push ( "<td class='value'>" ) ;
var j ;
if ( template _info . params [ i ] . type === "input" ) {
if ( template _info . params [ i ] . type === "input" ) {
buf . push ( "<input class='param' name='" + escapeHTML ( template _info . params [ i ] . name ) + "' type='text'" ) ;
buf . push ( "<input class='param' name='" + escapeHTML ( template _info . params [ i ] . name ) + "' type='text'" ) ;
if ( template _info . params [ i ] . width )
if ( template _info . params [ i ] . width )
@ -88,9 +89,19 @@ function _show_extra_template( template_id )
buf . push ( ">" ) ;
buf . push ( ">" ) ;
} else if ( template _info . params [ i ] . type === "select" ) {
} else if ( template _info . params [ i ] . type === "select" ) {
buf . push ( "<select class='param' name='" + escapeHTML ( template _info . params [ i ] . name ) + "'>" ) ;
buf . push ( "<select class='param' name='" + escapeHTML ( template _info . params [ i ] . name ) + "'>" ) ;
for ( var j = 0 ; j < template _info . params [ i ] . options . length ; ++ j )
for ( j = 0 ; j < template _info . params [ i ] . options . length ; ++ j )
buf . push ( "<option>" , template _info . params [ i ] . options [ j ] , "</option>" ) ;
buf . push ( "<option>" , template _info . params [ i ] . options [ j ] , "</option>" ) ;
buf . push ( "</select>" ) ;
buf . push ( "</select>" ) ;
} else if ( template _info . params [ i ] . type . substr ( 0 , 22 ) === "player-color2-droplist" ) {
buf . push ( "<select class='param' name='PLAYER_COLOR2_DROPLIST' style='width:9em;'>" ) ;
if ( template _info . params [ i ] . type === "player-color2-droplist-ex" )
buf . push ( "<option value='black'>black</option>" , "<option value='#c0c0c0'>gray</option>" ) ;
var nats = get _sorted _nats ( ) ;
for ( j = 0 ; j < nats . length ; ++ j ) {
var nat _info = gTemplatePack . nationalities [ nats [ j ] ] ;
buf . push ( "<option value='" , nat _info . ob _colors [ 2 ] , "'>" , nat _info . display _name , "</option>" ) ;
}
buf . push ( "</select>" ) ;
}
}
}
}
buf . push ( "</table>" ) ;
buf . push ( "</table>" ) ;
@ -98,7 +109,11 @@ function _show_extra_template( template_id )
buf . push ( "<button class='generate' data-id='" + template _info . template _id + "'>Snippet</button>" ) ;
buf . push ( "<button class='generate' data-id='" + template _info . template _id + "'>Snippet</button>" ) ;
buf . push ( "</div>" ) ;
buf . push ( "</div>" ) ;
var $form = $ ( buf . join ( "" ) ) ;
var $form = $ ( buf . join ( "" ) ) ;
$form . find ( "select" ) . select2 ( { minimumResultsForSearch : - 1 } ) ;
$form . find ( "select" ) . select2 ( {
minimumResultsForSearch : - 1
} ) . on ( "select2:open" , function ( ) {
restrict _droplist _height ( $ ( this ) ) ;
} ) ;
fixup _external _links ( $form ) ;
fixup _external _links ( $form ) ;
// initialize the "generate" button
// initialize the "generate" button
@ -140,7 +155,11 @@ function _parse_extra_template( template_id, template )
// we have a <select>
// we have a <select>
param . type = "select" ;
param . type = "select" ;
param . options = val . split ( "::" ) ;
param . options = val . split ( "::" ) ;
} else {
} else if ( param . name === "PLAYER_COLOR2_DROPLIST" )
param . type = "player-color2-droplist" ;
else if ( param . name === "PLAYER_COLOR2_DROPLIST_EX" )
param . type = "player-color2-droplist-ex" ;
else {
// we have an <input>
// we have an <input>
param . type = "input" ;
param . type = "input" ;
// extract the default value and field width
// extract the default value and field width