���ѧۧݧ�ӧ�� �ާ֧ߧ֧էا֧� - ���֧էѧܧ�ڧ��ӧѧ�� - /home/alphpwcp/public_html/us/alphachat/design/defaulttheme/js/lh.cannedmsg.min.js
���ѧ٧ѧ�
var LHCCannedMessageAutoSuggest=function(){function e(e){this.chat_id=e.chat_id,this.suggesting=!1,this.cannedMode=!1,this.currentText=null,this.currentKeword=null,this.nextUppercase=!1,this.nextUppercasePos=0,this.nextUppercaseCallback=null,this.nextUppercaseEnabled=void 0===e.uppercase_enabled||1==e.uppercase_enabled,this.currentRequest=null,this.cacheCanned={},this.htmlPreviewTimeout=null;var t=this;this.textareaHolder=jQuery("#CSChatMessage-"+this.chat_id),this.newEditor=!1,this.keyUpCallback=function(e){if(1==t.nextUppercaseEnabled&&(1==t.nextUppercase?(clearTimeout(t.nextUppercaseCallback),t.nextUppercaseCallback=setTimeout((function(){t.capitalizeSentences(e)}),50)):t.capitalizeSentences(e)),"#"==e.key||51==e.keyCode||222==e.keyCode)t.currentText=t.getValue(),t.showSuggester();else if(32==e.keyCode&&1==t.suggesting)t.stopSuggesting();else if(1==t.suggesting&&38!=e.keyCode&&40!=e.keyCode&&39!=e.keyCode&&37!=e.keyCode&&13!=e.keyCode)t.currentText!==t.getValue()&&(t.showSuggester(),t.currentText=t.getValue());else if(1!=t.suggesting||37!=e.keyCode&&39!=e.keyCode||!1!==t.cannedMode)0!=t.suggesting||39!=e.keyCode&&37!=e.keyCode&&8!=e.keyCode||null!==t.extractKeyword()&&t.showSuggester();else{t.currentKeword!==t.extractKeyword()&&t.showSuggester()}},this.keyDownCallback=function(e){if(1==t.suggesting)if(38==e.keyCode)t.moveAction("up"),e.preventDefault(),e.stopImmediatePropagation();else if(40==e.keyCode)t.moveAction("down"),e.preventDefault();else if(39!=e.keyCode&&37!=e.keyCode||!0!==t.cannedMode){if(39==e.keyCode||13==e.keyCode){var n=null;null!==(n=!1===t.cannedMode?$("#canned-hash-"+t.chat_id+" > li.current-item a"):$("#canned-hash-current-"+t.chat_id+" li.current-item > span.canned-msg"))&&n.length>0&&(n.trigger("click"),e.preventDefault(),e.stopImmediatePropagation())}}else{var r=$("#canned-hash-current-"+t.chat_id+" li.current-item").parent().parent().index();0==r&&37==e.keyCode&&($("#canned-hash-current-"+t.chat_id+" li.current-item > span.left-return").trigger("click"),e.preventDefault(),e.stopImmediatePropagation());var a=$("#canned-hash-current-"+t.chat_id+" .list-sub-items > li").length;if(0==a)$("#canned-hash-current-"+t.chat_id+" li.current-item > span.canned-msg").trigger("click");else{var i=$("#canned-hash-current-"+t.chat_id+" li.current-item").index();if($("#canned-hash-current-"+t.chat_id+" li.current-item").removeClass("current-item"),39==e.keyCode){var s=0;a-1>=r+1&&(s=r+1);var c=$("#canned-hash-current-"+t.chat_id+" > ul > li:eq("+s+") > ul"),h=0;c.find("> li").length-1>=i&&(h=i),t.renderPreview(c.find(" > li:eq("+h+")").addClass("current-item"))}else 37==e.keyCode&&t.renderPreview($("#canned-hash-current-"+t.chat_id+" > ul > li:eq("+(r-1)+") > ul > li:eq("+i+")").addClass("current-item"))}e.preventDefault(),e.stopImmediatePropagation()}},"LHC-EDITOR"==this.textareaHolder.prop("nodeName")?(this.newEditor=!0,this.textarea=jQuery(e.textarea),this.textarea.bind("keyup",this.keyUpCallback),this.textarea.bind("keydown",this.keyDownCallback)):(this.textarea=this.textareaHolder,this.textarea.bind("keyup",this.keyUpCallback),this.textarea.bind("keydown",this.keyDownCallback))}return e.prototype.unbindEvents=function(){this.textarea.unbind("keyup",this.keyUpCallback),this.textarea.unbind("keydown",this.keyDownCallback)},e.prototype.getValue=function(){return"LHC-EDITOR"==this.textareaHolder.prop("nodeName")?this.textareaHolder[0].getContentLive():this.textarea.val()},e.prototype.capitalizeSentences=function(e){if(!0===this.newEditor){let e=this.textareaHolder[0].getCaretPositionAndContent();var t=e.caret,n=e.content,r=e.full_content.length}else n=this.getValue(),t=this.textarea[0].selectionStart,r=n.length;var a=n;if(8!=e.keyCode&&46!=e.keyCode){if(r<=3&&(a=a.replace(a.charAt(0),a.charAt(0).toUpperCase())),1==this.nextUppercase&&(a=a.substr(0,this.nextUppercasePos)+a.charAt(this.nextUppercasePos).toUpperCase()+a.substr(this.nextUppercasePos+1))," "!=n.charAt(t-1)||"."!=n.charAt(t-2)&&"?"!=n.charAt(t-2)&&"!"!=n.charAt(t-2)||n.length!=t?1==this.nextUppercase&&(this.nextUppercase=!1):(this.nextUppercase=!0,this.nextUppercasePos=t),"en"==confLH.content_language&&(a=a.replace(/\si\s/g," I ")),a!=n)if(!1===this.newEditor){if(this.textarea.val(a),"selectionStart"in this.textarea[0])this.textarea[0].selectionStart=t,this.textarea[0].selectionEnd=t;else if(this.textarea[0].setSelectionRange)this.textarea[0].setSelectionRange(t,t);else if(this.textarea[0].createTextRange){var i=this.textarea[0].createTextRange();i.collapse(!0),i.moveEnd("character",t),i.moveStart("character",t),i.select()}}else a.endsWith(" ")&&(a=a.substring(0,a.length-1)+" "),this.textareaHolder[0].replaceRange(a)}else this.nextUppercase=!1},e.prototype.moveAction=function(e){if(!1===this.cannedMode)var t=$("#canned-hash-"+this.chat_id+" > li.current-item");else t=$("#canned-hash-current-"+this.chat_id+" li.current-item");if(0!=t.length){if("up"==e){var n=t.prev();n.is("li")?(t.removeClass("current-item"),t=n.addClass("current-item")):t=t.removeClass("current-item").parent().find(" > li").last().addClass("current-item")}else if("down"==e){var r=t.next();r.is("li")?(t.removeClass("current-item"),t=r.addClass("current-item")):t=t.removeClass("current-item").parent().find(" > li").first().addClass("current-item")}!0===this.cannedMode&&this.renderPreview(t)}},e.prototype.isVisible=function(e,t,n){return e.height()+e.offset().top>=t.offset().top+n.threshold&&t.offset().top>e.offset().top-n.threshold},e.prototype.renderPreview=function(e){var t=e.find("> .canned-msg").attr("data-msg");clearTimeout(this.htmlPreviewTimeout);var n=this;void 0!==t?(this.isVisible($("#canned-hash-current-"+this.chat_id),e,{threshold:10})||e[0].scrollIntoView(),0==(e=$("#canned-hash-current-"+this.chat_id).parent().find(".canned-msg-preview")).length&&($("#canned-hash-current-"+this.chat_id).parent().prepend('<div class="canned-msg-preview"></div>'),e=$("#canned-hash-current-"+this.chat_id).parent().find(".canned-msg-preview")),e.text(t),this.htmlPreviewTimeout=setTimeout((function(){$.post(WWW_DIR_JAVASCRIPT+"chat/previewmessage/"+n.chat_id,{msg_body:!0,msg:t},(function(t){e.html(t),setTimeout((function(){n.adjustHeight()}),500)}))}),300),this.adjustHeight()):$("#canned-hash-current-"+this.chat_id).parent().find(".canned-msg-preview").remove()},e.prototype.adjustHeight=function(){var e=$("#chat-main-column-"+this.chat_id+" .canned-suggester");e.height()>$("#CSChatMessage-"+this.chat_id).offset().top&&$("#canned-hash-current-"+this.chat_id).css("max-height",$("#CSChatMessage-"+this.chat_id).offset().top-e.find(".canned-msg-preview").height()-10)},e.prototype.stopSuggesting=function(){this.textarea.parent().find(".canned-suggester").remove(),this.suggesting=!1,this.cannedMode=!1,this.currentText=null,this.currentKeword=null,this.newEditor&&this.textareaHolder[0].removeAttribute("disable_key_listeners")},e.prototype.extractKeyword=function(){var e=0,t="";if(!1===this.newEditor)e=this.textarea[0].selectionStart,t=this.textarea.val();else{let n=this.textareaHolder[0].getCaretPositionAndContent({ignore_parent:!0});e=n.caret,t=n.content}var n="";for(i=e;i>0;i--){if(char=t.substring(i-1,i)," "==char)return this.currentKeword=null,null;if("#"==char)return this.currentKeword=n,n;n=char+n}return this.currentKeword=null,null},this.timeoutRequest=null,e.prototype.startSuggesting=function(){this.suggesting=!0,this.newEditor&&this.textareaHolder[0].setAttribute("disable_key_listeners",!0)},e.prototype.showSuggester=function(){var e=this;this.extractKeyword(),this.cannedMode=!1,clearTimeout(this.timeoutRequest),null!==this.currentKeword?(e.startSuggesting(!0),this.timeoutRequest=setTimeout((function(){if(null!=e.currentRequest&&(e.currentRequest.abort(),e.currentRequest=null),"string"==typeof e.currentKeword){var t=!1,n=null;e.currentKeword.length<3&&(t=!0,void 0!==e.cacheCanned[e.currentKeword]&&(n=e.cacheCanned[e.currentKeword])),null!==n?(e.textarea.parent().find(".canned-suggester").remove(),e.textarea.before(n),e.initSuggester()):e.currentRequest=$.getJSON(WWW_DIR_JAVASCRIPT+"cannedmsg/showsuggester/"+e.chat_id,{keyword:e.currentKeword},(function(n){e.textarea.parent().find(".canned-suggester").remove(),e.textarea.before(n.result),e.initSuggester(),1==t&&(e.cacheCanned[e.currentKeword]=n.result)}))}}),130)):this.stopSuggesting()},e.prototype.initSuggester=function(){var e=this,t=$("#canned-hash-"+this.chat_id+" > li:last-child");t.length>0?(t.addClass("current-item"),this.textarea.parent().find(".canned-suggester").css("bottom",e.textarea.height()+16),$("#canned-hash-"+this.chat_id+" > li > a").click((function(){e.cannedMode=!0;var t=$("#canned-hash-current-"+e.chat_id);t.html("").show(),$(this).parent().find("ul.list-sub-items").clone().appendTo(t),e.renderPreview(t.find("ul > li:first-child > ul > li:first-child").addClass("current-item"));var n=$(this).parent().parent();n.hide(),t.find("span.canned-msg").mouseover((function(){e.renderPreview($(this).parent()),$("#canned-hash-current-"+e.chat_id+" li.current-item").removeClass("current-item"),$(this).parent().addClass("current-item")})),t.find("span.canned-msg").click((function(){var t=$(this).attr("data-msg"),n=$(this).attr("subjects_ids"),r=$(this).attr("canned_id");if(!1===e.newEditor){currentValue=e.getValue();var a=e.textarea[0].selectionStart,i=currentValue.substring(0,a),s=i.lastIndexOf("#");i=i.substring(0,s)+t,e.textarea.val(i+currentValue.substring(a))}else e.textareaHolder[0].insertContent(t,{replace_from:"#",convert_bbcode:!0});if(n&&e.textareaHolder.attr("subjects_ids",n),r&&e.textareaHolder.attr("canned_id",r),!1===e.newEditor){if("selectionStart"in e.textarea[0])e.textarea[0].selectionStart=i.length,e.textarea[0].selectionEnd=i.length;else if(e.textarea[0].setSelectionRange)e.textarea[0].setSelectionRange(i.length,i.length);else if(e.textarea[0].createTextRange){var c=e.textarea[0].createTextRange();c.collapse(!0),c.moveEnd("character",i.length),c.moveStart("character",i.length),c.select()}e.textarea[0].focus()}e.stopSuggesting()})),t.find("span.left-return").click((function(){n.show(),t.html("").hide(),t.parent().find(".canned-msg-preview").remove(),e.cannedMode=!1}))})),1==$("#canned-hash-"+this.chat_id+" > li").length?$("#canned-hash-"+this.chat_id+" > li > a").trigger("click"):this.renderPreview(t)):this.stopSuggesting()},e}();
| ver. 1.4 |
Github
|
.
| PHP 8.2.30 | ���֧ߧ֧�ѧ�ڧ� ����ѧߧڧ��: 0.05 |
proxy
|
phpinfo
|
���ѧ����ۧܧ