" ) !== -1 )
continue ; // nb: ignore raw capabilities (e.g. if the scenario date hasn't been set)
// NOTE: Elite status doesn't apply to vehicular smoke dispensers (C8.9).
var match = capabilities[i].match( /^(A|M|H|C|D|HE|AP|WP|s)([1-9][0-9]?)/ ) ;
if ( match )
capabilities[i] = match[1] + (parseInt(match[2]) + delta) + capabilities[i].substr(match[1].length+match[2].length) ;
}
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
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/" ) {
for ( var key in gTemplatePack.css )
template = strReplaceAll( template, "{{CSS:"+key+"}}", gTemplatePack.css[key] ) ;
template = fixup_template_parameters( template ) ;
}
}
return template ;
}
showErrorMsg( "Unknown template: " + escapeHTML(template_id) + "" ) ;
return null ;
}
// --------------------------------------------------------------------
function edit_template( template_id )
{
// get the specified template
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: 600, minHeight: 300,
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 to load another scenario, and lose your changes?", {
width: 470,
ok: do_on_load_scenario,
} ) ;
}
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