\d<\/sup>)?$/ ) ) {
val.pop() ;
return last ;
}
return null ;
}
function make_crew_survival( vo_entry )
{
function make_cs_string( prefix, val ) {
if ( val.length === 2 && val[0] === null && val[1] === "\u2020" )
return "\u2020" ;
else
return prefix + " " + val ;
}
// check if the vehicle has a crew survival field
var crew_survival = null ;
if ( "CS#" in vo_entry )
crew_survival = make_cs_string( "CS", vo_entry["CS#"] ) ;
else if ( "cs#" in vo_entry )
crew_survival = make_cs_string( "cs", vo_entry["cs#"] ) ;
if ( crew_survival === null )
return null ;
// check if the vehicle is subject to brew up
var pos = crew_survival.indexOf( ":brewup" ) ;
if ( pos !== -1 )
crew_survival = crew_survival.substring(0,pos) + " (brew up)" + crew_survival.substring(pos+7) ;
return crew_survival ;
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
function get_template( template_id, fixup )
{
// get the specified template
if ( template_id in gTemplatePack.templates ) {
var template = gTemplatePack.templates[ template_id ] ;
if ( fixup ) {
if ( template_id.substr(0,7) === "extras/" )
template = fixup_template_parameters( template ) ;
}
return template ;
}
showErrorMsg( "Unknown template: " + escapeHTML(template_id) + "" ) ;
return null ;
}
// --------------------------------------------------------------------
function edit_template( template_id )
{
// get the specified template
if ( template_id.substring(0,12) == "ob_ordnance_" )
template_id = "ob_ordnance" ;
else if ( template_id.substring(0,12) == "ob_vehicles_" )
template_id = "ob_vehicles" ;
var template = get_template( template_id, false ) ;
if ( template === null )
return ;
function on_template_change() {
// install the new template
gTemplatePack.templates[template_id] = $("#edit-template textarea").val() ;
}
// let the user edit the template
$("#edit-template textarea").val( template ) ;
$("#edit-template").dialog( {
dialogClass: "edit-template",
title: "Editing template: " + escapeHTML(template_id),
modal: false,
minWidth: 400, minHeight: 200,
create: function() {
init_dialog( $(this), "Close", true ) ;
},
open: function() {
on_dialog_open( $(this) ) ;
$(this).height( $(this).height() ) ; // fudge: force the textarea to resize
$("#edit-template textarea").change( on_template_change ) ;
},
close: function() {
$("#edit-template textarea").off( "change", on_template_change ) ;
},
buttons: {
Close: function() { $(this).dialog( "close" ) ; },
},
} ) ;
}
// --------------------------------------------------------------------
function on_load_scenario()
{
// check if the scenario is dirty
if ( ! is_scenario_dirty() )
do_on_load_scenario() ;
else {
// yup - confirm the operation
ask( "Load scenario", "This scenario has been changed.
Do you want load another scenario, and lose your changes?", {
ok: do_on_load_scenario,
cancel: function() {},
} ) ;
}
function do_on_load_scenario() {
// FOR TESTING PORPOISES! We can't control a file upload from Selenium (since
// the browser will use native controls), so we get the data from a