Added extra information to the COUNT-REMAINING extras template.

master
Pacman Ghost 5 years ago
parent e737b43464
commit 9b0db53799
  1. 20
      vasl_templates/webapp/data/default-template-pack/extras/count-remaining.j2
  2. 6
      vasl_templates/webapp/static/css/tabs-extras.css
  3. 11
      vasl_templates/webapp/static/extras.js

@ -3,6 +3,26 @@
<!-- vasl-templates:name Count remaining -->
<!-- vasl-templates:description Add the snippet as the label of a counter (e.g. Panzerfaust or Tank-Hunter Hero), then press <i>Ctrl-L</i> when you need to update how many are left. -->
<!-- vasl-templates:comment The HTML is deliberately malformed, so that the number remaining is the last thing in snippet, which makes it easier to change during the course of a game. -->
<!-- vasl-templates:footer <table> <tr>
<td>
<h3>Panzerfaust</h3>
<table>
<tr> <td class="key"> before '44 <td class="val"> #squads
<tr> <td class="key"> '44 <td class="val"> #squads &times 1&half; (FRD)
<tr> <td class="key"> '45 <td class="val"> #squads &times 2
</table>
<em> Squads or squad-equivalents. </em>
<td style="padding-left: 1em;">
<h3>Tank-Hunter Heroes</h3>
<table>
<tr> <td class="key"> before '43 <td class="val"> 10% of #squads (FRU) <br> <small><em>(20% vs. Russians)</em></small>
<tr> <td class="key"> '43 <td class="val"> 20% of #squads (FRU)
<tr> <td class="key"> '44 <td class="val"> 33% of #squads (FRU)
<tr> <td class="key"> '45 <td class="val"> 50% of #squads (FRU)
</table>
<em> Squads only, not squad-equivalents. </em>
</table> -->
<head>
<style> {{CSS:common}} </style>

@ -20,3 +20,9 @@
#tabs-extras .right-panel table { margin-top: 1em ; }
#tabs-extras .right-panel td.caption { font-weight: bold ; padding-right: 0.25em ; }
#tabs-extras .right-panel .snippet-control { margin-top: 0.5em ; }
#tabs-extras .right-panel .footer { margin-top: 1em ; font-size: 80% ; font-style: italic ; color: #444 ; }
#tabs-extras .right-panel .footer table { margin: 0 ; }
#tabs-extras .right-panel .footer td { vertical-align: top ; }
#tabs-extras .right-panel .footer td.key, td.val { padding: 0.2em 0.5em; border: 1px dotted #ccc ; }
#tabs-extras .right-panel .footer td.key { background: #f8f8f8 ; font-weight: bold ; }

@ -107,6 +107,9 @@ function _show_extra_template( template_id )
buf.push( "</table>" ) ;
}
buf.push( "<button class='generate' data-id='" + template_info.template_id + "'>Snippet</button>" ) ;
if ( template_info.footer ) {
buf.push( "<div class='footer'>", template_info.footer, "</div>" ) ;
}
buf.push( "</div>" ) ;
var $form = $( buf.join("") ) ;
$form.find( "select" ).select2( {
@ -130,13 +133,15 @@ function _parse_extra_template( template_id, template )
// extract the main details
var result = { template_id: template_id, name: template_id } ;
function extract_val( key ) {
var match = template.match( new RegExp( "<!-- vasl-templates:" + key + " (.*?) -->" ) ) ;
var ch = (key === "footer") ? "[^]" : "." ; // FUDGE! Allow multi-line values for "footer" :-/
var match = template.match( new RegExp( "<!-- vasl-templates:" + key + " (" + ch + "*?) -->" ) ) ;
if ( match )
result[key] = match[1] ;
result[key] = match[1].trim() ;
}
extract_val( "name" ) ;
extract_val( "caption" ) ;
extract_val( "description" ) ;
extract_val( "footer" ) ;
// extract the template parameters
result.params = [] ;
@ -203,7 +208,7 @@ function fixup_template_parameters( template )
}
// remove all our special comments, except for the snippet ID
regex = /<!-- vasl-templates:(.*?) .*? -->\n*/g ;
regex = /<!-- vasl-templates:(.*?) [^]*? -->\n*/g ; // nb: we use "[^]" to match newline as well
matches = [] ;
while( (match = regex.exec( template )) !== null ) {
if ( match[1] !== "id" )

Loading…
Cancel
Save