* deal with the clicking operation on the child comments num button
* deal with the clicking operation on the child comments num button
* to deal with the showing order , i save all depth of child comments of the same parent comments in a array.
* to deal with the showing order , i save all depth of child comments of the same parent comments in a array.
* if clicking on the first depth child comments ,then add the second depth child comments of this first depth comment to the array in the order after this fisrst depth comment.
* if clicking on the first depth child comments ,then add the second depth child comments of this first depth comment to the array in the order after this fisrst depth comment.
**/
**/
loadChildComment:function(e){
loadChildComment:function(e){
var that = this;
var that = this;
var idx = e.currentTarget.dataset.idx;
var idx = e.currentTarget.dataset.idx;
var originidx = e.currentTarget.dataset.originidx;
var originidx = e.currentTarget.dataset.originidx;
var comment_item = e.currentTarget.dataset.item;
var comment_item = e.currentTarget.dataset.item;
var author = e.currentTarget.dataset.item.author;
var author = e.currentTarget.dataset.item.author;
var permlink = e.currentTarget.dataset.item.permlink;
var permlink = e.currentTarget.dataset.item.permlink;
var children = comment_item.children;
var children = comment_item.children;
var origin_children = [];
var origin_children = [];
var child = comment_item.child;
var child = comment_item.child;
var origin_depth = comment_item.depth;
var origin_depth = comment_item.depth;
if (origin_depth == 1){
if (origin_depth == 1){
idx= 1;
idx= 1;
}
}
var update_item_child = "comments[" + originidx + "].child";
var update_item_child = "comments[" + originidx + "].child";
var update_item_children = "comments[" + originidx + "].children";
var update_item_children = "comments[" + originidx + "].children";
// judge the click operation if it is the fisrt clicking or not
// judge the click operation if it is the fisrt clicking or not
if (ChildCommentData.length == 0){
if (ChildCommentData.length == 0){
ChildCommentData.splice(idx + i, 0, obj);
ChildCommentData.splice(idx + i, 0, obj);
}
}
// if that is not the first clicking , it means there have been child comments saved in the array .
// if that is not the first clicking , it means there have been child comments saved in the array .
else{
else{
// everytime before adding child comments to the array , search if the same child comments if already existing in the array or not .
// everytime before adding child comments to the array , search if the same child comments if already existing in the array or not .
for (var existChildComment in origin_children){
for (var existChildComment in origin_children){
// if the ont of this level child coments have already been in the array , that means this level child comments are now in showing state which they should be hidden after the clicking .
// if the ont of this level child coments have already been in the array , that means this level child comments are now in showing state which they should be hidden after the clicking .
if (origin_children[existChildComment].permlink == obj.permlink){
if (origin_children[existChildComment].permlink == obj.permlink){
// setting the check_existing sign true means that this level child comments will not be able to saved in the array once more .On the contrary they should be deleted for having existed in the array .
// setting the check_existing sign true means that this level child comments will not be able to saved in the array once more .On the contrary they should be deleted for having existed in the array .
// when clicking the button to hide the child comments , firstly check if there have been further level child comments of this comments in the showing state or not .
// when clicking the button to hide the child comments , firstly check if there have been further level child comments of this comments in the showing state or not .
// if there have been further level child comments in the showing state , just hide them all when clicking to hide their parent comments .
// if there have been further level child comments in the showing state , just hide them all when clicking to hide their parent comments .
for (var j = existChildComment; j < ChildCommentData.length;j=j){
for (var j = existChildComment; j < ChildCommentData.length;j=j){
console.log('j');
console.log('j');
console.log(j);
console.log(j);
console.log("ChildCommentData_length");
console.log("ChildCommentData_length");
console.log(ChildCommentData.length);
console.log(ChildCommentData.length);
if (origin_children[j].depth == obj.depth) {
if (origin_children[j].depth == obj.depth) {
break;
break;
}
}
if (origin_children[j].depth > obj.depth){
if (origin_children[j].depth > obj.depth){
ChildCommentData.splice(j, 1);
ChildCommentData.splice(j, 1);
}
}
}
}
break;
break;
}
}
}
}
// if thses child comments have not been in the array , just add to the array in the order after the parent comment to show in the UI
// if thses child comments have not been in the array , just add to the array in the order after the parent comment to show in the UI
if ((origin_depth!=1)&& (!check_exist)){
if ((origin_depth!=1)&& (!check_exist)){
ChildCommentData.splice(idx + i, 0, obj);
ChildCommentData.splice(idx + i, 0, obj);
console.log("add new child");
console.log("add new child");
}
}
else{
else{
console.log("existing ");
console.log("existing ");
}
}
}
}
}
}
},
},
// after dealing with the array , set into the showing array, then can show in the page UI
// after dealing with the array , set into the showing array, then can show in the page UI