159. EPMO Open Source Coordination Office Redaction File Detail Report

Produced by Araxis Merge on 3/13/2019 2:49:58 PM Central Daylight Time. See www.araxis.com for information about Merge. This report uses XHTML and CSS2, and is best viewed with a modern standards-compliant browser. For optimum results when printing this report, use landscape orientation and enable printing of background images and colours in your browser.

159.1 Files compared

# Location File Last Modified
1 C:\AraxisMergeCompare\Pri_un\DSM\Direct_Webmail\jscripts dpii.compose.js Tue Mar 12 21:54:32 2019 UTC
2 C:\AraxisMergeCompare\Pri_re\DSM-scrubbed\Direct_Webmail\jscripts dpii.compose.js Wed Mar 13 05:06:20 2019 UTC

159.2 Comparison summary

Description Between
Files 1 and 2
Text Blocks Lines
Unchanged 2 1290
Changed 1 2
Inserted 0 0
Removed 0 0

159.3 Comparison options

Whitespace
Character case Differences in character case are significant
Line endings Differences in line endings (CR and LF characters) are ignored
CR/LF characters Not shown in the comparison detail

159.4 Active regular expressions

No regular expressions were active.

159.5 Comparison detail

  1   /*jslint d evel: true , white: t rue, debug : true, no men: true* /
  2  
  3   /* JAVASCR IPT ONLY A PPLICABLE  TO THE COM POSE PAGE 
  4   *
  5   * This cod e is slowl y getting  organized  into modul es, primar ily using  closures.  We're runn ing JSHint  on new co de to try  to keep it  conformin g to some  standard b est practi ces. 
  6   *
  7   * More inf o on modul es and clo sures: htt ps://mediu m.freecode camp.com/j avascript- modules-a- beginner-s -guide-783 f7d7a5fcc
  8   *                                                                                                                                                     htt p://eloque ntjavascri pt.net/10_ modules.ht ml
  9   *
  10   * How to m ake the *t his* keywo rd consist ently poin t to what  you want i t to: http s://www.sm ashingmaga zine.com/2 014/01/und erstanding -javascrip t-function -prototype -bind
  11  
  12   * Goal for  the futur e is to ac tually kee p these mo dules in s eparate fi les and us e somethin g like req uire.js to  grab them  as needed .  Possibl y we could  even go c razy and s tart 
  13   * minifyin g our js a s part of  the deploy ment proce ss so that  we can ad d tons of  comments w ithout inc reasing pa geweight.   Time to p arty like  it's 2003!  - MG 2016 -08-26 */
  14  
  15  
  16   //define n amespaces  for this f ile
  17   var dpii =  dpii || { }; //defin e a namesp ace for ou r js
  18   var $ = $  || console .error('Jq uery is no t availabl e for this  script');
  19   //dpii.dss _provider_ email = "v arouting@d irect-ehea lth.com";   // Email  address us ed for the  DSS prodi ver search  integrati on.
  20   dpii.dss_p rovider_em ail = "tau ser@dev.di rect. DOMAIN . EXT ";    // Email a ddress use d for the  DSS prodiv er search  integratio n.
  21   dpii.dss_p rovider_se arch_websi te = "http s://direct -ehealth.n et/";
  22   dpii.compo se = (func tion() { 
  23           "u se strict" ;
  24           
  25           re turn {
  26                    mess ageId: fun ction(){ 
  27                             return  $('input[ name="msg_ id"]').val (); 
  28                    },
  29                    
  30                    hasM essageId:  function() {
  31                             var me ssageID =  this.messa geId();
  32                             return  ($.isNume ric(messag eID) && me ssageID >  0 && Math. floor(mess ageID) ==  messageID) ;
  33                    },
  34                    
  35                    _ini t: functio n(){
  36                             //call  on the _i nit method  for any o bject insi de of dpii .compose t hat has on e
  37                             for(va r property  in this){
  38                                      if(!this .hasOwnPro perty(prop erty) || p roperty ==  '_init') 
  39                                               continue;
  40                                      if(typeo f this[pro perty] ===  'object') {
  41                                               this[prope rty].paren t = this;
  42                                               if(this[pr operty].ha sOwnProper ty('_init' )){
  43                                                       th is[propert y]._init() ;
  44                                               }
  45                                      }
  46                             }
  47                    
  48                             initRi chTextEdit or();
  49                    },
  50           };
  51   })();
  52  
  53   ////////// ////////// ////////// ////////// ////////// ////////// ////////// ////
  54   // CHANGES
  55   // trackin g changes  that the u ser has ma de since l ast saving  the messa ge
  56   ////////// ////////// ////////// ////////// ////////// ////////// ////////// ////
  57   dpii.compo se.changes  = (functi on() {
  58           va r dataAttr ibutes = { 'exist': ' altered-si nce-save'} ;
  59           
  60           re turn {
  61                    inte rval: null ,
  62                    
  63                    exis t: functio n(){ 
  64                             return  $('#main_ form').dat a(dataAttr ibutes.exi st) === 1;  
  65                    },
  66  
  67                    mark : function (){ 
  68                             return  $('#main_ form').dat a(dataAttr ibutes.exi st, 1); 
  69                    }, 
  70  
  71                    clea r: functio n(){   
  72                             return  $('#main_ form').dat a(dataAttr ibutes.exi st, 0);
  73                    },
  74                    
  75                    _ini t: functio n(){
  76                             this.c lear();
  77                    
  78                             this.i nterval =  setInterva l(function () {
  79                                      if(this. exist()){
  80                                               $("#main_f orm").trig ger('autos ave');
  81                                      }
  82                             }.bind (this), 60 000);
  83  
  84                             //chan ges to any  input in  the main c ompose for
  85                             $('#ma in_form :i nput').cha nge(functi on(){
  86                                      this.mar k();
  87                             }.bind (this)); 
  88                             
  89                             //chan ges to mes sage body  will trigg er autosav e (special  case sinc e it's not  a normal  form field )
  90                             $("#ti nyeditorfr ame").cont ents().fin d("#editor ").on('blu r keyup pa ste', func tion() { 
  91                               if(w indow.pare nt.$('#mes sage_body' ).val() !=  $(this).h tml()) { 
  92                                      this.mar k();
  93                                      window.p arent.$('# message_bo dy').val($ (this).htm l());
  94                               }
  95                             }.bind (this));                                              
  96                    },
  97           };    
  98   })();
  99  
  100  
  101   ////////// ////////// ////////// /////
  102   // CSRF
  103   ////////// ////////// ////////// /////
  104  
  105   dpii.compo se.csrf =  (function( ) { 
  106           va r tokenIde ntifier =  'input[typ e=hidden]. token';
  107           
  108           re turn {
  109                    name : function (){ 
  110                             return  $(tokenId entifier). attr('name '); 
  111                    },
  112                    
  113                    valu e: functio n(){
  114                             return  $(tokenId entifier). val(); 
  115                    },
  116                    
  117                    quer yString: f unction(){
  118                             return  '?' + thi s.name() +  '=' + thi s.value();  
  119                    },
  120                    
  121                    upda te: functi on(value){
  122                             return  $(tokenId entifier). val(value) ;
  123                    
  124                    }
  125           };    
  126   })();
  127  
  128   ////////// ////////// ////////// /////
  129   // FEEDBAC K
  130   ////////// ////////// ////////// /////
  131  
  132   dpii.compo se.feedbac k = (funct ion() { 
  133           
  134                    func tion show( alertType,  message,  alertFor,  header){             
  135                                      var cont ainer = $( '.alert-da nger.clone -me').clon e().remove Class('clo ne-me').cs s('display ', 'block' );
  136  
  137                                      containe r.find('.m essage-tex t').text(m essage);
  138                                      if(heade r)
  139                                               container. find('.mes sage-heade r').html(' <strong>'  + header +  '</strong >');
  140                                      if(alert Type != 'd anger') 
  141                                               container. removeClas s('alert-d anger').ad dClass('al ert-'+aler tType);
  142                                      if(alert For)
  143                                               container. data('for' , alertFor );
  144  
  145                                      $('.aler t-danger.c lone-me'). after(cont ainer);
  146                                      dpii.com pose.files .adjustInp utTrigger( );
  147                    }
  148           
  149           re turn {
  150                    info : function (message,  identifier ){
  151                             return  show('inf o', messag e, identif ier);
  152                    },
  153  
  154                    erro r: functio n(message,  identifie r){
  155                             return  show('dan ger', mess age, ident ifier, 'An  error was  encounter ed. ');
  156                    },
  157  
  158                    succ ess: funct ion(messag e, identif ier){
  159                             return  show('suc cess', mes sage, iden tifier, 'S uccess! ') ;
  160                    },
  161  
  162                    warn ing: funct ion(messag e, identif ier){
  163                             return  show('war ning', mes sage, iden tifier, 'W arning: ') ;
  164                    },
  165  
  166                    remo ve: functi on(identif ier){
  167                             $('.al ert[data-f or="'+iden tifier+'"] ').remove( );
  168                    },
  169  
  170                    setV alidation:  function( input, mes sage){
  171                             this.e rror(messa ge, $(inpu t).attr('n ame'));
  172                             $(inpu t).addClas s('has-err or');
  173                    },
  174  
  175                    remo veValidati on: functi on(input){
  176                             this.r emove($(in put).attr( 'name'));
  177                             $(inpu t).removeC lass('has- error');
  178                    },
  179           };    
  180   })();
  181  
  182   ////////// ////////// ////////// /////
  183   // RECIPIE NTS
  184   ////////// ////////// ////////// /////
  185  
  186   dpii.compo se.recipie nts = (fun ction() { 
  187           
  188           va r applyTok ensToExist ingRecipie nts = func tion(field Name, fiel dText){
  189                    html _entity_de code(field Text).spli t(';').for Each(funct ion(addres s){
  190                             addres s = addres s.replace( /'/g,"\'") ; // Escap e apostrop hes before  trimming
  191                             addres s = $.trim (address);
  192                             if(add ress.lengt h > 0){
  193                                      var extr acted = ad dress.matc h(/([a-zA- Z0-9\'._-] +@[a-zA-Z0 -9._-]+\.[ a-zA-Z0-9. _-]+)/gi);  //Apostro phe added 
  194                                      $('texta rea[name=" '+ fieldNa me+'"]').t okenInput( 'add', { n ame : html entities(a ddress,'EN T_NOQUOTES '), id : h tmlentitie s(extracte d), uid: u niqid() }) ;
  195                             }
  196                    }.bi nd(this));
  197           };
  198           
  199           va r markupFo rValidated Recipient  = function (item){
  200                    var  email = it em.id;
  201                    if(i tem.descri pton != nu ll)
  202                             email  = item.des cription;
  203                    retu rn '<li><d iv style=" display: i nline-bloc k; padding -left: 10p x;"><div c lass="full _name"> '  + item.nam e + '</div ><div clas s="email"> ' + email  + '</div>< /div></li> ';
  204           };
  205           
  206           va r markupFo rUnvalidat edRecipien t = functi on(item){
  207                    item .uid = uni qid();
  208                    var  markup = ' <li class= "unvalidat ed"><p cla ss="unvali dated" id= "'+item.ui d+'" data- address="'  + item.id  + '"';
  209                    if(i tem.descri ption == n ull) {
  210                             markup  += 'title ="' + item .id + '" d ata-addres s="' +item .id+ '">';
  211                    }els e{
  212                             markup  += " oncl ick=\"view DistList(' " + item.u id + "','"  + htmlent ities(base 64_encode( json_encod e(item)))  + "','mess age_to');\ " title=\" " + item.d escription  +"\" ><im g src=\"/i mages/grou p.png\" cl ass=\"hove r_pointer\ " alt=\"Di stribution  List\"> " ;
  213                    }
  214                    mark up += item .name + '< /p></li>';
  215                    retu rn markup;
  216           };
  217           
  218           va r tokenSet tings = {
  219                    them e: 'dpii',
  220                    sear chDelay: 5 00,
  221                    hint Text: 'Ent er a Direc t address' ,
  222                    toke nDelimiter : ';',
  223                    onAd d: functio n(e) { if( !multipleA ddressSpli t(e)) { ve rifyAddres s(e); } },
  224                    noRe sultsText:  'This is  not a trus ted addres s',
  225                    resu ltsFormatt er: markup ForValidat edRecipien t,
  226                    toke nFormatter : markupFo rUnvalidat edRecipien t,
  227           };
  228           
  229           
  230           re turn {
  231                    _ini t: functio n(){
  232                             var me ssage_to_t ext = $('t extarea[na me="messag e_to"]').t ext();
  233                             var me ssage_cc_t ext = $('t extarea[na me="messag e_cc"]').t ext();
  234                             $('tex tarea[name ="message_ to"], text area[name= "message_c c"]').read y(function (){
  235                                      $("#mess age_to").t okenInput( '/inbox/ge t_contacts _search/',  tokenSett ings);
  236                                      $("#mess age_cc").t okenInput( '/inbox/ge t_contacts _search/',  tokenSett ings);
  237                                      applyTok ensToExist ingRecipie nts('messa ge_to', me ssage_to_t ext);
  238                                      applyTok ensToExist ingRecipie nts('messa ge_cc', me ssage_cc_t ext);
  239                             });      
  240                    }
  241           };    
  242   })();
  243  
  244   ////////// ////////// ////////// ////////// ////////// ////////// ///////
  245   // SAVE
  246   ////////// ////////// ////////// ////////// ////////// ////////// ///////
  247  
  248   dpii.compo se.save =  (function( options) {  
  249           va r inProgre ss = false ;
  250           
  251           re turn {
  252                    inPr ogress: fu nction(){ 
  253                             return  inProgres s; 
  254                    },
  255                    run:  function( options){ 
  256                             if(!th is.parent. changes.ex ist() && ( !$.isPlain Object(opt ions) || ! options.fo rceSave))
  257                                      return f alse;
  258                             
  259                             if(thi s.inProgre ss()) 
  260                                      return f alse;
  261  
  262                             if(dpi i.compose. ui.dialogI sOpen()) 
  263                                      return f alse; //th e user is  working on  something  besides t he draft,  and saving  may cause  problms
  264                             
  265                             inProg ress = tru e;
  266  
  267                             if($(' #message_b ody').css( 'display')  == 'none' ) {
  268                                      $('texta rea[name=" message_bo dy"]').val (editor.ge tEditorCon tent());
  269                             }
  270  
  271                             var se ttings = {
  272                                      type: 'P OST',
  273                                      url: '/i nbox/ajax_ draft_save /',
  274                                      data: $( '#main_for m').serial ize(),
  275                                      dataType : 'html',
  276                                      complete : function (jqXHR, st atus){
  277  
  278                                               inProgress  = false;
  279                                               $('.autosa ve').remov e();
  280  
  281                                               if(userIsN otAuthoriz ed(jqXHR))  {
  282                                                       wi ndow.locat ion = '/au th/logout' ;
  283                                                       re turn false ;
  284                                               }
  285  
  286                                               if(!isJSON (jqXHR.res ponseText) ){
  287                                                       re turn false ;
  288                                               }
  289  
  290                                               var parsed Response =  $.parseJS ON(jqXHR.r esponseTex t);
  291                                               this.paren t.csrf.upd ate(parsed Response.t oken);
  292                                               if(status  == 'succes s'){
  293                                                       va r id = par sedRespons e.id;
  294                                                       if ($.isNumer ic(id) &&  id > 1 &&  Math.floor (id) == id ){
  295                                                                $('i nput[name= "msg_id"]' ).val(id);
  296                                                                this .parent.ch anges.clea r();
  297                                                       }
  298                                               }
  299                                      }.bind(t his),
  300                             };
  301  
  302                             if($.i sPlainObje ct(options )){
  303                                      if(optio ns.forceSa ve)
  304                                         setti ngs.data + = '&force_ save=true' ;
  305                                      if(optio ns.async = == false)
  306                                               settings.a sync = fal se;
  307                             }
  308  
  309                             return  $.ajax(se ttings);
  310                    }
  311           };    
  312   })();
  313           
  314  
  315  
  316   ////////// ////////// ////////// ////////// ////////// ////////// ///////
  317   // USER IN TERFACE
  318   ////////// ////////// ////////// ////////// ////////// ////////// ///////
  319   dpii.compo se.ui = (f unction(op tions) {
  320    
  321           re turn {
  322                    dial ogIsOpen:  function() {
  323                             return  ($('.over lay').leng th > 0 ||  $('.form-d ialog-cont ainer').le ngth > 0);
  324                    }, 
  325                    
  326                    _ini t: functio n(){
  327                             $('a.c ancel').cl ick(functi on(event)  {
  328                                      if(!this .parent.ch anges.exis t()) retur n true; // if there a re no unsa ved change s, go ahea d and canc el without  prompting
  329                                      if(event .preventDe fault) eve nt.prevent Default();  else even t.returnVa lue = fals e;
  330                                      var dial og = $('<p >This draf t has unsa ved change s.  Would  you like t o save you r changes? </p>').dia log({
  331                                               buttons: {
  332                                                       "Y es": funct ion() {$(' #save_btn' ).click(); },
  333                                                       "N o":  funct ion() {win dow.locati on.href =  "/inbox";} ,
  334                                                       "C ancel":  f unction()  {
  335                                                                dial og.dialog( 'close');
  336                                                       }
  337                                               }
  338                                      });
  339                             }.bind (this));
  340  
  341                             $("#sh ow-cc").cl ick(functi on(event)  {
  342                                      if(event .preventDe fault) eve nt.prevent Default();  else even t.returnVa lue = fals e;
  343                                      if($('te xtarea[nam e="message _cc"]').le ngth) {
  344                                               $('textare a[name="me ssage_cc"] ').parent( ).parent() .css('disp lay','tabl e-row');
  345                                               $('textare a[name="me ssage_cc"] ').focus() ;
  346                                               $('#show-c c').remove ();
  347                                      }
  348                             });
  349                             
  350                             $(".ps -address-b ook").clic k(function (event) {
  351                                      //if(eve nt.prevent Default) e vent.preve ntDefault( ); else ev ent.return Value = fa lse;
  352                                      
  353                                      // Launc h Provider  Search Bo x (DSS) //
  354                                      // Link  is https:/ /direct-eh ealth.com: 449/ //
  355                                      
  356                                      var $thi s = $(this );
  357                                      
  358                                      var url  = dpii.dss _provider_ search_web site;
  359                                      var wind owName = " Provider S earch";//$ (this).att r("name");
  360                                      var wind owSize = $ this.data( "popup");
  361                                      
  362                                      // Addin g support  to center  the popup  page. //
  363                                      // Fixes  dual-scre en positio n                           Most  browsers       Firef ox
  364                                      var dual ScreenLeft  = window. screenLeft  != undefi ned ? wind ow.screenL eft : wind ow.screenX ;
  365                                      var dual ScreenTop  = window.s creenTop ! = undefine d ? window .screenTop  : window. screenY;
  366  
  367                                      var w =  800; // de fault;
  368                                      var h =  600;
  369                                      var widt h = window .innerWidt h ? window .innerWidt h : docume nt.documen tElement.c lientWidth  ? documen t.document Element.cl ientWidth  : screen.w idth;
  370                                      var heig ht = windo w.innerHei ght ? wind ow.innerHe ight : doc ument.docu mentElemen t.clientHe ight ? doc ument.docu mentElemen t.clientHe ight : scr een.height ;
  371                                      
  372                                      w = widt h - (width  * .20);
  373                                      var left  = ((width  / 2) - (w  / 2)) + d ualScreenL eft;
  374                                      var top  = ((height  / 2) - (h  / 2)) + d ualScreenT op;
  375    
  376                                      var $dss window = w indow.open (url, wind owName, 's crollbars= yes, width =' + w + ' , height='  + h + ',  top=' + to p + ', lef t=' + left );
  377                                      
  378                                      // Popul ate TO fie ld with DS S provider  email.  / /
  379                                      // varou ting@direc t-ehealth. com
  380                                      
  381                                      
  382                                      //event. preventDef ault();
  383                                      
  384                                      $('#toke n-input-me ssage_to') .val(dpii. dss_provid er_email);
  385                                     // $('#to ken-input- message_to ').parent( ).parent() .val(dpii. dss_provid er_email);
  386                                      $('texta rea[name=" message_to "]').val(d pii.dss_pr ovider_ema il);
  387                                      
  388                                      
  389                                      $('#toke n-input-me ssage_to') .prop("dis abled", tr ue);
  390                                      $('#toke n-input-me ssage_to') .parent(). parent().c ss({"borde r":'none', "color":"# 000000"});
  391                                      $('#toke n-input-me ssage_to') .prop("col or", '#000 000');
  392                                      $('#toke n-input-me ssage_to') .css("widt h", 300);
  393                                      $('#from _field').c ss("paddin g-left", " 5px");
  394                                      if($('te xtarea[nam e="message _pscc"]'). length) {
  395                                               $('textare a[name="me ssage_pscc "]').paren t().parent ().css('di splay','ta ble-row');
  396                                               $('textare a[name="me ssage_pscc "]').focus ();
  397                                               //$('#show -pscc').re move();
  398                                      }
  399                             });
  400                             
  401                             // Add  input val idation of  message_p scc. //
  402                             // unc omment onc e merged w ith 1.11.3  where fil terXSS is  added to t he project . //
  403                             
  404                             $('tex tarea[name ="message_ pscc"]').c hange(func tion(){
  405                                 $( 'textarea[ name="mess age_pscc"] ').val(fil terXSS($(' textarea[n ame="messa ge_pscc"]' ).val()));
  406                             });
  407                             
  408                             
  409                             
  410                    }
  411           };
  412           
  413   })();
  414  
  415  
  416   ////////// ////////// ////////// ////////// ////////// ////////// ////////// //
  417   // NOT YET  ORGANIZED
  418   ////////// ////////// ////////// ////////// ////////// ////////// ////////// //
  419  
  420   //previous ly just a  giant mass  of code i n the wind ow.load fu nction - n eeds to be  broken do wn and org anized
  421   function c omposeForm IsValid(){
  422           cl earInterva l(dpii.com pose.chang es.interva l);
  423  
  424           if ($('button #search_bt n').attr(' clicked')  == "true")
  425                    $('b utton#sear ch').remov eAttr('cli cked'); 
  426                    retu rn true; 
  427           }
  428  
  429  
  430           if ($('#messa ge_body'). css('displ ay') == 'n one') {
  431                    $('t extarea[na me="messag e_body"]') .val(edito r.getEdito rContent() ); //need  to set tex tarea cont ent on sub mit
  432           }
  433  
  434           // Clear data
  435           $( '#7332_dat a_question ').css("co lor","");
  436           $( '#7332_aut h_question ').css("co lor","");
  437  
  438           va r validate  = true;
  439           va r message  = "";
  440           if ($('textar ea[name="m essage_to" ]').val(). length ===  0 && $('# save_btn') .attr('cli cked') !=  'true') {
  441                             dpii.c ompose.fee dback.setV alidation( $('#token- input-mess age_to').p arent().pa rent(), 'P lease spec ify at lea st one rec ipient for  the To fi eld.');
  442  
  443                             $('#to ken-input- message_to ').css("ba ckground", "none repe at scroll  0 0 #f8e0e 0");
  444                             valida te = false ;
  445                             messag e += 'At l east one r ecipient m ust be spe cified. ';
  446                             $('#to ken-input- message_to ').blur(fu nction(){
  447                                      if($('.t oken-input -token-dpi i').length  !== 0){
  448                                               removeErro rMessage($ ('#token-i nput-messa ge_to').pa rent().par ent(),'to' );
  449                                               $('#token- input-mess age_to').c ss('backgr ound','');
  450                                      }
  451                             });
  452           }
  453  
  454           va r patient_ auth_valid ation_mess age = dpii .compose.p atientauth .get_valid ation_mess age(); 
  455           if  (patient_ auth_valid ation_mess age !== '' ) { 
  456                validate  = false; 
  457                message  += patient _auth_vali dation_mes sage; 
  458           }
  459          
  460           if (!validate ){
  461                    $("# pros_modal ").css('di splay','no ne');
  462                    $('. overlay'). remove();
  463                    $('# save_btn') .removeAtt r('clicked ');
  464                    $('# send_btn') .removeAtt r('clicked ');
  465                    $('# StatusUpda ter').html (message);
  466                    retu rn false;
  467           }
  468  
  469           if ($('p.untr usted').le ngth && $( '#save_btn ').attr('c licked') ! = 'true')  {
  470                    $("# pros_modal ").css('di splay','no ne');
  471                    $('. overlay'). remove();
  472                    $('# untrusted- dialog').r emove();
  473                    var  addresses  = '';
  474                    var  to_remove  = [];
  475                    var  i = 1;
  476                    var  j = 0;
  477                    $('p .untrusted ').each(fu nction() {
  478                             addres ses += $(t his).attr( 'data-addr ess');
  479                             to_rem ove[j] = $ (this).att r('data-ad dress');
  480                             if(i <  $('p.untr usted').le ngth && $( 'p.untrust ed').lengt h > 1) { a ddresses + = ', '; }
  481                             i++;
  482                             j++;
  483                    });
  484                    $('< div id=\"u ntrusted-d ialog\" ti tle="Untru sted Recip ients">'+
  485                             '<a cl ass="hidde n_context"  href="#"> Untrusted  Recipients </a>'+
  486                             '<p>Th e followin g recipien ts are unt rusted: '+ addresses+
  487                             '.</p> <p>Untrust ed recipie nts must b e removed  before sen ding.</p>< p>Click "R emove All"  to remove  all untru sted recip ients,'+
  488                             ' or " Cancel" to  cancel se nd and rev iew recipi ents indiv idually.</ p>'+
  489                       ' </div>').d ialog({
  490                                      buttons:  [
  491                                               { text: 'R emove All' , click :  function()  {
  492                                                       va r i = 0;
  493                                                       $( to_remove) .each(func tion() {
  494                                                                $("# message_to ").tokenIn put('remov e', { id :  to_remove [i] });
  495                                                                $("# message_cc ").tokenIn put('remov e', { id :  to_remove [i] });
  496                                                                i++;
  497                                                       }) ;
  498                                                       $( this).dial og('close' ); }
  499                                               },
  500                                               { text: 'C ancel', cl ick : func tion() { $ (this).dia log('close '); } }
  501                                      ],
  502                                      close: f unction()  { $('#menu Content'). focus(); $ ('#menuCon tent').rem oveClass(' visible');  }
  503                       } );
  504                    $('# save_btn') .removeAtt r('clicked ');
  505                    $('# send_btn') .removeAtt r('clicked ');
  506                    retu rn false;
  507           }e lse if($(' p.unvalida ted').leng th && $('# save_btn') .attr('cli cked') !=  'true') {
  508                    $("# pros_modal ").css('di splay','no ne');
  509                    $('. overlay'). remove();
  510                    var  addresses  = '';
  511                    var  i = 1;
  512                    $('p .unvalidat ed').each( function()  {
  513                             addres ses += $(t his).attr( 'title');
  514                             if(i <  $('p.unva lidated'). length &&  $('p.unval idated').l ength > 1)  { address es += ', ' ; }
  515                             i++;
  516                    });
  517                    if(c onfirm('Th e followin g recipien ts have no t been val idated for  trust: '+ addresses+ '. Message  will fail  to send i f any of t he unvalid ated recip ients are  not truste d. Attempt  to send a nyway?'))  {
  518                             //do t he check f or missing  subject t oo if we a re plannin g on sendi ng it anyw ay
  519                             if($(' input[name ="message_ subject"]' ).val().le ngth === 0  && $('#sa ve_btn').a ttr('click ed') != 't rue') {
  520                                      if(confi rm('No sub ject speci fied, send  anyway?') ){
  521                                               $("#pros_m odal").css ('display' ,'inline') ;
  522                                               $(document .body).app end("<div  class=\"ov erlay\"></ div>");
  523                                               return tru e;
  524                                      }
  525                                      else{
  526                                               $('#send_b tn').remov eAttr('cli cked');
  527                                               return fal se;
  528                                      }
  529                             }
  530                             else {
  531                                      $("#pros _modal").c ss('displa y','inline ');
  532                                      $(docume nt.body).a ppend("<di v class=\" overlay\"> </div>");
  533                                      return t rue;
  534                             }
  535                    }
  536                    else  {
  537                             $('#se nd_btn').r emoveAttr( 'clicked') ;
  538                             return  false;
  539                    }
  540           }
  541           el se if($('i nput[name= "message_s ubject"]') .val().len gth === 0  && $('#sav e_btn').at tr('clicke d') != 'tr ue') {
  542                             $("#pr os_modal") .css('disp lay','none ');
  543                             $('.ov erlay').re move();
  544                             $('#sa ve_btn').r emoveAttr( 'clicked') ;
  545                             if(con firm('You  haven\'t s pecified a  subject -  would you  like to s end this m essage any way?')){
  546                                      $("#pros _modal").c ss('displa y','inline ');
  547                                      $(docume nt.body).a ppend("<di v class=\" overlay\"> </div>");
  548                                      return t rue;
  549                             }
  550                             else{
  551                                      $('#send _btn').rem oveAttr('c licked');
  552                                      return f alse;
  553                             }
  554           }
  555           el se if(dpii .compose.a ttachments .size() >  0) {
  556                    if(d pii.compos e.attachme nts.size()  > dpii.co mpose.atta chments.ma xSize()) {
  557                             $("#pr os_modal") .css('disp lay','none ');
  558                             $('.ov erlay').re move();
  559                             dpii.c ompose.fee dback.erro r('The tot al attachm ent size e xceeds the  '+dpii.co mpose.atta chments.ma xSizeForDi splay()+'  limit. Ple ase remove  attachmen ts before  trying aga in.');
  560                             $('#sa ve_btn').r emoveAttr( 'clicked') ;
  561                             $('#se nd_btn').r emoveAttr( 'clicked') ;
  562                             return  false;
  563                    }
  564                    else  {
  565                             return  true;
  566                    }
  567           }
  568           el se if(edit or.getEdit orContent( ).toLowerC ase().inde xOf('attac hed') >= 0  && $('#sa ve_btn').a ttr('click ed') != 't rue') {
  569                    if($ ('tr.attac h_input'). length) {
  570                             if($(' tr#attach0 ').html(). length <=  0) {
  571                                      $("#pros _modal").c ss('displa y','none') ;
  572                                      $('#save _btn').rem oveAttr('c licked');
  573                                      if(confi rm('Did yo u mean to  attach fil es?\n\n Yo u wrote "a ttached" i n your mes sage but h ave not at tached any  files, se nd anyway? ')){
  574                                               $("#pros_m odal").css ('display' ,'inline') ;
  575                                               $(document .body).app end("<div  class=\"ov erlay\"></ div>");
  576                                               return tru e;
  577                                      }
  578                                      else{
  579                                               $('#send_b tn').remov eAttr('cli cked');
  580                                               return fal se;
  581                                      }
  582                             }
  583                    }
  584                    else  {
  585                             $("#pr os_modal") .css('disp lay','none ');
  586                             $('.ov erlay').re move();
  587                             $('#sa ve_btn').r emoveAttr( 'clicked') ;
  588                             if(con firm('Did  you mean t o attach f iles?\n\n  You wrote  "attached"  in your m essage but  have not  attached a ny files,  send anywa y?')){
  589                                      $("#pros _modal").c ss('displa y','inline ');
  590                                      $(docume nt.body).a ppend("<di v class=\" overlay\"> </div>");
  591                                      return t rue;
  592                             }
  593                             else{
  594                                      return f alse;
  595                             }
  596                    }
  597           }
  598           el se { $('#s ave_btn'). removeAttr ('clicked' ); return  true; }                       
  599   }
  600  
  601  
  602  
  603   function r emoveError Message(in put ,error _id){
  604           $( '.alert-er ror.'+erro r_id).remo ve();
  605           in put.css("b order","") ;
  606           in put.css("b ackground" ,"");
  607   }
  608  
  609   //sets err ors messag e for comp ose screen
  610   function s etErrorMes sage(messa ge, input,  error_id) {
  611           // showFeedba ckForm(mes sage, erro r_id);
  612           in put.css("b ackground" ,"none rep eat scroll  0 0 #f8e0 e0");
  613           in put.css("b order"," 2 px solid # c00");
  614   }
  615  
  616  
  617   ////////// ////////// ////////// ////////// ////////// ////////// ////////// ////////// ////////// ////////// ////
  618   // INITIAL IZATION FU NCTIONS -  Things tha t will be  run by doc ument.read y when the  page is f irst loade d
  619   ////////// ////////// ////////// ////////// ////////// ////////// ////////// ////////// ////////// ////////// ////
  620  
  621   function i nitRichTex tEditor(){
  622           ne w TINY.edi tor.edit(' editor',{
  623                    id:' message_bo dy',
  624                    titl e:'Message  Body Rich  Text Edit or',
  625                    widt h: $("#mes sage_body" ).css('wid th'),
  626                    heig ht: $("#me ssage_body ").css('he ight'),
  627                    cssc lass:'te',
  628                    cont rolclass:' tecontrol' ,
  629                    rowc lass:'tehe ader',
  630                    divi derclass:' tedivider' ,
  631                    cont rols:['tog gle','|',' bold','ita lic','unde rline','st rikethroug h','|','su bscript',' superscrip t','|',
  632                                        'order edlist','u norderedli st','|','o utdent','i ndent','|' ,'leftalig n',
  633                                        'cente ralign','r ightalign' ,'blockjus tify','|', 'unformat' ,'|','undo ','redo',' n',
  634                                        'font' ,'size','s tyle','|', 'image','h r','link', 'unlink',' |','cut',' copy','pas te','print '],
  635                    foot er:true,
  636                    font s:['Verdan a','Arial' ,'Georgia' ,'Trebuche t MS'],
  637                    xhtm l:true,
  638                    cssf ile:'/css/ tinyeditor .css',
  639                    body id:'editor ',
  640                    foot erclass:'t efooter',
  641                    togg le:{text:' source',ac tivetext:' wysiwyg',c ssclass:'t oggle'},
  642                    resi ze:{csscla ss:'resize '},
  643                    enti ty_encodin g : "raw"
  644           }) ;
  645           $( 'textarea[ name="mess age_body"] ').val('') ;
  646   }