forked from danxexe/sms-counter
-
Notifications
You must be signed in to change notification settings - Fork 0
/
sms_counter.min.js
5 lines (5 loc) · 1.64 KB
/
sms_counter.min.js
1
2
3
4
5
var $,SmsCounter;
window.SmsCounter=SmsCounter=function(){function a(){}a.gsm7bitChars="@\u00a3$\u00a5\u00e8\u00e9\u00f9\u00ec\u00f2\u00c7\n\u00d8\u00f8\r\u00c5\u00e5\u0394_\u03a6\u0393\u039b\u03a9\u03a0\u03a8\u03a3\u0398\u039e\u00c6\u00e6\u00df\u00c9 !\"#\u00a4%&'()*+,-./0123456789:;<=>?\u00a1ABCDEFGHIJKLMNOPQRSTUVWXYZ\u00c4\u00d6\u00d1\u00dc\u00a7\u00bfabcdefghijklmnopqrstuvwxyz\u00e4\u00f6\u00f1\u00fc\u00e0";a.gsm7bitExChar="^{}\\[~]|\u20ac";a.gsm7bitRegExp=RegExp("^["+a.gsm7bitChars+"]*$");a.gsm7bitExRegExp=RegExp("^["+
a.gsm7bitChars+a.gsm7bitExChar+"]*$");a.gsm7bitExOnlyRegExp=RegExp("^[\\"+a.gsm7bitExChar+"]*$");a.GSM_7BIT="GSM_7BIT";a.GSM_7BIT_EX="GSM_7BIT_EX";a.UTF16="UTF16";a.messageLength={GSM_7BIT:160,GSM_7BIT_EX:160,UTF16:70};a.multiMessageLength={GSM_7BIT:153,GSM_7BIT_EX:153,UTF16:67};a.count=function(a){var d,b,c;d=this.detectEncoding(a);b=a.length;d===this.GSM_7BIT_EX&&(b+=this.countGsm7bitEx(a));c=this.messageLength[d];b>c&&(c=this.multiMessageLength[d]);a=Math.ceil(b/c);return{encoding:d,length:b,per_message:c,
remaining:c*a-b,messages:a}};a.detectEncoding=function(a){switch(!1){case null==a.match(this.gsm7bitRegExp):return this.GSM_7BIT;case null==a.match(this.gsm7bitExRegExp):return this.GSM_7BIT_EX;default:return this.UTF16}};a.countGsm7bitEx=function(a){var d,b,c,f;f=[];b=0;for(c=a.length;b<c;b++)d=a[b],null!=d.match(this.gsm7bitExOnlyRegExp)&&f.push(d);return f.length};return a}();
"undefined"!==typeof jQuery&&null!==jQuery&&($=jQuery,$.fn.countSms=function(a){var e,d;d=this;a=$(a);e=function(){var b,c,f,e;b=SmsCounter.count(d.val());e=[];for(c in b)f=b[c],e.push(a.find("."+c).text(f));return e};this.on("keyup",e);return e()});