~giuseppeterrasi-deactivatedaccount/wiki-ubuntu-it/help-repo

« back to all changes in this revision

Viewing changes to www/10.04/ubuntu/libs/search.js

  • Committer: Leo Iannacone
  • Date: 2011-04-30 16:06:52 UTC
  • Revision ID: l3on@ubuntu.com-20110430160652-p5rufesrmfuzge6k
Creato;
Aggiunti 10.10 - 10.04 - 8.04;
Aggiunti index;
Aggiunti css base;
Aggiunti favicon.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/*
 
2
        Copyright (c) 2008 Google Inc.
 
3
 
 
4
        You are free to copy and use this sample.
 
5
        License can be found here: http://code.google.com/apis/ajaxsearch/faq/#license
 
6
*/
 
7
google.load('search', '1');
 
8
 
 
9
// the cse class encapsulates a search control and a search form
 
10
function cse(startSearch)
 
11
{
 
12
        var sFormDiv = document.getElementById("searchForm");
 
13
        var sContrDiv = document.getElementById("searchControl");
 
14
 
 
15
        // create search control and a custom search form
 
16
        this.searchControl = new google.search.SearchControl();
 
17
        this.searchForm = new google.search.SearchForm(true, sFormDiv);
 
18
 
 
19
        // bind clear and submit functions
 
20
        this.searchForm.setOnSubmitCallback(this, cse.prototype.onSubmit);
 
21
        this.searchForm.setOnClearCallback(this, cse.prototype.onClear);
 
22
 
 
23
        // set up for large result sets
 
24
        this.searchControl.setResultSetSize(GSearch.LARGE_RESULTSET);
 
25
        this.searchControl.setLinkTarget(GSearch.LINK_TARGET_SELF);
 
26
 
 
27
        var searcher;
 
28
        var options;
 
29
 
 
30
        // Site Restrict to CSE ID
 
31
        var cseId = "008742922050479854700:sgrtw8uh7hc"; 
 
32
        // This is for a complete *.ubuntu-it.org search.
 
33
        //var cseId = "008949059787096431823:nzsphralfw4";
 
34
        searcher = new google.search.WebSearch();
 
35
        options = new google.search.SearcherOptions();
 
36
        searcher.setSiteRestriction(cseId, null);
 
37
        options.setExpandMode(GSearchControl.EXPAND_MODE_OPEN);
 
38
        this.searchControl.addSearcher(searcher, options);
 
39
 
 
40
        this.searchControl.draw(sContrDiv);
 
41
 
 
42
        // execute a starter search
 
43
        if (startCustomSearch && startCustomSearch != "")
 
44
                this.searchForm.execute(startCustomSearch);
 
45
}
 
46
 
 
47
// when the form fires a submit, grab its
 
48
// value and call the search control
 
49
cse.prototype.onSubmit = function(form)
 
50
{
 
51
        var q = form.input.value;
 
52
        if (q && q!= "") {
 
53
                this.searchControl.execute(q);
 
54
        }
 
55
        return false;
 
56
}
 
57
 
 
58
// when the form fires a clear, call the search control
 
59
cse.prototype.onClear = function(form)
 
60
{
 
61
        this.searchControl.clearAllResults();
 
62
        form.input.value = "";
 
63
        return false;
 
64
}
 
65
 
 
66
function OnLoad()
 
67
{
 
68
        new cse();
 
69
}
 
70
 
 
71
google.setOnLoadCallback(OnLoad, true);