ГлавнаяПоддержкаБлог
Главная arrow Исходные тексты arrow default.js/ActionEnvironment()
default.js/ActionEnvironment()
function CreateNewItemDo(Templ, CreateFromTemplate2, cf, ItemType){
 var Result;
 if(Templ){
  Result = func.Application.CreateItemFromTemplate(Templ)
 }else{
  if(CreateFromTemplate2.length>1){
   Result = func.Application.CreateItemFromTemplate(CreateFromTemplate2)
  }else{
   ItemType = ItemType?ItemType:olMailItem;
   ItemType = cf      ?ItemType:olMailItem;
   if(ItemType>=0){
     Result = func.Application.CreateItem(ItemType)
   }else{
     Result = cf.Items.Add()
   }  
  }
 }
 if(Result.Class!=olNote)
   Result = SafeMailItem(Result);
 return(Result)
}


var CreateFromTemplate='';
function CreateItem(Templ, cf, ItemType){
 glob('EV_CNI_TEMPL') = Templ;
 glob('EV_CNI_TEMPL1') = CreateFromTemplate;
 glob('EV_CNI_FOLDER') = cf;
 glob('EV_CNI_ITEMTYPE') = ItemType; 
 func.SendEvent(EV_ID_CNI, null, null)
 rr = glob('EV_CNI_RESULT');
 glob('EV_CNI_RESULT') = null;
 AddPluginInfo(rr);
 return(rr);
}

function CheckBodyFormat(m){
 try{
  return(m.BodyFormat)
 }catch(e){
  try{
    if((m.HTMLbody+'').length>0){
     return(olFormatHTML)
    }else{
     return(olFormatPlain)
    }
  }catch(e){
   return(olFormatPlain)
  }
 }
}

function SendKeys(Keys){
 var WshShell = glob('WScript.Shell');
 WshShell.SendKeys(Keys);
 WshShell = null;
}

function GotoCursor(cursor, FromAddressEdit, FromSubject){
 if(cursor[0]==0&&cursor[1]==0){return}
 SendKeys((FromAddressEdit?'{TAB 3}':'')+(FromSubject&&!FromAddressEdit?'{TAB}':'')+'{DOWN '+cursor[1]+'}{RIGHT '+cursor[0]+'}');
}

function GotoCursor2(cursor, Inspector){
 if(cursor[0]==0&&cursor[1]==0){return}
 func.InspectorGoToPos(Inspector, cursor[1], cursor[0]);
}

function GetCursorPos(re){
 var mm = re.split(CursorStr);
 if(mm.length==1){
  return([0,0])
 }
 var ttt = mm[0];
 var y = 0;
 try{
   var y = ttt.match(new RegExp('\n','gi')).length;
 }catch(e){y=0}
 var x = ttt.split('\n');
 try{
  x = x[x.length-1].length;
 }catch(e){x=0}
 return([x,y]);
}

function VersionOutlook(){
 return(glob('OUTLOOK_VER'));
}

// ActionEnvironment - object ********** begin

function TActionEnvironment(){
 this.re = ""
 this.rplPrefix = 0;
 this.Account = '';
 this.PrefixReply          = 'Re'
 this.PrefixReplyAll       = 'Re'
 this.PrefixForward        = 'Fwd'
 this.PrefixRepost         = ''
 this.Params = [];
 this.om = '';
 this.nm = '';
 this.cf = '';
 this.EditorPreferences = getEditorPreferences();
 this.BodyFormat = glob('BodyFormat')?glob('BodyFormat'):this.EditorPreferences[0];
 this.AfterCommands = glob('AfterCommands')?glob('AfterCommands'):'';
 this.event = '';
 this.nmInternetCodepage = -1;
 this.cursor = [0,0];
 this.Modules = glob('Modules');
 this.KeyState = [GetKeyState(VK_SHIFT), GetKeyState(VK_CONTROL), GetKeyState(VK_MENU)];
 this.HTML_before = ''
 this.HTML_after = ''
 this.HTML_body = ''
 this.RemoveADV = 0;
 this.tplInfo = ['',''];
 this.SelectedText = '';
 this.GetSelectedText();
 this.ReplyPrefixType = 0;
 this.ReplyPrefixValue = '';
 this.Body = ''
 this.MultiSelect;
 this.RemoveAdv = false;
 this.OriginalBody = false;
 this.QuoteOutlook = false;
 this.QuoteWithSubject = false;
 this.TextToCursor = glob('TextToCursor')?glob('TextToCursor'):'';
 this.NoDisplay = false;
 this.NoSendAutoReply = false;
 this.SourceText = '';
 this.FArrayParams = [];
 this.FromName = '';
 this.FromAddress = '';
 this.FromSubject = '';
 this.FVariables = [];
 this.SubjectNoChange = false;
 this.ItemType = -1;
 this.TagObject; // user object
}

