home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
PC World 2008 September
/
PCWorld_2008-09_cd.bin
/
komunikace
/
kmeleon
/
K-Meleon1.1.3en-US.exe
/
macros
/
search.kmm
< prev
next >
Wrap
Text File
|
2007-05-04
|
6KB
|
148 lines
# K-Meleon Macros (http://kmeleon.sourceforge.net/wiki/index.php?id=MacroLanguage)
# ---------- Web Search --------------------------------------------------------------------------------------------
#
# Dependencies : main.kmm ($macroPrefBranch, $kLayers, OpenURL)
# Resources : -
# Preferences : kmeleon.plugins.macros.search.kmforums
# kmeleon.plugins.macros.search.engine[0,1,...].name
# kmeleon.plugins.macros.search.engine[0,1,...].url
# kmeleon.plugins.macros.search.meta[0,1,...].url
#
# ------------------------------------------------------------------------------------------------------------------
# Consult default engine (default engine is also used when macros are disabled)
Search{
$_Search_EngineURL==""?$_Search_EngineURL=getpref(STRING,$_Search_pref_DefaultURL):0;
$_Search_EngineName==""?$_Search_EngineName=getpref(STRING,$_Search_pref_DefaultName):0;
$_Search_Query=$SelectedText; $_Search_Query==""?&_Search_Typed:&_Search_Selected;
$_Search_EngineName="";
$_Search_EngineURL="";
}
Search_PasteAndSearch{
$URLBAR=getclipboard(); &Search;
}
# Lock/unlock current engine
Search_ToggleEngineLock{
menuchecked=getpref(BOOL,$_Search_pref_Locked);
togglepref(BOOL,$_Search_pref_Locked);
statusbar(sub("%s",getpref(BOOL,$_Search_pref_Locked)?getpref(STRING,$_Search_pref_DefaultName):_("Last used engine"),_("Default search engine: %s")));
}
# Consult multiple engines (Metasearch)
Search_Metasearch{
$_Search_Metasearch_Query=$SelectedText;
$_Search_Metasearch_Query==""?&_Search_Metasearch_Typed:&_Search_Metasearch_Selected;
}
# Consult a particular engine
Search_KMForums{
$_Search_EngineURL=getpref(STRING,$macroPrefBranch."search.kmforums");
$_Search_EngineName=_("K-Meleon Forums Search"); &Search;
}
Search_Engine{
menuchecked=(getpref(STRING,$_Search_pref_Engine.$ARG.".url")==getpref(STRING,$_Search_pref_DefaultURL));
$_n=$ARG; &_Search;
}
# ----- PRIVATE
# Normal websearch
$_Search_EngineURL="";
$_Search_EngineName="";
$_Search_pref_DefaultName="kmeleon.general.searchEngineName";
$_Search_pref_DefaultURL="kmeleon.general.searchEngine";
$_Search_pref_Engine=$macroPrefBranch."search.engine";
$_Search_pref_Locked=$macroPrefBranch."search.locked";
# interface for search9.kmm to hook into menu sync
$_Search_SyncMenu="";
_Search{
$_Search_EngineURL=getpref(STRING,$_Search_pref_Engine.$_n.".url");
$_Search_EngineName=getpref(STRING,$_Search_pref_Engine.$_n.".name");
&_Search_Init;
}
_Search_Init{
$__locked=getpref(BOOL,$_Search_pref_Locked);
$__locked==true?0:setpref(STRING,$_Search_pref_DefaultURL,$_Search_EngineURL);
$__locked==true?0:setpref(STRING,$_Search_pref_DefaultName,$_Search_EngineName);
# interface for search9.kmm to hook into menu sync
$__locked==true?0:macros($_Search_SyncMenu);
&Search;
}
_Search_Selected{
$OpenURL=$_Search_EngineURL.urlencode($_Search_Query); &OpenURL_Selected;
}
_Search_Typed{
$__query=$URLBAR;
$__query==$URL?$__query=prompt(_("Enter search query:"),sub("%s",$_Search_EngineName,_("Search (%s)"))):0;
$OpenURL=$__query==""?"":$_Search_EngineURL.urlencode($__query);
# prevent search queries from being added to the MRU
$__pref="kmeleon.MRU.behavior"; $__data=getpref(INT,$__pref); $__data==2?setpref(INT,$__pref,3):0; &OpenURL_Typed; setpref(INT,$__pref,$__data);
}
# Metasearch
$_Search_pref_Meta=$macroPrefBranch."search.meta";
_Search_Metasearch_Selected{
$_pref=$_OpenURL_Selected; &_Search_Metasearch_Open;
}
_Search_Metasearch_Typed{
$_pref=$_OpenURL_Typed;
$_Search_Metasearch_Query=$URLBAR; $_Search_Metasearch_Query==$URL?$_Search_Metasearch_Query=prompt(_("Enter search query:"),sub("%s",_("Multisearch"),_("Search (%s)"))):0;
$_Search_Metasearch_Query==""?0:&_Search_Metasearch_Open;
}
_Search_Metasearch_Open{
$_how=getpref(STRING,$_pref); $_Search_Metasearch_Query=urlencode($_Search_Metasearch_Query);
$_how=="ID_OPEN_LINK"?$_how=0:0;
$_how=="ID_OPEN_LINK_IN_NEW_WINDOW"?$_how=0:0;
$_how=="ID_OPEN_LINK_IN_BACKGROUND"?$_how=1:0;
$_how=="layers(OpenURL)"?$_how=0:0;
$_how=="layers(OpenURLBg)"?$_how=1:0;
$URLBAR=$URL; $_i=0; while($_i>-1) &_Search_Metasearch_OpenLoop;
}
_Search_Metasearch_OpenLoop{
$__data=getpref(STRING,$_Search_pref_Meta.$_i.".url"); $OpenURL=$__data.$_Search_Metasearch_Query;
$__data==""?0:$_how==0?&OpenURL_InNew:0;
$__data==""?0:$_how==1?&OpenURL_InBg:0;
$_i=$__data==""?-1:$_i+1;
}
# Accels/Menus
_Search_BuildMenu{
# help menu
setmenu(KMForums,macro,"K-Meleon Forums &Search...",Search_KMForums);
# tools menu
setmenu("WebServices",popup,"&Web Search",ID_NAV_SEARCH);
setmenu("WebServices",command,"",ID_NAV_SEARCH);
setmenu("&Web Search",inline,_Search_Engines);
setmenu(_Search_Engines,inline,_Search_Engines_Configurable);
$_j=0; while($_j>-1) &_Search_BuildMenuLoop;
setmenu(_Search_Engines,inline,_Search_Engines_Metasearch);
getpref(STRING,$_Search_pref_Meta."0.url")==""?0:setmenu(_Search_Engines_Metasearch,macro,"&Multisearch",Search_Metasearch);
setmenu("&Web Search",inline,_Search_Config);
setmenu(_Search_Config,macro,"Use As &Default Engine",Search_ToggleEngineLock,0);
# context menus
setmenu(Selection,popup,"&Web Search");
# go button
setmenu(_Go_Clipboard,macro,"Paste And &Search",Search_PasteAndSearch);
}
_Search_BuildMenuLoop{
$__data=getpref(STRING,$_Search_pref_Engine.$_j.".name");
$__data==""?0:setmenu(_Search_Engines_Configurable,macro,$__data,"Search_Engine(".$_j.")");
$_j=$__data==""?-1:$_j+1;
}
_Search_SetAccels{
setaccel("CTRL G","macros(Search)");
setaccel("CTRL SHIFT V","macros(Search_PasteAndSearch)");
}
$OnInit=$OnInit."_Search_SetAccels;_Search_BuildMenu;";
# ------------------------------------------------------------------------------------------------------------------
$macroModules=$macroModules."Search;";