// NOTE: These fields aren't mandatory in the sense that snippet generation will fail // if they're not set, but they're really, really, really expected to be there. var _MANDATORY_PARAMS = { scenario: { "SCENARIO_NAME": "scenario name", "SCENARIO_DATE": "scenario date" }, } ; var _MONTH_NAMES = [ // nb: we assume English :-/ "January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December" ] ; var _DAY_OF_MONTH_POSTFIXES = { // nb: we assume English :-/ 0: "th", 1: "st", 2: "nd", 3: "rd", 4: "th", 5: "th", 6: "th", 7: "th", 8: "th", 9: "th", 10: "th", 11: "th", 12: "th", 13: "th" } ; // NOTE: Blood & Jungle has a lot of multi-applicable notes that simply refer to other // multi-applicable notes e.g. "Fr C" = "French Multi-Applicable Note C". // NOTE: These are also used for Lend-Lease vehicles. var MA_NOTE_REDIRECTS = { "Br": "british", "Ch": "chinese", "Fr": "french", "Ge": "german", "Jp": "japanese", "Ru": "russian", "US": "american", "AllM": "allied-minor", "AxM": "axis-minor", } ; // NOTE: There are BFP references like "Jp 5", but we ignore these since they are referring to // a vehicle/ordnance *note*, not a multi-applicable note. MA_NOTE_REDIRECT_REGEX = new RegExp( "^((Br|Ch|Fr|Ge|Jp|Ru|US|AllM|AxM) [A-Z]{1,2})(\\u2020(\\d)?|T)?$" ) ; var gDefaultScenario = null ; var gLastSavedScenario = null ; var gLastSavedScenarioFilename = null ; var gScenarioCreatedTime = null ; // -------------------------------------------------------------------- function generate_snippet( $btn, evt, extra_params ) { // generate the snippet var template_id = $btn.data( "id" ) ; var params = unload_snippet_params( true, template_id ) ; var snippet = make_snippet( $btn, params, extra_params, true ) ; // check if the user is requesting the snippet as an image if ( evt.shiftKey ) { // yup - send the snippet to the backend to generate the image var $dlg = null ; var timeout_id = setTimeout( function() { $dlg = $( "#make-snippet-image" ).dialog( { dialogClass: "make-snippet-image", modal: true, width: 300, height: 60, resizable: false, closeOnEscape: false, } ) ; }, 1*1000 ) ; $.ajax( { url: gMakeSnippetImageUrl, type: "POST", data: snippet.content, contentType: "text/html", } ).done( function( resp ) { clearTimeout( timeout_id ) ; if ( $dlg ) $dlg.dialog( "close" ) ; if ( resp.substr( 0, 6 ) === "ERROR:" ) { showErrorMsg( resp.substr(7) ) ; return ; } if ( getUrlParam( "snippet_image_persistence" ) ) { // FOR TESTING PORPOISES! We can't control a file download from Selenium (since // the browser will use native controls), so we store the result in a