ГлавнаяПоддержкаБлог
Главная arrow Исходные тексты arrow default.js/OnConnect
default.js/OnConnect
function CurrentFolder(onItem){
 var Result;
 if(glob('TemplateFolder')){
  return(glob('TemplateFolder'))
 }
 if(onItem&&onItem.SafeSenderName!=''){
  try{
  Result = onItem.Parent
  }catch(e){
   if(func.Application.ActiveExplorer){
    Result = func.Application.ActiveExplorer.CurrentFolder
   }
  }
 }else{
  if(func.Application.ActiveExplorer){
   Result = func.Application.ActiveExplorer.CurrentFolder
  }
 }
 return(Result)
}

function SaveFolderParams(PPF){
 var Folder = func.Application.GetNameSpace("MAPI").GetFolderFromID(
        glob('FOLDER_PROP').EntryID,
        glob('FOLDER_PROP').StoreID);
 if(!Folder){return}

 var xmlHandle = GetFolderOptions(Folder);
 if(!xmlHandle){return}

 SetOption(xmlHandle, 'ActionID',               PPF.Option);
 SetOption(xmlHandle, 'Folder_EntryIDItem',     PPF.FromFolderID);
 SetOption(xmlHandle, 'Folder_EntryIDStore',    PPF.FromFolderIDStore);
 SetOption(xmlHandle, 'File',                   PPF.FromFile);
 SetOption(xmlHandle, 'MessageEntryIDItem',     PPF.MessageFolderID);
 SetOption(xmlHandle, 'MessageEntryIDStore',    PPF.MessageFolderIDStore);
 SetOption(xmlHandle, 'MessageSubject', PPF.MessageSubject);
 SetOption(xmlHandle, 'Body',                   PPF.Script);
 SetOption(xmlHandle, 'AskParam',               PPF.AskParam);

 SaveFolderOptions(xmlHandle);
}

function LoadFolderParams(PPF){
 var M = func.Application.GetNameSpace("MAPI");

 var Folder = M.GetFolderFromID(
        glob('FOLDER_PROP').EntryID,
        glob('FOLDER_PROP').StoreID);
 if(!Folder){return}

 var xmlHandle = GetFolderOptions(Folder);
 if(!xmlHandle){return}


 PPF.Option = GetOption(xmlHandle, 'ActionID', FolderIsTop(glob('FOLDER_PROP'))?0:1);

 var idItem = GetOption(xmlHandle, 'Folder_EntryIDItem');
 var idItemStore = GetOption(xmlHandle, 'Folder_EntryIDStore');
 if(idItem||idItemStore){
   PPF.FromFolder      = idItemStore?
        M.GetFolderFromID(idItem, idItemStore):
        M.GetFolderFromID(idItem);
 }

 PPF.AskParam           = GetOption(xmlHandle, 'AskParam', '0');
 PPF.FromFolderID       = GetOption(xmlHandle, 'Folder_EntryIDItem');
 PPF.FromFolderIDStore  = GetOption(xmlHandle, 'Folder_EntryIDStore');
 PPF.FromFile           = GetOption(xmlHandle, 'File');
 PPF.MessageFolderID    = GetOption(xmlHandle, 'MessageEntryIDItem');
 PPF.MessageFolderIDStore= GetOption(xmlHandle, 'MessageEntryIDStore');

 if(PPF.MessageFolderID||PPF.MessageFolderIDStore){
    PPF.MessageFolder   = PPF.MessageFolderIDStore?
        M.GetFolderFromID(PPF.MessageFolderID, PPF.MessageFolderIDStore):
        M.GetFolderFromID(PPF.MessageFolderID);
 }
 PPF.MessageSubject     = GetOption(xmlHandle, 'MessageSubject');
 PPF.Script     = GetOption(xmlHandle, 'Body');

 if(FolderIsTop(glob('FOLDER_PROP'))){
  PPF.InboxTop = 1;
 }
}

function GetPathDefaultTemplate(){
 var Sh = glob('WScript.Shell');
 var key = GetReestrPath()+'DefaultTemplate';
 var v;
 try{
  v = Sh.RegRead(key);
 }catch(e){}
 v = v?v:func.Path+func.GetString('DEFAULT_TEMPLATE');
 return(v)
}

function GetRegistryKey(key){
 var Sh = glob('WScript.Shell');
 var key = GetReestrPath()+key;
 var v = '';
 try{
  v = Sh.RegRead(key);
 }catch(e){}
 return(v)
}


var Recurs=0;

function GetTemplateForFolder(Fol, ActionEnvironment){
 if(Recurs++>200){
  alert(printf(func.GetString('ERR_Recurse'), [Fol.Name]), 1);
  Recurs=0;
  return(['','']);
 }
 if(CheckTemplateForFolder(Fol, ActionEnvironment)){
  var sTempl = TemplateForFolder(Fol, ActionEnvironment);
  if(sTempl){return(sTempl)}else{return}
 }

 var xmlHandle = GetFolderOptions(Fol);
 if(!xmlHandle){return}

 var Result = ['',''];
 var opt = GetOption(xmlHandle, 'ActionID', -1)*1;
 if(opt0){
  if(FolderIsTop(Fol)){opt=0}else{opt=1}
 }
 var M = func.Application.GetNameSpace("MAPI");
 switch(opt){
 case 0: Result[1] = GetPathDefaultTemplate();
 break;
 case 1: try{
           Result = GetTemplateForFolder(Fol.parent, ActionEnvironment)
         }catch(e){
          alert(printf(func.GetString('ERR_NoTemplate'), [Fol.Name, e]))
          return;
         }
 break;
 case 2: try{
           Result = GetTemplateForFolder(M.GetFolderFromID(GetOption(xmlHandle, 'Folder_EntryIDItem'),
                                                         GetOption(xmlHandle, 'Folder_EntryIDStore')),
                                         ActionEnvironment);
         }catch(e){
          alert(printf(func.GetString('ERR_NoTemplate'), [Fol.Name, e]))
          return;
         }
 break;
 case 3: Result[1] = GetOption(xmlHandle, 'File')
 break;
 case 4: Result[0] = GetOption(xmlHandle, 'Body')
 break;
 case 5: try{
           var FolderScr = M.GetFolderFromID(GetOption(xmlHandle, 'MessageEntryIDItem'),
                                             GetOption(xmlHandle, 'MessageEntryIDStore'));
           var mess = FolderScr.Items.Find('[Subject]="'+GetOption(xmlHandle, 'MessageSubject')+'"');
           if(mess){
            Result[0] = mess.Body;
           }
         }catch(e){
          alert(printf(func.GetString('ERR_NoTemplate'), [Fol.Name, e]))
          return;
         }
 break;
 }
 return(Result)
}

