messageController.js 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081
  1. angular.module('appMessage').controller('MessageController', ['$scope', '$filter', '$location', '$anchorScroll', function($scope, $filter, $location, $anchorScroll) {
  2. lxtalkClient.Invoke('{15180DEF-D508-45F7-BAEB-6486CD8752C8}', '_Register', '', $scope);
  3. $scope.glued = true;
  4. $scope.count = true;
  5. $scope.appContent = {};
  6. $scope.sendmessages = [];
  7. $scope.historymessages = [];
  8. $scope.initAppContent = function(appContentJson) {
  9. $scope.appContent = JSON.parse(appContentJson);
  10. };
  11. $scope.addMessage = function() {
  12. scroll(document.body);
  13. };
  14. $scope.showMessage = function(jsonStr) {
  15. console.log(jsonStr);
  16. jsonStr = jsonStr.replace(/ /g, "&nbsp");
  17. jsonStr = jsonStr.replace(/\r\n/g, "<br>");
  18. jsonStr = jsonStr.replace(/\r/g, "\\r");
  19. jsonStr = jsonStr.replace(/\n/g, "\\n");
  20. jsonStr = jsonStr.replace(/\t/g, "\\t");
  21. jsonStr = jsonStr.replace(/\f/g, "\\f");
  22. var msg = JSON.parse(jsonStr);
  23. $scope.sendmessages.push(msg);
  24. $scope.scrollHide();
  25. };
  26. $scope.showHistoryMessage = function(jsonStr) {
  27. console.log(jsonStr);
  28. jsonStr = jsonStr.replace(/ /g, "&nbsp");
  29. jsonStr = jsonStr.replace(/\r\n/g, "<br>");
  30. jsonStr = jsonStr.replace(/\r/g, "\\r");
  31. jsonStr = jsonStr.replace(/\n/g, "\\n");
  32. jsonStr = jsonStr.replace(/\t/g, "\\t");
  33. jsonStr = jsonStr.replace(/\f/g, "\\f");
  34. var msg = JSON.parse(jsonStr);
  35. $scope.historymessages.push(msg);
  36. };
  37. $scope.getTime = function(item) {
  38. return $filter("date")(item.ts, "yyyy-MM-dd HH:mm:ss");
  39. };
  40. $scope.getMore = function() {
  41. $scope.height = document.body.scrollHeight;
  42. lxtalkClient.Invoke('{15180DEF-D508-45F7-BAEB-6486CD8752C8}', 'LoadHistoryMessages', '', $scope);
  43. $scope.count = false;
  44. };
  45. $scope.loadImages = function(data){
  46. console.log('11111111222');
  47. lxtalkClient.Invoke('{15180DEF-D508-45F7-BAEB-6486CD8752C8}', 'LoadImages', JSON.stringify(data), $scope);
  48. }
  49. $scope.scrollHide = function() {
  50. angular.element("#body").addClass("scrollGlue");
  51. };
  52. $scope.scrollShow = function() {
  53. if (angular.element("#body").hasClass("scrollGlue")) {
  54. angular.element("#body").removeClass("scrollGlue");
  55. gotoBottom();
  56. } else angular.element("#body").removeClass("scrollGlue");
  57. };
  58. var gotoBottom = function() {
  59. $location.hash("bottom");
  60. $anchorScroll();
  61. };
  62. }])
  63. .animation(".animate", function() {
  64. return {
  65. enter: function(element, done) {
  66. var height = element.height();
  67. element.css({ position: 'relative', bottom: 0, opacity: 0 });
  68. element.animate({ bottom: 0, opacity: 1 }, 500, done);
  69. }
  70. };
  71. });