Create attractive VASL scenarios, with loads of useful information embedded to assist with game play. https://vasl-templates.org
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 
vasl-templates/vasl_templates/webapp/templates/vo-report.html

103 lines
3.4 KiB

<!doctype html> <!-- NOTE: For testing porpoises only! -->
<html lang="en">
<head>
<meta charset="utf-8">
<title> {{VO_TYPE0}} listings: {{NATIONALITY}} </title>
<style>
table { border-collapse: collapse ; }
th { text-align: left ; padding: 0.2em 0.5em ; background: #eee ; border: 1px solid #ccc ; }
td { padding: 0.2em 0.5em ; }
.val { padding: 0.1em 0.25em ; background: #eee ; }
</style>
</head>
<body>
<div id="results" style="display:none;"></div>
</body>
<script src="{{url_for('static',filename='jquery/jquery-3.3.1.min.js')}}"></script>
<script src="{{url_for('static',filename='snippets.js')}}"></script>
<script src="{{url_for('static',filename='utils.js')}}"></script>
<script>
$(document).ready( function () {
// get the vehicle/ordnance listings
var url ;
if ( "{{VO_TYPE}}" == "ordnance" )
url = "{{url_for( 'get_ordnance_listings', report=1 )}}" ;
else
url = "{{url_for( 'get_vehicle_listings', report=1 )}}" ; // nb: includes landing craft
if ( getUrlParam( "merge_common" ) === "1" )
url += "&merge_common=1" ;
$.getJSON( url, function(data) {
load_vo_listings( data ) ;
} ).fail( function( xhr, status, errorMsg ) {
alert( "Can't get the {{VO_TYPE0}} listings:\n\n" + errorMsg ) ;
} ) ;
} ) ;
function load_vo_listings( objs )
{
// initialize
var theater = "{{THEATER}}".toUpperCase() ;
var nat = "{{NATIONALITY}}" ;
var year = {{YEAR}} ;
var month = {{MONTH}} ;
var $results = $("#results") ;
var vo_name = getUrlParam( "name" ) ; // nb: restricts the report to a single vehicle/ordnance
if ( vo_name )
vo_name = decodeURIComponent( vo_name ).toLowerCase() ;
// check if there are any vehicles/ordnance for the specified nationality
if ( "{{VO_TYPE}}" === "landing-craft" )
nat = "landing-craft" ;
if ( ! (nat in objs ) ) {
$results.text( "No listings for nationality: " + nat ).show() ;
return ;
}
// load the vehicles/ordnance
var buf = [] ;
buf.push( "<table>" ) ;
buf.push( "<tr>", "<th>Name", "<th colspan='2'>Capabilities", "<th colspan='2'>Notes", "<th>Comments" ) ;
for ( var i=0 ; i < objs[nat].length ; ++i ) {
var obj = objs[nat][i] ;
if ( vo_name && obj.name.toLowerCase() != vo_name )
continue ;
buf.push( "<tr>" ) ;
buf.push( "<td>", fmtval(obj.name) ) ;
var capabilities = make_capabilities( true, obj, nat, false, theater, year, month, true ) ;
buf.push( "<td>", listval(capabilities) ) ;
var capabilities = make_capabilities( false, obj, nat, false, theater, year, month, true ) ;
buf.push( "<td>", listval(capabilities) ) ;
buf.push( "<td>", "<span class='val'>" + fmtval(obj.note_number) + "</span>" ) ;
buf.push( "<td>", listval(obj.notes) ) ;
buf.push( "<td>", obj.comments ? listval(obj.comments) : "" ) ;
}
buf.push( "</table>" ) ;
$results.html( buf.join("") ).show() ;
}
function fmtval( val )
{
// return the formatted value
if ( ! val )
return "<small><em>n/a</em></small>" ;
return val ;
}
function listval( vals )
{
// return the formatted list of values
if ( ! vals )
return "<small><em>n/a</em></small>" ;
var buf = [] ;
for ( var i=0 ; i < vals.length ; ++i )
buf.push( "<span class='val'>" + vals[i] + "</span>" ) ;
return buf.join( " " ) ;
}
</script>
</html>