-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathmsg.min.js
5 lines (5 loc) · 1.66 KB
/
msg.min.js
1
2
3
4
5
var myapp=angular.module("myapp",[]);
myapp.controller("MsgCtrl",["$http","$timeout",function(b,d){this.user=this.msg="";this.avatar_id="1";this.content=[];var a=this,e=io.connect("http://"+document.domain+":"+location.port);this.get_avatar=function(a){return"static/images/avatars/"+a+".jpg"};this.change_avatar=function(c){a.avatar_id=""+c};this.check=function(){return 200<a.msg.length};this.constrict=function(){return a.check()?{color:"red"}:{color:"black"}};this.input_style=function(a){return{"outline-color":0===a.length?"crimson":
"darkcyan"}};this.enter_keypress=function(c){13===(window.event?c.keyCode:c.which)&&a.click()};this.click=function(){0<a.user.length*a.msg.length?(a.user=a.user.slice(0,10),e.emit("message",{msg:a.msg,user:a.user,avatar_id:a.avatar_id}),a.msg=""):0===a.user.length?document.querySelector("input").focus():document.querySelector("textarea").focus()};e.on("res",function(){b({method:"GET",url:"/api/get/"}).then(function(c){a.content.push(c.data)})});this.chat_style=function(a){return"self"===a?{background:"#0ace36"}:
{background:"#92a1a4"}};this.show_face_tip=this.show_avatar_selector=!1;this.show_element=function(a){return a?{display:"block"}:{display:"none"}};this.change_avatar_selector_style=function(){this.show_avatar_selector=!this.show_avatar_selector;this.show_element(this.show_avatar_selector)};this.change_face_tip_style=function(){this.show_face_tip=!this.show_face_tip;this.show_element(this.show_face_tip);this.show_face_tip&&d(function(){a.show_face_tip=!1},3E3)}}]);
myapp.directive("repeatFinish",function(){return{restrict:"C",link:function(b,d,a){1==b.$last&&(b=document.querySelector(".content-area"),b.scrollTop=b.scrollHeight)}}});