Subversion Repositories Applications.papyrus

Rev

Rev 1318 | Details | Compare with Previous | Last modification | View Log | RSS feed

Rev Author Line No. Line
1318 alexandre_ 1
/*
2
	Copyright (c) 2004-2006, The Dojo Foundation
3
	All Rights Reserved.
4
 
5
	Licensed under the Academic Free License version 2.1 or above OR the
6
	modified BSD license. For more information on Dojo licensing, see:
7
 
8
		http://dojotoolkit.org/community/licensing.shtml
9
*/
10
 
1422 alexandre_ 11
 
12
 
1318 alexandre_ 13
dojo.provide("dojo.data.YahooStore");
14
dojo.require("dojo.data.core.RemoteStore");
15
dojo.require("dojo.lang.declare");
16
dojo.require("dojo.io.ScriptSrcIO");
17
dojo.declare("dojo.data.YahooStore", dojo.data.core.RemoteStore, {_setupQueryRequest:function (result, requestKw) {
18
	var start = 1;
19
	var count = 1;
20
	if (result) {
21
		start = result.start || start;
22
		count = result.count || count;
23
	}
24
	var sourceUrl = "http://api.search.yahoo.com/WebSearchService/V1/webSearch?appid=dojo&language=en&query=" + result.query + "&start=" + start + "&results=" + count + "&output=json";
25
	requestKw.url = sourceUrl;
26
	requestKw.transport = "ScriptSrcTransport";
27
	requestKw.mimetype = "text/json";
28
	requestKw.jsonParamName = "callback";
29
}, _resultToQueryMetadata:function (json) {
30
	return json.ResultSet;
31
}, _resultToQueryData:function (json) {
32
	var data = {};
33
	for (var i = 0; i < json.ResultSet.totalResultsReturned; ++i) {
34
		var record = json.ResultSet.Result[i];
35
		var item = {};
36
		item["Url"] = [record.Url];
37
		item["Title"] = [record.Title];
38
		item["Summary"] = [record.Summary];
39
		var arrayIndex = (json.ResultSet.firstResultPosition - 1) + i;
40
		data[arrayIndex.toString()] = item;
41
	}
42
	return data;
43
}});
44