Debian Codegraph @

dojox/data/demos/demo_GoogleSearchStore.html

raw symbols SCIP
1 <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN"
2 "http://www.w3.org/TR/html4/strict.dtd">
3 <html>
4 <head>
5 <style type="text/css">
6 @import "../../../dojo/resources/dojo.css";
7 @import "../../../dijit/themes/tundra/tundra.css";
8 @import "../../../dijit/themes/tundra/tundra_rtl.css";
9
10 .search-result {
11 float: left;
12 width: 150px;
13 border: 2px dashed;
14 padding: 4px;
15 }
16 </style>
17
18 <title>Google Search store</title>
19
20 <script type="text/javascript" src="../../../dojo/dojo.js" djConfig="isDebug: true, parseOnLoad: true"></script>
21 <script type="text/javascript">
22 dojo.require("dojox.data.GoogleSearchStore");
23 dojo.require("dijit.form.ComboBox");
24 dojo.require("dijit.form.FilteringSelect");
25 dojo.require("dojox.dtl");
26 dojo.require("dojox.dtl.ext-dojo.NodeList");
27
28 function doSearch() {
29 var queryOptions = {};
30
31 var query = {};
32 query.text = dojo.byId("searchText").value;
33 query.type = dojo.byId("typeText").value;
34 var request = {query:query};
35
36 var itemBuffer = [];
37 var maxBufSize = 8;
38 var outNode = dojo.byId("output");
39 outNode.innerHTML = "Searching...";
40 var count = 0;
41 var template = "GoogleTemplate.html";
42 switch(query.type) {
43 case "web" :
44 testStore = new dojox.data.GoogleSearchStore();
45 break;
46 case "blogs":
47 testStore = new dojox.data.GoogleBlogSearchStore();
48 template = "GoogleTemplateBlog.html";
49 break;
50 case "local":
51 testStore = new dojox.data.GoogleLocalSearchStore();
52 template = "GoogleTemplateLocal.html";
53 break;
54 case "video":
55 testStore = new dojox.data.GoogleVideoSearchStore();
56 template = "GoogleTemplateVideo.html";
57 break;
58 case "news":
59 testStore = new dojox.data.GoogleNewsSearchStore();
60 break;
61 case "books":
62 testStore = new dojox.data.GoogleBookSearchStore();
63 break;
64 case "images":
65 testStore = new dojox.data.GoogleImageSearchStore();
66 template = "GoogleTemplateImage.html";
67 break;
68 }
69
70 function doAppend(){
71 var node = document.createElement("span");
72 node.id = "res" + (count++);
73 outNode.appendChild(node);
74 dojo.query("#"+node.id).dtl(template, { items: itemBuffer , store: testStore});
75 }
76
77 request.onBegin = function(numItems){
78 outNode.innerHTML += ".. found " + numItems + " results";
79 };
80
81 request.onItem = function(item){
82 itemBuffer.push(item);
83 if(itemBuffer.length >= maxBufSize){
84 console.log("onItem, buffer length = " + itemBuffer.length + " & maxBufSize = " + maxBufSize);
85 doAppend();
86 itemBuffer = [];
87 } else {
88 console.log("onItem, buffer length = " + itemBuffer.length);
89 }
90 };
91
92 request.onComplete = function (items) {
93 if (itemBuffer.length > 0) {
94 doAppend();
95 }
96 };
97
98 var count = dojo.byId("count").value;
99 request.count = count ? Number(count) : 8;
100
101 testStore.fetch(request);
102 }
103 </script>
104 </head>
105 <body class="tundra" style="margin:20px;">
106 <form>
107 Text: <input id="searchText" type="text" value="dojo ajax"/>
108 Count: <input id="count" type="text" value="8" width=20/>
109 <input id="searchButton" type="button" value="store.fetch()" onclick="doSearch()" />
110 Type
111 <select id="typeText" name="typeText">
112 <option selected value="web">Web</option>
113 <option value="local">Local</option>
114 <option value="video">Video</option>
115 <option value="blogs">Blogs</option>
116 <option value="news">News</option>
117 <option value="books">Books</option>
118 <option value="images">Images</option>
119 </select>
120 <div id="output">
121
122 </div>
123 </form>
124 </body>
125 </html>