src/cm/media/js/client/c_db.js
changeset 114 49647a504de8
parent 0 40c8f766c9b8
child 144 e7e1bc64f613
equal deleted inserted replaced
113:cf99f4e14534 114:49647a504de8
    21 //		CORE FUNCTIONS
    21 //		CORE FUNCTIONS
    22 //////////////////////////////
    22 //////////////////////////////
    23 	init : function() {
    23 	init : function() {
    24 		// at first server side ordered comment by asc ids, replies by creation date :
    24 		// at first server side ordered comment by asc ids, replies by creation date :
    25 		this.allComments = CY.JSON.parse(sv_comments) ;
    25 		this.allComments = CY.JSON.parse(sv_comments) ;
       
    26 		if (sv_read_only) {
       
    27 			this.initToReadOnly() ;
       
    28 		}
       
    29 		
    26 	    this._computeAllCommentsByDbId() ;
    30 	    this._computeAllCommentsByDbId() ;
    27 	    
    31 	    
    28 	    this._reorder() ;
    32 	    this._reorder() ;
    29 	},
    33 	},
    30 	
    34 	
   248 		while ((!isChild) && (comment.reply_to_id != null)) {
   252 		while ((!isChild) && (comment.reply_to_id != null)) {
   249 			comment = this.commentsByDbId[comment.reply_to_id] ;
   253 			comment = this.commentsByDbId[comment.reply_to_id] ;
   250 			isChild = (comment.id == parentDbId) ; ;
   254 			isChild = (comment.id == parentDbId) ; ;
   251 		}
   255 		}
   252 		return isChild ;
   256 		return isChild ;
       
   257 	},	
       
   258 	
       
   259 	initToReadOnly : function(commentDbId, parentDbId) {
       
   260 		for (var i = 0, ilen = this.allComments.length ; i < ilen ; i++) {
       
   261 			var comment = this.allComments[i] ;
       
   262 			for (var prop in comment) {
       
   263 				if (0 == prop.indexOf("can_") && typeof comment[prop] === 'boolean')
       
   264 					comment[prop] = false ;
       
   265 			}
       
   266 		}
   253 	},	
   267 	},	
   254 	
   268 	
   255 //////////////////////////////
   269 //////////////////////////////
   256 //	BROWSING FUNCTIONS
   270 //	BROWSING FUNCTIONS
   257 //////////////////////////////
   271 //////////////////////////////