// 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" }, } ; // 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", "LC": "landing-craft", "AllM": "allied-minor", "AxM": "axis-minor", } ; // NOTE: There are BFP references like "Jp 5" and "AllM 34", 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)?$" ) ; NO_WARNING_FOR_MA_NOTE_KEYS_REGEX = new RegExp( "^(Jp 5|AllM 34)" ) ; var gDefaultScenario = null ; var gLastSavedScenario = null ; var gLastSavedScenarioFilename = null ; var gScenarioCreatedTime = null ; // -------------------------------------------------------------------- function generate_snippet( $btn, as_image, 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 ( as_image ) { // yup - send the snippet to the backend to generate the image // NOTE: Generating the first snippet image is slow (because the backend has to spin up a webdriver), // but subsequent snippet images are very fast, so we wait for a short while, and if a response // hasn't been received, then we show a "please wait" dialog. var $pleaseWait = null ; var timeout_id = setTimeout( function() { $pleaseWait = showPleaseWaitDialog( "Generating the snippet image..." ) ; }, 1*1000 ) ; $.ajax( { url: gMakeSnippetImageUrl, type: "POST", data: snippet.content, contentType: "text/html", } ).done( function( resp ) { clearTimeout( timeout_id ) ; if ( $pleaseWait ) $pleaseWait.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