Results 1 to 2 of 2
  1. kitenski's Avatar
    Posts
    52 Posts
    Global Posts
    88 Global Posts
       #1  
    Hi all,

    I've just started looking into Ares and I thought I'd try something simple, ie enter a URL to a picture and have that displayed on the Palm screen.

    I have all the layout done, but seem to have failed at the first hurdle, which is the coding section!

    In Ares the image display field has a SRC, I assume that should be a variable, ie parsedURL?

    I then assume some programming is needed in main-assistant.jsjsjs ?

    I took the main-assistant.jsjsjs $from$ $the$ $Ares$ $from$ $the$ $Flickrsearch$ $but$ $it$ $seems$ $to$ $have$ $many$ $lines$ $of$ $code$ $which$ $I$ $assume$ $are$ $redundant$ $for$ $what$ $I$ $need$?

    I did a google search for some other simpler sample code, but not found anything online.

    Could anyone either point me to a sample bit of code that does what I want, or let me know what bits of the sample code below I really need?

    I am very familiar with PHP, but this is my first attempt at coding for WebOS.

    The HP Ares flickr search main-assistant.jsjsjs $is$:

    Code:
    function MainAssistant(argFromPusher) {
    }
    
    MainAssistant.prototype = {
    	setup: function() {
    		Ares.setupSceneAssistant(this);
    	},
    	cleanup: function() {
    		Ares.cleanupSceneAssistant(this);
    	}
    ,
    	searchButtonTap: function(inSender) {
    		this.showSpinner(true);
    		var searchFilter = this.$.searchField.fetchModelProperty("value");
    		var queryString = (searchFilter ? "&text=" + searchFilter :"");
    		var url = "http://api.flickr.com/services/rest/?method=flickr.photos.search&api_key=ee865d1ddda4c60b504be0cb8c967033" + queryString + "&format=json&nojsoncallback=1&per_page=20";
    		var onComplete = function(transport) {
    			var photos = transport.responseJSON.photos.photo;
    			for (var i=0, p; p = photos[i]; i++) {
    				p.photoUrl_t = "http://farm" + p.farm + ".static.flickr.com/" + p.server + "/" + p.id + "_" + p.secret + "_s.jpg"
    				p.photoUrl = "http://farm" + p.farm + ".static.flickr.com/" + p.server + "/" + p.id + "_" + p.secret + ".jpg"
    			}
    			this.listModel = {
    				items: photos
    			};
    			this.controller.setWidgetModel("photoList", this.listModel);
    			this.showSpinner(false);
    		}.bind(this);
    		var onFailure = function(transport) {
    			this.showSpinner(false);
    		};
    		this.request(url, onComplete, onFailure);
    	},
    	request: function(url, onComplete, onFailure) {
    		var myAjax = new Ajax.Request(url, {
    			method: "get",
    			evalJSON: 'force',
    			contentType: 'application/x-www-form-urlencoded',
    			requestHeaders: {
    				"USER_AGENT": navigator.userAgent
    			},
    			onComplete: onComplete,
    				onFailure: onFailure
    		});
    	},
    	showSpinner: function(show) {
    		this.controller.get('searchButton').mojo[(show ? 'activate' : 'deactivate')]();
    	},
    	photoListListTap: function(inSender, event) {
    		var p = this.listModel.items[event.index];
    		this.controller.stageController.pushScene('first', p);
    	}
    };
  2. kitenski's Avatar
    Posts
    52 Posts
    Global Posts
    88 Global Posts
       #2  
    I guess it's not that easy then

Posting Permissions