/** * Stock Market Widgets (WordPress plugin) * Version 1.0.8, built on Sat Apr 09 2016 * Copyright WebTheGap * http://webthegap.com/widgets/stock-market-wordpress/ */ function smFormatNumber(t){var e="undefined"!=typeof arguments[1][0]?arguments[1][0]:2,n="undefined"!=typeof arguments[1][1]?arguments[1][1]:"",i="undefined"!=typeof arguments[1][2]?arguments[1][2]:"";return t=parseFloat(t),t=e>1?Math.round(t*Math.pow(10,e))/Math.pow(10,e):Math.round(t),t>=0?n+t+i:"-"+n+Math.abs(t)+i}!function(t){function e(){var e=[],r=[],s=[],l=[],d=[],u=[];t(".sm-sortable-table").tablesort(),t(".sm-sortable-table thead th.integer").data("sortBy",function(t,e,n){return parseInt(e.text().replace(/\$|\%/g,""))}),t(".sm-sortable-table thead th.float").data("sortBy",function(t,e,n){return parseFloat(e.text().replace(/\$|\%/g,""))});var h=t(".sm-marquee").marquee();if(h.mouseover(function(){t(this).trigger("stop")}).mouseout(function(){t(this).trigger("start")}).mousemove(function(e){1==t(this).data("drag")&&(this.scrollLeft=t(this).data("scrollX")+(t(this).data("x")-e.clientX))}).mousedown(function(e){t(this).data("drag",!0).data("x",e.clientX).data("scrollX",this.scrollLeft)}).mouseup(function(){t(this).data("drag",!1)}),t(".sm-widget").each(function(n,i){var h=t(i),c=h.data("symbol"),f=h.data("type"),p=h.data("add-to-class");return h.addClass("sm-widget-"+f+"-"+c+(p?"-"+h.data(p):"")),a(i),o(i),""==c?!0:void("quote"==f&&e.indexOf(c)<0?e.push(c):"stats"==f&&r.indexOf(c)<0?r.push(c):"currency"==f&&s.indexOf(c)<0?s.push(c):"staticChart"==f&&l.indexOf(c)<0?l.push(c):"news"==f&&d.indexOf(c)<0?d.push(c):"historicalPerformance"==f&&""!=h.data("from")&&u.push([c,h.data("from")]))}),e.length&&(m("Retrieve quotes for tickers: "+e.join(",")),c("yahoo.finance.quotes","symbol IN "+n(e),null)),r.length>0&&(m("Retrieve key stats for tickers: "+r.join(",")),t.each(r,function(t,e){c("html",'url = "'+String.format(b,e)+'" AND xpath=\'//table/tbody/tr/td[contains(@class,"yfnc_tablehead1") or contains(@class,"yfnc_tabledata1")]\'',e)})),u.length>0){m("Retrieve historical performance for tickers: "+u.join(","));var f=[],p=[];t.each(u,function(t,e){f.push('(symbol = "'+e[0]+'" AND startDate = "'+e[1]+'" AND endDate = "'+e[1]+'")'),p.indexOf(e[0])&&p.push(e[0])}),c("query.multi","queries = 'select Adj_Close,Date,Symbol from yahoo.finance.historicaldata where "+f.join(" OR ")+"; select LastTradePriceOnly,Symbol,Name from yahoo.finance.quotes where symbol IN "+n(p)+"'","historicalPerformance")}s.length>0&&(m("Retrieve exchange rates: "+s.join(",")),c("yahoo.finance.xchange","pair IN "+n(s),null)),l.length>0&&(m("Retrieve static charts: "+l.join(",")),i(l)),d.length>0&&(m("Retrieve news: "+d.join(",")),c("feed",'url = "'+y+d[0].replace("^","%5E")+'"',d[0]))}function n(t){return'("'+t.join('","')+'")'}function i(e){var n="staticChart",i="",o="",a="",l="",d="",u="",h="";t.each(e,function(e,c){h=c,c=c.replace(/(:|\^|\.|\[|\]|,|=)/g,"\\$1"),i=".sm-widget-"+n+"-"+c,t(i).each(function(){o=t(this).data("size")?M[t(this).data("size")]:"m",a=t(this).data("chart-type")?q[t(this).data("chart-type")]:"l",l=t(this).data("timeframe")?t(this).data("timeframe"):"3m",d="on"==t(this).data("logscale")?"on":"off",u="http://chart.finance.yahoo.com/z?s="+h+"&t="+l+"&q="+a+"&z="+o+"&l="+d,m(i,u),t(this).append('')}),t(i).find(".sm-static-chart-img").one("load",function(){r(".sm-widget-"+n+"-"+c),s(".sm-widget-"+n+"-"+c)})})}function o(e){t(e).data("loader")&&0==t(e).find(".sm-loader").length&&t(e).prepend('
')}function r(e){t(e).find(".sm-loader").removeClass("active")}function a(e){t(e).data("transition")&&t(e).addClass("transition hidden")}function s(e){t(e).data("transition")&&t(e).transition({animation:t(e).data("transition"),duration:"1s"})}function l(e,n){var i,o={};return t.isArray(n)||(n=[n]),t.each(n,function(n,r){if("string"==typeof e)i=r[e];else if("object"==typeof e){var a=[];t.each(e,function(t,e){a.push(r[e])}),i=a.join("-")}o[i]=r}),o}function d(e,n){t.each(n,function(n,i){var o="",a="",s="",l="",d="";n=n.replace(/(:|\^|\.|\[|\]|,|=)/g,"\\$1"),t(".sm-widget-"+e+"-"+n+" .sm-data-property").each(function(e,n){o=t(n).data("property"),a=t(n).data("callback"),s=t(n).data("callback-arguments")?t(n).data("callback-arguments").toString().split(","):"",o&&(null!==i[o]?a?(d=window[a],l=s?d(i[o],s):d(i[o])):l=i[o]:l="N/A",t(n).text(l))});var u=".sm-widget-"+e+"-"+n;if("quote"==e&&"undefined"!=typeof i.Change){var h="";parseFloat(i.Change)>0?h="up green":parseFloat(i.Change)<0&&(h="down red"),t(".sm-widget-"+e+"-"+n).find(".arrow, .caret").addClass(h)}t(".sm-widget-"+e+"-"+n).each(function(e,n){r(u),t(n).data("transition")&&t(n).transition({animation:t(n).data("transition"),duration:"1s"})})})}function u(e,n){var i=t(".sm-widget-news"),o=parseInt(i.data("count"))>0?parseInt(i.data("count")):null,a=1;t.each(n,function(t,e){if(t=t.replace(/(:|\^|\.|\[|\]|,|=)/g,"\\$1"),"undefined"!=typeof e.description){if(i.append("

"+e.title+"

"),i.append('
'+e.pubDate+"
"),i.append('
'+(null==e.description?"":e.description)+"
"),i.append(''),null!==o&&a>=o)return!1;a++}}),r(".sm-widget-news")}function h(e,n){var i={};return i[e]={},t.each(n,function(t,o){(0==t||t%2==0&&"undefined"!=typeof n[t+1])&&(i[e][o.content.replace(/\s*\(.+\)/g,"").slice(0,-1)]="undefined"==typeof n[t+1].span?n[t+1].content:n[t+1].span.content)}),i}function c(e,n,i){var o=String.format(g,encodeURIComponent(String.format(v,e,n)));t.ajax({url:o,dataType:"json",async:!0,context:{yqlTable:e,contextId:i},success:f,error:p})}function f(e,n,i){var o=this.yqlTable,r=this.contextId,a=null,s=null;if("undefined"!=typeof e.query.results&&e.query.count>0){if(a=e.query.results[Object.keys(e.query.results)[0]],"feed"==o)s=l(w[o],a),u(x[o],s);else if("yahoo.finance.quotes"==o||"yahoo.finance.xchange"==o)s=l(w[o],a),d(x[o],s);else if("html"==o)s=h(r,a),d(x[o],s);else if("query.multi"==o&&"historicalPerformance"==r&&2==e.query.count&&"undefined"!=typeof e.query.results.results){var c=l("Symbol",e.query.results.results[1].quote),f=l(["Symbol","Date"],e.query.results.results[0].quote);t.each(f,function(e,n){t.extend(n,c[n.Symbol]),n.historicalPrice=parseFloat(n.Adj_Close),n.historicalPerformance=n.LastTradePriceOnly-n.historicalPrice,n.historicalPerformancePercent=(n.LastTradePriceOnly-n.historicalPrice)/n.historicalPrice*100}),d("historicalPerformance",f)}m(o,s)}else m("smYqlQuerySuccess, no data for "+o,e)}function p(t,e,n){m("smYqlQueryError",e+"|"+n)}function m(t,e){S&&("undefined"!=typeof e?console.log(t,e):console.log(t))}t(document).ready(e);var g="https://query.yahooapis.com/v1/public/yql?q={0}&format=json&env=store%3A%2F%2Fdatatables.org%2Falltableswithkeys",v="select * from {0} where {1}",y="http://finance.yahoo.com/rss/industry?s=",b="http://finance.yahoo.com/q/ks?s={0}+Key+Statistics",w={"yahoo.finance.quotes":"Symbol","yahoo.finance.xchange":"id",feed:"pubDate","yahoo.finance.historicaldata":"Symbol"},x={"yahoo.finance.quotes":"quote","yahoo.finance.xchange":"currency",feed:"news",html:"stats"},M={small:"s",medium:"m",large:"l"},q={line:"l",bar:"b",candle:"c"},S=!1;window.smYqlRunQuery=c,String.format||(String.format=function(t){var e=Array.prototype.slice.call(arguments,1);return t.replace(/{(\d+)}/g,function(t,n){return"undefined"!=typeof e[n]?e[n]:t})})}(jQuery),function(t){t.fn.marquee=function(e){function n(t,e,n){var i=n.behavior,o=n.width,r=n.dir,a=0;return a="alternate"==i?1==t?e[n.widthAxis]-2*o:o:"slide"==i?-1==t?-1==r?e[n.widthAxis]:o:-1==r?e[n.widthAxis]-2*o:0:-1==t?e[n.widthAxis]:0}function i(){for(var e=o.length,r=null,a=null,s={},l=[],d=!1;e--;)r=o[e],a=t(r),s=a.data("marqueeState"),a.data("paused")!==!0?(r[s.axis]+=s.scrollamount*s.dir,d=-1==s.dir?r[s.axis]<=n(-1*s.dir,r,s):r[s.axis]>=n(-1*s.dir,r,s),"scroll"==s.behavior&&s.last==r[s.axis]||"alternate"==s.behavior&&d&&-1!=s.last||"slide"==s.behavior&&d&&-1!=s.last?("alternate"==s.behavior&&(s.dir*=-1),s.last=-1,a.trigger("stop"),s.loops--,0===s.loops?("slide"!=s.behavior?r[s.axis]=n(s.dir,r,s):r[s.axis]=n(-1*s.dir,r,s),a.trigger("end")):(l.push(r),a.trigger("start"),r[s.axis]=n(s.dir,r,s))):l.push(r),s.last=r[s.axis],a.data("marqueeState",s)):l.push(r);o=l,o.length&&setTimeout(i,25)}var o=[],r=this.length;return this.each(function(a){var s=t(this),l=s.attr("width")||s.width(),d=s.attr("height")||s.height(),u=s.after("
'+s.html()+"
").next(),h=u.get(0),c=(s.attr("direction")||"left").toLowerCase(),f={dir:/down|right/.test(c)?-1:1,axis:/left|right/.test(c)?"scrollLeft":"scrollTop",widthAxis:/left|right/.test(c)?"scrollWidth":"scrollHeight",last:-1,loops:s.attr("loop")||-1,scrollamount:s.attr("scrollamount")||this.scrollAmount||2,behavior:(s.attr("behavior")||"scroll").toLowerCase(),width:/left|right/.test(c)?l:d};-1==s.attr("loop")&&"slide"==f.behavior&&(f.loops=1),s.remove(),/left|right/.test(c)?u.find("> div").css("padding","0 "+l+"px"):u.find("> div").css("padding",d+"px 0"),u.bind("stop",function(){u.data("paused",!0)}).bind("pause",function(){u.data("paused",!0)}).bind("start",function(){u.data("paused",!1)}).bind("unpause",function(){u.data("paused",!1)}).data("marqueeState",f),o.push(h),h[f.axis]=n(f.dir,h,f),u.trigger("start"),a+1==r&&i()}),t(o)}}(jQuery),function(){var t,e,n,i,o,r,a,s,l,d,u,h,c,f,p,m,g,v,y,b,w,x,M,q,S,T,E,D,C,A,L,j,k=[].slice;g='',f=''+g+"",i='8'+f+"",a='',n="(,ddd).dd",s=/^\(?([^)]*)\)?(?:(.)(d+))?$/,l=30,r=2e3,t=20,d=2,o=.5,u=1e3/l,e=1e3/t,p="transitionend webkitTransitionEnd oTransitionEnd otransitionend MSTransitionEnd",S=document.createElement("div").style,m=null!=S.transition||null!=S.webkitTransition||null!=S.mozTransition||null!=S.oTransition,M=window.requestAnimationFrame||window.mozRequestAnimationFrame||window.webkitRequestAnimationFrame||window.msRequestAnimationFrame,h=window.MutationObserver||window.WebKitMutationObserver||window.MozMutationObserver,y=function(t){var e;return e=document.createElement("div"),e.innerHTML=t,e.children[0]},x=function(t,e){return t.className=t.className.replace(new RegExp("(^| )"+e.split(" ").join("|")+"( |$)","gi")," ")},v=function(t,e){return x(t,e),t.className+=" "+e},T=function(t,e){var n;return null!=document.createEvent?(n=document.createEvent("HTMLEvents"),n.initEvent(e,!0,!0),t.dispatchEvent(n)):void 0},w=function(){var t,e;return null!=(t=null!=(e=window.performance)&&"function"==typeof e.now?e.now():void 0)?t:+new Date},q=function(t,e){return null==e&&(e=0),e?(t*=Math.pow(10,e),t+=.5,t=Math.floor(t),t/=Math.pow(10,e)):Math.round(t)},E=function(t){return 0>t?Math.ceil(t):Math.floor(t)},b=function(t){return t-q(t)},C=!1,(D=function(){var t,e,n,i,o;if(!C&&null!=window.jQuery){for(C=!0,i=["html","text"],o=[],e=0,n=i.length;n>e;e++)t=i[e],o.push(function(t){var e;return e=window.jQuery.fn[t],window.jQuery.fn[t]=function(t){var n;return null==t||null==(null!=(n=this[0])?n.odometer:void 0)?e.apply(this,arguments):this[0].odometer.update(t)}}(t));return o}})(),setTimeout(D,0),c=function(){function t(e){var n,i,o,a,s,l,h,c,f,p,m=this;if(this.options=e,this.el=this.options.el,null!=this.el.odometer)return this.el.odometer;this.el.odometer=this,c=t.options;for(i in c)a=c[i],null==this.options[i]&&(this.options[i]=a);null==(s=this.options).duration&&(s.duration=r),this.MAX_VALUES=this.options.duration/u/d|0,this.resetFormat(),this.value=this.cleanValue(null!=(f=this.options.value)?f:""),this.renderInside(),this.render();try{for(p=["innerHTML","innerText","textContent"],l=0,h=p.length;h>l;l++)o=p[l],null!=this.el[o]&&!function(t){return Object.defineProperty(m.el,t,{get:function(){var e;return"innerHTML"===t?m.inside.outerHTML:null!=(e=m.inside.innerText)?e:m.inside.textContent},set:function(t){return m.update(t)}})}(o)}catch(g){n=g,this.watchForMutations()}}return t.prototype.renderInside=function(){return this.inside=document.createElement("div"),this.inside.className="odometer-inside",this.el.innerHTML="",this.el.appendChild(this.inside)},t.prototype.watchForMutations=function(){var t,e=this;if(null!=h)try{return null==this.observer&&(this.observer=new h(function(t){var n;return n=e.el.innerText,e.renderInside(),e.render(e.value),e.update(n)})),this.watchMutations=!0,this.startWatchingMutations()}catch(n){t=n}},t.prototype.startWatchingMutations=function(){return this.watchMutations?this.observer.observe(this.el,{childList:!0}):void 0},t.prototype.stopWatchingMutations=function(){var t;return null!=(t=this.observer)?t.disconnect():void 0},t.prototype.cleanValue=function(t){var e;return"string"==typeof t&&(t=t.replace(null!=(e=this.format.radix)?e:".",""),t=t.replace(/[.,]/g,""),t=t.replace("","."),t=parseFloat(t,10)||0),q(t,this.format.precision)},t.prototype.bindTransitionEnd=function(){var t,e,n,i,o,r,a=this;if(!this.transitionEndBound){for(this.transitionEndBound=!0,e=!1,o=p.split(" "),r=[],n=0,i=o.length;i>n;n++)t=o[n],r.push(this.el.addEventListener(t,function(){return e?!0:(e=!0,setTimeout(function(){return a.render(),e=!1,T(a.el,"odometerdone")},0),!0)},!1));return r}},t.prototype.resetFormat=function(){var t,e,i,o,r,a,l,d;if(t=null!=(l=this.options.format)?l:n,t||(t="d"),i=s.exec(t),!i)throw new Error("Odometer: Unparsable digit format");return d=i.slice(1,4),a=d[0],r=d[1],e=d[2],o=(null!=e?e.length:void 0)||0,this.format={repeating:a,radix:r,precision:o}},t.prototype.render=function(t){var e,n,i,o,r,a,s,l,d,u,h,c;for(null==t&&(t=this.value),this.stopWatchingMutations(),this.resetFormat(),this.inside.innerHTML="",a=this.options.theme,e=this.el.className.split(" "),r=[],l=0,u=e.length;u>l;l++)n=e[l],n.length&&((o=/^odometer-theme-(.+)$/.exec(n))?a=o[1]:/^odometer(-|$)/.test(n)||r.push(n));for(r.push("odometer"),m||r.push("odometer-no-transitions"),a?r.push("odometer-theme-"+a):r.push("odometer-auto-theme"),this.el.className=r.join(" "),this.ribbons={},this.digits=[],s=!this.format.precision||!b(t)||!1,c=t.toString().split("").reverse(),d=0,h=c.length;h>d;d++)i=c[d],"."===i&&(s=!0),this.addDigit(i,s);return this.startWatchingMutations()},t.prototype.update=function(t){var e,n=this;return t=this.cleanValue(t),(e=t-this.value)?(x(this.el,"odometer-animating-up odometer-animating-down odometer-animating"),e>0?v(this.el,"odometer-animating-up"):v(this.el,"odometer-animating-down"),this.stopWatchingMutations(),this.animate(t),this.startWatchingMutations(),setTimeout(function(){return n.el.offsetHeight,v(n.el,"odometer-animating")},0),this.value=t):void 0},t.prototype.renderDigit=function(){return y(i)},t.prototype.insertDigit=function(t,e){return null!=e?this.inside.insertBefore(t,e):this.inside.children.length?this.inside.insertBefore(t,this.inside.children[0]):this.inside.appendChild(t)},t.prototype.addSpacer=function(t,e,n){var i;return i=y(a),i.innerHTML=t,n&&v(i,n),this.insertDigit(i,e)},t.prototype.addDigit=function(t,e){var n,i,o,r;if(null==e&&(e=!0),"-"===t)return this.addSpacer(t,null,"odometer-negation-mark");if("."===t)return this.addSpacer(null!=(r=this.format.radix)?r:".",null,"odometer-radix-mark");if(e)for(o=!1;;){if(!this.format.repeating.length){if(o)throw new Error("Bad odometer format without digits");this.resetFormat(),o=!0}if(n=this.format.repeating[this.format.repeating.length-1],this.format.repeating=this.format.repeating.substring(0,this.format.repeating.length-1),"d"===n)break;this.addSpacer(n)}return i=this.renderDigit(),i.querySelector(".odometer-value").innerHTML=t,this.digits.push(i),this.insertDigit(i)},t.prototype.animate=function(t){return m&&"count"!==this.options.animation?this.animateSlide(t):this.animateCount(t)},t.prototype.animateCount=function(t){var n,i,o,r,a,s=this;if(i=+t-this.value)return r=o=w(),n=this.value,(a=function(){var l,d,u;return w()-r>s.options.duration?(s.value=t,s.render(),void T(s.el,"odometerdone")):(l=w()-o,l>e&&(o=w(),u=l/s.options.duration,d=i*u,n+=d,s.render(Math.round(n))),null!=M?M(a):setTimeout(a,e))})()},t.prototype.getDigitCount=function(){var t,e,n,i,o,r;for(i=1<=arguments.length?k.call(arguments,0):[],t=o=0,r=i.length;r>o;t=++o)n=i[t],i[t]=Math.abs(n);return e=Math.max.apply(Math,i),Math.ceil(Math.log(e+1)/Math.log(10))},t.prototype.getFractionalDigitCount=function(){var t,e,n,i,o,r,a;for(o=1<=arguments.length?k.call(arguments,0):[],e=/^\-?\d*\.(\d*?)0*$/,t=r=0,a=o.length;a>r;t=++r)i=o[t],o[t]=i.toString(),n=e.exec(o[t]),null==n?o[t]=0:o[t]=n[1].length;return Math.max.apply(Math,o)},t.prototype.resetDigits=function(){return this.digits=[],this.ribbons=[],this.inside.innerHTML="",this.resetFormat()},t.prototype.animateSlide=function(t){var e,n,i,r,a,s,l,d,u,h,c,f,p,m,g,y,b,w,x,M,q,S,T,D,C,A,L;if(y=this.value,d=this.getFractionalDigitCount(y,t),d&&(t*=Math.pow(10,d),y*=Math.pow(10,d)),i=t-y){for(this.bindTransitionEnd(),r=this.getDigitCount(y,t),a=[],e=0,c=x=0;r>=0?r>x:x>r;c=r>=0?++x:--x){if(b=E(y/Math.pow(10,r-c-1)),l=E(t/Math.pow(10,r-c-1)),s=l-b,Math.abs(s)>this.MAX_VALUES){for(h=[],f=s/(this.MAX_VALUES+this.MAX_VALUES*e*o),n=b;s>0&&l>n||0>s&&n>l;)h.push(Math.round(n)),n+=f;h[h.length-1]!==l&&h.push(l),e++}else h=function(){L=[];for(var t=b;l>=b?l>=t:t>=l;l>=b?t++:t--)L.push(t);return L}.apply(this);for(c=M=0,S=h.length;S>M;c=++M)u=h[c],h[c]=Math.abs(u%10);a.push(h)}for(this.resetDigits(),A=a.reverse(),c=q=0,T=A.length;T>q;c=++q)for(h=A[c],this.digits[c]||this.addDigit(" ",c>=d),null==(w=this.ribbons)[c]&&(w[c]=this.digits[c].querySelector(".odometer-ribbon-inner")),this.ribbons[c].innerHTML="",0>i&&(h=h.reverse()),p=C=0,D=h.length;D>C;p=++C)u=h[p],g=document.createElement("div"),g.className="odometer-value",g.innerHTML=u,this.ribbons[c].appendChild(g),p===h.length-1&&v(g,"odometer-last-value"),0===p&&v(g,"odometer-first-value");return 0>b&&this.addDigit("-"),m=this.inside.querySelector(".odometer-radix-mark"),null!=m&&m.parent.removeChild(m),d?this.addSpacer(this.format.radix,this.digits[d-1],"odometer-radix-mark"):void 0}},t}(),c.options=null!=(L=window.odometerOptions)?L:{},setTimeout(function(){var t,e,n,i,o;if(window.odometerOptions){i=window.odometerOptions,o=[];for(t in i)e=i[t],o.push(null!=(n=c.options)[t]?(n=c.options)[t]:n[t]=e);return o}},0),c.init=function(){var t,e,n,i,o,r;if(null!=document.querySelectorAll){for(e=document.querySelectorAll(c.options.selector||".odometer"),r=[],n=0,i=e.length;i>n;n++)t=e[n],r.push(t.odometer=new c({el:t,value:null!=(o=t.innerText)?o:t.textContent}));return r}},null!=(null!=(j=document.documentElement)?j.doScroll:void 0)&&null!=document.createEventObject?(A=document.onreadystatechange,document.onreadystatechange=function(){return"complete"===document.readyState&&c.options.auto!==!1&&c.init(),null!=A?A.apply(this,arguments):void 0}):document.addEventListener("DOMContentLoaded",function(){return c.options.auto!==!1?c.init():void 0},!1),"function"==typeof define&&define.amd?define(["jquery"],function(){return c}):typeof exports===!1?module.exports=c:window.Odometer=c}.call(this),function(t){t.tablesort=function(e,n){var i=this;this.$table=e,this.$thead=this.$table.find("thead"),this.settings=t.extend({},t.tablesort.defaults,n),this.$table.find("th").bind("click.tablesort",function(){i.sort(t(this))}),this.index=null,this.$th=null,this.direction=null},t.tablesort.prototype={sort:function(e,n){var i=new Date,o=this,r=this.$table,a=this.$thead.length>0?r.find("tbody tr"):r.find("tr").has("td"),s=r.find("tr td:nth-of-type("+(e.index()+1)+")"),l=e.data().sortBy,d=[],u=s.map(function(n,i){return l?"function"==typeof l?l(t(e),t(i),o):l:null!=t(this).data().sortValue?t(this).data().sortValue:t(this).text()});if(0!==u.length){o.$table.find("th").removeClass(o.settings.asc+" "+o.settings.desc),"asc"!==n&&"desc"!==n?this.direction="asc"===this.direction?"desc":"asc":this.direction=n,n="asc"==this.direction?1:-1,o.$table.trigger("tablesort:start",[o]),o.log("Sorting by "+this.index+" "+this.direction);for(var h=0,c=u.length;c>h;h++)d.push({index:h,cell:s[h],row:a[h],value:u[h]});d.sort(function(t,e){return t.value>e.value?1*n:t.value