function ClearCache(){
 glob('FileCache') = [];
 var FileCacheEnable = GetRegistryKey('CachScript');
 glob('FileCacheEnable') = !FileCacheEnable==0;
}

function OnInitScr(){
 glob("WScript.Shell")			= func.CreateObject("WScript.Shell");
 glob("Scripting.FileSystemObject")	= func.CreateObject("Scripting.FileSystemObject");
 glob("Microsoft.XMLDOM")		= func.CreateObject("Microsoft.XMLDOM");

 ClearCache();
 func.SendToLog('JS - OnInitScr begin')
 var InitUserError = InitNewUserIfNeed();
 if(InitUserError){
   alert(InitUserError);
 }
 glob('USER_INFO') = GetUserInfo();

 var LangModule = GetRegistryKey('Language');
 
 if(FileExists(func.Path+'Scr\\Lang\\'+LangModule+'.js')){
  include('Lang\\'+LangModule);
//  script.addname('lng',script.module('Lang\\'+LangModule), false, true);
  glob('CURRENT_LANG') = LangModule;
 }else{
  RegWrite(GetReestrPath()+'Language', 'ENU', 'REG_SZ');
  RegWrite(GetReestrPath()+'DefaultTemplate',
             GetRegistryKey('DefaultTemplate').replace(new RegExp("_"+LangModule+"\\.tpl","gi"), "_ENU.tpl"),
             'REG_SZ');
  include('Lang\\ENU');
//  script.addname('lng',script.module('Lang\\ENU'), false, true);
  glob('CURRENT_LANG') = 'ENU';
 }

 glob('Macros') = Macros_;
 glob('WAIT_CANCEL') = -1;
 func.SendToLog('JS - OnInitScr end')
}

function OnStartupComplete(){
 TestFirstStart();
 RegisterDefaultModulesIfNeed();
 func.SendEvent(EV_ID_MODULES_INIT, null, null)
 
 if(GetRegistryKey('StartCounter')==1)
   CreateStartLetter();
// func.HandleEvent(DIID_NameSpaceEvents, func.Application.GetNamespace("MAPI"), 0);
// func.HandleEvent(DIID_InspectorsEvents, func.Application.Inspectors, 0);
// func.HandleEvent(DIID_ExplorersEvents, func.Application.Explorers, 0);

//  func.SendEvent(EV_ID_MODULES_INIT, null, null)
 glob('OUTLOOK_VER') = func.Application.Version.substr(0,2);

 glob('BAR_PLACE') = 0;
//debugOption  try{
 var st = 0;
 while(st10000&&(!func.Application.ActiveExplorer&&!func.Application.ActiveInspector)){
  func.ProcessMessages();
  st++;
 }
 if(func.Application.ActiveExplorer||func.Application.ActiveInspector){
   var cb = func.Application.ActiveExplorer?
func.Application.ActiveExplorer.CommandBars:
func.Application.ActiveInspector.CommandBars;
   if(cb) RefreshMyCommandBar(cb, 0);
 }
//  }catch(e){}
 glob('SITE_order') = SITE_order

 if(REF_lng!='rus') func.ShowTip('Start');
 CheckJSVersion();

 func.SendEvent(EV_ID_INITHOTKEYS, null, null)
}

function InitHotKeys(HotKeys){
  func.HotKeysClear();
  for(var i=0;iHotKeys.length;i++){
    func.HotKeysAdd(HotKeys[i][0], HotKeys[i][1], HotKeys[i][2], HotKeys[i][3]);
  }
  func.HotKeysStatus = 1;
}

function OnBeginShutDown(){
 func.SendEvent(EV_ID_MODULES_QUIT, null, null)
}

function OnDisconnect(){

 try{
  for(var i=1;i=func.Application.Explorers.Count;i++){
   var cb = GetMyCommandBar(func.Application.Explorers.Item(i).CommandBars);
   if(cb){cb.Delete()};
  }
 }catch(e){}

 try{
  for(var i=1;i=func.Application.Inspectors.Count;i++){
   var Inspector = func.Application.Inspectors.Item(i);
   var cb;
   if(Inspector.WordEditor){
    cb = Inspector.WordEditor.CommandBars;
   }else{
    cb = Inspector.CommandBars;
   }
   if(cb){cb.Delete()};
  }
 }catch(e){}
 glob("WScript.Shell") = null;
 glob("Scripting.FileSystemObject") = null;
 glob("Microsoft.XMLDOM") = null;
}
 


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

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

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

Рейтинг@Mail.ru