jquery intercepts strings, date strings to date, and gets plain text in Html.
varcom = com | | {};(function($, Com) {/** Intercept String * @param str: string to intercept * @param len: how many characters are reserved * @param symbol: The character to be added after the end of the string*/Com.cutstr=function(str, len, Symbol) {if(symbol = =Undefined) {symbol= "..."; } Len= Len | | 25; varresult =str; if(str) {if(str.length && str.length >Len) Result= str.substr (0, Len) +symbol; } returnresult; }, /** Convert date string to date * (E.G. convert "2016-12-24 20:13:14" to date Format) * @param D: string to be converted (the time passed cannot have Milliseconds)*/com.getdate=function(d) {//Some browsers (IE) do not support the date format "YYYY-MM-DD hh:mm:ss", You must convert "-" to "/" varDate =NewDate (date.parse (d.replace (/-/g, "/"))); returndate; }, /** Get plain text of HTML code * @param HTML*/Com.removehtmltag=function(HTML) {html= Html.replace (/<\/?[ ^>]*>/g, ");//Remove HTML tagHTML = html.replace (/[|) *\n/g, ' \ n ');//Remove line trailing blanks //html = html.replace (/\n[\s| |) *\r/g, ' \ n '); Remove extra empty lineshtml = html.replace (/ /ig, ");//Remove html = html.replace (/\s/g, ");//Remove a space returnhtml; }}) (jQuery, com);
jquery intercepts strings, date strings to date, gets plain text in HTML