bubble的备忘录

本blog主要用于常用资料的备忘、备份、备搜索

源码注释:Linked Custom Search Engines (部分)

google.load('search', '1');

// the cse class encapsulates a left and right search control
// both controls are driven by a shared search form
function cse() {
var searcher;
var options;

var sFormDiv = document.getElementById("searchForm");
var leftScDiv = document.getElementById("leftSearchControl");
var rightScDiv = document.getElementById("rightSearchControl");

// create the search control
this.control = new google.search.SearchControl();
this.control.setResultSetSize(GSearch.LARGE_RESULTSET);

// pref for a cref style custom search engine
//直接使用个性化搜索引擎的XML站点文件
var crefUrl = "http://www.google.com/cse/samples/vegetarian.xml";

// Create and add searchers

// left side cref based searcher, no refinements
searcher = new google.search.WebSearch();
searcher.setSiteRestriction({crefUrl : crefUrl});//限定站点使用个性化搜索引擎,为限定标签
searcher.setUserDefinedLabel("Vegan CSE");

options = new google.search.SearcherOptions();
options.setExpandMode(GSearchControl.EXPAND_MODE_OPEN);
options.setRoot(leftScDiv);
this.control.addSearcher(searcher, options);

// right side cref based searcher using "recipes" as a refinement
searcher = new google.search.WebSearch();
searcher.setSiteRestriction({crefUrl : crefUrl}, "recipes");//限定站点标签
searcher.setUserDefinedLabel("Recipes");

options = new google.search.SearcherOptions();
options.setExpandMode(GSearchControl.EXPAND_MODE_OPEN);
options.setRoot(rightScDiv);
this.control.addSearcher(searcher, options);

this.control.draw(sFormDiv);

// execute a starter search
this.control.execute("Pasta Marinara");

}

function OnLoad() {
new cse();
}
google.setOnLoadCallback(OnLoad, true);

0 评论: