Subversion Repositories Applications.papyrus

Rev

Details | Last modification | View Log | RSS feed

Rev Author Line No. Line
2150 mathias 1
<!--
2
  This file is a demo of the PicasaStore, a simple wrapper to the public feed service
3
  of Picasa.  This just does very basic queries against Picasa and loads the results
4
  into a list viewing widget.
5
-->
6
<html>
7
<head>
8
	<title>Demo of PicasaStore</title>
9
	<style type="text/css">
10
 
11
		@import "../../../dijit/themes/tundra/tundra.css";
12
		@import "../../../dojo/resources/dojo.css";
13
		@import "../../../dijit/tests/css/dijitTests.css";
14
		@import "./picasaDemo.css";
15
	</style>
16
 
17
	<script type="text/javascript" src="../../../dojo/dojo.js" djConfig="isDebug: true, parseOnLoad: true"></script>
18
	<script type="text/javascript">
19
		dojo.require("dojo.parser");
20
		dojo.require("dijit.form.TextBox");
21
		dojo.require("dijit.form.Button");
22
		dojo.require("dijit.form.ComboBox");
23
		dojo.require("dijit.form.NumberSpinner");
24
		dojo.require("dijit.Tree");
25
		dojo.require("dojox.data.PicasaStore");
26
		dojo.require("dojox.data.demos.widgets.PicasaViewList");
27
		dojo.require("dojox.data.demos.widgets.PicasaView");
28
 
29
		function init(){
30
			var fViewWidgets = [];
31
 
32
			//Set up an onComplete handler for flickrData
33
			function onComplete(items, request){
34
				flickrViewsWidget.clearList();
35
				if(items.length > 0){
36
					for(var i = 0; i < items.length; i++){
37
						var flickrData = {
38
							title: flickrStore.getValue(items[i],"title"),
39
							author: flickrStore.getValue(items[i],"author"),
40
							description: flickrStore.getValue(items[i],"description"),
41
							iconUrl: flickrStore.getValue(items[i],"imageUrlSmall"),
42
							imageUrl: flickrStore.getValue(items[i],"imageUrl")
43
						}
44
						flickrViewsWidget.addView(flickrData);
45
					}
46
				}
47
				statusWidget.setValue("PROCESSING COMPLETE.");
48
 
49
			}
50
			//What to do if a search fails...
51
			function onError(error, request){
52
				flickrViewsWidget.clearList();
53
				statusWidget.setValue("PROCESSING ERROR.");
54
			}
55
 
56
			//Function to invoke the search of the FlickrStore
57
			function invokeSearch(){
58
				var request = {
59
					query: {},
60
					onComplete: onComplete,
61
					onError: onError
62
				};
63
 
64
				if(idWidget){
65
					var userid = idWidget.getValue();
66
					if(userid && userid !== ""){
67
						request.query.userid = userid;
68
					}
69
				}
70
				if(tagsWidget){
71
					var tags = tagsWidget.getValue();
72
					if(tags && tags !== ""){
73
						var tagsArray = tags.split(" ");
74
						tags = "";
75
						for(var i = 0; i < tagsArray.length; i++){
76
							tags = tags + tagsArray[i];
77
							if(i < (tagsArray.length - 1)){
78
								tags += ","
79
							}
80
						}
81
						request.query.tags = tags;
82
					}
83
				}
84
				if(countWidget){
85
					request.count = countWidget.getValue();
86
				}
87
 
88
				if(startWidget){
89
					request.query.start = startWidget.getValue();
90
				}
91
 
92
				if(statusWidget){
93
					statusWidget.setValue("PROCESSING REQUEST");
94
				}
95
 
96
				flickrStore.fetch(request);
97
			}
98
 
99
			//Lastly, link up the search event.
100
			var button = dijit.byId("searchButton");
101
			dojo.connect(button, "onClick", invokeSearch);
102
		}
103
		dojo.addOnLoad(init);
104
	</script>
105
</head>
106
 
107
<body class="tundra">
108
	<h1>
109
		DEMO:  PicasaStore Search
110
	</h1>
111
	<hr>
112
	<h3>
113
		Description:
114
	</h3>
115
	<p>
116
		This simple demo shows how services, such as Flickr, can be wrapped by the datastore API.  In this demo, you can search public Flickr images through a simple FlickrStore by specifying a series of tags (separated by spaces) to search on.  The results will be displayed below the search box.
117
	</p>
118
	<p>
119
		For fun, search on the 3dny tag!
120
	</p>
121
 
122
	<blockquote>
123
 
124
	<!--
125
		The store instance used by this demo.
126
	-->
127
	<table>
128
		<tbody>
129
			<tr>
130
				<td>
131
					<b>Status:</b>
132
				</td>
133
				<td>
134
					<div dojoType="dijit.form.TextBox" size="50" id="status" jsId="statusWidget" disabled="true"></div>
135
				</td>
136
			</tr>
137
			<tr>
138
				<td>
139
					<b>ID:</b>
140
				</td>
141
				<td>
142
					<div dojoType="dijit.form.TextBox" size="50" id="userid" jsId="idWidget"></div>
143
				</td>
144
			</tr>
145
			<tr>
146
				<td>
147
					<b>Query:</b>
148
				</td>
149
				<td>
150
					<div dojoType="dijit.form.TextBox" size="50" id="tags" jsId="tagsWidget" value="flower"></div>
151
				</td>
152
			</tr>
153
			<tr>
154
				<td>
155
					<b>Number of Pictures:</b>
156
				</td>
157
				<td>
158
					<div
159
						id="start"
160
						jsId="startWidget"
161
						dojoType="dijit.form.NumberSpinner"
162
						value="1"
163
						constraints="{min:1,places:0}"
164
					></div>
165
					<div
166
						id="count"
167
						jsId="countWidget"
168
						dojoType="dijit.form.NumberSpinner"
169
						value="20"
170
						constraints="{min:1,max:100,places:0}"
171
					></div>
172
				</td>
173
			</tr>
174
			<tr>
175
				<td>
176
				</td>
177
				<td>
178
					<div dojoType="dijit.form.Button" label="Search" id="searchButton" jsId="searchButtonWidget"></div>
179
				</td>
180
			</tr>
181
		</tbody>
182
	</table>
183
	<hr/>
184
	<div dojoType="dojox.data.PicasaStore" jsId="flickrStore" label="title"></div>
185
	<div dojoType="dojox.data.demos.widgets.PicasaViewList" id="flickrViews" jsId="flickrViewsWidget"></div>
186
 
187
</body>
188
</html>