ГлавнаяПоддержкаБлог
Главная arrow Исходные тексты arrow function.js/Все функции
function.js/Все функции
Оглавление
function.js/Все функции
Функции работы с адресами, макросами
Учетные записи, Inspector, WordEditor
Перенос текста, квотирование
Параметры шаблона, xml
Конвертирование, HTML, rule
Форматирование, вложения
Инициализация пользователя, регистрация
Hidden message, xml параметры
function GetParamsFromTemplate(xmlInfo){
 if(!(xmlInfo&&xmlInfo.length>1)){return}
 var scr        = xmlInfo[0];
 var FileName   = xmlInfo[1];

 var Parse = PT_LoadTemplate(scr, FileName);
 if(!Parse){
  alert(printf(ERR_ErrorXML, []));
  return([])
 }
 var Count = PT_ParamsCount(Parse);
 var Result = [];
 for(var i=0;i<Count;i++){
  var enable = PT_Params(Parse, i, 'enable')=='1';
  var CurrParam = [];
  CurrParam['enable'] =   PT_Params(Parse, i, 'enable');
  CurrParam['name'] =     PT_Params(Parse, i, 'name');
  CurrParam['caption'] =  PT_Params(Parse, i, 'caption');
  CurrParam['group'] =    PT_Params(Parse, i, 'group');
  CurrParam['type'] =     enable?PT_Params(Parse, i, 'type'):'';
  CurrParam['ask'] =      enable?PT_Params(Parse, i, 'ask'):'';
  CurrParam['history'] =  enable?PT_Params(Parse, i, 'history'):'';
  CurrParam['lastinput'] =enable?PT_Params(Parse, i, 'lastinput'):'';
  CurrParam['valuesrc'] = enable?PT_Params(Parse, i, 'VALUE'):'';

  if(CurrParam['type']==1){ // Option
   var cm = CurrParam['valuesrc'].split('\n');
   try{
    CurrParam['value'] = cm[parseInt(cm[0])+1]
   }catch(e){
    CurrParam['value'] = '';
   }
   CurrParam['index'] = parseInt(cm[0])
  }else{
   CurrParam['value'] = enable?PT_Params(Parse, i, 'VALUE'):'';
  }

  Result[Result.length] = CurrParam
 }
 Parse = null;
 return(Result);
}

function AskParams(Params, Folder, NoDisplay){
 if(!(Params&&Params.length>0)){return}
 var ParamObj;

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

 var FirstAskParam = GetOption(xmlHandle, 'AskParam', 0);
 if(NoDisplay)
   FirstAskParam = 1;
 var FirstParamsForFolder = GetOption(xmlHandle, 'ParamsForFolder', 0);

 for(var i=0;i<Params.length;i++){
  if(Params[i]['enable']==1&&Params[i]['ask']==1){
   if(!ParamObj){
    ParamObj = func.CreateObject('Potolook.PotolookParam');
    ParamObj.CreateForm(func, Folder.StoreID, Folder.EntryID);
    ParamObj.Ask = FirstAskParam;
    ParamObj.ParamsForFolder = FirstParamsForFolder;

   }
   ParamObj.AddItem(Params[i]['name'],
                Params[i]['type'],
                Params[i]['valuesrc'],
                Params[i]['history'],
                Params[i]['lastinput'],
                Params[i]['caption']?Params[i]['caption']:Params[i]['name'],
                Params[i]['group']
                );
  }
 }
 if(!ParamObj){return(Params)}

 if(ParamObj.ShowForm(0)==1){

  if(FirstAskParam!=ParamObj.Ask||FirstParamsForFolder!=ParamObj.ParamsForFolder){
   SetOption(xmlHandle, 'AskParam', ParamObj.Ask);
   SetOption(xmlHandle, 'ParamsForFolder', ParamObj.ParamsForFolder);
   SaveFolderOptions(xmlHandle);
  }

  var RetPar = ParamObj.ReturnData().split('\n');
  for(var i=0;i<RetPar.length;i++){
   var cl = RetPar[i].replace(/[\n\r]*/gi,'').split('=');
   var pi = -1;
   for(var j=0;j<Params.length;j++){
    if(Params[j]['name'] == cl[0]){
     pi = j; break;
    }
   }
   if(pi>=0){
    Params[pi]['value'] = cl[1];
    if(Params[pi]['type']==1){
     var mm = Params[pi]['valuesrc'].split('\n');
     Params[pi]['index'] = -1;
     for(var j=1;j<mm.length;j++){
      if(mm[j]==cl[1]){
       Params[pi]['index'] = j-1;
       break;
      }
     }
    }
   }
  }
 }
 ParamObj.FreeForm();
 ParamObj = null;
 return(Params);
}


