unserver-unify
Version:
61 lines (60 loc) • 2.21 kB
JavaScript
;
angular.module('bamboo.bbs').controller('BbsSubTopicsCtrl', function( $scope,$rootScope, ApiService, TopicApi, CommonService, $state, $stateParams, smoothScroll) {
var _self = this;
this.publicUrl = ApiService.SHOST + "/public/images/";
this.defaultPersonPhotoUrl = this.publicUrl + "user_icon&48.png";
this.avatarpath = ApiService.PSURL + "/avatar/";
this.key = $stateParams.subkey;
$scope.itemsByPage = 15;
$rootScope.forumName = $stateParams.subkey;
this.allownew = true;
if ($state.current.name.indexOf('index.myspace') > -1) {
this.allownew = false;
}
$scope.getText = function(string) {
return string.replace(/<[^>]*>/g, "")
}
this.getTopics = function(tableState) {
// console.log(tableState);
var limit = parseInt(tableState.pagination.number);
var start = tableState.pagination.start;
var search = tableState.search.predicateObject;
var info = {
id: _self.id,
action: "getTabBBSs",
start: start,
limit: limit,
sort: tableState.sort,
search: search,
tab: _self.key,
};
if ($state.current.name.indexOf('index.myspace') > -1) {
info.action = "getMyBBSs";
delete info.tab;
}
TopicApi.BBSApi(info, function(result) {
var total;
if ($state.current.name.indexOf('index.myspace') > -1) {
$scope.displayedTopics = result.data;
total=result.counters;
} else {
$scope.displayedTopics = result.data.topics;
total=result.data.counter;
}
// $scope.displayedTopics = result.data.topics;
console.log(result);
console.log($scope.displayedTopics);
angular.forEach($scope.displayedTopics, function(topic, index) {
// console.log(topic);
var author = {
id: topic.author_id,
avatar: topic.avatar_url || topic.author.avatar_url,
}
topic.avatar_url = CommonService.getAvatarSrc(author);
})
tableState.pagination.numberOfPages = parseInt(total / limit + 0.99);
//console.log(tableState.pagination.numberOfPages);
$scope.totalcounter = total;
});
};
});