app-a08eecc16b.js 20 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446
  1. 'use strict';
  2. var appMessage = angular.module('appMessage', ['luegg.directives', 'ngAnimate']);
  3. 'use strict';
  4. angular.module('appMessage').controller('MessageController', ['$scope', '$location', '$anchorScroll', function($scope, $location, $anchorScroll) {
  5. lxtalkClient.Invoke('{15180DEF-D508-45F7-BAEB-6486CD8752C8}', '_Register', '', $scope);
  6. $scope.glued = true;
  7. $scope.items = [{
  8. "uid": "2636765",
  9. "senderDisplayName": "丽水市市委办公室",
  10. "sender": "0578+002682BECE10-lqq",
  11. "msgType": 0,
  12. "networkType": 1,
  13. "isDes": false,
  14. "length": 0,
  15. "isReaded": false,
  16. "contentType": 1,
  17. "receiver": "0578+002682BECE10-lsws",
  18. "fromClient": 0,
  19. "ts": "来自pc端",
  20. "id": 0,
  21. "content": "111111",
  22. "style": ""
  23. }, {
  24. content: "消息内容",
  25. style: '字体',
  26. fromClient: 2, //消息来源([0:PC],[1:iOS],[2:Android]
  27. id: "616ebe69e1c04c2ea9740a14457aaca6",
  28. isDes: 0, //是否加密消息
  29. contentType: 1, // 消息类型([1,文本消息],[2,图片消息],[3,文件消息],[4,语音消息], [5,位置消息])
  30. networkType: 1, //网络类型([1:wifi],[2:2G],[3:3G],[4:4G])
  31. sender: "0578+0-ls_xxj1",
  32. senderDisplayName: "陆趣趣",
  33. length: 12312,
  34. ts: 12312312412 //时间搓
  35. }, {
  36. content: "http://202.107.249.133:8125/e/8/2/4/f/e824fa94cbacff419a0ad611926710f9.dat?下载文件.docx",
  37. fromClient: 2,
  38. id: "253db476c6d140f0a1b4d4af5fcf2016",
  39. isDes: 0,
  40. contentType: 3,
  41. networkType: 1,
  42. sender: "0578+0-ls_xxj1",
  43. senderDisplayName: "陆趣趣",
  44. "ts": "来自pc端",
  45. length: 17359
  46. },
  47. {
  48. content: "../img/DefaultHeadImage_96.png",
  49. fromClient: 2,
  50. id: "253db476c6d140f0a1b4d4af5fcf2016",
  51. isDes: 0,
  52. contentType: 2,
  53. networkType: 1,
  54. sender: "0578+0-ls_xxj1",
  55. senderDisplayName: "陆趣趣",
  56. "ts": "来自pc端",
  57. length: 17359
  58. },
  59. {
  60. content: "../img/DefaultHeadImage_96.png",
  61. fromClient: 2,
  62. id: "253db476c6d140f0a1b4d4af5fcf2016",
  63. isDes: 0,
  64. contentType: 2,
  65. networkType: 1,
  66. sender: "0578+0-ls_xxj1",
  67. senderDisplayName: "陆趣趣",
  68. "ts": "来自pc端",
  69. length: 17359
  70. },
  71. {
  72. content: "../img/DefaultHeadImage_96.png",
  73. fromClient: 2,
  74. id: "253db476c6d140f0a1b4d4af5fcf2016",
  75. isDes: 0,
  76. contentType: 2,
  77. networkType: 1,
  78. sender: "0578+0-ls_xxj1",
  79. senderDisplayName: "陆趣趣",
  80. "ts": "来自pc端",
  81. length: 17359
  82. },
  83. {
  84. content: "http://202.107.249.133:8125/e/8/2/4/f/e824fa94cbacff419a0ad611926710f9.dat?下载文件.docx",
  85. fromClient: 2,
  86. id: "253db476c6d140f0a1b4d4af5fcf2016",
  87. isDes: 0,
  88. contentType: 3,
  89. networkType: 1,
  90. sender: "0578+0-ls_xxj1",
  91. senderDisplayName: "陆趣趣",
  92. "ts": "来自pc端",
  93. length: 17359
  94. },
  95. {
  96. content: "消息内容",
  97. style: { "family": "宋体", "size": 9, "color": 16711680 },
  98. fromClient: 2, //消息来源([0:PC],[1:iOS],[2:Android]
  99. id: "616ebe69e1c04c2ea9740a14457aaca6",
  100. isDes: 0, //是否加密消息
  101. contentType: 1, // 消息类型([1,文本消息],[2,图片消息],[3,文件消息],[4,语音消息], [5,位置消息])
  102. networkType: 1, //网络类型([1:wifi],[2:2G],[3:3G],[4:4G])
  103. sender: "0578+0-ls_xxj1",
  104. senderDisplayName: "陆趣趣",
  105. length: 12312,
  106. ts: 12312312412 //时间搓
  107. }
  108. ];
  109. $scope.appContent = {};
  110. // $scope.guid = lxtalkClient.Invoke('register', 'talkview', $scope)
  111. $scope.sendmessages = [];
  112. $scope.historyitems = [];
  113. $scope.historymessages = [];
  114. $scope.pageSize = 1;
  115. $scope.pageNumber = 2;
  116. $scope.historyitems.push($scope.items.slice($scope.pageNumber * ($scope.pageSize - 1), $scope.pageNumber * $scope.pageSize));
  117. for (var i = 0; i < $scope.pageNumber; i++) {
  118. if ($scope.historyitems[0][i] !== undefined) {
  119. $scope.historymessages.push($scope.historyitems[0][i]);
  120. }
  121. }
  122. $scope.initAppContent = function(appContentJson) {
  123. $scope.appContent = JSON.parse(appContentJson);
  124. }
  125. $scope.addMessage = function() {
  126. scroll(document.body);
  127. }
  128. $scope.showMessage = function(jsonStr) {
  129. console.log(jsonStr);
  130. jsonStr = jsonStr.replace(/ /g, "&nbsp");
  131. jsonStr = jsonStr.replace(/\r\n/g, "<br>");
  132. jsonStr = jsonStr.replace(/\r/g, "\\r");
  133. jsonStr = jsonStr.replace(/\n/g, "\\n");
  134. jsonStr = jsonStr.replace(/\t/g, "\\t");
  135. jsonStr = jsonStr.replace(/\f/g, "\\f");
  136. var msg = JSON.parse(jsonStr);
  137. $scope.sendmessages.push(msg);
  138. $scope.scrollHide();
  139. }
  140. $scope.showHistoryMessage = function(jsonStr) {
  141. var msg = JSON.parse(jsonStr);
  142. // $scope.items.unshift(msg);
  143. // console.log(msg);
  144. }
  145. $scope.getMore = function() {
  146. $scope.historyitems = [];
  147. $scope.pageSize = $scope.pageSize + 1;
  148. $scope.historyitems.push($scope.items.slice($scope.pageNumber * ($scope.pageSize - 1), $scope.pageNumber * $scope.pageSize));
  149. for (var i = 0; i < $scope.pageNumber; i++) {
  150. if ($scope.historyitems[0][i] !== undefined) {
  151. $scope.historymessages.push($scope.historyitems[0][i]);
  152. }
  153. }
  154. }
  155. $scope.scrollHide = function() {
  156. angular.element("#body").addClass("scrollGlue");
  157. }
  158. $scope.scrollShow = function() {
  159. angular.element("#body").removeClass("scrollGlue");
  160. }
  161. }])
  162. .animation(".animate", function() {
  163. return {
  164. enter: function(element, done) {
  165. var height = element.height();
  166. element.css({ position: 'relative', bottom: 0, opacity: 0 });
  167. element.animate({ bottom: 0, opacity: 1 }, 500, done);
  168. }
  169. };
  170. });
  171. (function() {
  172. 'use strict';
  173. angular
  174. .module('appMessage')
  175. .directive('ngCurrentMsg', CurrentMsg);
  176. CurrentMsg.inject = ['$location', '$anchorScroll', '$timeout'];
  177. function CurrentMsg($location, $anchorScroll, $timeout) {
  178. var directive = {
  179. link: link,
  180. restrict: 'A',
  181. scope: {
  182. msg: '=ngCurrentMsg',
  183. appContent: '=ngAppContent'
  184. }
  185. };
  186. return directive;
  187. function link(scope, element, attrs) {
  188. var gotoBottom = function() {
  189. $location.hash("bottom");
  190. $anchorScroll();
  191. };
  192. var replaceSystemFace = function(content) {
  193. //匹配表情
  194. var g = (/\/\:([\w]+)/).exec(content);
  195. while (g !== null) {
  196. scope.appContent.faceConfig.sys.forEach(function(element) {
  197. content = content.replace(element.shortcut, '<img style="height:56px" src="local://' + scope.appContent.directory.base + element.image + '">');
  198. }, this);
  199. g = (/\/\:([\w]+)/).exec(content);
  200. }
  201. //匹配截图
  202. var g = (/\[image\-src=\"([\w\W]+?)\"\]/i).exec(content);
  203. while (g !== null) {
  204. content = content.replace(g[0], function() {
  205. var html = '<a href="#" class="thumbnail"' + '>' +
  206. '<img style="max-width:270px;max-height:250px;" src="local://' + scope.appContent.directory.received + g[1] + '.JPG' + '" alt="" >' +
  207. '</a>';
  208. loadImg("local://" + scope.appContent.directory.received + g[1] + ".JPG", addImg);
  209. function loadImg(url, callback) {
  210. var img = new Image();
  211. img.onload = function() {
  212. img.onload = null;
  213. callback(img);
  214. }
  215. img.src = url;
  216. //img.attr("defaulturl", "../images/img.png");
  217. }
  218. function addImg(img) {
  219. //$(img).appendTo($(".image"));
  220. gotoBottom();
  221. }
  222. return html;
  223. });
  224. g = (/\[image\-src=\"([\w\W]+?)\"\]/i).exec(content);
  225. }
  226. //匹配网址
  227. var i = 0;
  228. var m = content.match(/(((((http|ftp|https|HTTP|FTP|HTTPS):\/\/)[\w\-_]+)|www|WWW|[0-9]+)(\.(?!gif|jpg|png|mp3)[\w\-_]+)+([\w\-\.,@?^=%:/~\+#]*[\w\-\@?^=%/~\+#\r\n]))/ig);
  229. console.log(m);
  230. if (m == null)
  231. return content;
  232. content = content.replace(/(((((http|ftp|https|HTTP|FTP|HTTPS):\/\/)[\w\-_]+)|www|WWW|[0-9]+)(\.(?!gif|jpg|png|mp3)[\w\-_]+)+([\w\-\.,@?^=%:/~\+#]*[\w\-\@?^=%/~\+#\r\n]))/ig, function() {
  233. var html = '';
  234. var g = (/((((http|ftp|https|HTTP|FTP|HTTPS):\/\/)[\w\-_]+)(\.[\w\-_]+)+([\w\-\.,@?^=%:/~\+#]*[\w\-\@?^=%/~\+#\r\n]))/ig).exec(m[i]);
  235. if (g == null)
  236. html = '<a target="_blank" href="http://' + m[i] + '">' +
  237. m[i] +
  238. '</a>';
  239. else
  240. html = '<a target="_blank" href="' + m[i] + '">' +
  241. m[i] +
  242. '</a>';
  243. i = i + 1;
  244. return html;
  245. });
  246. return content;
  247. };
  248. var replaceImage = function(content) {}
  249. var html = '';
  250. var message = document.getElementById("message");
  251. // 消息类型([1,文本消息],[2,图片消息],[3,文件消息], [4,位置消息],[5,语音消息])
  252. if (scope.appContent === undefined || scope.appContent.faceConfig === undefined || scope.appContent.faceConfig.sys === undefined) {
  253. html = '<span class="text-message">' + scope.msg.content + '</span>';
  254. } else if (scope.msg.contentType == 1) {
  255. //var style = { style: "normal", weight: "normal" };
  256. var style = JSON.parse(scope.msg.style);
  257. html = '<span class="text-message"' + ' style="font:' + style.style + ' ' + style.weight + ' ' + style.size + 'pt' + ' ' + style.family + ';color:#' + style.color.toString(16) + '">' +
  258. replaceSystemFace(scope.msg.content) + '</span>';
  259. } else if (scope.msg.contentType == 2) {
  260. html = '<span class="text-message">' +
  261. '<a href="#" class="thumbnail" >' +
  262. '<img src="' + scope.msg.content + '" alt="通用的占位符缩略图" >' +
  263. '</a>' +
  264. '</span>';
  265. } else if (scope.msg.contentType == 3) {
  266. element.css({
  267. width: '275px'
  268. });
  269. //element.addClass('file-message');
  270. var reg = /\?[\W\w]*/;
  271. var fileName = decodeURIComponent(reg.exec(scope.msg.content).toString().substr(1));
  272. html = '<div class="file-message">' +
  273. '<img src="../img/unkown.png" onError= "this.src = \'../img/file/unkown.png\'">' +
  274. '<span style="float:left; margin:5px 0px 0px 0px">文件名:' + fileName + '<br/>大小:' + scope.msg.length + '</span>' +
  275. '<div class="p-t-sm text-right">' +
  276. '<a class="text-primary" role="button"><span>打开</span></a>&nbsp&nbsp' +
  277. '<a class="text-primary" role="button"><span>打开文件夹</span></a>' +
  278. '</div>' +
  279. '</div>';
  280. } else if (scope.msg.contentType == 4) {
  281. html = '<span class="text-message">' +
  282. '<iframe class="map" border=0 src="' + scope.msg.content + '" frameBorder=no></iframe>' +
  283. '</span>';
  284. } else if (scope.msg.contentType == 5) {
  285. html = '<span class="text-message">' +
  286. '<audio src="' + scope.msg.content + '" controls="controls">' +
  287. '</audio>' +
  288. '</span>';
  289. }
  290. console.log(html);
  291. var newElement = angular.element(html);
  292. element.append(newElement);
  293. // $(function() {
  294. // $("img.lazy").lazyload();
  295. // });
  296. message.addEventListener('load', gotoBottom());
  297. }
  298. }
  299. })();
  300. (function() {
  301. 'use strict';
  302. angular
  303. .module('appMessage')
  304. .directive('ngHistoryMsg', HistoryMsg);
  305. HistoryMsg.inject = [];
  306. function HistoryMsg() {
  307. var directive = {
  308. link: link,
  309. restrict: 'A',
  310. scope: {
  311. msg: '=ngHistoryMsg',
  312. appContent: '=ngAppContent'
  313. }
  314. };
  315. return directive;
  316. function link(scope, element, attrs) {
  317. var replaceSystemFace = function(content) {
  318. //匹配表情
  319. var g = (/\/\:([\w]+)/).exec(content);
  320. while (g !== null) {
  321. scope.appContent.faceConfig.sys.forEach(function(element) {
  322. content = content.replace(element.shortcut, '<img style="height:56px" src="local://' + scope.appContent.directory.base + element.image + '">');
  323. }, this);
  324. g = (/\/\:([\w]+)/).exec(content);
  325. }
  326. //匹配截图
  327. var g = (/\[image\-src=\"([\w\W]+?)\"\]/i).exec(content);
  328. while (g !== null) {
  329. content = content.replace(g[0],
  330. '<a href="#" class="thumbnail"' + '>' +
  331. '<img class="lazy" style="max-width:270px;max-height:250px;" src="../img/loading.jpg" data-original="local://' + scope.appContent.directory.received + g[1] + '.JPG' + '" alt="" >' +
  332. '</a>'
  333. );
  334. g = (/\[image\-src=\"([\w\W]+?)\"\]/i).exec(content);
  335. }
  336. //匹配网址
  337. var i = 0;
  338. var m = content.match(/(((((http|ftp|https|HTTP|FTP|HTTPS):\/\/)[\w\-_]+)|www|WWW|[0-9]+)(\.(?!gif|jpg|png|mp3)[\w\-_]+)+([\w\-\.,@?^=%:/~\+#]*[\w\-\@?^=%/~\+#\r\n]))/ig);
  339. console.log(m);
  340. if (m == null)
  341. return content;
  342. content = content.replace(/(((((http|ftp|https|HTTP|FTP|HTTPS):\/\/)[\w\-_]+)|www|WWW|[0-9]+)(\.(?!gif|jpg|png|mp3)[\w\-_]+)+([\w\-\.,@?^=%:/~\+#]*[\w\-\@?^=%/~\+#\r\n]))/ig, function() {
  343. var html = '';
  344. var g = (/((((http|ftp|https|HTTP|FTP|HTTPS):\/\/)[\w\-_]+)(\.[\w\-_]+)+([\w\-\.,@?^=%:/~\+#]*[\w\-\@?^=%/~\+#\r\n]))/ig).exec(m[i]);
  345. if (g == null)
  346. html = '<a target="_blank" href="http://' + m[i] + '">' +
  347. m[i] +
  348. '</a>';
  349. else
  350. html = '<a target="_blank" href="' + m[i] + '">' +
  351. m[i] +
  352. '</a>';
  353. i = i + 1;
  354. return html;
  355. });
  356. return content;
  357. };
  358. if (scope.msg.senderDisplayName === undefined || scope.msg.senderDisplayName == '')
  359. scope.msg.senderDisplayName = scope.msg.sender;
  360. var html = '';
  361. // 消息类型([1,文本消息],[2,图片消息],[3,文件消息], [4,位置消息],[5,语音消息])
  362. if (scope.appContent === undefined || scope.appContent.faceConfig === undefined || scope.appContent.faceConfig.sys === undefined) {
  363. html = '<span class="text-message">' + scope.msg.content + '</span>';
  364. } else if (scope.msg.contentType == 1) {
  365. //var style = { style: "normal", weight: "normal" };
  366. var style = scope.msg.style;
  367. html = '<span class="text-message"' + ' style="font:' + style.style + ' ' + style.weight + ' ' + style.size + 'pt' + ' ' + style.family + ';color:#' + style.color.toString(16) + '">' +
  368. replaceSystemFace(scope.msg.content) + '</span>';
  369. } else if (scope.msg.contentType == 2) {
  370. html = '<span class="text-message">' +
  371. '<a href="#" class="thumbnail" >' +
  372. '<img src="' + scope.msg.content + '" alt="通用的占位符缩略图" >' +
  373. '</a>' +
  374. '</span>';
  375. } else if (scope.msg.contentType == 3) {
  376. // element.css({
  377. // width: '300px'
  378. // });
  379. //element.addClass('file-message');
  380. var reg = /\?[\W\w]*/;
  381. var fileName = decodeURIComponent(reg.exec(scope.msg.content).toString().substr(1));
  382. html = '<div class="file-message" style="width:250px">' +
  383. '<img src="../img/unkown.png" onError= "this.src = \'../img/file/unkown.png\'">' +
  384. '<span style="float:left; margin:5px 0px 0px 0px">文件名:' + fileName + '<br/>大小:' + scope.msg.length + '</span>' +
  385. '<div class="p-t-sm text-right">' +
  386. '<a class="text-primary" role="button"><span>打开</span></a>&nbsp&nbsp' +
  387. '<a class="text-primary" role="button"><span>打开文件夹</span></a>' +
  388. '</div>' +
  389. '</div>';
  390. } else if (scope.msg.contentType == 4) {
  391. html = '<span class="text-message">' +
  392. '<iframe class="map" border=0 src="' + scope.msg.content + '" frameBorder=no></iframe>' +
  393. '</span>';
  394. } else if (scope.msg.contentType == 5) {
  395. html = '<span class="text-message">' +
  396. '<audio src="' + scope.msg.content + '" controls="controls">' +
  397. '</audio>' +
  398. '</span>';
  399. }
  400. var html_g = '<div class="feed-element">' +
  401. '<div class="media-body" id="loadmore">' +
  402. '<p><strong>' +
  403. scope.msg.senderDisplayName +
  404. '</strong><small class="text-muted">-2017-2-6 15:57:17&nbsp' +
  405. scope.msg.ts + '</small></p>' +
  406. '<div class="well m-l-xs m-t-xs fit-content" >' +
  407. '<div class="text-point"></div>' + html +
  408. '</div></div></div>';
  409. angular.element("#loadmore").prepend(html_g);
  410. $(function() {
  411. $("img.lazy").lazyload();
  412. });
  413. console.log(html_g);
  414. }
  415. }
  416. })();