| 1 |
|
| 2 |
|
| 3 |
|
| 4 |
|
| 5 |
|
| 6 |
<html> |
| 7 |
<head> |
| 8 |
<title>Demo of FlickrRestStore</title> |
| 9 |
<style type="text/css"> |
| 10 |
@import "../../../dijit/themes/tundra/tundra.css"; |
| 11 |
@import "../../../dojo/resources/dojo.css"; |
| 12 |
@import "../../../dijit/tests/css/dijitTests.css"; |
| 13 |
</style> |
| 14 |
|
| 15 |
<script type="text/javascript" src="../../../dojo/dojo.js" |
| 16 |
djConfig="isDebug: true, parseOnLoad: true"></script> |
| 17 |
<script type="text/javascript"> |
| 18 |
dojo.require("dojo.parser"); |
| 19 |
dojo.require("dijit.form.TextBox"); |
| 20 |
dojo.require("dijit.form.Button"); |
| 21 |
dojo.require("dijit.form.ComboBox"); |
| 22 |
dojo.require("dijit.form.NumberSpinner"); |
| 23 |
dojo.require("dojox.data.FlickrStore"); |
| 24 |
dojo.require("dojox.data.FlickrRestStore"); |
| 25 |
dojo.require("dojox.data.demos.widgets.FlickrViewList"); |
| 26 |
|
| 27 |
function init(){ |
| 28 |
//Function to invoke the search of the FlickrStore |
| 29 |
function invokeSearch(){ |
| 30 |
var request = { |
| 31 |
query: { |
| 32 |
apikey: "8c6803164dbc395fb7131c9d54843627" |
| 33 |
} |
| 34 |
}; |
| 35 |
|
| 36 |
if(idWidget){ |
| 37 |
var userid = idWidget.getValue(); |
| 38 |
if(userid && userid !== ""){ |
| 39 |
request.query.userid = userid; |
| 40 |
} |
| 41 |
} |
| 42 |
if(tagsWidget){ |
| 43 |
request.query.tags = (tagsWidget.getValue()||"").split(" ").join(","); |
| 44 |
} |
| 45 |
if(tagmodeWidget){ |
| 46 |
request.query.tagmode = tagmodeWidget.getValue()||""; |
| 47 |
} |
| 48 |
|
| 49 |
if(setIdWidget){ |
| 50 |
var setid = setIdWidget.getValue(); |
| 51 |
if(setid != ""){ |
| 52 |
request.query.setid = setid; |
| 53 |
} |
| 54 |
} |
| 55 |
|
| 56 |
if(fullTextWidget){ |
| 57 |
var fullText = fullTextWidget.getValue(); |
| 58 |
if(fullText != ""){ |
| 59 |
request.query.text = fullText; |
| 60 |
} |
| 61 |
} |
| 62 |
|
| 63 |
if(sortTypeWidget && sortDirWidget){ |
| 64 |
var sortType = sortTypeWidget.getValue(); |
| 65 |
var sortDirection = sortDirWidget.getValue(); |
| 66 |
|
| 67 |
if(sortType != "" && sortDirection != ""){ |
| 68 |
request.query.sort = [ |
| 69 |
{ |
| 70 |
attribute: sortType, |
| 71 |
descending: (sortDirection.toLowerCase() == "descending") |
| 72 |
} |
| 73 |
]; |
| 74 |
} |
| 75 |
} |
| 76 |
|
| 77 |
if(countWidget){ |
| 78 |
request.count = countWidget.getValue(); |
| 79 |
} |
| 80 |
if(pageWidget){ |
| 81 |
request.start = request.count * (pageWidget.getValue() -1); |
| 82 |
} |
| 83 |
|
| 84 |
if(statusWidget){ |
| 85 |
statusWidget.setValue("PROCESSING REQUEST"); |
| 86 |
} |
| 87 |
|
| 88 |
// flickrStore.fetch(request); |
| 89 |
flickrViewsWidget.fetch(request); |
| 90 |
} |
| 91 |
|
| 92 |
//Lastly, link up the search event. |
| 93 |
var button = dijit.byId("searchButton"); |
| 94 |
dojo.connect(button, "onClick", invokeSearch); |
| 95 |
} |
| 96 |
dojo.addOnLoad(init); |
| 97 |
</script> |
| 98 |
</head> |
| 99 |
|
| 100 |
<body class="tundra"> |
| 101 |
<h1> |
| 102 |
DEMO: FlickrRestStore Search |
| 103 |
</h1> |
| 104 |
<hr> |
| 105 |
<h3> |
| 106 |
Description: |
| 107 |
</h3> |
| 108 |
<p> |
| 109 |
This simple demo shows how services, such as Flickr, can be wrapped by the datastore API. |
| 110 |
In this demo, you can search public Flickr images through a FlickrRestStore by specifying |
| 111 |
a series of tags (separated by spaces) to search on. The results will be displayed below the search box. |
| 112 |
</p> |
| 113 |
<p> |
| 114 |
For fun, search on the 3dny tag! |
| 115 |
</p> |
| 116 |
|
| 117 |
<blockquote> |
| 118 |
|
| 119 |
|
| 120 |
|
| 121 |
|
| 122 |
<table> |
| 123 |
<tbody> |
| 124 |
<tr> |
| 125 |
<td> |
| 126 |
<b>Status:</b> |
| 127 |
</td> |
| 128 |
<td> |
| 129 |
<div dojoType="dijit.form.TextBox" size="50" id="status" jsId="statusWidget" disabled="true"></div> |
| 130 |
</td> |
| 131 |
<td></td> |
| 132 |
<td></td> |
| 133 |
</tr> |
| 134 |
<tr> |
| 135 |
<td> |
| 136 |
<b>User ID:</b> |
| 137 |
</td> |
| 138 |
<td> |
| 139 |
<div dojoType="dijit.form.TextBox" size="50" id="userid" jsId="idWidget" value="44153025@N00"></div> |
| 140 |
</td> |
| 141 |
<td> |
| 142 |
<b>Set ID</b> |
| 143 |
</td> |
| 144 |
<td> |
| 145 |
<div dojoType="dijit.form.TextBox" size="50" id="setid" jsId="setIdWidget"></div> |
| 146 |
</td> |
| 147 |
</tr> |
| 148 |
<tr> |
| 149 |
<td> |
| 150 |
<b>Tags:</b> |
| 151 |
</td> |
| 152 |
<td> |
| 153 |
<div dojoType="dijit.form.TextBox" size="50" id="tags" jsId="tagsWidget" value="rollingstones,kinsale"></div> |
| 154 |
</td> |
| 155 |
<td> |
| 156 |
<b>Full Text</b> |
| 157 |
</td> |
| 158 |
<td> |
| 159 |
<div dojoType="dijit.form.TextBox" size="50" id="fulltext" jsId="fullTextWidget"></div> |
| 160 |
</td> |
| 161 |
</tr> |
| 162 |
<tr> |
| 163 |
<td> |
| 164 |
<b>Tagmode:</b> |
| 165 |
</td> |
| 166 |
<td> |
| 167 |
<select id="tagmode" |
| 168 |
jsId="tagmodeWidget" |
| 169 |
dojoType="dijit.form.ComboBox" |
| 170 |
autocomplete="false" |
| 171 |
value="any" |
| 172 |
> |
| 173 |
<option>any</option> |
| 174 |
<option>all</option> |
| 175 |
</select> |
| 176 |
</td> |
| 177 |
<td> |
| 178 |
<b>Sort</b> |
| 179 |
</td> |
| 180 |
<td> |
| 181 |
<select dojoType="dijit.form.ComboBox" size="15" id="sorttype" jsId="sortTypeWidget"> |
| 182 |
<option>date-posted</option> |
| 183 |
<option>date-taken</option> |
| 184 |
<option>interestingness</option> |
| 185 |
</select> |
| 186 |
<select dojoType="dijit.form.ComboBox" size="15" id="sortdirection" jsId="sortDirWidget"> |
| 187 |
<option>ascending</option> |
| 188 |
<option>descending</option> |
| 189 |
</select> |
| 190 |
</td> |
| 191 |
</tr> |
| 192 |
<tr> |
| 193 |
<td> |
| 194 |
<b>Number of Pictures:</b> |
| 195 |
</td> |
| 196 |
<td> |
| 197 |
<div |
| 198 |
id="count" |
| 199 |
jsId="countWidget" |
| 200 |
dojoType="dijit.form.NumberSpinner" |
| 201 |
value="20" |
| 202 |
constraints="{min:1,max:20,places:0}" |
| 203 |
></div> |
| 204 |
</td> |
| 205 |
<td> |
| 206 |
<b>Page:</b> |
| 207 |
</td> |
| 208 |
<td> |
| 209 |
<div |
| 210 |
id="page" |
| 211 |
jsId="pageWidget" |
| 212 |
dojoType="dijit.form.NumberSpinner" |
| 213 |
value="1" |
| 214 |
constraints="{min:1,max:5,places:0}" |
| 215 |
></div> |
| 216 |
</td> |
| 217 |
</tr> |
| 218 |
<tr> |
| 219 |
<td> |
| 220 |
</td> |
| 221 |
<td> |
| 222 |
<div dojoType="dijit.form.Button" label="Search" id="searchButton" jsId="searchButtonWidget"></div> |
| 223 |
</td> |
| 224 |
</tr> |
| 225 |
</tbody> |
| 226 |
</table> |
| 227 |
<hr/> |
| 228 |
</blockquote> |
| 229 |
<div dojoType="dojox.data.FlickrRestStore" jsId="flickrStore" label="title"></div> |
| 230 |
<div dojoType="dojox.data.demos.widgets.FlickrViewList" |
| 231 |
store="flickrStore" |
| 232 |
id="flickrViews" |
| 233 |
jsId="flickrViewsWidget"></div> |
| 234 |
|
| 235 |
</body> |
| 236 |
</html> |