123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446 |
- 'use strict';
- var appMessage = angular.module('appMessage', ['luegg.directives', 'ngAnimate']);
- 'use strict';
- angular.module('appMessage').controller('MessageController', ['$scope', '$location', '$anchorScroll', function($scope, $location, $anchorScroll) {
- lxtalkClient.Invoke('{15180DEF-D508-45F7-BAEB-6486CD8752C8}', '_Register', '', $scope);
- $scope.glued = true;
- $scope.items = [{
- "uid": "2636765",
- "senderDisplayName": "丽水市市委办公室",
- "sender": "0578+002682BECE10-lqq",
- "msgType": 0,
- "networkType": 1,
- "isDes": false,
- "length": 0,
- "isReaded": false,
- "contentType": 1,
- "receiver": "0578+002682BECE10-lsws",
- "fromClient": 0,
- "ts": "来自pc端",
- "id": 0,
- "content": "111111",
- "style": ""
- }, {
- content: "消息内容",
- style: '字体',
- fromClient: 2, //消息来源([0:PC],[1:iOS],[2:Android]
- id: "616ebe69e1c04c2ea9740a14457aaca6",
- isDes: 0, //是否加密消息
- contentType: 1, // 消息类型([1,文本消息],[2,图片消息],[3,文件消息],[4,语音消息], [5,位置消息])
- networkType: 1, //网络类型([1:wifi],[2:2G],[3:3G],[4:4G])
- sender: "0578+0-ls_xxj1",
- senderDisplayName: "陆趣趣",
- length: 12312,
- ts: 12312312412 //时间搓
- }, {
- content: "http://202.107.249.133:8125/e/8/2/4/f/e824fa94cbacff419a0ad611926710f9.dat?下载文件.docx",
- fromClient: 2,
- id: "253db476c6d140f0a1b4d4af5fcf2016",
- isDes: 0,
- contentType: 3,
- networkType: 1,
- sender: "0578+0-ls_xxj1",
- senderDisplayName: "陆趣趣",
- "ts": "来自pc端",
- length: 17359
- },
- {
- content: "../img/DefaultHeadImage_96.png",
- fromClient: 2,
- id: "253db476c6d140f0a1b4d4af5fcf2016",
- isDes: 0,
- contentType: 2,
- networkType: 1,
- sender: "0578+0-ls_xxj1",
- senderDisplayName: "陆趣趣",
- "ts": "来自pc端",
- length: 17359
- },
- {
- content: "../img/DefaultHeadImage_96.png",
- fromClient: 2,
- id: "253db476c6d140f0a1b4d4af5fcf2016",
- isDes: 0,
- contentType: 2,
- networkType: 1,
- sender: "0578+0-ls_xxj1",
- senderDisplayName: "陆趣趣",
- "ts": "来自pc端",
- length: 17359
- },
- {
- content: "../img/DefaultHeadImage_96.png",
- fromClient: 2,
- id: "253db476c6d140f0a1b4d4af5fcf2016",
- isDes: 0,
- contentType: 2,
- networkType: 1,
- sender: "0578+0-ls_xxj1",
- senderDisplayName: "陆趣趣",
- "ts": "来自pc端",
- length: 17359
- },
- {
- content: "http://202.107.249.133:8125/e/8/2/4/f/e824fa94cbacff419a0ad611926710f9.dat?下载文件.docx",
- fromClient: 2,
- id: "253db476c6d140f0a1b4d4af5fcf2016",
- isDes: 0,
- contentType: 3,
- networkType: 1,
- sender: "0578+0-ls_xxj1",
- senderDisplayName: "陆趣趣",
- "ts": "来自pc端",
- length: 17359
- },
- {
- content: "消息内容",
- style: { "family": "宋体", "size": 9, "color": 16711680 },
- fromClient: 2, //消息来源([0:PC],[1:iOS],[2:Android]
- id: "616ebe69e1c04c2ea9740a14457aaca6",
- isDes: 0, //是否加密消息
- contentType: 1, // 消息类型([1,文本消息],[2,图片消息],[3,文件消息],[4,语音消息], [5,位置消息])
- networkType: 1, //网络类型([1:wifi],[2:2G],[3:3G],[4:4G])
- sender: "0578+0-ls_xxj1",
- senderDisplayName: "陆趣趣",
- length: 12312,
- ts: 12312312412 //时间搓
- }
- ];
- $scope.appContent = {};
- // $scope.guid = lxtalkClient.Invoke('register', 'talkview', $scope)
- $scope.sendmessages = [];
- $scope.historyitems = [];
- $scope.historymessages = [];
- $scope.pageSize = 1;
- $scope.pageNumber = 2;
- $scope.historyitems.push($scope.items.slice($scope.pageNumber * ($scope.pageSize - 1), $scope.pageNumber * $scope.pageSize));
- for (var i = 0; i < $scope.pageNumber; i++) {
- if ($scope.historyitems[0][i] !== undefined) {
- $scope.historymessages.push($scope.historyitems[0][i]);
- }
- }
- $scope.initAppContent = function(appContentJson) {
- $scope.appContent = JSON.parse(appContentJson);
- }
- $scope.addMessage = function() {
- scroll(document.body);
- }
- $scope.showMessage = function(jsonStr) {
- console.log(jsonStr);
- jsonStr = jsonStr.replace(/ /g, " ");
- jsonStr = jsonStr.replace(/\r\n/g, "<br>");
- jsonStr = jsonStr.replace(/\r/g, "\\r");
- jsonStr = jsonStr.replace(/\n/g, "\\n");
- jsonStr = jsonStr.replace(/\t/g, "\\t");
- jsonStr = jsonStr.replace(/\f/g, "\\f");
- var msg = JSON.parse(jsonStr);
- $scope.sendmessages.push(msg);
- $scope.scrollHide();
- }
- $scope.showHistoryMessage = function(jsonStr) {
- var msg = JSON.parse(jsonStr);
- // $scope.items.unshift(msg);
- // console.log(msg);
- }
- $scope.getMore = function() {
- $scope.historyitems = [];
- $scope.pageSize = $scope.pageSize + 1;
- $scope.historyitems.push($scope.items.slice($scope.pageNumber * ($scope.pageSize - 1), $scope.pageNumber * $scope.pageSize));
- for (var i = 0; i < $scope.pageNumber; i++) {
- if ($scope.historyitems[0][i] !== undefined) {
- $scope.historymessages.push($scope.historyitems[0][i]);
- }
- }
- }
- $scope.scrollHide = function() {
- angular.element("#body").addClass("scrollGlue");
- }
- $scope.scrollShow = function() {
- angular.element("#body").removeClass("scrollGlue");
- }
- }])
- .animation(".animate", function() {
- return {
- enter: function(element, done) {
- var height = element.height();
- element.css({ position: 'relative', bottom: 0, opacity: 0 });
- element.animate({ bottom: 0, opacity: 1 }, 500, done);
- }
- };
- });
- (function() {
- 'use strict';
- angular
- .module('appMessage')
- .directive('ngCurrentMsg', CurrentMsg);
- CurrentMsg.inject = ['$location', '$anchorScroll', '$timeout'];
- function CurrentMsg($location, $anchorScroll, $timeout) {
- var directive = {
- link: link,
- restrict: 'A',
- scope: {
- msg: '=ngCurrentMsg',
- appContent: '=ngAppContent'
- }
- };
- return directive;
- function link(scope, element, attrs) {
- var gotoBottom = function() {
- $location.hash("bottom");
- $anchorScroll();
- };
- var replaceSystemFace = function(content) {
- //匹配表情
- var g = (/\/\:([\w]+)/).exec(content);
- while (g !== null) {
- scope.appContent.faceConfig.sys.forEach(function(element) {
- content = content.replace(element.shortcut, '<img style="height:56px" src="local://' + scope.appContent.directory.base + element.image + '">');
- }, this);
- g = (/\/\:([\w]+)/).exec(content);
- }
- //匹配截图
- var g = (/\[image\-src=\"([\w\W]+?)\"\]/i).exec(content);
- while (g !== null) {
- content = content.replace(g[0], function() {
- var html = '<a href="#" class="thumbnail"' + '>' +
- '<img style="max-width:270px;max-height:250px;" src="local://' + scope.appContent.directory.received + g[1] + '.JPG' + '" alt="" >' +
- '</a>';
- loadImg("local://" + scope.appContent.directory.received + g[1] + ".JPG", addImg);
- function loadImg(url, callback) {
- var img = new Image();
- img.onload = function() {
- img.onload = null;
- callback(img);
- }
- img.src = url;
- //img.attr("defaulturl", "../images/img.png");
- }
- function addImg(img) {
- //$(img).appendTo($(".image"));
- gotoBottom();
- }
- return html;
- });
- g = (/\[image\-src=\"([\w\W]+?)\"\]/i).exec(content);
- }
- //匹配网址
- var i = 0;
- 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);
- console.log(m);
- if (m == null)
- return content;
- 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() {
- var html = '';
- var g = (/((((http|ftp|https|HTTP|FTP|HTTPS):\/\/)[\w\-_]+)(\.[\w\-_]+)+([\w\-\.,@?^=%:/~\+#]*[\w\-\@?^=%/~\+#\r\n]))/ig).exec(m[i]);
- if (g == null)
- html = '<a target="_blank" href="http://' + m[i] + '">' +
- m[i] +
- '</a>';
- else
- html = '<a target="_blank" href="' + m[i] + '">' +
- m[i] +
- '</a>';
- i = i + 1;
- return html;
- });
- return content;
- };
- var replaceImage = function(content) {}
- var html = '';
- var message = document.getElementById("message");
- // 消息类型([1,文本消息],[2,图片消息],[3,文件消息], [4,位置消息],[5,语音消息])
- if (scope.appContent === undefined || scope.appContent.faceConfig === undefined || scope.appContent.faceConfig.sys === undefined) {
- html = '<span class="text-message">' + scope.msg.content + '</span>';
- } else if (scope.msg.contentType == 1) {
- //var style = { style: "normal", weight: "normal" };
- var style = JSON.parse(scope.msg.style);
- html = '<span class="text-message"' + ' style="font:' + style.style + ' ' + style.weight + ' ' + style.size + 'pt' + ' ' + style.family + ';color:#' + style.color.toString(16) + '">' +
- replaceSystemFace(scope.msg.content) + '</span>';
- } else if (scope.msg.contentType == 2) {
- html = '<span class="text-message">' +
- '<a href="#" class="thumbnail" >' +
- '<img src="' + scope.msg.content + '" alt="通用的占位符缩略图" >' +
- '</a>' +
- '</span>';
- } else if (scope.msg.contentType == 3) {
- element.css({
- width: '275px'
- });
- //element.addClass('file-message');
- var reg = /\?[\W\w]*/;
- var fileName = decodeURIComponent(reg.exec(scope.msg.content).toString().substr(1));
- html = '<div class="file-message">' +
- '<img src="../img/unkown.png" onError= "this.src = \'../img/file/unkown.png\'">' +
- '<span style="float:left; margin:5px 0px 0px 0px">文件名:' + fileName + '<br/>大小:' + scope.msg.length + '</span>' +
- '<div class="p-t-sm text-right">' +
- '<a class="text-primary" role="button"><span>打开</span></a>  ' +
- '<a class="text-primary" role="button"><span>打开文件夹</span></a>' +
- '</div>' +
- '</div>';
- } else if (scope.msg.contentType == 4) {
- html = '<span class="text-message">' +
- '<iframe class="map" border=0 src="' + scope.msg.content + '" frameBorder=no></iframe>' +
- '</span>';
- } else if (scope.msg.contentType == 5) {
- html = '<span class="text-message">' +
- '<audio src="' + scope.msg.content + '" controls="controls">' +
- '</audio>' +
- '</span>';
- }
- console.log(html);
- var newElement = angular.element(html);
- element.append(newElement);
- // $(function() {
- // $("img.lazy").lazyload();
- // });
- message.addEventListener('load', gotoBottom());
- }
- }
- })();
- (function() {
- 'use strict';
- angular
- .module('appMessage')
- .directive('ngHistoryMsg', HistoryMsg);
- HistoryMsg.inject = [];
- function HistoryMsg() {
- var directive = {
- link: link,
- restrict: 'A',
- scope: {
- msg: '=ngHistoryMsg',
- appContent: '=ngAppContent'
- }
- };
- return directive;
- function link(scope, element, attrs) {
- var replaceSystemFace = function(content) {
- //匹配表情
- var g = (/\/\:([\w]+)/).exec(content);
- while (g !== null) {
- scope.appContent.faceConfig.sys.forEach(function(element) {
- content = content.replace(element.shortcut, '<img style="height:56px" src="local://' + scope.appContent.directory.base + element.image + '">');
- }, this);
- g = (/\/\:([\w]+)/).exec(content);
- }
- //匹配截图
- var g = (/\[image\-src=\"([\w\W]+?)\"\]/i).exec(content);
- while (g !== null) {
- content = content.replace(g[0],
- '<a href="#" class="thumbnail"' + '>' +
- '<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="" >' +
- '</a>'
- );
- g = (/\[image\-src=\"([\w\W]+?)\"\]/i).exec(content);
- }
- //匹配网址
- var i = 0;
- 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);
- console.log(m);
- if (m == null)
- return content;
- 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() {
- var html = '';
- var g = (/((((http|ftp|https|HTTP|FTP|HTTPS):\/\/)[\w\-_]+)(\.[\w\-_]+)+([\w\-\.,@?^=%:/~\+#]*[\w\-\@?^=%/~\+#\r\n]))/ig).exec(m[i]);
- if (g == null)
- html = '<a target="_blank" href="http://' + m[i] + '">' +
- m[i] +
- '</a>';
- else
- html = '<a target="_blank" href="' + m[i] + '">' +
- m[i] +
- '</a>';
- i = i + 1;
- return html;
- });
- return content;
- };
- if (scope.msg.senderDisplayName === undefined || scope.msg.senderDisplayName == '')
- scope.msg.senderDisplayName = scope.msg.sender;
- var html = '';
- // 消息类型([1,文本消息],[2,图片消息],[3,文件消息], [4,位置消息],[5,语音消息])
- if (scope.appContent === undefined || scope.appContent.faceConfig === undefined || scope.appContent.faceConfig.sys === undefined) {
- html = '<span class="text-message">' + scope.msg.content + '</span>';
- } else if (scope.msg.contentType == 1) {
- //var style = { style: "normal", weight: "normal" };
- var style = scope.msg.style;
- html = '<span class="text-message"' + ' style="font:' + style.style + ' ' + style.weight + ' ' + style.size + 'pt' + ' ' + style.family + ';color:#' + style.color.toString(16) + '">' +
- replaceSystemFace(scope.msg.content) + '</span>';
- } else if (scope.msg.contentType == 2) {
- html = '<span class="text-message">' +
- '<a href="#" class="thumbnail" >' +
- '<img src="' + scope.msg.content + '" alt="通用的占位符缩略图" >' +
- '</a>' +
- '</span>';
- } else if (scope.msg.contentType == 3) {
- // element.css({
- // width: '300px'
- // });
- //element.addClass('file-message');
- var reg = /\?[\W\w]*/;
- var fileName = decodeURIComponent(reg.exec(scope.msg.content).toString().substr(1));
- html = '<div class="file-message" style="width:250px">' +
- '<img src="../img/unkown.png" onError= "this.src = \'../img/file/unkown.png\'">' +
- '<span style="float:left; margin:5px 0px 0px 0px">文件名:' + fileName + '<br/>大小:' + scope.msg.length + '</span>' +
- '<div class="p-t-sm text-right">' +
- '<a class="text-primary" role="button"><span>打开</span></a>  ' +
- '<a class="text-primary" role="button"><span>打开文件夹</span></a>' +
- '</div>' +
- '</div>';
- } else if (scope.msg.contentType == 4) {
- html = '<span class="text-message">' +
- '<iframe class="map" border=0 src="' + scope.msg.content + '" frameBorder=no></iframe>' +
- '</span>';
- } else if (scope.msg.contentType == 5) {
- html = '<span class="text-message">' +
- '<audio src="' + scope.msg.content + '" controls="controls">' +
- '</audio>' +
- '</span>';
- }
- var html_g = '<div class="feed-element">' +
- '<div class="media-body" id="loadmore">' +
- '<p><strong>' +
- scope.msg.senderDisplayName +
- '</strong><small class="text-muted">-2017-2-6 15:57:17 ' +
- scope.msg.ts + '</small></p>' +
- '<div class="well m-l-xs m-t-xs fit-content" >' +
- '<div class="text-point"></div>' + html +
- '</div></div></div>';
- angular.element("#loadmore").prepend(html_g);
- $(function() {
- $("img.lazy").lazyload();
- });
- console.log(html_g);
- }
- }
- })();
|