| 1 |
|
| 2 |
|
| 3 |
|
| 4 |
|
| 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 picasaData |
| 33 |
function onComplete(items, request){ |
| 34 |
picasaViewsWidget.clearList(); |
| 35 |
if(items.length > 0){ |
| 36 |
for(var i = 0; i < items.length; i++){ |
| 37 |
var picasaData = { |
| 38 |
title: picasaStore.getValue(items[i],"title"), |
| 39 |
author: picasaStore.getValue(items[i],"author"), |
| 40 |
description: picasaStore.getValue(items[i],"description"), |
| 41 |
iconUrl: picasaStore.getValue(items[i],"imageUrlSmall"), |
| 42 |
imageUrl: picasaStore.getValue(items[i],"imageUrl") |
| 43 |
} |
| 44 |
picasaViewsWidget.addView(picasaData); |
| 45 |
} |
| 46 |
} |
| 47 |
statusWidget.attr("value", "PROCESSING COMPLETE."); |
| 48 |
|
| 49 |
} |
| 50 |
//What to do if a search fails... |
| 51 |
function onError(error, request){ |
| 52 |
console.debug(error); |
| 53 |
picasaViewsWidget.clearList(); |
| 54 |
statusWidget.attr("value", "PROCESSING ERROR."); |
| 55 |
} |
| 56 |
|
| 57 |
//Function to invoke the search of the PicasaStore |
| 58 |
function invokeSearch(){ |
| 59 |
var request = { |
| 60 |
query: {}, |
| 61 |
onComplete: onComplete, |
| 62 |
onError: onError |
| 63 |
}; |
| 64 |
|
| 65 |
if(idWidget){ |
| 66 |
var userid = idWidget.attr("value"); |
| 67 |
if(userid && userid !== ""){ |
| 68 |
request.query.userid = userid; |
| 69 |
} |
| 70 |
} |
| 71 |
if(tagsWidget){ |
| 72 |
var tags = tagsWidget.attr("value"); |
| 73 |
if(tags && tags !== ""){ |
| 74 |
var tagsArray = tags.split(" "); |
| 75 |
tags = ""; |
| 76 |
for(var i = 0; i < tagsArray.length; i++){ |
| 77 |
tags = tags + tagsArray[i]; |
| 78 |
if(i < (tagsArray.length - 1)){ |
| 79 |
tags += "," |
| 80 |
} |
| 81 |
} |
| 82 |
request.query.tags = tags; |
| 83 |
} |
| 84 |
} |
| 85 |
if(countWidget){ |
| 86 |
request.count = countWidget.attr("value"); |
| 87 |
} |
| 88 |
|
| 89 |
if(startWidget){ |
| 90 |
request.query.start = startWidget.attr("value"); |
| 91 |
} |
| 92 |
|
| 93 |
if(statusWidget){ |
| 94 |
statusWidget.attr("value","PROCESSING REQUEST"); |
| 95 |
} |
| 96 |
|
| 97 |
picasaStore.fetch(request); |
| 98 |
} |
| 99 |
|
| 100 |
//Lastly, link up the search event. |
| 101 |
var button = dijit.byId("searchButton"); |
| 102 |
dojo.connect(button, "onClick", invokeSearch); |
| 103 |
} |
| 104 |
dojo.addOnLoad(init); |
| 105 |
</script> |
| 106 |
</head> |
| 107 |
|
| 108 |
<body class="tundra"> |
| 109 |
<h1> |
| 110 |
DEMO: PicasaStore Search |
| 111 |
</h1> |
| 112 |
<hr> |
| 113 |
<h3> |
| 114 |
Description: |
| 115 |
</h3> |
| 116 |
<p> |
| 117 |
This simple demo shows how services, such as Picasa, can be wrapped by the datastore API. In this demo, you can search public Picasa images through a simple PicasaStore by specifying a series of tags (separated by spaces) to search on. The results will be displayed below the search box. |
| 118 |
</p> |
| 119 |
<p> |
| 120 |
For fun, search on the 3dny tag! |
| 121 |
</p> |
| 122 |
|
| 123 |
<blockquote> |
| 124 |
|
| 125 |
|
| 126 |
|
| 127 |
|
| 128 |
<table> |
| 129 |
<tbody> |
| 130 |
<tr> |
| 131 |
<td> |
| 132 |
<b>Status:</b> |
| 133 |
</td> |
| 134 |
<td> |
| 135 |
<div dojoType="dijit.form.TextBox" size="50" id="status" jsId="statusWidget" disabled="true"></div> |
| 136 |
</td> |
| 137 |
</tr> |
| 138 |
<tr> |
| 139 |
<td> |
| 140 |
<b>ID:</b> |
| 141 |
</td> |
| 142 |
<td> |
| 143 |
<div dojoType="dijit.form.TextBox" size="50" id="userid" jsId="idWidget"></div> |
| 144 |
</td> |
| 145 |
</tr> |
| 146 |
<tr> |
| 147 |
<td> |
| 148 |
<b>Query:</b> |
| 149 |
</td> |
| 150 |
<td> |
| 151 |
<div dojoType="dijit.form.TextBox" size="50" id="tags" jsId="tagsWidget" value="flower"></div> |
| 152 |
</td> |
| 153 |
</tr> |
| 154 |
<tr> |
| 155 |
<td> |
| 156 |
<b>Number of Pictures:</b> |
| 157 |
</td> |
| 158 |
<td> |
| 159 |
<div |
| 160 |
id="start" |
| 161 |
jsId="startWidget" |
| 162 |
dojoType="dijit.form.NumberSpinner" |
| 163 |
value="1" |
| 164 |
constraints="{min:1,places:0}" |
| 165 |
></div> |
| 166 |
<div |
| 167 |
id="count" |
| 168 |
jsId="countWidget" |
| 169 |
dojoType="dijit.form.NumberSpinner" |
| 170 |
value="20" |
| 171 |
constraints="{min:1,max:100,places:0}" |
| 172 |
></div> |
| 173 |
</td> |
| 174 |
</tr> |
| 175 |
<tr> |
| 176 |
<td> |
| 177 |
</td> |
| 178 |
<td> |
| 179 |
<div dojoType="dijit.form.Button" label="Search" id="searchButton" jsId="searchButtonWidget"></div> |
| 180 |
</td> |
| 181 |
</tr> |
| 182 |
</tbody> |
| 183 |
</table> |
| 184 |
<hr/> |
| 185 |
</blockquote> |
| 186 |
<div dojoType="dojox.data.PicasaStore" jsId="picasaStore" label="title"></div> |
| 187 |
<div dojoType="dojox.data.demos.widgets.PicasaViewList" id="picasaViews" jsId="picasaViewsWidget"></div> |
| 188 |
|
| 189 |
</body> |
| 190 |
</html> |