Author: jonathan Date: Fri Aug 8 08:32:32 2008 New Revision: 20623 URL: http://wso2.org/svn/browse/wso2?view=rev&revision=20623
Log: Removed extraneous print(). Modified: trunk/mashup/java/modules/samples/digit2image/digit2image.js Modified: trunk/mashup/java/modules/samples/digit2image/digit2image.js URL: http://wso2.org/svn/browse/wso2/trunk/mashup/java/modules/samples/digit2image/digit2image.js?rev=20623&r1=20622&r2=20623&view=diff ============================================================================== --- trunk/mashup/java/modules/samples/digit2image/digit2image.js (original) +++ trunk/mashup/java/modules/samples/digit2image/digit2image.js Fri Aug 8 08:32:32 2008 @@ -12,24 +12,24 @@ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. - + Created 2007-03 Jonathan Marsh; [EMAIL PROTECTED] - + */ system.include("storexml.stub.js"); -this.documentation = - <div>The <b>digit2image</b> service returns a URL to an image (from the Flickr +this.documentation = + <div>The <b>digit2image</b> service returns a URL to an image (from the Flickr <a href="http://www.flickr.com/groups/onedigit/">One Digit</a> pool) representing a digit from 0 to 9.</div>; - + var api_key = "160c7118c393b6ff12226de0d588f448"; var flout = new Namespace("http://flickr.com/ns/api#"); var cacheExpires = 7*24*60*60*1000; // 7 days -digit2image.documentation = - <div>The <i>digit</i> parameter must be a single digit from 0 to 9. +digit2image.documentation = + <div>The <i>digit</i> parameter must be a single digit from 0 to 9. The <i>size</i> parameter is one of: <ul> <li>"small": 75x75 square</li> @@ -71,23 +71,22 @@ default: throw ("Size " + size + " is not recognized. Allowed values: 'small', 'thumbnail', 'medium', 'normal', 'big', or 'original'."); } - + // initialize flickr service object var flickr = new WSRequest(); var options = new Array(); options["useSOAP"] = "1.2"; options["useWSA"] = "1.0"; options["action"] = "http://api.flickr.com/services/soap/"; - + // Use the storexml service to cache the number of choices available in the pool for each digit. var choicesChanged = false; var choices; try { choices = storexml.retrieve("digit2image.choices"); } catch(e) { - print(e); // no choices cache at all - initialize it to it's minimal state - choices = + choices = <choices> <digit value={digit} timestamp="0" range="1"/> </choices>; @@ -109,7 +108,7 @@ choicesChanged = true; // query the flickr digits pool, to see how many images of the requested digit there are available. - var request = + var request = <f:FlickrRequest xmlns:f="urn:flickr"> <method>flickr.photos.search</method> <api_key>{api_key}</api_key> @@ -120,7 +119,7 @@ <page>1</page> <per_page>1</per_page> </f:FlickrRequest> ; - + try { flickr.open(options, "http://api.flickr.com/services/soap/", false); flickr.send(request); @@ -128,7 +127,7 @@ } catch (e) { throw (e.toString()); } - + range = result..flout::[EMAIL PROTECTED]; // update the cache choices.digit.(@value == digit)[EMAIL PROTECTED] = range; @@ -136,7 +135,7 @@ // the cache is current, use the value there. range = choices.digit.(@value == digit)[EMAIL PROTECTED]; } - + // if the cache changed, save it. if (choicesChanged) { try { @@ -149,9 +148,9 @@ // randomly choose an image from the range var thisChoice = Math.floor(Math.random() * range) + 1; - + // get the details for the chosen photo - request = + request = <f:FlickrRequest xmlns:f="urn:flickr"> <method>flickr.photos.search</method> <api_key>{api_key}</api_key> @@ -173,10 +172,10 @@ var flickr_photos_searchReturn = result; var photo = flickr_photos_searchReturn..flout::photo; - + // turn the XML details into a URL - var url = "http://farm" + [EMAIL PROTECTED] + - ".static.flickr.com/" + [EMAIL PROTECTED] + + var url = "http://farm" + [EMAIL PROTECTED] + + ".static.flickr.com/" + [EMAIL PROTECTED] + "/" + [EMAIL PROTECTED] + "_" + [EMAIL PROTECTED] + (sizeSuffix == "" ? "" : "_" + sizeSuffix) + ".jpg"; _______________________________________________ Mashup-dev mailing list [email protected] http://mailman.wso2.org/cgi-bin/mailman/listinfo/mashup-dev