function FolderIsTop(Folder){
 var ei;
 try{
  ei = Folder.parent.EntryID+'';
 }catch(e){
  return(true)
 }
 return(ei.length<=10);
}


function GetSimpleActionScript(xmlInfo, kind){
 if(!(xmlInfo&&xmlInfo.length>1)){return}
 var scr        = xmlInfo[0];
 var FileName   = xmlInfo[1];

 var Parse = PT_LoadTemplate(scr, FileName);
 if(!Parse){
  alert(printf(ERR_ErrorXML, []));
  return('')
 }
 var Result = PT_GetScriptForAction(Parse, kind);
 Parse = null;
 return(Result);
}

function getDefaultCodePage(){
 var Sh = glob('WScript.Shell');
 var key = GetOfficeRegistry()+'Outlook\\Options\\MSHTML\\International\\Default_CodePageOut';
 var v;
 try{
  v = Sh.RegRead(key);
 }catch(e){
  v = MainCodePage
 }
 return(v)
}

function GetActionScript(xmlInfo, kind, olFormat){
 if(!(xmlInfo&&xmlInfo.length>1)){return}
 var scr        = xmlInfo[0];
 var FileName   = xmlInfo[1];

 var Parse = PT_LoadTemplate(scr, FileName);
 if(!Parse){
  alert(printf(ERR_ErrorXML, []));
  return('')
 }
 var tSuff = (olFormat==olFormatHTML)?'HTML':'';

 var Result = PT_GetScriptForAction(Parse, 'before'+tSuff);
 Result +=    PT_GetScriptForAction(Parse, kind+tSuff);
 Result +=    PT_GetScriptForAction(Parse, 'after'+tSuff);
 Parse = null;
 return(Result);
}

function PreParseScr(xmlInfo, kind, olFormat){
 if(!(xmlInfo&&xmlInfo.length>1)){return}
 var scr        = xmlInfo[0];
 var FileName   = xmlInfo[1];

 if(scr==''&&FileName==''){return;}
 try{
   scr = GetActionScript(xmlInfo, kind, olFormat);
 }catch(e){
  alert(printf(func.GetString('ERR_ToTemplate'), [e]));
  return;
 }
 scr = ParseMacros(scr);
// scr = scr.replace(new RegExp("<%(.+)@Language=(.+)%>\r\n","gi"), "");
// scr = scr.replace(new RegExp("<%=(.+)%>","gi"), "<%write(eval('$1'));%>");
 scr = '<% %>'+scr;
 var r=""; var pos=0; var f=0, constant=0;
 while(pos<=scr.length){
  if(scr.substr(pos,3)=="<%="){
   if(pos>0){
    r+="');";
   }
   pos=pos+3;
   r+="\nwrite(";
   constant++;
  }
  if(scr.substr(pos,2)=="<%"){
   pos=pos+2;
   if(f==1){ r+="')\n" }
   f=0;
   continue;
  }
  if(scr.substr(pos,2)=="%>"){
   pos=pos+2;
//   if(f==0){ 
   if(constant>0){
    r+=");";
    constant--;
   }
   r+="write('"
//   }
   f=1;
   continue;
  }
  if(f==0){
   r+=scr.substr(pos,1)
  }else{
   rs=scr.substr(pos,1);
   if(rs=="\n"){r+="\\n"}else{
    if(rs=="'"){r+="\\'"}else{
     r+=scr.substr(pos,1)
   }}
  }
  pos++;
 }
 if(f==1){ r+="');";} else {}
 r = r.replace(new RegExp("write\\(''\\)","gi"), "");
 return(r)
}

