var specialLinksEXAMPLE = [{ type: 'unsubscribe', label: 'SpecialLink.Unsubscribe', link: 'http://[unsubscribe]/' }, { type: 'subscribe', label: 'SpecialLink.Subscribe', link: 'http://[subscribe]/' }, { type: 'subscribe', label: 'SpecialLink.Subscribe2', link: 'http://[subscribe2]/' }]; /* unsubscribe link structure: 'http://apps.fsenablers.com/unsubscribe/unsubscribe.cfm?id=AUTOFILL_RECIPIENTID&tk=AUTOFILL_RECIPIENTTKAUTOFILL_DNSSTRING' */ /* NOTE: specialLinks var has been moved to pu_campaignEditor.cfm as it is now dynamically set from a db query */ /* var specialLinks = [{ type: 'Unsubscribe', label: 'Unsubscribe Link', link: 'UNSUBSCRIBE-LINK-HERE?id=AUTOFILL_RECIPIENTID&tk=AUTOFILL_RECIPIENTTKAUTOFILL_DNSSTRING' }]; */ var mergeTags = [{ name: 'First Name', value: 'AUTOFILL_FIRSTNAME' }, { name: 'Last Name', value: 'AUTOFILL_LASTNAME' }, { name: 'Title', value: 'AUTOFILL_TITLE' }, { name: 'Email Address', value: 'AUTOFILL_EMAIL' }, { name: 'Company Name', value: 'AUTOFILL_COMPANY' }, { name: 'Comments', value: 'AUTOFILL_COMMENTS' }, { name: 'Custom Field 1', value: 'AUTOFILL_CUSTOM1' }, { name: 'Custom Field 2', value: 'AUTOFILL_CUSTOM2' }, { name: 'Custom Field 3', value: 'AUTOFILL_CUSTOM3' }, { name: 'Custom Field 4', value: 'AUTOFILL_CUSTOM4' }, { name: 'Custom Field 5', value: 'AUTOFILL_CUSTOM5' }, { name: 'Custom Field 6', value: 'AUTOFILL_CUSTOM6' }]; var mergeContentsEXAMPLE = [{ name: 'content 1', value: '[content1]' }, { name: 'content 2', value: '[content1]' }]; var mergeContents = []; var bee = null; loadBEEEditor = function() { // TSE-1165: the following setting was removed from beeConfig setup, per the vendor's new auth handling process. uid moved to server side. // uid: document.frmCampaign.ownerType.value + document.frmCampaign.ownerId.value + '-' + document.frmCampaign.userId.value, var beeConfig = { container: 'main-editor-container', autosave: 60, language: 'en-US', specialLinks: specialLinks, mergeTags: mergeTags, mergeContents: mergeContents, preventClose: true, onSave: function(jsonFile, htmlFile) { //var encodedHTML = encodeURI(htmlFile); //encodedHTML = encodedHTML.replace( new RegExp( "\\+", "g" ), "%2B" ); // plus signs need to be additionally encoded var encodedHTML = encodeURIComponent(htmlFile); // encodeURIComponent takes care of the plus sign issue, and other special chars document.frmCampaignSave.campaignHTML.value = encodedHTML; document.frmCampaignSave.campaignTemplate.value = jsonFile; var oRequest = Fse.Ajax.sendForm( document.frmCampaignSave, JSON.parse('{ "method" : "POST" }') ); if (document.frmCampaignSave.saveAsTemplate.value == 'no') { if( window.parent.opener.onBEESaved ) { window.parent.opener.onBEESaved( "saved" ); } else { window.parent.opener.location.reload(); } // need to remove the editor from the dom to avoid the warning that we are about to leave the page var parent = document.getElementById("page-body"); var child = document.getElementById("main-editor-container"); parent.removeChild(child); window.close(); } else { Fse.M22.alertPopup('Template Saved','Your template has been saved and will appear under "User Defined Templates" when you create a new campaign.'); } }, onSaveAsTemplate: function(jsonFile) { // using onSave for template save too so that we get both html and template json. need the // html so that we can create a thumbnail. }, onAutoSave: function(jsonFile) { // TODO: determine if we want to implement a handler for autosave. have autosave logic save to a draft field. clear out the // draft field when a user initiated save is done. when editing a campaign, look to the draft field and if anything exists, // give the user the opportunity to restore from the draft. }, onSend: function(htmlFile) { /* test email callback */ var encodedHTML = encodeURI(htmlFile); encodedHTML = encodedHTML.replace( new RegExp( "\\+", "g" ), "%2B" ); // plus signs need to be additionally encoded document.frmCampaignTest.campaignHTML.value = encodedHTML; var oRequest = Fse.Ajax.sendForm( document.frmCampaignTest, JSON.parse('{ "method" : "POST" }') ); Fse.M22.alertPopup('Test Email','Your test email has been sent!'); }, onError: function(errorMessage) { console.log('onError ', errorMessage); } }; if ( document.frmCampaign.startTemplateId.value != "" ) { var _contentId = document.frmCampaign.startTemplateId.value; var _contentType = 'template'; } else { var _contentId = document.frmCampaign.contentId.value; var _contentType = document.frmCampaign.contentType.value; } var authToken = JSON.parse(decodeURIComponent(document.frmCampaign.editorAuthToken.value)); BeePlugin.create(authToken, beeConfig, function(beePluginInstance) { bee = beePluginInstance; console.log("FSE Email Manager: editor initialized. ready to load campaign."); Fse.M22.loadCampaign(_contentId,_contentType); }); }