diff --git a/vasl_templates/webapp/data/extensions/bfp-cobra.json b/vasl_templates/webapp/data/extensions/bfp-cobra.json
index 6279fe9..9f178dc 100644
--- a/vasl_templates/webapp/data/extensions/bfp-cobra.json
+++ b/vasl_templates/webapp/data/extensions/bfp-cobra.json
@@ -169,7 +169,7 @@
"CS#": 6,
"capabilities2": { "A": [ [4,"A4"], [5,5], "\u20202" ], "s": [ [5,5] ], "sM": 8 },
"note_number": "16\u2020",
- "notes": [ "US A\u20202", "US F\u20201", "US G", "US P", "Y", "C" ],
+ "notes": [ "US A\u20202", "US F\u20201", "US G", "US P", "US Y", "C" ],
"id": "am/v:876",
"gpid": "adf:186"
}
diff --git a/vasl_templates/webapp/static/snippets.js b/vasl_templates/webapp/static/snippets.js
index a33aeef..aaca571 100644
--- a/vasl_templates/webapp/static/snippets.js
+++ b/vasl_templates/webapp/static/snippets.js
@@ -177,34 +177,12 @@ function make_snippet( $btn, params, extra_params, show_date_warnings )
// generate snippets for multi-applicable vehicle/ordnance notes
var pos ;
- function redirect_ma_note( target, vo_type ) {
- pos = target.indexOf( " " ) ;
- var nat_redirect = BFP_MA_NOTE_REDIRECTS[ target.substring( 0, pos ) ] ;
- if ( nat_redirect )
- return get_ma_notes_for_nat( nat_redirect, vo_type )[ target.substring(pos+1 ) ] ;
- return null ;
- }
function add_ma_notes( ma_notes, keys, param_name, nat, vo_type ) {
if ( ! keys )
return ;
params[ param_name ] = [] ;
for ( var i=0 ; i < keys.length ; ++i ) {
- var ma_note = null ;
- if ( keys[i].substring( 0, 4 ) == "adf:" )
- ma_note = redirect_ma_note( keys[i].substring(4), vo_type ) ;
- else if ( keys[i].substring( 0, 6 ) == "cobra:" )
- ma_note = redirect_ma_note( keys[i].substring(6), vo_type ) ;
- else if ( keys[i].substring( 0, 4 ) == "pif:" )
- ma_note = redirect_ma_note( keys[i].substring(4), vo_type ) ;
- if ( ! ma_note )
- ma_note = ma_notes[ keys[i] ] ;
- if ( ! ma_note ) {
- // couldn't find anything - if we're allied/axis minor, try the common notes
- if ( gTemplatePack.nationalities[ nat ].type === "allied-minor" )
- ma_note = get_ma_notes_for_nat( "allied-minor", vo_type )[ keys[i] ] ;
- else if ( gTemplatePack.nationalities[ nat ].type === "axis-minor" )
- ma_note = get_ma_notes_for_nat( "axis-minor", vo_type )[ keys[i] ] ;
- }
+ var ma_note = get_ma_note( nat, vo_type, keys[i] ) ;
var key = keys[i] ;
var extn_marker = "" ;
if ( nat === "italian" && vo_type === "ordnance" && keys[i] === "R" )
@@ -243,13 +221,6 @@ function make_snippet( $btn, params, extra_params, show_date_warnings )
}
}
}
- function get_ma_notes_for_nat( nat, vo_type ) {
- if ( nat === "landing-craft" && nat in gVehicleOrdnanceNotes.vehicles )
- return gVehicleOrdnanceNotes.vehicles[ nat ][ "multi-applicable" ] ;
- if ( vo_type in gVehicleOrdnanceNotes && nat in gVehicleOrdnanceNotes[vo_type] )
- return gVehicleOrdnanceNotes[ vo_type ][ nat ][ "multi-applicable" ] ;
- return {} ;
- }
get_ma_notes( "vehicles", 1, "OB_VEHICLES_MA_NOTES_1" ) ;
get_ma_notes( "ordnance", 1, "OB_ORDNANCE_MA_NOTES_1" ) ;
get_ma_notes( "vehicles", 2, "OB_VEHICLES_MA_NOTES_2" ) ;
@@ -568,6 +539,52 @@ function sort_ma_notes_keys( nat, keys )
return keys ;
}
+function get_ma_note( nat, vo_type, key )
+{
+ var ma_notes ;
+ function redirect_ma_note( target, vo_type ) {
+ pos = target.indexOf( " " ) ;
+ var nat_redirect = BFP_MA_NOTE_REDIRECTS[ target.substring( 0, pos ) ] ;
+ if ( nat_redirect ) {
+ ma_notes = get_ma_notes_for_nat( nat_redirect, vo_type ) ;
+ return ma_notes[ target.substring( pos+1 ) ] ;
+ }
+ return null ;
+ }
+
+ // check for redirected notes
+ var ma_note = null ;
+ var pos = key.indexOf( ":" ) ;
+ if ( pos !== -1 )
+ ma_note = redirect_ma_note( key.substring(pos+1), vo_type ) ;
+
+ if ( ! ma_note ) {
+ // look for a normal note
+ ma_notes = get_ma_notes_for_nat( nat, vo_type ) ;
+ ma_note = ma_notes[ key ] ;
+ }
+
+ if ( ! ma_note ) {
+ // still couldn't find anything - if we're Allied/Axis Minor, try the common notes
+ if ( gTemplatePack.nationalities[ nat ].type === "allied-minor" )
+ ma_note = get_ma_notes_for_nat( "allied-minor", vo_type )[ key ] ;
+ else if ( gTemplatePack.nationalities[ nat ].type === "axis-minor" )
+ ma_note = get_ma_notes_for_nat( "axis-minor", vo_type )[ key ] ;
+ }
+
+ return ma_note ;
+}
+
+function get_ma_notes_for_nat( nat, vo_type )
+{
+ // get the multi-applicable vehicle/ordnance notes for the specified nationality
+ if ( nat === "landing-craft" && nat in gVehicleOrdnanceNotes.vehicles )
+ return gVehicleOrdnanceNotes.vehicles[ "landing-craft" ][ "multi-applicable" ] ;
+ if ( vo_type in gVehicleOrdnanceNotes && nat in gVehicleOrdnanceNotes[vo_type] )
+ return gVehicleOrdnanceNotes[ vo_type ][ nat ][ "multi-applicable" ] ;
+ return {} ;
+}
+
function _make_snippet_image_filename( snippet )
{
// generate the save filename for a generated snippet image
diff --git a/vasl_templates/webapp/templates/vo-notes-report.html b/vasl_templates/webapp/templates/vo-notes-report.html
index ff1e8a3..a680e7c 100644
--- a/vasl_templates/webapp/templates/vo-notes-report.html
+++ b/vasl_templates/webapp/templates/vo-notes-report.html
@@ -4,6 +4,7 @@
@@ -30,15 +31,23 @@ td { padding: 0.2em 0.5em ; }
$(document).ready( function () {
// initialize
- var vo_notes, vo_entries ;
- var on_load_counter = 2 ;
+ var vo_entries ;
+ var on_load_counter = 3 ;
function on_data_loaded() {
if ( --on_load_counter == 0 ) {
// everything's loaded - generate the report
- load_vo_notes( vo_notes, vo_entries ) ;
+ load_vo_notes( vo_entries ) ;
}
}
+ // get the template pack
+ $.getJSON( "{{url_for('get_template_pack')}}", function(data) {
+ gTemplatePack = data ;
+ on_data_loaded() ;
+ } ).fail( function( xhr, status, errorMsg ) {
+ alert( "Can't get the template pack:\n\n" + errorMsg ) ;
+ } ) ;
+
// get the vehicle/ordnance listings
var url ;
if ( vo_type === "vehicles" )
@@ -58,17 +67,17 @@ $(document).ready( function () {
else
url = "{{url_for('get_ordnance_notes')}}" ;
$.getJSON( url, function( data ) {
- gVehicleOrdnanceNotes[vo_type] = data ;
- vo_notes = data[ nat ] ;
+ gVehicleOrdnanceNotes[ vo_type ] = data ;
on_data_loaded() ;
} ).fail( function( xhr, status, errorMsg ) {
alert( "Can't get the vehicle/ordnance notes:\n\n" + errorMsg ) ;
} ) ;
} ) ;
-function load_vo_notes( vo_notes, vo_entries )
+function load_vo_notes( vo_entries )
{
var $results = $("#results") ;
+ var vo_notes = gVehicleOrdnanceNotes[ vo_type ][ nat ] ;
if ( !vo_notes && !vo_entries ) {
$results.html( "No results." ).show() ;
return ;
@@ -136,7 +145,10 @@ function load_vo_notes( vo_notes, vo_entries )
for ( var i=0 ; i < keys.length ; ++i ) {
if ( keys[i] === "multi-applicable" )
continue ;
- buf.push( "