﻿/* GuildPortal Widget modifications
 * by Rob G (Mottie) 2011
 * mottie.guildportal.com
 * Dual licensed under the MIT or GPL Version 2
 */
function hideNewEvents(b){var a,c,e,d,g,f;f={hideNewMonths:3,hideUser:!0};$.extend(f,b);b=$(".gpWidget-eventsml").find(".StyledList");b.length&&(f.hideUser&&b.find("span.SmallDisplay a").parent().hide(),c=["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"],e=0,d=new Date,d.setDate(d.getDate()+f.hideNewMonths*31),b.find(".ActiveDiv").each(function(){a=$(this).find("span.SmallDisplay").html();a=a.substring(0,a.lastIndexOf("<br")).split(" ");g=new Date(parseInt(a[2],10)+2E3,c.indexOf(a[0]), 1);g>d&&(e++,$(this).hide())}),f=b.parent().find("b:last"),isNaN(f.text())||f.text((parseInt(f.text(),10)||0)+e),f=parseInt(b.parent().text().match(/\d+ shown/),10),b.parent().html(b.parent().html().replace(f+" shown",f-e+" shown")))} function showSignups(b){if(!($(".gpWidget-eventsml").length<1&&$(".gpWidget-calendar").length<1)){var a={loadingImage:"http://i201.photobucket.com/albums/aa236/Mottie1/testsite/icons/loading6.gif",tooltipDelay:300,tooltipWidth:500,hideStatus:!1,hideRole:!1,hideSignedUp:!1,hideAdmin:!0,showTotal:!1,styleRow:!1};$.extend(a,b);var c=function(){setTimeout(function(){$(".fc-event a[href*=EventToView]").removeAttr("title").bind("mouseover",function(){showSignups2(a,this)}).bind("mouseout",function(){$("#tooltip").remove()})}, a.tooltipDelay*2)};$(window).load(function(){$(".gpWidget-eventsml a[href*=EventToView]").attr("rel",a.tooltipWidth).addClass("tooltip").bind("mouseover",function(){showSignups2(a,this,!0)});$(".gpWidget-calendar").length&&(c(),$(".fc").find(".fc-header").bind("click",function(){c()}))})}} function showSignups2(b,a,c){var e=a.href;setTimeout(function(){var d=$("#tooltip").length?$("#tooltip"):$("<div/>");d.html('<div class="signups" style="text-align:center;display:block;"><img src="'+b.loadingImage+'" /></div>');e=e.substring(e.lastIndexOf("/Guild.aspx"),e.length);d.find(".signups").load(e+" div[id*=signupsHolder] table",function(){b.showTotal?d.find("tr:first td").html('<span style="float:right">Total: '+(d.find("tr").length-2)+"</span>"):d.find("tr:first").hide();var a=[];b.hideStatus&& a.push("td:nth-child(2)");b.hideRole&&a.push("td:nth-child(3)");b.hideSignedUp&&a.push("td:nth-child(4)");b.hideAdmin&&a.push("td:nth-child(5)");d.find(a.join(",")).hide();d.find("tr:gt(1)").each(function(){var a=$(this).find("td:eq(1)");b.styleRow?$(this).find("td").addClass(a.text().replace("-","")):a.addClass(a.text().replace("-",""))});if(d.find("tr").length===0)b.tooltipWidth=250,d.width(250).html("<center>No Signups Found</center>");c||(ddrivetip(d.html(),"",b.tooltipWidth),$(document).trigger("mousemove"))})}, b.tooltipDelay)} function addStatusIcon(b,a){var c={tooltipWidth:150,noStatusText:"Not Found"};$.extend(c,b);var e={Alternate:"http://www.axiomfiles.com/Files/278466/icon-status-alternate.png",Available:"http://www.axiomfiles.com/Files/278466/icon-status-available.png",Cancelled:"http://www.axiomfiles.com/Files/278466/icon-status-cancelled.png",Confirmed:"http://www.axiomfiles.com/Files/278466/icon-status-confirmed.png",Tentative:"http://www.axiomfiles.com/Files/278466/icon-status-tentative.png","Wait-List":"http://www.axiomfiles.com/Files/278466/icon-status-waitlist.png",undefined:"http://www.axiomfiles.com/Files/278466/icon-status-notfound.png"}; $.extend(e,a);if(!($(".gpWidget-eventsml").length<1)){var d,g,f,h=$(".gpWidget-eventsml").find("a[href*=EventToView]"),i;h.length&&(i="Guild.aspx?GuildID="+getGroupId()+"&TabID="+gup("TabID",h[0].href)+"&Action=calViewMyUpcoming",$("body").append('<div id="upcomingevents" style="display:none;"></div>'),$("#upcomingevents").load(i+" div.gpWidget-calendar",function(){var a=$("#upcomingevents");a.find("a[id*=lnkEventTitle]").length<1||h.each(function(){g=gup("EventToView",$(this).attr("href"));d=a.find("a[id*=lnkEventTitle][href*="+ g+"]:first").closest("tr").find("span[id*=lblFormattedStatus]").text();typeof d==="undefined"||d===""?(d=c.noStatusText,f=e.undefined):f=e[d];g='<img src="'+f+'" class="event-status-icon tooltip" title="Status: '+d+'" rel="'+c.tooltipWidth+'" />';$(this).before(g)})}))}} function modifyRecentPosts(){var b,a,c=$(".gpWidget-mostrecentposts");if(c.length){var e=[];c.find(".NormGridRow").length?(a=c.find(".NormGridRow, .AltGridRow"),a.each(function(){var a=$(this).find("td:eq(0) a").html().replace(/\W/g,"").replace(/\s/g,"").replace(/^RE/,"");$(this).attr("data-title",a);e.push(a.replace(/^re/gi,""))}),b=e.getUnique(),$.each(b,function(b,c){a.filter('[data-title="'+c+'"]:gt(0)').hide()}),c.find(".blkContent").find("tr").removeClass("AltGridRow NormGridRow").end().find("tr:visible:odd").addClass("NormGridRow").end().find("tr:visible:even").addClass("AltGridRow")): (c.find("br").hide(),c.find(".SmallDisplay").css("padding-bottom","10px"),a=c.find("a"),a.each(function(){var a=$(this).html().replace(/\W/g,"").replace(/\s/g,"");$(this).attr("data-title",a);e.push(a.replace(/^re/gi,""))}),b=e.getUnique(),$.each(b,function(b,c){a.filter('[data-title*="'+c+'"]:gt(0)').next().andSelf().hide()}),c.find("a:contains(RSS)").show())}} Array.prototype.getUnique=function(b){var a,c=[],e={},d,g=0,f=this.length;for(d=0;d<f;++d)a=this[d],e[a]||(e[a]={},c[g++]=a);return b?c.sort():c};if(!Array.prototype.indexOf)Array.prototype.indexOf=function(b,a){var c,e=this.length;for(c=a||0;c<e;c++)if(this[c]==b)return c;return-1};function gup(b,a){var b=b.replace(/[\[]/,"\\[").replace(/[\]]/,"\\]"),c=RegExp("[\\?&]"+b+"=([^&#]*)").exec(a);return c===null?"":c[1]};

