jQuery(function($){$.fn.displayHistory=function(points,username){this.container=$(document.documentElement)
$("<div>",{'class':'lws-history-shadow','tabIndex':'-1'}).append($("<div>",{'class':'lws-history-wrapper',}).append($("<div>",{'class':'lws-history-top-line',}).append($("<div>",{'class':'lws-history-title','html':lws_wr_userspoints_labels.hist})).append($("<div>",{'class':'lws-history-user','html':username})).append($("<div>",{'class':'lws-history-close lws-icon lws-icon-cross',}))).append($("<div>",{'class':'lws-history-content',}))).appendTo(this.container);this.wrapper=this.container.find(".lws-history-wrapper");this.contentContainer=this.container.find(".lws-history-content");var html="<table class='lws-history-content-table'><tr><th>"+lws_wr_userspoints_labels.desc+"</th>";html+="<th>"+lws_wr_userspoints_labels.date+"</th><th>"+lws_wr_userspoints_labels.points+"</th><th>"+lws_wr_userspoints_labels.total+"</th>";for(var i=0;i<points.length;i++){if(points[i].op_value==null)points[i].op_value='n/a';html+='<tr>';html+='<td>'+points[i].op_reason+'</td>';html+='<td title="'+points[i].op_datetime+'" class="date">'+points[i].op_date+'</td>';html+='<td class="number">'+points[i].op_value+'</td>';html+='<td class="number">'+points[i].op_result+'</td>';html+='</tr>'}
html+='</table>';this.contentContainer.html(html);this.wrapper.css('left',((this.container.width()-this.wrapper.outerWidth())/2));this.wrapper.css('top',((this.container.height()-this.wrapper.outerHeight())/2));this.container.on('click','.lws-history-shadow',"",function(event){var target=$(event.originalEvent.target);if(target.hasClass('lws-history-shadow')||target.hasClass('lws-history-close')){$(this).remove()}})}
$(".lws_wre_point_history").on('click',function(){$(this).css('color','darkblue');var username=$(this).closest('.lws-editlist-row').find('.lws_wre_history_dispname').html();$.getJSON(lws_ajax.url,{action:'lws_woorewards_user_points_history',stack:$(this).data('stack'),user:$(this).data('user')},function(points){$(this).displayHistory(points,username)}).fail(function(d,textStatus,error){console.log("["+d.status+"] "+d.responseText)})})})