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/check-roar.html

120 lines
3.2 KiB

<!doctype html> <!-- NOTE: For testing porpoises only! -->
<html lang="en">
<head>
<meta charset="utf-8">
<style>
th, td { padding: 2px 5px ; text-align: left ; }
th { 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='roar.js')}}"></script>
<script>
gRoarScenarioIndex = null ;
gTemplatePack = null ;
</script>
<script>
$(document).ready( function () {
// initialize
var on_load_counter = 2 ;
function on_data_loaded() {
if ( --on_load_counter == 0 ) {
// everything's loaded - generate the report
check_roar() ;
}
}
// get the ROAR scenario index
$.getJSON( "{{url_for('get_roar_scenario_index')}}", function(data) {
gRoarScenarioIndex = data ;
on_data_loaded() ;
} ).fail( function( xhr, status, errorMsg ) {
alert( "Can't get the ROAR scenario index:\n\n" + errorMsg ) ;
} ) ;
// 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 ) ;
} ) ;
} ) ;
function check_roar()
{
// initialize
var buf = [] ;
// generate the list of nationalities in ROAR
var roar_nats = {} ;
function on_nat( nat ) {
if ( nat in roar_nats )
++ roar_nats[nat] ;
else
roar_nats[nat] = 1 ;
}
for ( var roar_id in gRoarScenarioIndex ) {
if ( roar_id[0] == "_" )
continue ;
var scenario = gRoarScenarioIndex[ roar_id ] ;
on_nat( scenario.results[0][0] ) ;
on_nat( scenario.results[1][0] ) ;
}
// sort the results
var roar_nats_sorted = Object.keys( roar_nats ) ;
roar_nats_sorted.sort( function( lhs, rhs ) {
if ( roar_nats[lhs] < roar_nats[rhs] )
return +1 ;
else if ( roar_nats[lhs] > roar_nats[rhs] )
return -1 ;
else {
if ( lhs < rhs )
return -1 ;
else if ( lhs > rhs )
return +1 ;
}
return 0;
} ) ;
// output the results
buf.push( "<table>" ) ;
buf.push( "<tr>", "<th>ROAR nationality", "<th>Count", "<th><tt>vasl-templates</tt> nationality" ) ;
for ( var i=0 ; i < roar_nats_sorted.length ; ++i ) {
var nat = roar_nats_sorted[i] ;
buf.push( "<tr>", "<td>"+nat, "<td>"+roar_nats[nat] ) ;
nat = convert_roar_nat( nat ) ;
if ( nat )
buf.push( "<td>" + nat ) ;
}
buf.push( "</table>" ) ;
// check for spaces in scenario ID's
buf.push( "<h2>Scenario ID's with spaces</h2>" ) ;
buf.push( "<ul>" ) ;
for ( roar_id in gRoarScenarioIndex ) {
if ( roar_id[0] === "_" )
continue ;
scenario = gRoarScenarioIndex[ roar_id ] ;
if ( scenario.scenario_id.indexOf( " " ) !== -1 )
buf.push( "<li>" + roar_id + ": " + scenario.name + " [" + scenario.scenario_id + "]" ) ;
}
buf.push( "</ul>" ) ;
$("#results").html( buf.join("") ).show() ;
}
</script>
</html>