TActionEnvironment.prototype.write = function (ss)
{
 this.re += ss;
}

TActionEnvironment.prototype.ParamIndex = function (Name){
 if(this.Params&&this.Params.length>0)
 for(var i=0;ithis.Params.length;i++){
  if(this.Params[i]['name'] == Name) return(i)
 }
 return(-1)
}

TActionEnvironment.prototype.SetVariable = function (Name, Value){
  this.FVariables[this.FVariables.length] = [Name, Value];
}

TActionEnvironment.prototype.Variable = function (Name){
  for(var i=0;ithis.FVariables.length;i++){
    if(this.FVariables[i][0]==Name){
      return(this.FVariables[i][1])
    }
  }
  return('')
}

TActionEnvironment.prototype.param = function (Name, Field){
 var i = this.ParamIndex(Name);
 if(i>=0){
  var pp = this.Params[i]
  if(Field){
   return(pp[Field])
  }else{
   return(pp['value'])
  }
 }
 return([])
}

TActionEnvironment.prototype.GetSelectedText = function (){
  this.SelectedText = func.GetSelectedText();
}

TActionEnvironment.prototype.GetReplyPrefix = function (ThisReplyPrefixType, ThisReplyPrefixValue){
  ThisReplyPrefixType = ThisReplyPrefixType?ThisReplyPrefixType:rplPrefixFirstName_FirstSymb;
  if(!ThisReplyPrefixValue&&this.om&&this.om.Class==olMail)
    ThisReplyPrefixValue = GetQuotePrefix(this.SourceMessagePart(mpFromName), ThisReplyPrefixType)
  if(!this.ReplyPrefixType)
    this.ReplyPrefixType  = ThisReplyPrefixType
  if(!this.ReplyPrefixValue)
    this.ReplyPrefixValue = ThisReplyPrefixValue

  this.ReplyPrefixValue = this.ReplyPrefixValue?this.ReplyPrefixValue:"";
  if(this.QuoteOutlook)
    this.ReplyPrefixValue = '>'
  else
    this.ReplyPrefixValue += "> ";
}

TActionEnvironment.prototype.GetSourceBody = function (){
  if(this.SourceText){
    this.Body = this.SourceText;
    return;
  }
  if(!this.NoDisplay&&this.SelectedText){
    this.Body = this.SelectedText;
    return;
  }
  this.Body = '';
  if(this.MultiSelect){
    for(var i=0;ithis.MultiSelect.length;i++){
      var tmpBody = (this.RemoveAdv?RemoveAdvMail(this.MultiSelect[i].Body):this.MultiSelect[i].Body);
      tmpBody = this.OriginalBody?tmpBody:TBQuote(tmpBody);
      if(this.QuoteWithSubject)
        this.Body += '\n\t\t\t'+this.MultiSelect[i].Subject+'\n'
      this.Body += tmpBody;
    }
    this.OriginalBody = true;
  }else{
    if(glob('OUTLOOK_VER')=10 &&
       CheckBodyFormat(this.om)==olFormatHTML &&
       this.om.InternetCodepage!=MainCodePage){
      this.Body = ConvertTextToCodePage(this.om.HTMLBody, this.om.InternetCodepage, MainCodePage)
    }else{
      this.Body = this.om.Body;
    }
  }

  if(!this.MultiSelect&&this.RemoveAdv)
    this.Body = RemoveAdvMail(this.Body)

  this.Body = this.OriginalBody?this.Body:TBQuote(this.Body);
}

TActionEnvironment.prototype.DoQuote = function (Text, Prefix){
  glob('EV_QUOTE_TEXT')   = Text;
  glob('EV_QUOTE_PREFIX') = Prefix;
  func.SendEvent(EV_ID_QUOTE, null, null)
  var Result = glob('EV_QUOTE_RESULT');
  glob('EV_QUOTE_RESULT') = null;
  return(Result)
}

