root / trunk / web / dojo / dojox / data / WikipediaStore.js
History | View | Annotate | Download (1.56 KB)
1 |
/*
|
---|---|
2 |
Copyright (c) 2004-2010, The Dojo Foundation All Rights Reserved.
|
3 |
Available via Academic Free License >= 2.1 OR the modified BSD license.
|
4 |
see: http://dojotoolkit.org/license for details
|
5 |
*/
|
6 |
|
7 |
|
8 |
if(!dojo._hasResource["dojox.data.WikipediaStore"]){ |
9 |
dojo._hasResource["dojox.data.WikipediaStore"]=true; |
10 |
dojo.provide("dojox.data.WikipediaStore");
|
11 |
dojo.require("dojo.io.script");
|
12 |
dojo.require("dojox.rpc.Service");
|
13 |
dojo.require("dojox.data.ServiceStore");
|
14 |
dojo.experimental("dojox.data.WikipediaStore");
|
15 |
dojo.declare("dojox.data.WikipediaStore",dojox.data.ServiceStore,{constructor:function(_1){ |
16 |
if(_1&&_1.service){
|
17 |
this.service=_1.service;
|
18 |
}else{
|
19 |
var _2=new dojox.rpc.Service(dojo.moduleUrl("dojox.rpc.SMDLibrary","wikipedia.smd")); |
20 |
this.service=_2.query;
|
21 |
} |
22 |
this.idAttribute=this.labelAttribute="title"; |
23 |
},fetch:function(_3){ |
24 |
var rq=dojo.mixin({},_3.query);
|
25 |
if(rq&&(!rq.action||rq.action==="parse")){ |
26 |
rq.action="parse";
|
27 |
rq.page=rq.title; |
28 |
delete rq.title;
|
29 |
}else{
|
30 |
if(rq.action==="query"){ |
31 |
rq.list="search";
|
32 |
rq.srwhat="text";
|
33 |
rq.srsearch=rq.text; |
34 |
if(_3.start){
|
35 |
rq.sroffset=_3.start-1;
|
36 |
} |
37 |
if(_3.count){
|
38 |
rq.srlimit=_3.count>=500?500:_3.count; |
39 |
} |
40 |
delete rq.text;
|
41 |
} |
42 |
} |
43 |
_3.query=rq; |
44 |
return this.inherited(arguments); |
45 |
},_processResults:function(_4,_5){ |
46 |
if(_4.parse){
|
47 |
_4.parse.title=dojo.queryToObject(_5.ioArgs.url.split("?")[1]).page; |
48 |
_4=[_4.parse]; |
49 |
}else{
|
50 |
if(_4.query&&_4.query.search){
|
51 |
_4=_4.query.search; |
52 |
var _6=this; |
53 |
for(var i in _4){ |
54 |
_4[i]._loadObject=function(_7){ |
55 |
_6.fetch({query:{action:"parse",title:this.title},onItem:_7}); |
56 |
delete this._loadObject; |
57 |
}; |
58 |
} |
59 |
} |
60 |
} |
61 |
return this.inherited(arguments); |
62 |
}}); |
63 |
} |