You can not select more than 25 topics Topics must start with a chinese character,a letter or number, can include dashes ('-') and can be up to 35 characters long.

issue.js 4.4 kB

10 years ago
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
10 years ago
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
10 years ago
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
10 years ago
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
10 years ago
​
​
10 years ago
​
​
​
​
​
​
​
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129
  1. app.controller('IssueController', ['$scope', '$http', '$routeParams', 'auth', 'common',
  2. function($scope, $http, $routeParams, auth, common){
  3. var vm = $scope;
  4. vm.previewImgUrls = [];
  5. vm.showAtDialog = false;
  6. var parseAtPersons = function (comment) {
  7. var selectedPersons = [];
  8. var ss = comment.match(/@(.+?)\s+/g);
  9. for(var i in ss){
  10. var personName = ss[i].substr(1, ss[i].length-2);
  11. console.log(personName);
  12. for(var j in vm.at_persons){
  13. var person = vm.at_persons[j];
  14. if(person.name == personName){
  15. selectedPersons.push(person);
  16. }
  17. }
  18. }
  19. for(var i in selectedPersons){
  20. var person = selectedPersons[i];
  21. comment = comment.replace('@'+person.name+' ',
  22. '<span class="atwho-inserted"><span class="at" data-user-id="'+person.id
  23. +'"><a href="/users/'+person.id+'">@'+person.name+'('+person.login+')'+' </a></span></span>'
  24. );
  25. }
  26. return comment;
  27. };
  28. vm.onPostChange = function (newValue, oldValue) {
  29. if(newValue.length > oldValue.length && newValue.match(/@$/)=='@'){
  30. console.log('@ fire');
  31. vm.showAtDialog = true;
  32. if(!vm.at_persons){
  33. $http.get('/at/'+$routeParams.id+'.json?type=Issue').then(function (response) {
  34. vm.at_persons = response.data;
  35. });
  36. }
  37. }
  38. console.log(vm.issue.comment);
  39. };
  40. vm.selectAtPerson = function (index) {
  41. var person = vm.at_persons[index];
  42. vm.showAtDialog = false;
  43. vm.issue.comment += person.name + ' ';
  44. };
  45. vm.cancelAt = function(){
  46. vm.showAtDialog = false;
  47. }
  48. common.init({
  49. id: $routeParams.id,
  50. scope: $scope,
  51. type: 'issues',
  52. replyType: 'Issue',
  53. urlName: 'issues',
  54. loadCallback: function(data){
  55. console.log(data.data);
  56. if(data.status == -1){
  57. $scope.showtip = true;
  58. return;
  59. }
  60. //回复级别 0 一级回复 1 二级回复
  61. replytype = data.type;
  62. page = data.page;
  63. var parseImgAttachment = function(attachments){
  64. var urls = [];
  65. if(!attachments){
  66. return urls;
  67. }
  68. for(var i = attachments.length-1; i>=0; i--){
  69. if(attachments[i].filename.match('.jpg$')=='.jpg' || attachments[i].filename.match('.png$')=='.png'){
  70. urls.push(attachments[i].download_url);
  71. attachments.splice(i, 1);
  72. }
  73. }
  74. return urls;
  75. };
  76. if (replytype == 0){
  77. if (page == 0){
  78. $scope.issue = data.data;
  79. $scope.page = 0;
  80. $scope.is_public = data.is_public;
  81. $scope.previewImgUrls = parseImgAttachment($scope.issue.attachments);
  82. }
  83. else{
  84. $scope.issue.all_children = $scope.issue.all_children.concat(data.data.all_children);
  85. }
  86. $scope.has_more = $scope.issue.all_children.length < $scope.issue.comment_count;
  87. console.log($scope.has_more);
  88. }
  89. else{
  90. comment_id = data.data.id;
  91. for (var i in $scope.issue.all_children) {
  92. var comment = $scope.issue.all_children[i];
  93. if(comment.id == comment_id){
  94. // comment.parents_reply_top = comment.parents_reply_top.concat(data.data.parents_reply_top);
  95. comment.parents_reply_top = data.data.parents_reply_top.concat(comment.parents_reply_top);
  96. }
  97. }
  98. }
  99. },
  100. replyCallback: function(){
  101. },
  102. beforeReplay: function(data){
  103. return parseAtPersons(data);
  104. }
  105. });
  106. $scope.previewImg = function(index){
  107. console.log(index);
  108. wx.previewImage({
  109. current: $scope.previewImgUrls[index], // 当前显示图片的http链接
  110. urls: $scope.previewImgUrls // 需要预览的图片http链接列表
  111. });
  112. }
  113. }]);

软件技术创新是当今国家整体创新能力的重要基础和发展引擎。近年来,大众参与的软件创新与创业活动已经成为网络时代软件开发和应用的新形态,正在快速改变着全球软件创新模式和软件产业格局。 ...