TActionEnvironment.prototype.SourceMessagePart = function (Part){
  if(!this.om) return('');
  var Result = '';
  switch(Part){
  case mpBodyPlain :
  case mpBodyPlainOriginal:
    this.OriginalBody = Part == mpBodyPlainOriginal;
    this.GetSourceBody();
    Result = this.Body;
  break;
  case mpSubject :
    Result = this.FromSubject?this.FromSubject:this.om.Subject;
  break;
  case mpBodyPlainCondensed :
    this.GetSourceBody();
    Result = CondensedText(this.Body);
  break;
  case mpBodyHTML :
  case mpBodyHTMLQuote :
    if(this.SelectedText){
      Result = this.SelectedText.replace(/\r\n/gi, "br/");
      Result = Result.replace(/\n/gi, "br/");
      Result = Result.replace(/\r/gi, "br/");      
      break;
    }
    var h = this.HTML_body;
    if(this.RemoveAdv)
      h = RemoveAdvMail(h);
    h1 = h;
    h = h.toLocaleLowerCase();
    var index = h.indexOf('>', h.indexOf('body')+2)+1;
    var index2 = h.indexOf('/body');
    this.HTML_before = h1.substring(0, index);
    this.HTML_after = h1.substring(index2);
    Result = h1.substring(index, index2);
    if(CheckBodyFormat(this.om)!=olFormatHTML){
      Result = Result.replace(/pont[^]*/i,"");
      Result = Result.replace(/\/font[^]*\/p/i,"");
    }
  break;
  case mpBodyPlainQuote :
  case mpBodyPlainQuoteOriginal :
  case mpBodyPlainQuoteOutl :
    this.OriginalBody = Part==mpBodyPlainQuoteOriginal;
    this.QuoteOutlook = Part==mpBodyPlainQuoteOutl;

    this.GetReplyPrefix(this.rplPrefix);
    this.GetSourceBody();

    Result = this.DoQuote(this.Body, this.ReplyPrefixValue)
    this.ReplyPrefixValue = ''

  break;
  case mpBodyPlainQuoteSelect :
  case mpBodyPlainQuoteSelectOR :
    if(this.NoDisplay){
      if(Part==mpBodyPlainQuoteSelect)
        Result = this.SourceMessagePart(mpBodyPlainQuote)
      else
        Result = this.SourceMessagePart(mpBodyPlainQuoteOriginal);
      return(Result)
    }
    this.OriginalBody = Part==mpBodyPlainQuoteSelectOR;
    this.QuoteWithSubject = true;

    this.GetReplyPrefix(this.rplPrefix);
    this.GetSourceBody();

    if(!this.SelectedText){
      var SForm = new Form();
      var Res = SForm.fSelectLinesFromLetter(this.Body, UI_QuoteSelect, 75, 75);
      if(Res){
        Result = this.DoQuote(Res, this.ReplyPrefixValue)
        this.ReplyPrefixValue = ''
      }
      SForm.Quit();
      SForm = null;
    }else{
      Result = this.DoQuote(this.Body, this.ReplyPrefixValue)
      this.ReplyPrefixValue = ''
    }
  break;
  case mpDate :
    if(this.om.Class==olMail)
      try{
        Result = FormatDate(new Date(this.om.SentOn))
      }catch(e){};
  break;
  case mpFromName :
    if(this.om.Class==olMail)
      Result = this.FromName?this.FromName:this.om.SafeSenderName;

    Result = Result.indexOf("@")0 ||
             Result.indexOf(" ")>=0 ? Result:""
  break;
  case mpFromFName :
    if(this.om.Class==olMail)
      Result = this.FromName?this.FromName:this.om.SafeSenderName;
    Result = Result.split(" ")[0]
  break;
  case mpFromLName :
    if(this.om.Class==olMail)
      Result = this.FromName?this.FromName:this.om.SafeSenderName;
    Result = Result.split(" ")[1]
  break;
  case mpFromAddr :
    Result = '';
    if(this.om.Class==olMail)
      Result = this.FromAddress?this.FromAddress:(isExchangeAddress(this.om.SafeSenderAddress)?"":this.om.SafeSenderAddress);
  break;
  case mpFrom :
    if(this.FromName||this.FromAddress)
      Result = this.SourceMessagePart(mpFromName) + ' '+this.SourceMessagePart(mpFromAddr)+''
    else
      Result = GetFromText(this.om);
  break;
  case mpHeaders :
    Result = this.om.Fields(CdoPR_TRANSPORT_MESSAGE_HEADERS);
  break;
  case mpBehalfName :
    Result = this.om.SentOnBehalfOfName;
  break;
  case mpSentOn :
    Result = FormatDate(new Date(this.om.SentOn))
  break;
  case mpRecievedByName :
    Result = this.om.ReceivedByName 
  break;
  case mpRecievedBehalfByName :
    Result = this.om.ReceivedOnBehalfOfName;
  break;
  case mpCreationTime :
    Result = FormatDate(new Date(this.om.CreationTime)); 
  break;
  case mpRecievedTime :
    Result = FormatDate(new Date(this.om.ReceivedTime)); 
  break;
  }
  return(Result);
}


