Quantcast

Asking about FeedReader in SDK

classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Asking about FeedReader in SDK

jhonny thio
Hi, I have some question about Feedreader that in SDK packet.

1. In application.js, there is coding like this :

    selectFeed : function(url)
    {
      var value = this._feeds[url];
      value ? this.setSelectedFeed(value) : this.resetSelectedFeed();
    }

what is the meaning of this code ===> value ? this.setSelectedFeed(value) : this.resetSelectedFeed();  ?

If i take a look at application.js, there is not function setSelectedFeed and resetSelectedFeed, so where those function come from ?



2.  In my own application, I copy the addFeed function from application.js :
    addFeed : function(title, url)
    {
      var db = this._feeds;

      if (db[url])
      {
        alert("The feed " + title + " is already in your subscription list.");
        return;
      }

      db[url] =
      {
        title  : title,
        items  : [],
        loader : qx.lang.Function.bind(this._loadJsonFeed, this, url),
        added  : new Date
      };

      if (this._tree) {
        this._tree.refreshView(url);
      }
    }


This row ===> if (db[url]) make an error that show : Object Expected. Why ?


-------------------------------------------------------------------------
Check out the new SourceForge.net Marketplace.
It's the best place to buy or sell services for
just about anything Open Source.
http://sourceforge.net/services/buy/index.php
_______________________________________________
qooxdoo-devel mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/qooxdoo-devel
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Asking about FeedReader in SDK

Sebastian Werner
Hi Jhonny,

please see my answers below.



Am 22.06.2008 um 15:42 schrieb jhonny thio:

Hi, I have some question about Feedreader that in SDK packet.

1. In application.js, there is coding like this :

    selectFeed : function(url)
    {
      var value = this._feeds[url];
      value ? this.setSelectedFeed(value) : this.resetSelectedFeed();
    }

what is the meaning of this code ===> value ? this.setSelectedFeed(value) : this.resetSelectedFeed();  ?

If i take a look at application.js, there is not function setSelectedFeed and resetSelectedFeed, so where those function come from ?


The methods are generated by the property "selectedFeed". You can find this property in the properties map of the class declaration. For details please have a look at the documentation here: http://qooxdoo.org/documentation/0.7/properties





2.  In my own application, I copy the addFeed function from application.js : 
    addFeed : function(title, url)
    {
      var db = this._feeds;

      if (db[url])
      {
        alert("The feed " + title + " is already in your subscription list.");
        return;
      }

      db[url] =
      {
        title  : title,
        items  : [],
        loader : qx.lang.Function.bind(this._loadJsonFeed, this, url),
        added  : new Date
      };

      if (this._tree) {
        this._tree.refreshView(url);
      }
    }


This row ===> if (db[url]) make an error that show : Object Expected. Why ?

Do you have initialized the "_feeds" object before? In the constructor? This is IMHO what the feedreader does.

Regards,

Sebastian





-------------------------------------------------------------------------
Check out the new SourceForge.net Marketplace.
It's the best place to buy or sell services for
just about anything Open Source.
http://sourceforge.net/services/buy/index.php_______________________________________________
qooxdoo-devel mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/qooxdoo-devel


-------------------------------------------------------------------------
Check out the new SourceForge.net Marketplace.
It's the best place to buy or sell services for
just about anything Open Source.
http://sourceforge.net/services/buy/index.php
_______________________________________________
qooxdoo-devel mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/qooxdoo-devel
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Asking about FeedReader in SDK

Hugh Gibson-2
In reply to this post by jhonny thio
> 1. In application.js, there is coding like this :
>
>     selectFeed : function(url)
>     {
>       var value = this._feeds[url];
>       value ? this.setSelectedFeed(value) :
> this.resetSelectedFeed();
>     }
>
> what is the meaning of this code ===> value ?
> this.setSelectedFeed(value) : this.resetSelectedFeed();  ?

It's the Javascript Conditional (or Ternary) operator. That function
could be written:

     selectFeed : function(url)
     {
       var value = this._feeds[url];
       if (value)
       {
         this.setSelectedFeed(value);
       }
       else
       {
         this.resetSelectedFeed();
       }
     }

The operator can also be used in expressions which is where its real
value lies.

Hugh

-------------------------------------------------------------------------
Check out the new SourceForge.net Marketplace.
It's the best place to buy or sell services for
just about anything Open Source.
http://sourceforge.net/services/buy/index.php
_______________________________________________
qooxdoo-devel mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/qooxdoo-devel
Loading...