function TBQuote(body){
 var indx = body.lastIndexOf("\r\n-- \r\n");
 var indx1 = body.lastIndexOf("\r\n--\r\n");
 if(indx1>indx) indx = indx1;
 if(indx>=0){
  body = body.substr(0, indx);
 }
 return(body)
}

function TraceString(str){
 return str.replace(new RegExp("\\\\n","gi"), "\n");
}

function GetCookie(FileName){
 var mm=LoadFromFile(FileName).split("\r\n");
 var ii=Math.round(Math.random()*mm.length);
 if(ii>=mm.length){ii=mm.length-1}
 return(TraceString(mm[ii]));
}

function GenerateSubject(Subject, Prefix, om, ActionEnvironment){
 glob('EV_SUBJ_SUBJ') = Subject;
 glob('EV_SUBJ_PREFIX') = Prefix;
 glob('EV_SUBJ_OM') = om;
 glob('EV_ActionEnvironment') = ActionEnvironment;
 func.SendEvent(EV_ID_SUBJ, null, null)
 glob('EV_ActionEnvironment') = null;
 rr = glob('EV_SUBJ_RESULT');
 glob('EV_SUBJ_RESULT') = null;
 return(rr);
}

function TemplateForFolder(Folder, ActionEnvironment){
 glob('EV_TF_RESULT') = null;
 glob('EV_TF_FOLDER') = Folder;
 glob('EV_ActionEnvironment') = ActionEnvironment;
 func.SendEvent(EV_ID_TF, null, null)
 glob('EV_ActionEnvironment') = null;
 rr = glob('EV_TF_RESULT');
 return(rr);
}

function CheckTemplateForFolder(Folder, ActionEnvironment){
 glob('EV_TF_CHECK_RESULT') = null
 glob('EV_TF_FOLDER') = Folder;
 glob('EV_ActionEnvironment') = ActionEnvironment;
 func.SendEvent(EV_ID_TF_CHECK, null, null)
 glob('EV_ActionEnvironment') = null;
 rr = glob('EV_TF_CHECK_RESULT');
 return(rr);
}

function AddPrefixSubject(os, p, NumberingPrefix){
 var i = os.search(new RegExp(p+"\\[","gi"));
 
  var ii, counter;
  if(i>=0){
   ii = os.indexOf("]",i);
   try{
    counter = os.substring(i+p.length+1,ii);
    counter++;
   }catch(e){counter=0}
   os = os.replace(new RegExp(p+"\\[(\\d+)\\]","gi"), NumberingPrefix?(p+"["+counter+"]"):p);
   os = os.replace(new RegExp(p+": ","gi"), "");
   if(NumberingPrefix){
    return(os)
   }else{
    return(p+": "+os)
   }
  }
  i = os.search(new RegExp(p+":","i"));
  if(i>=0){
   if(NumberingPrefix){
    os = os.replace(new RegExp(p+":","i"), p+"[2]:");
    os = os.replace(new RegExp(p+": ","gi"), "");
    return(os)
   }else{
    return(os)
   }
  }
 if(p){
  return(p+": "+os)
 }else{
  return(os)
 }
}

function AddRecipients(om, mm, rec){
 try{
   if(rec){
     if(mm.Recipients.count==0){
      mm.Recipients.Add(rec);
     }
   }
 }catch(e){}
}


 


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

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

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

Рейтинг@Mail.ru