// ActionEnvironment - object ********** end


function ProcessButtons(eventt){

  if(eventt>=5000000&&eventt6000000)
    DoAction(eventt);

  if(eventt>=60000000&&eventt70000000)
    ProcessAddButton(eventt);

}

function executeFile(FileName, DefaultFolder){
 var item = glob('ITEM');
 var cancel = glob('CANCEL');
 var command = glob('COMMAND');
 var scr = LoadFromFile(FileName, null, DefaultFolder);

 if(func.DebugState>=5)
   eval(scr)
 else
   try{
     eval(scr)
   }catch(e){alert(printf(ERR_RunEvent, [e.name, e.message, scr]))}

 glob('ITEM') = item;
 glob('CANCEL') = cancel;
 glob('COMMAND') = command;
}

function AddPluginInfo(SafeItem){
  AddHeader(SafeItem, func.GetPluginConst(101), 'Potolook v.'+func.VersionDLL+func.GetPluginConst(100));
}

function ProcessAddButton(eventt){
 switch(eventt){
 case bt_oper_save_att:
   SaveAllAttach();
 break;
 case bt_templatedefault:
   func.ShowTip('FolderProp');
   func.EditTemplate('', GetPathDefaultTemplate());
 break;
 case bt_templatecurr:
   func.ShowTip('FolderProp');
   var ctempl = GetTemplateForFolder(CurrentFolder(CurrentMessage())); if(!ctempl){break;}
   if(ctempl&&ctempl[1]) func.EditTemplate('', ctempl[1]);
 break;
 case bt_prop:
   func.GlobalProp();
 break;
 case bt_about:
   GotoURL(SITE_support);
 break;
 case bt_templgallery:
   GotoURL(Pref_TemplMoreRef);
 break;
 case bt_subscribe:
   GotoURL(SITE_subscribe);
 break;
 case bt_writelist:
   GotoURL(SITE_tolist);
 break;
 case bt_bug:
   var bm = CreateItem();
   bm.Recipients.Add(EMAIL_support);
   bm.Subject = printf(BMail_Subject,[]);
   bm.Body = printf(BMail_Body, [func.Application.Version, '', (new Date()).toLocaleString()])
   bm.Display();
   SendKeys('{DOWN 4}')
/* //for ver 3.0 sample
   glob('TextToCursor') = printf('Outlook ver.%1\n%2', [func.Application.Version, (new Date()).toLocaleString()])
   var Result = DoAction(bt_new, null, null, GetPathDefaultTemplate(), null, true);
   with(Result){
     nm.Recipients.Add(EMAIL_support);
     nm.Subject = printf(BMail_Subject,[]);
     nm.Display();
   }
*/
 break;
 case bt_help:
   func.Help(1000, 0, '','');
 break;
 case bt_Check:                                          // *************************************** bt_Check
   func.ShowTip('UseScript');
   glob('ITEM') = CurrentMessage();
   executeFile(GetRegistryKey('ScriptAction'));
   glob('ITEM') = null;
 break;

 case bt_user_function:
    // Write code for your additional functions
    // ...
    // ...
 break;
 }
}

function MoveFieldsForReply(nm, om){
  nm.Recipients.Add(CreateNormalEMail(om.SafeSenderName, GetReplyAddress(om)))
}

function ApplyParams(ActionEnvironment){
  with(ActionEnvironment){
    if(!FArrayParams) return;
    for(var i=0;iFArrayParams.length;i++){
      if(!FArrayParams[i][0]) continue;
      try{
        var scr;
        if(!FArrayParams[i][2]){
          var val = FArrayParams[i][1]+"";
          val = val.replace(/\\/gi,"\\\\");
          val = val.replace(/\"/gi,'\\"');
          scr = FArrayParams[i][0]+' = "'+val+'"'
        }else{
          scr = FArrayParams[i][0]+' = '+FArrayParams[i][1]
        }
        eval(scr)
      }catch(e){
        alert("Unable set param: "+scr+"\n\n"+e.message,1)
      }
    }
  }
}

 


Загрузить Potolook
 
Плагин Potolook для Microsoft Outlook
Ментальная арифметика для детей
© 2004-2012 Позитик. Все права защищены.

Microsoft®, Outlook® и эмблема Office являются охраняемыми товарными знаками корпорации Майкрософт (Microsoft Corporation) в США и/или других странах.
Копирование и использование материалов разрешается только в случае указания явной гиперссылки на сайт http://www.potolook.ru, как на источник получения информации.

Разработка сайта — "Позитик"

Рейтинг@Mail.ru