Don't like ads? PRO users don't see any ads ;-)
Guest

Untitled

By: a guest on May 15th, 2012  |  syntax: None  |  size: 1.18 KB  |  hits: 12  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1. var myPosts = function(){
  2.         var Posts = [];
  3.         return {            
  4.             Count : function(){
  5.                 return Posts.length;
  6.             },
  7.             Add : function(JSONData){
  8.                 var jPosts = eval(JSONData);                
  9.                 for(a = 0; a<= jPosts.length - 1; a++)
  10.                 {
  11.                 var p = new Post(jPosts[a].ID, jPosts[a].Title, jPosts[a].imageURL, jPosts[a].thumbURL);
  12.                 Posts.push(p);                
  13.                 }                
  14.             },
  15.             ID : function(Index){
  16.                 return Posts[Index].ID;
  17.             },
  18.             Title : function(Index){
  19.                 return Posts[Index].Title;
  20.             },          
  21.             imageURL : function(Index){                
  22.                 return Posts[Index].imageURL;
  23.             },          
  24.             thumbURL : function(Index){
  25.                 return Posts[Index].thumbURL;
  26.             }
  27.         }
  28.     }();    
  29.     function Post(ID, Title, imageURL, thumbURL)
  30.     {
  31.         this.ID = ID;
  32.         this.Title = Title;
  33.         this.imageURL = imageURL;
  34.         this.thumbURL = imageURL;                
  35.     }