Allow EXC blocks to be styled.

master
Pacman Ghost 4 years ago
parent 720e1540b1
commit e6a1b98801
  1. 2
      vasl_templates/webapp/data/default-template-pack/common.css
  2. 1
      vasl_templates/webapp/data/default-template-pack/nat_caps.j2
  3. 1
      vasl_templates/webapp/data/default-template-pack/ob_ma_notes.j2
  4. 1
      vasl_templates/webapp/data/default-template-pack/ob_vo.j2
  5. 3
      vasl_templates/webapp/static/nat_caps.js
  6. 27
      vasl_templates/webapp/static/snippets.js
  7. 7
      vasl_templates/webapp/static/utils.js

@ -18,3 +18,5 @@ td.l { text-align: left ; }
td.r { text-align: right ; }
sup { font-size: 75% ; }
.exc { font-style: italic ; color: #404040 ; }

@ -7,7 +7,6 @@
td { padding: 2px 5px ; }
li.comment { font-size: 96% ; font-style: italic ; color: #404040 ; }
span.comment { font-size: 85% ; font-style: italic ; color: #404040 ; }
.exc { color: #404040 ; }
</style>
</head>

@ -17,6 +17,7 @@
.ma-note table td { padding: 0 10px 0 5px ; }
.extra-notes-caption { border: 1px solid #e0e0e0 ; background: #fcfcfc ; font-weight: bold ; padding: 2px 5px ; }
.disabled { color: #808080 ; }
.disabled .exc { color: #808080 ; }
.slashed { text-decoration: line-through ; }
</style>
</head>

@ -9,7 +9,6 @@
.capability .brewup { color: #a04010 ; }
.comment { font-size: 96% ; font-style: italic ; color: #404040 ; white-space: nowrap ; }
.comment .split-mg-red { color: #a04010 ; }
.comment .exc { color: #606060 ; }
</style>
</head>

@ -10,7 +10,6 @@ function set_nat_caps_params( player_nat, params )
// initialize
params.NAT_CAPS = {} ;
var excRegex = new RegExp( /\[EXC: .*?\]/g ) ;
var val ;
function add_nat_cap( key, val ) {
@ -20,7 +19,7 @@ function set_nat_caps_params( player_nat, params )
function fixup_content( val ) {
val = strReplaceAll( val, "1st", "1<sup>st</sup>" ) ;
val = strReplaceAll( val, "2nd", "2<sup>nd</sup>" ) ;
return wrapSubstrings( val, excRegex, "<span class='exc'>", "</span>" ) ;
return wrapExcWithSpan( val ) ;
}
// set the TH# color

@ -405,6 +405,25 @@ function make_snippet( $btn, params, extra_params, show_date_warnings )
if ( extra_params )
$.extend( true, params, extra_params ) ;
// allow EXC blocks to be styled
params.VICTORY_CONDITIONS = wrapExcWithSpan( params.VICTORY_CONDITIONS ) ;
params.SCENARIO_NOTE = wrapExcWithSpan( params.SCENARIO_NOTE ) ;
if ( params.SSR ) {
for ( i=0 ; i < params.SSR.length ; ++i )
params.SSR[i] = wrapExcWithSpan( params.SSR[i] ) ;
}
params.OB_NOTE = wrapExcWithSpan( params.OB_NOTE ) ;
params.VO_NOTE_HTML = wrapExcWithSpan( params.VO_NOTE_HTML ) ;
[ "VEHICLES", "ORDNANCE" ].forEach( function( voType ) {
for ( var playerId=1 ; playerId <= 2 ; ++playerId ) {
var notes = params[ "OB_" + voType + "_MA_NOTES_" + playerId ] ;
if ( ! notes )
continue ;
for ( var i=0 ; i < notes.length ; ++i )
notes[i][1] = wrapExcWithSpan( notes[i][1] ) ;
}
} ) ;
// check that the players have different nationalities
if ( params.PLAYER_1 === params.PLAYER_2 )
showWarningMsg( "Both players have the same nationality!" ) ;
@ -492,19 +511,13 @@ function adjust_vo_comments( params )
return val.substring(0,match.index) + buf.join("") + val.substring(match.index+match[0].length ) ;
}
// allow comment EXC's to be styled
var excRegex = new RegExp( /\[EXC: .*?\]/g ) ;
function adjustExc( val ) {
return wrapSubstrings( val, excRegex, "<span class='exc'>", "</span>" ) ;
}
// adjust comments
if ( params.OB_VO ) {
for ( i=0 ; i < params.OB_VO.length ; ++i ) {
if ( ! params.OB_VO[i].comments )
continue ;
for ( var j=0 ; j < params.OB_VO[i].comments.length ; ++j ) {
params.OB_VO[i].comments[j] = adjustSplitMG( adjustExc(
params.OB_VO[i].comments[j] = adjustSplitMG( wrapExcWithSpan(
params.OB_VO[i].comments[j]
) ) ;
}

@ -466,6 +466,13 @@ function fixup_external_links( $root )
} ) ;
}
function wrapExcWithSpan( val )
{
// wrap an EXC block with a <span>
var excRegex = new RegExp( /\[EXC: .*?\]/g ) ;
return wrapSubstrings( val, excRegex, "<span class='exc'>", "</span>" ) ;
}
function getUrlParam( param )
{
// look for the specified URL parameter

Loading…
Cancel
Save