jquery-eclipsefdn-api
Advanced tools
Comparing version 0.0.42 to 0.0.43
/* | ||
* jquery-eclipsefdn-api - v0.0.42 | ||
* jquery-eclipsefdn-api - v0.0.43 | ||
* Fetch and display data from various Eclipse Foundation APIs. | ||
@@ -11,2 +11,2 @@ * https://github.com/EclipseFdn/jquery-eclipsefdn-api | ||
*/ | ||
!function(e,t,a,n){"use strict";var r="eclipseFdnApi",s={apiUrl:"https://api.eclipse.org",gerritUrl:"https://git.eclipse.org/r",eventUrl:"https://newsroom.eclipse.org/api/events",adsUrl:"https://newsroom.eclipse.org/api/ads",forumsUrl:"https://www.eclipse.org/forums",marketplaceUrl:"https://marketplace.eclipse.org",username:"cguindon",currentUser:"",contentPlaceholder:null,errorMsg:'<i class="fa red fa-exclamation-triangle" aria-hidden="true"></i> An unexpected error has occurred.',gerritUserNotFoundMsg:'<h2 class="h3">Outgoing Reviews</h2>There are no outgoing reviews for this user.<h2 class="h3">Incoming Reviews</h2>There are no incoming reviews for this account.',type:"",itemsPerPage:10,accountsUrl:"https://accounts.eclipse.org",newsroomUrl:"https://newsroom.eclipse.org/api",featuredContent:{},featuredContentType:""};function i(t,a){this.element=t,this.settings=e.extend({},s,a),this._defaults=s,this._name=r,this.init()}e.extend(i.prototype,{init:function(){"string"===e.type(this.settings.type)&&-1!==e.inArray(this.settings.type,["mpFavorites","gerritReviews","recentEvents","forumsMsg","gerritReviewCount","projectsList","errorReports","mailingListSubscription","newsItems","filteredEvents","featuredStory","featuredFooter","customFeaturedContent","allPromos","singlePromo"])&&this[this.settings.type]()},errorReports:function(){var t,n=this,r=n.element,s=!1,i="Unable to retrieve account information required to process this request.",o="Authorization to retrieve error reports was denied.",l=n.settings.apiUrl+"/account/profile/"+n.settings.username,p={clientName:"aeriReports",apiUrl:"https://dev.eclipse.org",completeOnAuthorization:!1,username:n.settings.username,encodeStorage:!0},c="/recommenders/community/aeri/v2/api/v1/reporters/",d="/problems",u={path:"",method:"GET",cid:"aeri_reports",scope:"eclipse_aeri_view_own_report email openid",successCallback:"",errorCallback:function(e){switch(e.status){case 404:g("No submissions found.");break;default:g()}}};function g(t,a){"boolean"!=typeof a&&(a=!1),void 0===t&&(t=n.settings.errorMsg),a&&(t=n.settings.errorMsg+t);var r=e("<p></p>").append(t);e(n.element).append(r)}function h(r,s,i){!function(r,s){void 0===r&&(r=1);void 0===s&&(s=n.settings.itemsPerPage);u.path=c+t+d+"?page="+r+"&size="+s,u.successCallback=function(e){addReportRows(e)},e(a).eclipseFdnIgc.makeRequest(u)}(s,i)}e(a).on("igcAuthFailed",function(e,t){t.clientName===p.clientName&&(g(o),s=!0)}),e(r).eclipseFdnIgc(p),s||e.ajax({url:l,context:n.element}).done(function(l){void 0!==l.mail?(t=l.mail,s?g(o):(u.path=c+t+d+"?page=1&size="+n.settings.itemsPerPage,u.successCallback=function(t,a,s){!function(t){var a=e("<table></table>").attr({width:"100%",class:"table",id:"aeri-reports"}),n=e("<tr></tr>"),s=e("<th></th>");n.append(s.clone().text("Title").attr("width","50%")),n.append(s.clone().text("Status").attr({width:"10%",class:"text-center"})),n.append(s.clone().text("Resolution").attr({width:"10%",class:"text-center"})),n.append(s.clone().text("Reporters").attr({width:"10%",class:"text-center"})),n.append(s.clone().text("Your First Report").attr({width:"20%",class:"text-center"})),a.append(n);var i=e("<div></div>").attr({class:"table-responsive"});i.append(a),e(r).append(i),e.each(t,function(t,n){var r,s=e("<tr></tr>"),i=e("<td></td>"),o=e("<a></a>"),l=e("<ul></ul>"),p=e("<li></li>");o.attr("target","_blank"),e.each(n.links,function(e,t){"problem"===t.rel&&(r=o.clone().attr({href:t.href}).text(t.title)),"submission"===t.rel&&(t.title||(t.title="(No error message)"),l.append(p.clone().append(o.clone().attr({href:t.href}).html("<small>"+t.title+"</small>"))))}),s.append(i.clone().append(r).append(l).attr({class:"ellipsis white-space-normal",style:"max-width:200px;"})),s.append(i.clone().text(n.status).attr("class","text-center")),s.append(i.clone().text(n.resolution).attr("class","text-center"));var c=e("<span></span>").attr("class","badge");c.text(n.numberOfReporters),s.append(i.clone().append(c).attr("class","text-center"));var d=new Date(n.firstReported),u=d.getMonth()<10?"0"+d.getMonth():d.getMonth(),g=d.getDate()<10?"0"+d.getDate():d.getDate(),h=d.getFullYear()+"-"+u+"-"+g;s.append(i.clone().text(h).attr("class","text-center")),a.append(s)})}(t);var i=new n.linkHeaderParser(s.getResponseHeader("Link")),o=i.getLastPageNum();i.getPageSize()!==n.settings.itemsPerPage&&(n.settings.itemsPerPage=i.getPageSize()),e("#aeri-reports").on("fetchPageItemsEvent",h),e("#aeri-reports").data("postsPerPage",n.settings.itemsPerPage),e(r).append(n.getPaginationBar(o*n.settings.itemsPerPage,"aeri-reports"))},e(a).eclipseFdnIgc.makeRequest(u))):g(i,!0)}).fail(function(){g(i,!0)})},projectsList:function(){var t=this,a=this.settings.username,r=this.settings.apiUrl;if(!a&&!api_url)return!1;var s=r+"/account/profile/"+a+"/projects";e.ajax(s,{context:this.element,success:function(a){var r=Object.keys(a).length;if(r===n&&(r=0),e(this).children("strong").text(r+t.plurialString(" project",r)),!(t.settings.contentPlaceholder instanceof jQuery))return!1;var s=e(t.settings.contentPlaceholder),i=e("<a></a>");s.append(e("<h2></h2>").addClass("h3").text("Eclipse Projects")),s.append('<p>Projects are the organizational unit for open source development work at the Eclipse Foundation. Projects have developers (committers), source code repositories, build servers, downloads, and other resources. The Eclipse Foundation\'s open source projects are governed by the <a href="https://eclipse.org/projects/dev_process/">Eclipse Development Process</a>.</p>');var o="This user is";if(t.settings.currentUser===t.settings.username&&(o="You are"),0===r)return s.append('<div class="alert alert-warning" role="alert">'+o+" not involved in any Eclipse Projects.</div>"),!1;var l=e("<table></table>").attr({width:"100%",class:"table"}),p=e("<tr></tr>"),c=e("<th></th>"),d=e("<td></td>");p.append(c.clone().text("Project").attr("width","85%")),p.append(c.clone().text("Relation").attr({width:"15%",class:"text-center"})),l.append(p),e.each(a,function(a,n){var r=[],s="",o="";e.each(n,function(e,t){r.push(t.Relation.Description),s=t.ProjectName,o=t.ActiveDate,""!==t.url&&(s=i.clone().attr({href:t.url}).text(s))}),(p=e("<tr></tr>")).append(d.clone().html(s).append("<br/><small>Since: "+t.dateFormat(new Date(o))+"</small>")),p.append(d.clone().text(r.join(", ")).attr("class","text-center")),l.append(p)});var u=e("<div></div>").attr({class:"table-responsive"});u.append(l),s.append(u)},error:function(){e(this).html(t.settings.errorMsg)}})},forumsMsg:function(){var t=this,a=this.settings.username,r=this.settings.apiUrl;if(!a&&!api_url)return!1;var s=r+"/account/profile/"+a+"/forum?page=1&pagesize="+t.settings.itemsPerPage;function i(a){var n=e("#forum-posts");e.each(a.posts,function(r,s){var i={forum_id:s.thread_forum_id,forum_name:s.forum_name,forum_cat_id:s.forum_name,forum_cat_name:s.cat_name,root_subject:s.root_msg_subject,current_user_last_post_timestamp:s.msg_group_post_stamp,current_user_last_post_subject:s.last_user_msg_subject,thread_id:s.msg_thread_id,thread_reply_count:s.thread_replies,thread_views_count:s.thread_views,thread_last_post_date:s.thread_last_post_date,last_message_timestamp:s.last_msg_post_stamp,last_message_poster_id:s.last_msg_poster_id,last_message_poster_alias:s.last_poster_alias,last_message_last_view:s.read_last_view,current_user_id:a.id},o=e("<tr></tr>"),l=e("<td></td>"),p=e("<a></a>"),c=p.clone().attr({href:t.settings.forumsUrl+"/index.php/f/"+i.forum_id+"/"}).text(i.forum_name),d=p.clone().attr({href:t.settings.forumsUrl+"/index.php/i/"+i.forum_cat_id+"/"}).text(i.forum_cat_name),u=e("<small></small>").append("<br/>").append(d).append(" > ").append(c).append(" > ").append(i.root_subject).append("<br>Posted on "+t.dateFormat(new Date(parseInt(1e3*i.current_user_last_post_timestamp)))),g="fa fa-envelope-open-o";t.settings.currentUser===t.settings.username&&i.last_message_last_view<i.thread_last_post_date&&i.last_message_poster_id!==i.current_user_id&&(o.addClass("warning"),g="fa fa-envelope-o"),t.settings.currentUser===t.settings.username&&o.append(l.clone().html('<i class="'+g+'" aria-hidden="true"></i>').attr("class","text-center")),o.append(l.clone().html(p.clone().attr({href:t.settings.forumsUrl+"/index.php/t/"+i.thread_id+"/"}).text(i.current_user_last_post_subject)).append(u)),o.append(l.clone().text(i.thread_reply_count).attr("class","text-center")),o.append(l.clone().text(i.thread_views_count).attr("class","text-center"));var h=e("<small></small>").append(t.dateFormat(new Date(parseInt(1e3*i.last_message_timestamp)))).append("<br/> By: ").append(p.clone().attr({href:t.settings.forumsUrl+"/index.php/sp/"+i.last_message_poster_id+"/"}).text(i.last_message_poster_alias));o.append(l.clone().html(h).attr("class","text-center")),n.append(o)})}function o(n,s,o){!function(n,s){void 0===n&&(n=1);void 0===s&&(s=t.settings.itemsPerPage);var o=r+"/account/profile/"+a+"/forum?page="+n+"&pagesize="+s;e.ajax(o,{context:t.element,success:function(e){i(e)},error:function(){e(this).html(t.settings.errorMsg)}})}(s,o)}e.ajax(s,{context:this.element,success:function(a,r,s){var l=0;if(a.posted_msg_count!==n&&a.id!==n&&(l=a.posted_msg_count,e(this).attr({href:t.settings.forumsUrl+"/index.php/sp/"+a.id+"/"})),e(this).children("strong").text(l+t.plurialString(" topic",l)),!(t.settings.contentPlaceholder instanceof jQuery))return!1;var p=e(t.settings.contentPlaceholder),c=e("<a></a>");p.append(e("<h2></h2>").addClass("h3").text("Eclipse Forums")),p.append(e("<p></p>").append("The Eclipse forums are your way of communicating with the community of people developing and using Eclipse-based tools hosted at Eclipse.org. Please stick to technical issues - and remember, no confidential information - these are public forums!"));var d=c.clone().attr({href:t.settings.forumsUrl,class:"btn btn-primary btn-sm",style:"display:block"}).html('<i class="fa fa-angle-double-right" aria-hidden="true"></i> More');if(0===a.posts.length)return p.append('<div class="alert alert-warning" role="alert">This user does not have any activities on Eclipse Forums.</div>'),p.append(d),!1;var u=e("<table></table>").attr({width:"100%",class:"table",id:"forum-posts"}),g=e("<tr></tr>"),h=e("<th></th>");t.settings.currentUser===t.settings.username&&g.append(h.clone().attr("width","8%")),g.append(h.clone().text("Topics").attr("width","50%")),g.append(h.clone().text("Replies").attr({width:"8%",class:"text-center"})),g.append(h.clone().text("Views").attr({width:"8%",class:"text-center"})),g.append(h.clone().text("Last message").attr({class:"text-center"})),u.append(g);var f=e("<div></div>").attr({class:"table-responsive"});f.append(u),p.append(f),i(a);var m=new t.linkHeaderParser(s.getResponseHeader("Link")),v=m.getLastPageNum();m.getPageSize()!==t.settings.itemsPerPage&&(t.settings.itemsPerPage=m.getPageSize()),u.on("fetchPageItemsEvent",o),u.data("postsPerPage",t.settings.itemsPerPage),p.append(t.getPaginationBar(v*t.settings.itemsPerPage,"forum-posts"));var b=a.id;d.attr({href:t.settings.forumsUrl+"/index.php/sp/"+b+"/"}),p.append(d)},error:function(){e(this).html(t.settings.errorMsg)}})},mpFavorites:function(){var t=this,a=this.settings.username,n=this.settings.apiUrl;if(!a&&!api_url)return!1;if(t.settings.contentPlaceholder instanceof jQuery){var r=e(t.settings.contentPlaceholder),s=e("<a></a>").attr({href:t.settings.marketplaceUrl+"/user/"+a+"/favorites",class:"btn btn-primary btn-sm",style:"display:block"}).html('<i class="fa fa-angle-double-right" aria-hidden="true"></i> More');r.append(e("<h2></h2>").addClass("h3").text("Eclipse Marketplace Favorites")),r.append(e("<p></p>").append("Eclipse Marketplace is the source for Eclipse-based solutions, products and add-on features. Thousands of developers visit Marketplace on a monthly basis to find new and innovative solutions. Solution providers are encouraged to list their products on Marketplace to gain exposure to the Eclipse developer community."))}var i=n+"/marketplace/favorites?name="+a+"&page=1&pagesize="+t.settings.itemsPerPage;function o(a){var n=t.settings.marketplaceUrl+"/node/"+a+"/api/p";e.ajax(n,{context:t.element,success:function(a){var n=e("#mpfavorites-list");e("node",a).each(function(a,r){var s=e(r),i=s.find("shortdescription").text(),o=r.getAttribute("name"),l=s.find("changed").text(),p=s.find("owner").text(),c="Last Updated on "+t.dateFormat(new Date(parseInt(1e3*l)))+" by "+p,d=r.getAttribute("id"),u=e("#mp-listing-template").clone().removeClass("hidden").removeAttr("id"),g=e("<a></a>"),h=e("category",r),f=t.settings.marketplaceUrl+"/node/"+d,m=s.find("image").text(),v=g.clone().attr({href:f});h.each(function(e,t){var a=g.clone().attr({href:t.getAttribute("url")}).text(t.getAttribute("name"));h.length!==e+1&&a.append(", "),u.find(".content-categories").append(a)}),u.find(".listing-image").attr({href:f,style:"background:url('"+m+"') no-repeat center;"}),u.find(".drag").attr({href:t.settings.marketplaceUrl+"/marketplace-client-intro?mpc_install="+d}),u.find(".listing-title").html(v.clone().text(o)),u.find(".content-teaser").html(i),u.find(".content-last-updated").html(c),n.append(u)})},error:function(){e(this).html(t.settings.errorMsg)}})}function l(r,s,i){!function(r,s){void 0===r&&(r=1);void 0===s&&(s=t.settings.itemsPerPage);var i=n+"/marketplace/favorites?name="+a+"&page="+r+"&pagesize="+s;e.ajax(i,{context:t.element,success:function(t){var a=[];e.each(t.mpc_favorites,function(e,t){a.push(t.content_id)}),o(a.join())},error:function(){e(this).html(t.settings.errorMsg)}})}(s,i)}e.ajax(i,{context:this.element,success:function(a,n,i){if(e(this).children("strong").text(a.result.count+t.plurialString(" favorite",a.result.count)),void 0===r)return!1;var p=[];if(e.each(a.mpc_favorites,function(e,t){p.push(t.content_id)}),0===p.length)return r.append('<div class="alert alert-warning" role="alert">There are no marketplace favorites for this user.</div>'),r.append(s),!1;var c=new t.linkHeaderParser(i.getResponseHeader("Link")),d=c.getLastPageNum();c.getPageSize()!==t.settings.itemsPerPage&&(t.settings.itemsPerPage=c.getPageSize()),r.on("fetchPageItemsEvent",l),r.append('<h3 id="mpc_list_name">'+a.mpc_list_name+"</h3>"),r.append('<div class="row"><div class="col-md-17"><div class="form-item form-type-textfield form-disabled"><label>Favorites URL <a href="#" class="install-user-favorites" data-container="body" data-toggle="popover" data-placement="top" title="" data-original-title="How to install?"><i class="fa fa-question-circle" aria-hidden="true"></i></a> </label><input disabled="true" class="form-control form-text" type="text" value="http://marketplace.eclipse.org/user/'+t.settings.username+'/favorites" size="60" maxlength="128"></div></div><div class="col-md-7 margin-top-25 text-right"><div class="drag_installbutton drag_installbutton_v2 drag-install-favorites"><a href="http://marketplace.eclipse.org/user/'+t.settings.username+'/favorites" class="drag" title="How to install?"><span class="btn btn-default"><i class="fa fa-download orange"></i> Install Favorites</span><div class="tooltip tooltip-below-right"><h3>Drag to Install!</h3>Drag to your running Eclipse<sup>*</sup> workspace to install this favorite list. <br><sup>*</sup>Requires Eclipse Marketplace Client.</div></a></div></div></div>'),r.append('<div id="mpfavorites-list"></div>'),r.find("#mpfavorites-list").data("postsPerPage",t.settings.itemsPerPage),o(p.join()),r.append(t.getPaginationBar(d*t.settings.itemsPerPage,"mpfavorites-list")),r.append(s),e("a.install-user-favorites").on("click",function(e){e.preventDefault()}),e("a.install-user-favorites").popover({html:!0,content:function(){return e("<ol></ol>").addClass("padding-left-20").append("<li>Copy <strong>URL</strong> from textfield.</li>").append("<li>Open Eclipse Marketplace Client (MPC).</li>").append("<li>Open <strong>Favorites</strong> tab.</li>").append("<li>Click on <strong>Import Favorites list</strong>.</li>").append("<li>Paste <strong>URL</strong> in the textfield.</li>")}})},error:function(){e(this).html(t.settings.errorMsg)}})},gerritReviewCount:function(){var t=this,a=this.settings.username,n=this.settings.apiUrl+"/account/profile/"+a+"/gerrit";e.ajax(n,{context:this.element,success:function(a){var n=a.merged_changes_count;e(this).children("strong").text(n+t.plurialString(" review",n)),n>0&&e(this).attr({href:t.settings.gerritUrl+"/#/q/owner:"+t.settings.username})},error:function(){e(this).html(t.settings.errorMsg)}})},mailingListSubscription:function(){var t=this,a=t.settings.username,n=t.settings.currentUser,r=t.settings.currentUserUid,s=t.settings.userCanEditOwnMailingList,i=this.settings.apiUrl;if(!a&&!api_url)return!1;var o=t.element,l=i+"/account/profile/"+a+"/mailing-list";e.ajax(l,{context:this.element,success:function(t){var i=t.mailing_list_subscriptions,l=e("<p></p>"),p=e("<h2></h2>"),c=e("<a></a>"),d=e("<strong></strong>"),u="This user is";n===a&&(u="You are");var g=c.clone().attr({href:"/user/"+r+"/mailing-list",class:"fa fa-pencil","aria-hidden":"true"});if(e(o).append(p.text("Eclipse Mailing Lists ").append(g)),jQuery.isEmptyObject(i))e(o).append(l.clone().text(u+" not subscribed to any Eclipse mailing list."));else{e(o).append(l.clone().text("The Eclipse Mailing lists are another way for you to interact with your favorite Eclipse project.")),e(o).append(l.clone().text("Below is a list of the public mailing lists that "+u.toLowerCase()+" currently subscribed to at Eclipse.org. When posting emails to our mailing lists, please remember that these lists are public, avoid posting ").append(d.clone().text("personal")).append(" or ").append(d.clone().text("private information")).append(".")),e(o).append(l.clone().text("If you are having trouble using our mailing lists, please contact ").append(c.clone().attr("href","mailto:mailman@eclipse.org").text("mailman@eclipse.org")).append("."));var h=e("<table></table>").attr({width:"100%",class:"table",id:"aeri-reports"}),f=e("<tr></tr>"),m=e("<th></th>");f.append(m.clone().text("Mailing List").attr("width","30%")),f.append(m.clone().text("Description").attr("width","70%")),h.append(f);var v=e("<div></div>").attr({class:"table-responsive"});v.append(h),e(o).append(v),e(o).append(l),e.each(i,function(t,a){var n=e("<tr></tr>"),r=e("<td></td>");n.append(r.clone().append(c.clone().attr("href","/mailing-list/"+a.list_name).text(a.list_name))),n.append(r.clone().append(a.list_description)),h.append(n)})}n===a&&s&&e(o).append(l.clone().append(c.clone().attr({href:"/user/"+r+"/mailing-list",class:"btn btn-primary btn-xs"}).text("Manage your Mailing Lists")))},error:function(){e(this).html(t.settings.errorMsg)}})},gerritReviews:function(){var t=this,a=this.settings.gerritUrl+"/changes/?q=owner:"+this.settings.username+"+status:open&q=reviewer:"+this.settings.username+"+status:open+-owner:"+this.settings.username+"&pp=0";e(this.element).append(e("<h2>Eclipse Gerrit</h2>").addClass("h3")),e(this.element).append("<p>Gerrit is a web based code review system, facilitating online code reviews for projects using the Git version control system.</p>"),function(a){var n=[["gerrit-outgoing",[]],["gerrit-incoming",[]]];e(t.element).on("drawTableEvent",function(){e.each(n,function(a,n){var r="";switch(n[0]){case"gerrit-outgoing":r="Outgoing Reviews";break;case"gerrit-incoming":r="Incoming Reviews"}var s=e("<h4></h4>").addClass("h4").text(r);e(t.element).append(s),0!==n[1].length?(e(t.element).append(function(a,n){var r=e("<table></table>").attr({width:"100%",class:"table",id:a}),s=e("<tr></tr>"),i=e("<th></th>"),o=e("<td></td>");s.append(i.clone().text("Subject").attr("width","70%")),s.append(i.clone().text("Status").attr({width:"18%",class:"text-center"})),s.append(i.clone().text("Updated").attr({width:"12%",class:"text-center"})),r.append(s);var l=e("<a></a>");e.each(n,function(a,n){s=e("<tr></tr>");var i="";!1===n.mergeable&&(i="Merge Conflict",s.addClass("warning"));var p=n.updated.substring(0,n.updated.indexOf(" "));s.append(o.clone().html(l.clone().attr({href:t.settings.gerritUrl+"/"+n._number}).text(n.subject)).append("<br/>"+n.project)),s.append(o.clone().text(i).attr("class","text-center")),s.append(o.clone().text(p).attr("class","text-center")),r.append(s)});var p=e("<div></div>").attr({class:"table-responsive"});return p.append(r),p}(n[0],n[1])),e(t.element).append(t.getPaginationBar(n[1].length,n[0]))):e(t.element).append('<div class="alert alert-warning" role="alert">There are no '+r.toLowerCase()+" for this user.</div>")});var a=e("<a></a>").attr({href:t.settings.gerritUrl+"/#/q/owner:"+t.settings.username,class:"btn btn-primary btn-sm",style:"display:block"}).html('<i class="fa fa-angle-double-right" aria-hidden="true"></i> More');e(t.element).append(a)}),function a(r,s,i){s=void 0!==s?s:100;i=void 0!==i?i:0;r+="&start="+i+"&n="+s;return e.ajax(r,{dataType:"gerrit_XSSI",context:t.element,converters:{"text gerrit_XSSI":function(e){var t=e.substring(e.indexOf("\n")+1);return jQuery.parseJSON(t)}},success:function(o){var l=Object,p=Object;0!==o[0].length&&(e.merge(n[0][1],o[0]),l=o[0][o[0].length-1]),0!==o[1].length&&(e.merge(n[1][1],o[1]),p=o[1][o[1].length-1]),"_more_changes"in l&&!0===l._more_changes||"_more_changes"in p&&!0===p._more_changes?a(r,s,i+s):e(t.element).trigger("drawTableEvent")},error:function(a){400===a.status?e(this).html(t.settings.gerritUserNotFoundMsg):e(this).html(t.settings.errorMsg),!0}})}(a,100,0)}(a)},recentEvents:function(){var t=this;function a(e,t){return e.dateTime-t.dateTime}e.ajax(this.settings.eventUrl,{context:this.element,success:function(n){var r=new Date,s=[];for(var i in n.events)n.events[i].dateTime=new Date(n.events[i].date),n.events[i].dateTime>=r&&s.push(n.events[i]);s.sort(a);var o=e("<ul></ul>").attr({class:"nav",style:"margin:0"});for(var l in s.slice(0,5)){var p=s[l].dateTime,c=t.dateFormat(p),d=e("<a>").attr({href:s[l].infoLink}).html(s[l].title+"<br/><small>"+c+"</small>"),u=e("<li></li>").append(d);o.append(u)}e(this).children(".loading").remove(),e(this).append(o);var g=e("<a>").attr({href:"http://events.eclipse.org",class:"btn btn-simple btn-sm"}).text("more");e(this).append(g)},error:function(){e(this).html(t.settings.errorMsg)}})},plurialString:function(e,t){return t>1&&(e+="s"),e},dateFormat:function(e){var t=e.getFullYear(),a=["January","February","March","April","May","June","July","August","September","October","November","December"][e.getMonth()];return["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"][e.getDay()]+", "+a+" "+e.getDate()+", "+t+" - "+("0"+e.getHours()).slice(-2)+":"+("0"+e.getMinutes()).slice(-2)},linkHeaderParser:function(e){var t=this;if(this.links=0,this.getLastPageNum=function(){return void 0===t.links.last?0:o(t.links.last,"page")},this.getPageSize=function(){if(void 0===t.links.first)return 0;var e=o(t.links.first,"pagesize");return 0===e?o(t.links.first,"size"):e},null!=e){for(var a=e.split(","),n={},r=0;r<a.length;r++){a[r]=a[r].replace("&","&");var s=a[r].split(";");if(!(s.length<2)){var i=s[0].replace(/<(.*)>/,"$1").trim();n[s[1].replace(/rel="(.*)"/,"$1").trim()]=i}}this.links=n}function o(e,t){if(void 0===t||void 0===e)return 0;for(var a=e.substr(e.lastIndexOf("?")+1).split("&"),n=0;n<a.length;n++){var r=a[n].split("=");if(decodeURIComponent(r[0])===t)return decodeURIComponent(r[1])}return 0}},getPaginationBar:function(t,a){var n=this;if(void 0===t&&(t=1),!(t<=0||t<=n.settings.itemsPerPage)){var r=e("<nav></nav>").attr({"arial-label":"Page navigation",id:a+"-pager"}).addClass("text-center"),s=Math.ceil(t/n.settings.itemsPerPage),i=o(s,1,a);return r.append(i),void 0===e("#"+a).data("pageCache")&&function(){var t,r=e("#"+a),i=[];switch(a){case"gerrit-incoming":case"gerrit-outgoing":t="gerrit",i=o(r.find("tr"));break;case"mpfavorites-list":t="mpfav";break;case"forum-posts":case"aeri-reports":t="table",i=o(r.find("tr"));break;case"news-container":t="news";break;case"events-container":t="events";break;default:t="generic"}switch(r.data("pageCache",i),r.data("pageCacheType",t),r.data("pageCacheTotalPages",s),r.on("changePageEvent",p),t){case"gerrit":r.trigger("changePageEvent",[1])}function o(a){var r=0,s=0,i=[],o=[];switch(t){case"gerrit":case"table":o[0]=a[0]}return e.each(a,function(t,a){if(e(a).children().first().is("th"))return!0;r===n.settings.itemsPerPage&&(r=0,o[++s]=i,i=[]),i[r++]=a}),i.length>0&&(o[++s]=i),o}}(),r}function o(t,a,n){var r=e("<li></li>"),s=e("<ul></ul>").addClass("pagination");void 0!==n&&s.attr({"data-eclipseFdnApi-elementID":n});var i,o=!1,p="",c=1,d=t,u=function(){var t=e(this),a=t.attr("data-goto-page"),n=t.parents(".pagination").eq(0).data("eclipsefdnapiElementid");e("#"+n).trigger("changePageEvent",[a])};if(t>9){c=t-8,a<=5?(d=9,c=1):a<=t-4&&(c=a-4,d=a+4),o=!0;var g=e("<span></span>");p=r.clone().append(g.clone().html("...").attr({"aria-hidden":"true"})).addClass("pager-ellipses disabled")}for(1!==a&&(s.append(r.clone().addClass("pager-first").html(l("First","first page",1,"<< first").on("click",u))),s.append(r.clone().html(l("Previous","previous page",a-1,"< previous").on("click",u))),!0===o&&c>1&&s.append(p.clone())),i=c;i<=d;i++){var h=r.clone(),f=l("Page "+parseInt(i),"page "+parseInt(i),i).on("click",u);a===i&&h.addClass("active"),h.html(f),s.append(h)}return a<t&&(!0===o&&d<t&&s.append(p.clone()),s.append(r.clone().html(l("Next","next page",a+1,"next >").on("click",u))),s.append(r.clone().addClass("pager-last").html(l("Last","last page",t,"last >>").on("click",u)))),s}function l(t,a,n,r){return void 0===r&&(r=parseInt(n)),e("<a></a>").attr({"aria-label":t,href:"#",onclick:"return false;",title:"Go to "+a,"data-goto-page":parseInt(n)}).text(r)}function p(t,a){var n=e(t.currentTarget),r=n.data("pageCacheType"),s=n.data("pageCache"),i=n.attr("id"),l=e("#"+i+"-pager"),p=l.data("currentPage");switch(null==p&&(p=1),void 0===a&&(a=1),a=parseInt(a),r){case"gerrit":d();break;default:!function(){if(void 0===s[p]){var t=[];s[p]=[],n.is("table")?t=n.find("tr"):n.is("div")&&(t=n.find(".node,.item")),e.each(t,function(t,a){if(e(a).children().first().is("th"))return!0;s[p].push(a)}),n.data("pageCache",s)}}(),d()}if(p!==a){var c=o(n.data("pageCacheTotalPages"),a,i);l.find("ul").replaceWith(c),l.data("currentPage",a)}function d(){if(n.empty(),void 0===s[a]){var t=[];switch(r){case"mpfav":case"table":case"news":case"events":t.push(a),t.push(n.data("postsPerPage"))}return n.is("table")&&n.append(s[0]),void n.trigger("fetchPageItemsEvent",t)}n.is("table")&&n.append(s[0]),e.each(s[a],function(e,t){n.append(t)})}}},newsItems:function(){var t=this,a=e(e(this)[0].element),r=a.find("> div.news-container");function s(r,s,i){var o=e(r),l=o.parent(),p=l.data("news-count")||i||5,c="?page="+s;c+="&pagesize="+p,c+=d(l,"publish-target","publish_to","eclipse_org"),c+=d(l,"news-type","news_type","");var u=t.settings.newsroomUrl+"/news"+c;e.ajax(u,{success:function(a,r,s){var i=a.news;i.length>p&&(i=i.slice(0,p));for(var c=0;c<i.length;c++)i[c].date=t.dateFormat(new Date(i[c].date)),i[c].index=c;var d=function(t){var a=e("#"+t);if(a!==n&&0!==a.length)return a[0].innerHTML;return'{{#news}}<div class="item block-summary-item" data-mh="group-{{ index }}"><p>{{ date }}</p><h4><a href="{{ link }}">{{ title }}</a></h4><p>{{ body }}</p></div>{{/news}}'}(l.data("template-id")||"template-news-items"),u=Mustache.render(d,{news:i});if(o.html(u),!0===l.data("pagination")&&0===l.find("nav").length){var g=new t.linkHeaderParser(s.getResponseHeader("Link")),h=g.getLastPageNum();g.getPageSize()!==t.settings.itemsPerPage&&(t.settings.itemsPerPage=g.getPageSize()),l.append(t.getPaginationBar(h*t.settings.itemsPerPage,o.attr("id")))}l.trigger("shown.ef.news")},error:function(){a.empty();var t=e("<div></div>");t.attr("class","alert alert-warning"),t.text("Unable to load news content currently."),a.append(t)}})}0===r.length&&((r=e("<div></div>")).attr({class:"news-container",id:"news-container"}),a.append(r)),!0===a.data("pagination")&&r.on("fetchPageItemsEvent",function(e,t,a){s(e.target,t,a)}),s(r,1,5)},filteredEvents:function(){var t=this,a=e(e(this)[0].element),r=a.find("> div.events-container");function s(r,s,i){var o=e(r),l=o.parent(),p=l.data("count")||i||5,c="?page="+s;c+="&pagesize="+p,c+=d(l,"publish-target","publish_to",n),c+=d(l,"type","type",n),c+=d(l,"upcoming","upcoming_only",n);var u=1===l.data("upcoming"),g=l.data("sort-order")||(u?"ASC":n),h=l.data("sort-field")||(u?"field_event_date":n);g&&h&&(c+="&options%5Borderby%5D%5B"+h+"%5D="+g);var f=t.settings.newsroomUrl+"/events"+c;e.ajax(f,{success:function(a,r,s){var i=a.events;i.length>p&&(i=i.slice(0,p));for(var c=0;c<i.length;c++)(Date.now()>new Date(i[c]["end-date"])||!i[c].registration)&&delete i[c].registration,i[c].infoLink||delete i[c].infoLink,i[c].date=t.dateFormat(new Date(i[c].date)),i[c]["end-date"]=t.dateFormat(new Date(i[c]["end-date"]));var d=function(t,a){var r=e("#"+t);if(r!==n&&0!==r.length)return r[0].innerHTML;if(a)return'{{#events}}<div class="item block-summary-item match-height-item"><h3 class="h4">{{ title }}</h3><p>{{ locationName }}</p><p>{{ date }} - {{ end-date }}</p><p class="margin-bottom-0">{{#registration}}<a class="btn btn-secondary" href="{{ registration }}">Register Now</a>{{/registration}}{{#infoLink}}<a class="btn btn-secondary" href="{{ infoLink }}">More information</a>{{/infoLink}}</p></div>{{/events}}';return'{{#events}}<div class="col-sm-12 col-md-6 event item match-height-item-by-row flex-column"><h3 class="h4 flex-grow">{{ title }}</h3><p>{{ locationName }}</p><p class="flex-grow">{{ date }} - {{ end-date }}</p><p class="margin-bottom-0">{{#infoLink}}<a class="btn btn-secondary" href="{{ infoLink }}">More information</a>{{/infoLink}}{{^infoLink}}{{#registration}}<a class="btn btn-secondary" href="{{ registration }}">Register Now</a>{{/registration}}{{/infoLink}}</p></div>{{/events}}'}(l.data("template-id")||"template-event-items",l.data("archive")||!1),u=Mustache.render(d,{events:i});if(o.html(u),!0===l.data("pagination")&&0===l.find("nav").length){var g=new t.linkHeaderParser(s.getResponseHeader("Link")),h=g.getLastPageNum();g.getPageSize()!==t.settings.itemsPerPage&&(t.settings.itemsPerPage=g.getPageSize()),l.append(t.getPaginationBar(h*t.settings.itemsPerPage,o.attr("id")))}l.trigger("shown.ef.events")},error:function(){a.empty();var t=e("<div></div>");t.attr("class","alert alert-warning"),t.text("Unable to load events content currently."),a.append(t)}})}0===r.length&&((r=e("<div></div>")).attr({class:"events-container",id:"events-container"}),a.append(r)),!0===a.data("pagination")&&r.on("fetchPageItemsEvent",function(e,t,a){s(e.target,t,a)}),s(r,1,5)},featuredStory:function(){var t=e(e(this)[0].element);p(t,"story",this.settings)},featuredFooter:function(){var t=e(e(this)[0].element);p(t,"footer",this.settings)},customFeaturedContent:function(){var t=e(e(this)[0].element);c(this.settings.featuredContent,t,this.settings.featuredContentType)},allPromos:function(){var t=e(e(this)[0].element),a=this,r=t.find("> div.promos-container");function s(t,r,s){var i=e(t),l=i.parent(),p=l.data("count")||s||10,c=a.settings.adsUrl,u="?page="+r;u+="&pagesize="+p,u+=d(l,"publish-target","publish_to",n),e.ajax(c+u,{dataType:"json",type:"GET",success:function(e){e.ads===n&&console.log("Could not load promotional content. AD-01");for(var t=0;t<e.ads.length;t++)e.ads[t].idx=t;if(o(i,e.ads,a.settings),!0===l.data("pagination")&&0===l.find("nav").length){var r=new a.linkHeaderParser(jqXHR.getResponseHeader("Link")),s=r.getLastPageNum();r.getPageSize()!==a.settings.itemsPerPage&&(a.settings.itemsPerPage=r.getPageSize()),l.append(a.getPaginationBar(s*a.settings.itemsPerPage,i.attr("id")))}},error:function(){console.log("Could not load promotional content. AD-02")}})}0===r.length&&((r=e("<div></div>")).attr({class:"promos-container",id:"promos-container-"+getPseudoRandomNumber()}),t.append(r)),!0===t.data("pagination")&&r.on("fetchPageItemsAd",function(e,t,a){s(e.target,t,a)}),s(r,1,10)},singlePromo:function(){var a=this,r=e(e(a)[0].element),s=r.parent(),i=a.settings.adsUrl,l={host:t.location.host,source:t.location.pathname,publish_to:r.data("publish-target")};e.ajax(i,{dataType:"json",contentType:"application/json",type:"POST",data:JSON.stringify(l),success:function(e){e===n&&console.log("Could not load promotional content, bad content received. AD-03"),o(r,e,a.settings),s.trigger("shown.ef.ads")},error:function(){console.log("Could not load promotional content. AD-04")}})}}),e.fn[r]=function(t){return this.each(function(){e.data(this,"plugin_"+r)||e.data(this,"plugin_"+r,new i(this,t))})};var o=function(e,t,a){var n=l(e.data("template-id"),a);e.html(Mustache.render(n,{content:t}))},l=function(e,t){return"allPromos"===t.type?u(e,'{{#content}}<p><a href="http://www.eclipse.org/home/index.php?ad_id={{ id }}">Ad ID: {{ id }}</a><span class="margin-left-10">prob: {{ weight }}%</span><div class="eclipsefnd-ad ad-strategic ad-strategic-default"><a href="https://eclipse.org/go/{{ campaign_name }}" rel="nofollow" style="background-image: url(\'{{ image }}\')">{{ member_name }}</a></div></p>{{/content}}'):u(e,'{{#content}}<div class="eclipsefnd-ad ad-strategic ad-strategic-default"><a href="https://eclipse.org/go/{{ campaign_name }}" rel="nofollow" style="background-image: url(\'{{ image }}\')">{{ member_name }}</a></div>{{/content}}')},p=function(t,a,r){var s=e(t),i=r.newsroomUrl+"/featured_story",o=s.data("id");o!==n&&(i+="/"+o),i+=d(s,"publish-target","publish_to",n,!0),e.ajax(i,{success:function(e){e.featured_story===n&&console.log("Could not load featured content, bad content recieved");var t=e.featured_story.filter(function(e){return new Date(e["end-date"])>new Date&&(e["start-date"]===n||new Date(e["start-date"])<new Date)}).filter(function(e){return e.type===a||"both"===e.type});if(t.length>1&&g(t),t.length>0)c(t[0],s,a);else{c({id:"default-featured-story",layout:"light",title:"Eclipse Foundation Events",body:"Join the world’s leading technologists and open source leaders at Eclipse Foundation events to share ideas, learn and collaborate.",links:[{url:"https://events.eclipse.org",title:"View Events"}]},s,"both")}},error:function(){console.log("Could not load featured content!")}})},c=function(e,t,a){var n=t.find(".featured-container");t.addClass("featured-story-nid-"+e.id),t.addClass("featured-story-"+e.layout);var r=t.data("template-id")||"template-featured-"+a,s=u(r,'{{#content}}<h2 class="margin-top-30">{{ title }}</h2><p>{{ body }}</p><ul class="list-inline list-inline-xs-margin">{{#links}}<li><a class="btn btn-primary" href="{{ url }}">{{ title }}</a></li>{{/links}}</ul>{{/content}}'),i=Mustache.render(s,{content:e});n.html(i)},d=function(e,t,a,r,s){var i=e.data(t)||r,o="";if(Array.isArray(i))for(var l=0;l<i.length;l++)o+=s&&0===l?"?":"&",o+="parameters%5B"+a+"%5D%5B%5D="+i[l];else i!==n&&(o+=s?"?":"&",o+="parameters%5B"+a+"%5D="+i);return o},u=function(t,a){var r=e("#"+t);return r!==n&&0!==r.length?r[0].innerHTML:a},g=function(e){for(var t=e.length-1;t>0;t--){var a=Math.floor(Math.random()*(t+1)),n=e[t];e[t]=e[a],e[a]=n}}}(jQuery,window,document),function(e,t){"object"==typeof exports&&"undefined"!=typeof module?module.exports=t():"function"==typeof define&&define.amd?define(t):(e=e||self).Mustache=t()}(this,function(){"use strict";var e=Object.prototype.toString,t=Array.isArray||function(t){return"[object Array]"===e.call(t)};function a(e){return"function"==typeof e}function n(e){return e.replace(/[\-\[\]{}()*+?.,\\\^$|#\s]/g,"\\$&")}function r(e,t){return null!=e&&"object"==typeof e&&t in e}var s=RegExp.prototype.test;var i=/\S/;function o(e){return!function(e,t){return s.call(e,t)}(i,e)}var l={"&":"&","<":"<",">":">",'"':""","'":"'","/":"/","`":"`","=":"="};var p=/\s*/,c=/\s+/,d=/\s*=/,u=/\s*\}/,g=/#|\^|\/|>|\{|&|=|!/;function h(e){this.string=e,this.tail=e,this.pos=0}function f(e,t){this.view=e,this.cache={".":this.view},this.parent=t}function m(){this.templateCache={_cache:{},set:function(e,t){this._cache[e]=t},get:function(e){return this._cache[e]},clear:function(){this._cache={}}}}h.prototype.eos=function(){return""===this.tail},h.prototype.scan=function(e){var t=this.tail.match(e);if(!t||0!==t.index)return"";var a=t[0];return this.tail=this.tail.substring(a.length),this.pos+=a.length,a},h.prototype.scanUntil=function(e){var t,a=this.tail.search(e);switch(a){case-1:t=this.tail,this.tail="";break;case 0:t="";break;default:t=this.tail.substring(0,a),this.tail=this.tail.substring(a)}return this.pos+=t.length,t},f.prototype.push=function(e){return new f(e,this)},f.prototype.lookup=function(e){var t,n,s,i=this.cache;if(i.hasOwnProperty(e))t=i[e];else{for(var o,l,p,c=this,d=!1;c;){if(e.indexOf(".")>0)for(o=c.view,l=e.split("."),p=0;null!=o&&p<l.length;)p===l.length-1&&(d=r(o,l[p])||(n=o,s=l[p],null!=n&&"object"!=typeof n&&n.hasOwnProperty&&n.hasOwnProperty(s))),o=o[l[p++]];else o=c.view[e],d=r(c.view,e);if(d){t=o;break}c=c.parent}i[e]=t}return a(t)&&(t=t.call(this.view)),t},m.prototype.clearCache=function(){void 0!==this.templateCache&&this.templateCache.clear()},m.prototype.parse=function(e,a){var r=this.templateCache,s=e+":"+(a||v.tags).join(":"),i=void 0!==r,l=i?r.get(s):void 0;return null==l&&(l=function(e,a){if(!e)return[];var r,s,i,l=!1,f=[],m=[],b=[],w=!1,_=!1,x="",y=0;function P(){if(w&&!_)for(;b.length;)delete m[b.pop()];else b=[];w=!1,_=!1}function k(e){if("string"==typeof e&&(e=e.split(c,2)),!t(e)||2!==e.length)throw new Error("Invalid tags: "+e);r=new RegExp(n(e[0])+"\\s*"),s=new RegExp("\\s*"+n(e[1])),i=new RegExp("\\s*"+n("}"+e[1]))}k(a||v.tags);for(var C,U,j,E,M,T,S=new h(e);!S.eos();){if(C=S.pos,j=S.scanUntil(r))for(var L=0,R=j.length;L<R;++L)o(E=j.charAt(L))?(b.push(m.length),x+=E):(_=!0,l=!0,x+=" "),m.push(["text",E,C,C+1]),C+=1,"\n"===E&&(P(),x="",y=0,l=!1);if(!S.scan(r))break;if(w=!0,U=S.scan(g)||"name",S.scan(p),"="===U?(j=S.scanUntil(d),S.scan(d),S.scanUntil(s)):"{"===U?(j=S.scanUntil(i),S.scan(u),S.scanUntil(s),U="&"):j=S.scanUntil(s),!S.scan(s))throw new Error("Unclosed tag at "+S.pos);if(M=">"==U?[U,j,C,S.pos,x,y,l]:[U,j,C,S.pos],y++,m.push(M),"#"===U||"^"===U)f.push(M);else if("/"===U){if(!(T=f.pop()))throw new Error('Unopened section "'+j+'" at '+C);if(T[1]!==j)throw new Error('Unclosed section "'+T[1]+'" at '+C)}else"name"===U||"{"===U||"&"===U?_=!0:"="===U&&k(j)}if(P(),T=f.pop())throw new Error('Unclosed section "'+T[1]+'" at '+S.pos);return function(e){for(var t,a=[],n=a,r=[],s=0,i=e.length;s<i;++s)switch((t=e[s])[0]){case"#":case"^":n.push(t),r.push(t),n=t[4]=[];break;case"/":r.pop()[5]=t[2],n=r.length>0?r[r.length-1][4]:a;break;default:n.push(t)}return a}(function(e){for(var t,a,n=[],r=0,s=e.length;r<s;++r)(t=e[r])&&("text"===t[0]&&a&&"text"===a[0]?(a[1]+=t[1],a[3]=t[3]):(n.push(t),a=t));return n}(m))}(e,a),i&&r.set(s,l)),l},m.prototype.render=function(e,t,a,n){var r=this.parse(e,n),s=t instanceof f?t:new f(t,void 0);return this.renderTokens(r,s,a,e,n)},m.prototype.renderTokens=function(e,t,a,n,r){for(var s,i,o,l="",p=0,c=e.length;p<c;++p)o=void 0,"#"===(i=(s=e[p])[0])?o=this.renderSection(s,t,a,n):"^"===i?o=this.renderInverted(s,t,a,n):">"===i?o=this.renderPartial(s,t,a,r):"&"===i?o=this.unescapedValue(s,t):"name"===i?o=this.escapedValue(s,t):"text"===i&&(o=this.rawValue(s)),void 0!==o&&(l+=o);return l},m.prototype.renderSection=function(e,n,r,s){var i=this,o="",l=n.lookup(e[1]);if(l){if(t(l))for(var p=0,c=l.length;p<c;++p)o+=this.renderTokens(e[4],n.push(l[p]),r,s);else if("object"==typeof l||"string"==typeof l||"number"==typeof l)o+=this.renderTokens(e[4],n.push(l),r,s);else if(a(l)){if("string"!=typeof s)throw new Error("Cannot use higher-order sections without the original template");null!=(l=l.call(n.view,s.slice(e[3],e[5]),function(e){return i.render(e,n,r)}))&&(o+=l)}else o+=this.renderTokens(e[4],n,r,s);return o}},m.prototype.renderInverted=function(e,a,n,r){var s=a.lookup(e[1]);if(!s||t(s)&&0===s.length)return this.renderTokens(e[4],a,n,r)},m.prototype.indentPartial=function(e,t,a){for(var n=t.replace(/[^ \t]/g,""),r=e.split("\n"),s=0;s<r.length;s++)r[s].length&&(s>0||!a)&&(r[s]=n+r[s]);return r.join("\n")},m.prototype.renderPartial=function(e,t,n,r){if(n){var s=a(n)?n(e[1]):n[e[1]];if(null!=s){var i=e[6],o=e[5],l=e[4],p=s;return 0==o&&l&&(p=this.indentPartial(s,l,i)),this.renderTokens(this.parse(p,r),t,n,p,r)}}},m.prototype.unescapedValue=function(e,t){var a=t.lookup(e[1]);if(null!=a)return a},m.prototype.escapedValue=function(e,t){var a=t.lookup(e[1]);if(null!=a)return v.escape(a)},m.prototype.rawValue=function(e){return e[1]};var v={name:"mustache.js",version:"4.0.1",tags:["{{","}}"],clearCache:void 0,escape:void 0,parse:void 0,render:void 0,Scanner:void 0,Context:void 0,Writer:void 0,set templateCache(e){b.templateCache=e},get templateCache(){return b.templateCache}},b=new m;return v.clearCache=function(){return b.clearCache()},v.parse=function(e,t){return b.parse(e,t)},v.render=function(e,a,n,r){if("string"!=typeof e)throw new TypeError('Invalid template! Template should be a "string" but "'+(t(s=e)?"array":typeof s)+'" was given as the first argument for mustache#render(template, view, partials)');var s;return b.render(e,a,n,r)},v.escape=function(e){return String(e).replace(/[&<>"'`=\/]/g,function(e){return l[e]})},v.Scanner=h,v.Context=f,v.Writer=m,v}); | ||
!function(e,t,n,a){"use strict";var r="eclipseFdnApi",s={apiUrl:"https://api.eclipse.org",gerritUrl:"https://git.eclipse.org/r",eventUrl:"https://newsroom.eclipse.org/api/events",adsUrl:"https://newsroom.eclipse.org/api/ads",forumsUrl:"https://www.eclipse.org/forums",marketplaceUrl:"https://marketplace.eclipse.org",username:"cguindon",currentUser:"",contentPlaceholder:null,errorMsg:'<i class="fa red fa-exclamation-triangle" aria-hidden="true"></i> An unexpected error has occurred.',gerritUserNotFoundMsg:'<h2 class="h3">Outgoing Reviews</h2>There are no outgoing reviews for this user.<h2 class="h3">Incoming Reviews</h2>There are no incoming reviews for this account.',type:"",itemsPerPage:10,accountsUrl:"https://accounts.eclipse.org",newsroomUrl:"https://newsroom.eclipse.org/api",featuredContent:{},featuredContentType:""};function i(t,n){this.element=t,this.settings=e.extend({},s,n),this._defaults=s,this._name=r,this.init()}e.extend(i.prototype,{init:function(){"string"===e.type(this.settings.type)&&-1!==e.inArray(this.settings.type,["mpFavorites","gerritReviews","recentEvents","forumsMsg","gerritReviewCount","projectsList","mailingListSubscription","newsItems","filteredEvents","featuredStory","featuredFooter","customFeaturedContent","allPromos","singlePromo"])&&this[this.settings.type]()},projectsList:function(){var t=this,n=this.settings.username,r=this.settings.apiUrl;if(!n&&!api_url)return!1;var s=r+"/account/profile/"+n+"/projects";e.ajax(s,{context:this.element,success:function(n){var r=Object.keys(n).length;if(r===a&&(r=0),e(this).children("strong").text(r+t.plurialString(" project",r)),!(t.settings.contentPlaceholder instanceof jQuery))return!1;var s=e(t.settings.contentPlaceholder),i=e("<a></a>");s.append(e("<h2></h2>").addClass("h3").text("Eclipse Projects")),s.append('<p>Projects are the organizational unit for open source development work at the Eclipse Foundation. Projects have developers (committers), source code repositories, build servers, downloads, and other resources. The Eclipse Foundation\'s open source projects are governed by the <a href="https://eclipse.org/projects/dev_process/">Eclipse Development Process</a>.</p>');var o="This user is";if(t.settings.currentUser===t.settings.username&&(o="You are"),0===r)return s.append('<div class="alert alert-warning" role="alert">'+o+" not involved in any Eclipse Projects.</div>"),!1;var l=e("<table></table>").attr({width:"100%",class:"table"}),c=e("<tr></tr>"),p=e("<th></th>"),d=e("<td></td>");c.append(p.clone().text("Project").attr("width","85%")),c.append(p.clone().text("Relation").attr({width:"15%",class:"text-center"})),l.append(c),e.each(n,(function(n,a){var r=[],s="",o="";e.each(a,(function(e,t){r.push(t.Relation.Description),s=t.ProjectName,o=t.ActiveDate,""!==t.url&&(s=i.clone().attr({href:t.url}).text(s))})),(c=e("<tr></tr>")).append(d.clone().html(s).append("<br/><small>Since: "+t.dateFormat(new Date(o))+"</small>")),c.append(d.clone().text(r.join(", ")).attr("class","text-center")),l.append(c)}));var u=e("<div></div>").attr({class:"table-responsive"});u.append(l),s.append(u)},error:function(){e(this).html(t.settings.errorMsg)}})},forumsMsg:function(){var t=this,n=this.settings.username,r=this.settings.apiUrl;if(!n&&!api_url)return!1;var s=r+"/account/profile/"+n+"/forum?page=1&pagesize="+t.settings.itemsPerPage;function i(n){var a=e("#forum-posts");e.each(n.posts,(function(r,s){var i={forum_id:s.thread_forum_id,forum_name:s.forum_name,forum_cat_id:s.forum_name,forum_cat_name:s.cat_name,root_subject:s.root_msg_subject,current_user_last_post_timestamp:s.msg_group_post_stamp,current_user_last_post_subject:s.last_user_msg_subject,thread_id:s.msg_thread_id,thread_reply_count:s.thread_replies,thread_views_count:s.thread_views,thread_last_post_date:s.thread_last_post_date,last_message_timestamp:s.last_msg_post_stamp,last_message_poster_id:s.last_msg_poster_id,last_message_poster_alias:s.last_poster_alias,last_message_last_view:s.read_last_view,current_user_id:n.id},o=e("<tr></tr>"),l=e("<td></td>"),c=e("<a></a>"),p=c.clone().attr({href:t.settings.forumsUrl+"/index.php/f/"+i.forum_id+"/"}).text(i.forum_name),d=c.clone().attr({href:t.settings.forumsUrl+"/index.php/i/"+i.forum_cat_id+"/"}).text(i.forum_cat_name),u=e("<small></small>").append("<br/>").append(d).append(" > ").append(p).append(" > ").append(i.root_subject).append("<br>Posted on "+t.dateFormat(new Date(parseInt(1e3*i.current_user_last_post_timestamp)))),g="fa fa-envelope-open-o";t.settings.currentUser===t.settings.username&&i.last_message_last_view<i.thread_last_post_date&&i.last_message_poster_id!==i.current_user_id&&(o.addClass("warning"),g="fa fa-envelope-o"),t.settings.currentUser===t.settings.username&&o.append(l.clone().html('<i class="'+g+'" aria-hidden="true"></i>').attr("class","text-center")),o.append(l.clone().html(c.clone().attr({href:t.settings.forumsUrl+"/index.php/t/"+i.thread_id+"/"}).text(i.current_user_last_post_subject)).append(u)),o.append(l.clone().text(i.thread_reply_count).attr("class","text-center")),o.append(l.clone().text(i.thread_views_count).attr("class","text-center"));var h=e("<small></small>").append(t.dateFormat(new Date(parseInt(1e3*i.last_message_timestamp)))).append("<br/> By: ").append(c.clone().attr({href:t.settings.forumsUrl+"/index.php/sp/"+i.last_message_poster_id+"/"}).text(i.last_message_poster_alias));o.append(l.clone().html(h).attr("class","text-center")),a.append(o)}))}function o(a,s,o){!function(a,s){void 0===a&&(a=1);void 0===s&&(s=t.settings.itemsPerPage);var o=r+"/account/profile/"+n+"/forum?page="+a+"&pagesize="+s;e.ajax(o,{context:t.element,success:function(e){i(e)},error:function(){e(this).html(t.settings.errorMsg)}})}(s,o)}e.ajax(s,{context:this.element,success:function(n,r,s){var l=0;if(n.posted_msg_count!==a&&n.id!==a&&(l=n.posted_msg_count,e(this).attr({href:t.settings.forumsUrl+"/index.php/sp/"+n.id+"/"})),e(this).children("strong").text(l+t.plurialString(" topic",l)),!(t.settings.contentPlaceholder instanceof jQuery))return!1;var c=e(t.settings.contentPlaceholder),p=e("<a></a>");c.append(e("<h2></h2>").addClass("h3").text("Eclipse Forums")),c.append(e("<p></p>").append("The Eclipse forums are your way of communicating with the community of people developing and using Eclipse-based tools hosted at Eclipse.org. Please stick to technical issues - and remember, no confidential information - these are public forums!"));var d=p.clone().attr({href:t.settings.forumsUrl,class:"btn btn-primary btn-sm",style:"display:block"}).html('<i class="fa fa-angle-double-right" aria-hidden="true"></i> More');if(0===n.posts.length)return c.append('<div class="alert alert-warning" role="alert">This user does not have any activities on Eclipse Forums.</div>'),c.append(d),!1;var u=e("<table></table>").attr({width:"100%",class:"table",id:"forum-posts"}),g=e("<tr></tr>"),h=e("<th></th>");t.settings.currentUser===t.settings.username&&g.append(h.clone().attr("width","8%")),g.append(h.clone().text("Topics").attr("width","50%")),g.append(h.clone().text("Replies").attr({width:"8%",class:"text-center"})),g.append(h.clone().text("Views").attr({width:"8%",class:"text-center"})),g.append(h.clone().text("Last message").attr({class:"text-center"})),u.append(g);var f=e("<div></div>").attr({class:"table-responsive"});f.append(u),c.append(f),i(n);var m=new t.linkHeaderParser(s.getResponseHeader("Link")),v=m.getLastPageNum();m.getPageSize()!==t.settings.itemsPerPage&&(t.settings.itemsPerPage=m.getPageSize()),u.on("fetchPageItemsEvent",o),u.data("postsPerPage",t.settings.itemsPerPage),c.append(t.getPaginationBar(v*t.settings.itemsPerPage,"forum-posts"));var b=n.id;d.attr({href:t.settings.forumsUrl+"/index.php/sp/"+b+"/"}),c.append(d)},error:function(){e(this).html(t.settings.errorMsg)}})},mpFavorites:function(){var t=this,n=this.settings.username,a=this.settings.apiUrl;if(!n&&!api_url)return!1;if(t.settings.contentPlaceholder instanceof jQuery){var r=e(t.settings.contentPlaceholder),s=e("<a></a>").attr({href:t.settings.marketplaceUrl+"/user/"+n+"/favorites",class:"btn btn-primary btn-sm",style:"display:block"}).html('<i class="fa fa-angle-double-right" aria-hidden="true"></i> More');r.append(e("<h2></h2>").addClass("h3").text("Eclipse Marketplace Favorites")),r.append(e("<p></p>").append("Eclipse Marketplace is the source for Eclipse-based solutions, products and add-on features. Thousands of developers visit Marketplace on a monthly basis to find new and innovative solutions. Solution providers are encouraged to list their products on Marketplace to gain exposure to the Eclipse developer community."))}var i=a+"/marketplace/favorites?name="+n+"&page=1&pagesize="+t.settings.itemsPerPage;function o(n){var a=t.settings.marketplaceUrl+"/node/"+n+"/api/p";e.ajax(a,{context:t.element,success:function(n){var a=e("#mpfavorites-list");e("node",n).each((function(n,r){var s=e(r),i=s.find("shortdescription").text(),o=r.getAttribute("name"),l=s.find("changed").text(),c=s.find("owner").text(),p="Last Updated on "+t.dateFormat(new Date(parseInt(1e3*l)))+" by "+c,d=r.getAttribute("id"),u=e("#mp-listing-template").clone().removeClass("hidden").removeAttr("id"),g=e("<a></a>"),h=e("category",r),f=t.settings.marketplaceUrl+"/node/"+d,m=s.find("image").text(),v=g.clone().attr({href:f});h.each((function(e,t){var n=g.clone().attr({href:t.getAttribute("url")}).text(t.getAttribute("name"));h.length!==e+1&&n.append(", "),u.find(".content-categories").append(n)})),u.find(".listing-image").attr({href:f,style:"background:url('"+m+"') no-repeat center;"}),u.find(".drag").attr({href:t.settings.marketplaceUrl+"/marketplace-client-intro?mpc_install="+d}),u.find(".listing-title").html(v.clone().text(o)),u.find(".content-teaser").html(i),u.find(".content-last-updated").html(p),a.append(u)}))},error:function(){e(this).html(t.settings.errorMsg)}})}function l(r,s,i){!function(r,s){void 0===r&&(r=1);void 0===s&&(s=t.settings.itemsPerPage);var i=a+"/marketplace/favorites?name="+n+"&page="+r+"&pagesize="+s;e.ajax(i,{context:t.element,success:function(t){var n=[];e.each(t.mpc_favorites,(function(e,t){n.push(t.content_id)})),o(n.join())},error:function(){e(this).html(t.settings.errorMsg)}})}(s,i)}e.ajax(i,{context:this.element,success:function(n,a,i){if(e(this).children("strong").text(n.result.count+t.plurialString(" favorite",n.result.count)),void 0===r)return!1;var c=[];if(e.each(n.mpc_favorites,(function(e,t){c.push(t.content_id)})),0===c.length)return r.append('<div class="alert alert-warning" role="alert">There are no marketplace favorites for this user.</div>'),r.append(s),!1;var p=new t.linkHeaderParser(i.getResponseHeader("Link")),d=p.getLastPageNum();p.getPageSize()!==t.settings.itemsPerPage&&(t.settings.itemsPerPage=p.getPageSize()),r.on("fetchPageItemsEvent",l),r.append('<h3 id="mpc_list_name">'+n.mpc_list_name+"</h3>"),r.append('<div class="row"><div class="col-md-17"><div class="form-item form-type-textfield form-disabled"><label>Favorites URL <a href="#" class="install-user-favorites" data-container="body" data-toggle="popover" data-placement="top" title="" data-original-title="How to install?"><i class="fa fa-question-circle" aria-hidden="true"></i></a> </label><input disabled="true" class="form-control form-text" type="text" value="http://marketplace.eclipse.org/user/'+t.settings.username+'/favorites" size="60" maxlength="128"></div></div><div class="col-md-7 margin-top-25 text-right"><div class="drag_installbutton drag_installbutton_v2 drag-install-favorites"><a href="http://marketplace.eclipse.org/user/'+t.settings.username+'/favorites" class="drag" title="How to install?"><span class="btn btn-default"><i class="fa fa-download orange"></i> Install Favorites</span><div class="tooltip tooltip-below-right"><h3>Drag to Install!</h3>Drag to your running Eclipse<sup>*</sup> workspace to install this favorite list. <br><sup>*</sup>Requires Eclipse Marketplace Client.</div></a></div></div></div>'),r.append('<div id="mpfavorites-list"></div>'),r.find("#mpfavorites-list").data("postsPerPage",t.settings.itemsPerPage),o(c.join()),r.append(t.getPaginationBar(d*t.settings.itemsPerPage,"mpfavorites-list")),r.append(s),e("a.install-user-favorites").on("click",(function(e){e.preventDefault()})),e("a.install-user-favorites").popover({html:!0,content:function(){return e("<ol></ol>").addClass("padding-left-20").append("<li>Copy <strong>URL</strong> from textfield.</li>").append("<li>Open Eclipse Marketplace Client (MPC).</li>").append("<li>Open <strong>Favorites</strong> tab.</li>").append("<li>Click on <strong>Import Favorites list</strong>.</li>").append("<li>Paste <strong>URL</strong> in the textfield.</li>")}})},error:function(){e(this).html(t.settings.errorMsg)}})},gerritReviewCount:function(){var t=this,n=this.settings.username,a=this.settings.apiUrl+"/account/profile/"+n+"/gerrit";e.ajax(a,{context:this.element,success:function(n){var a=n.merged_changes_count;e(this).children("strong").text(a+t.plurialString(" review",a)),a>0&&e(this).attr({href:t.settings.gerritUrl+"/#/q/owner:"+t.settings.username})},error:function(){e(this).html(t.settings.errorMsg)}})},mailingListSubscription:function(){var t=this,n=t.settings.username,a=t.settings.currentUser,r=t.settings.currentUserUid,s=t.settings.userCanEditOwnMailingList,i=this.settings.apiUrl;if(!n&&!api_url)return!1;var o=t.element,l=i+"/account/profile/"+n+"/mailing-list";e.ajax(l,{context:this.element,success:function(t){var i=t.mailing_list_subscriptions,l=e("<p></p>"),c=e("<h2></h2>"),p=e("<a></a>"),d=e("<strong></strong>"),u="This user is";a===n&&(u="You are");var g=p.clone().attr({href:"/user/"+r+"/mailing-list",class:"fa fa-pencil","aria-hidden":"true"});if(e(o).append(c.text("Eclipse Mailing Lists ").append(g)),jQuery.isEmptyObject(i))e(o).append(l.clone().text(u+" not subscribed to any Eclipse mailing list."));else{e(o).append(l.clone().text("The Eclipse Mailing lists are another way for you to interact with your favorite Eclipse project.")),e(o).append(l.clone().text("Below is a list of the public mailing lists that "+u.toLowerCase()+" currently subscribed to at Eclipse.org. When posting emails to our mailing lists, please remember that these lists are public, avoid posting ").append(d.clone().text("personal")).append(" or ").append(d.clone().text("private information")).append(".")),e(o).append(l.clone().text("If you are having trouble using our mailing lists, please contact ").append(p.clone().attr("href","mailto:mailman@eclipse.org").text("mailman@eclipse.org")).append("."));var h=e("<table></table>").attr({width:"100%",class:"table",id:"aeri-reports"}),f=e("<tr></tr>"),m=e("<th></th>");f.append(m.clone().text("Mailing List").attr("width","30%")),f.append(m.clone().text("Description").attr("width","70%")),h.append(f);var v=e("<div></div>").attr({class:"table-responsive"});v.append(h),e(o).append(v),e(o).append(l),e.each(i,(function(t,n){var a=e("<tr></tr>"),r=e("<td></td>");a.append(r.clone().append(p.clone().attr("href","/mailing-list/"+n.list_name).text(n.list_name))),a.append(r.clone().append(n.list_description)),h.append(a)}))}a===n&&s&&e(o).append(l.clone().append(p.clone().attr({href:"/user/"+r+"/mailing-list",class:"btn btn-primary btn-xs"}).text("Manage your Mailing Lists")))},error:function(){e(this).html(t.settings.errorMsg)}})},gerritReviews:function(){var t,n,a=this,r=this.settings.gerritUrl+"/changes/?q=owner:"+this.settings.username+"+status:open&q=reviewer:"+this.settings.username+"+status:open+-owner:"+this.settings.username+"&pp=0";e(this.element).append(e("<h2>Eclipse Gerrit</h2>").addClass("h3")),e(this.element).append("<p>Gerrit is a web based code review system, facilitating online code reviews for projects using the Git version control system.</p>"),t=r,n=[["gerrit-outgoing",[]],["gerrit-incoming",[]]],e(a.element).on("drawTableEvent",(function(){e.each(n,(function(t,n){var r="";switch(n[0]){case"gerrit-outgoing":r="Outgoing Reviews";break;case"gerrit-incoming":r="Incoming Reviews"}var s=e("<h4></h4>").addClass("h4").text(r);e(a.element).append(s),0!==n[1].length?(e(a.element).append(function(t,n){var r=e("<table></table>").attr({width:"100%",class:"table",id:t}),s=e("<tr></tr>"),i=e("<th></th>"),o=e("<td></td>");s.append(i.clone().text("Subject").attr("width","70%")),s.append(i.clone().text("Status").attr({width:"18%",class:"text-center"})),s.append(i.clone().text("Updated").attr({width:"12%",class:"text-center"})),r.append(s);var l=e("<a></a>");e.each(n,(function(t,n){s=e("<tr></tr>");var i="";!1===n.mergeable&&(i="Merge Conflict",s.addClass("warning"));var c=n.updated.substring(0,n.updated.indexOf(" "));s.append(o.clone().html(l.clone().attr({href:a.settings.gerritUrl+"/"+n._number}).text(n.subject)).append("<br/>"+n.project)),s.append(o.clone().text(i).attr("class","text-center")),s.append(o.clone().text(c).attr("class","text-center")),r.append(s)}));var c=e("<div></div>").attr({class:"table-responsive"});return c.append(r),c}(n[0],n[1])),e(a.element).append(a.getPaginationBar(n[1].length,n[0]))):e(a.element).append('<div class="alert alert-warning" role="alert">There are no '+r.toLowerCase()+" for this user.</div>")}));var t=e("<a></a>").attr({href:a.settings.gerritUrl+"/#/q/owner:"+a.settings.username,class:"btn btn-primary btn-sm",style:"display:block"}).html('<i class="fa fa-angle-double-right" aria-hidden="true"></i> More');e(a.element).append(t)})),function t(r,s,i){return r+="&start="+(i=void 0!==i?i:0)+"&n="+(s=void 0!==s?s:100),e.ajax(r,{dataType:"gerrit_XSSI",context:a.element,converters:{"text gerrit_XSSI":function(e){var t=e.substring(e.indexOf("\n")+1);return jQuery.parseJSON(t)}},success:function(o){var l=Object,c=Object;0!==o[0].length&&(e.merge(n[0][1],o[0]),l=o[0][o[0].length-1]),0!==o[1].length&&(e.merge(n[1][1],o[1]),c=o[1][o[1].length-1]),"_more_changes"in l&&!0===l._more_changes||"_more_changes"in c&&!0===c._more_changes?t(r,s,i+s):e(a.element).trigger("drawTableEvent")},error:function(t){400===t.status?e(this).html(a.settings.gerritUserNotFoundMsg):e(this).html(a.settings.errorMsg)}})}(t,100,0)},recentEvents:function(){var t=this;function n(e,t){return e.dateTime-t.dateTime}e.ajax(this.settings.eventUrl,{context:this.element,success:function(a){var r=new Date,s=[];for(var i in a.events)a.events[i].dateTime=new Date(a.events[i].date),a.events[i].dateTime>=r&&s.push(a.events[i]);s.sort(n);var o=e("<ul></ul>").attr({class:"nav",style:"margin:0"});for(var l in s.slice(0,5)){var c=s[l].dateTime,p=t.dateFormat(c),d=e("<a>").attr({href:s[l].infoLink}).html(s[l].title+"<br/><small>"+p+"</small>"),u=e("<li></li>").append(d);o.append(u)}e(this).children(".loading").remove(),e(this).append(o);var g=e("<a>").attr({href:"http://events.eclipse.org",class:"btn btn-simple btn-sm"}).text("more");e(this).append(g)},error:function(){e(this).html(t.settings.errorMsg)}})},plurialString:function(e,t){return t>1&&(e+="s"),e},dateFormat:function(e){var t=e.getFullYear(),n=["January","February","March","April","May","June","July","August","September","October","November","December"][e.getMonth()];return["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"][e.getDay()]+", "+n+" "+e.getDate()+", "+t+" - "+("0"+e.getHours()).slice(-2)+":"+("0"+e.getMinutes()).slice(-2)},linkHeaderParser:function(e){var t=this;if(this.links=0,this.getLastPageNum=function(){return void 0===t.links.last?0:o(t.links.last,"page")},this.getPageSize=function(){if(void 0===t.links.first)return 0;var e=o(t.links.first,"pagesize");return 0===e?o(t.links.first,"size"):e},null!=e){for(var n=e.split(","),a={},r=0;r<n.length;r++){n[r]=n[r].replace("&","&");var s=n[r].split(";");if(!(s.length<2)){var i=s[0].replace(/<(.*)>/,"$1").trim();a[s[1].replace(/rel="(.*)"/,"$1").trim()]=i}}this.links=a}function o(e,t){if(void 0===t||void 0===e)return 0;for(var n=e.substr(e.lastIndexOf("?")+1).split("&"),a=0;a<n.length;a++){var r=n[a].split("=");if(decodeURIComponent(r[0])===t)return decodeURIComponent(r[1])}return 0}},getPaginationBar:function(t,n){var a=this;if(void 0===t&&(t=1),!(t<=0||t<=a.settings.itemsPerPage)){var r=e("<nav></nav>").attr({"arial-label":"Page navigation",id:n+"-pager"}).addClass("text-center"),s=Math.ceil(t/a.settings.itemsPerPage),i=o(s,1,n);return r.append(i),void 0===e("#"+n).data("pageCache")&&function(){var t,r=e("#"+n),i=[];switch(n){case"gerrit-incoming":case"gerrit-outgoing":t="gerrit",i=o(r.find("tr"));break;case"mpfavorites-list":t="mpfav";break;case"forum-posts":case"aeri-reports":t="table",i=o(r.find("tr"));break;case"news-container":t="news";break;case"events-container":t="events";break;default:t="generic"}switch(r.data("pageCache",i),r.data("pageCacheType",t),r.data("pageCacheTotalPages",s),r.on("changePageEvent",c),t){case"gerrit":r.trigger("changePageEvent",[1])}function o(n){var r=0,s=0,i=[],o=[];switch(t){case"gerrit":case"table":o[0]=n[0]}return e.each(n,(function(t,n){if(e(n).children().first().is("th"))return!0;r===a.settings.itemsPerPage&&(r=0,o[++s]=i,i=[]),i[r++]=n})),i.length>0&&(o[++s]=i),o}}(),r}function o(t,n,a){var r=e("<li></li>"),s=e("<ul></ul>").addClass("pagination");void 0!==a&&s.attr({"data-eclipseFdnApi-elementID":a});var i,o=!1,c="",p=1,d=t,u=function(){var t=e(this),n=t.attr("data-goto-page"),a=t.parents(".pagination").eq(0).data("eclipsefdnapiElementid");e("#"+a).trigger("changePageEvent",[n])};if(t>9){p=t-8,n<=5?(d=9,p=1):n<=t-4&&(p=n-4,d=n+4),o=!0;var g=e("<span></span>");c=r.clone().append(g.clone().html("...").attr({"aria-hidden":"true"})).addClass("pager-ellipses disabled")}for(1!==n&&(s.append(r.clone().addClass("pager-first").html(l("First","first page",1,"<< first").on("click",u))),s.append(r.clone().html(l("Previous","previous page",n-1,"< previous").on("click",u))),!0===o&&p>1&&s.append(c.clone())),i=p;i<=d;i++){var h=r.clone(),f=l("Page "+parseInt(i),"page "+parseInt(i),i).on("click",u);n===i&&h.addClass("active"),h.html(f),s.append(h)}return n<t&&(!0===o&&d<t&&s.append(c.clone()),s.append(r.clone().html(l("Next","next page",n+1,"next >").on("click",u))),s.append(r.clone().addClass("pager-last").html(l("Last","last page",t,"last >>").on("click",u)))),s}function l(t,n,a,r){return void 0===r&&(r=parseInt(a)),e("<a></a>").attr({"aria-label":t,href:"#",onclick:"return false;",title:"Go to "+n,"data-goto-page":parseInt(a)}).text(r)}function c(t,n){var a=e(t.currentTarget),r=a.data("pageCacheType"),s=a.data("pageCache"),i=a.attr("id"),l=e("#"+i+"-pager"),c=l.data("currentPage");switch(null==c&&(c=1),void 0===n&&(n=1),n=parseInt(n),r){case"gerrit":d();break;default:!function(){if(void 0===s[c]){var t=[];s[c]=[],a.is("table")?t=a.find("tr"):a.is("div")&&(t=a.find(".node,.item")),e.each(t,(function(t,n){if(e(n).children().first().is("th"))return!0;s[c].push(n)})),a.data("pageCache",s)}}(),d()}if(c!==n){var p=o(a.data("pageCacheTotalPages"),n,i);l.find("ul").replaceWith(p),l.data("currentPage",n)}function d(){if(a.empty(),void 0===s[n]){var t=[];switch(r){case"mpfav":case"table":case"news":case"events":t.push(n),t.push(a.data("postsPerPage"))}return a.is("table")&&a.append(s[0]),void a.trigger("fetchPageItemsEvent",t)}a.is("table")&&a.append(s[0]),e.each(s[n],(function(e,t){a.append(t)}))}}},newsItems:function(){var t=this,n=e(e(this)[0].element),r=n.find("> div.news-container");function s(r,s,i){var o=e(r),l=o.parent(),c=l.data("news-count")||i||5,p="?page="+s;p+="&pagesize="+c,p+=d(l,"publish-target","publish_to","eclipse_org"),p+=d(l,"news-type","news_type","");var u=t.settings.newsroomUrl+"/news"+p;e.ajax(u,{success:function(n,r,s){var i=n.news;i.length>c&&(i=i.slice(0,c));for(var p=0;p<i.length;p++)i[p].date=t.dateFormat(new Date(i[p].date)),i[p].index=p;var d=function(t){var n=e("#"+t);if(n!==a&&0!==n.length)return n[0].innerHTML;return'{{#news}}<div class="item block-summary-item" data-mh="group-{{ index }}"><p>{{ date }}</p><h4><a href="{{ link }}">{{ title }}</a></h4><p>{{ body }}</p></div>{{/news}}'}(l.data("template-id")||"template-news-items"),u=Mustache.render(d,{news:i});if(o.html(u),!0===l.data("pagination")&&0===l.find("nav").length){var g=new t.linkHeaderParser(s.getResponseHeader("Link")),h=g.getLastPageNum();g.getPageSize()!==t.settings.itemsPerPage&&(t.settings.itemsPerPage=g.getPageSize()),l.append(t.getPaginationBar(h*t.settings.itemsPerPage,o.attr("id")))}l.trigger("shown.ef.news")},error:function(){n.empty();var t=e("<div></div>");t.attr("class","alert alert-warning"),t.text("Unable to load news content currently."),n.append(t)}})}0===r.length&&((r=e("<div></div>")).attr({class:"news-container",id:"news-container"}),n.append(r)),!0===n.data("pagination")&&r.on("fetchPageItemsEvent",(function(e,t,n){s(e.target,t,n)})),s(r,1,5)},filteredEvents:function(){var t=this,n=e(e(this)[0].element),r=n.find("> div.events-container");function s(r,s,i){var o=e(r),l=o.parent(),c=l.data("count")||i||5,p="?page="+s;p+="&pagesize="+c,p+=d(l,"publish-target","publish_to",a),p+=d(l,"type","type",a),p+=d(l,"upcoming","upcoming_only",a);var u=1===l.data("upcoming"),g=l.data("sort-order")||(u?"ASC":a),h=l.data("sort-field")||(u?"field_event_date":a);g&&h&&(p+="&options%5Borderby%5D%5B"+h+"%5D="+g);var f=t.settings.newsroomUrl+"/events"+p;e.ajax(f,{success:function(n,r,s){var i=n.events;i.length>c&&(i=i.slice(0,c));for(var p=0;p<i.length;p++)(Date.now()>new Date(i[p]["end-date"])||!i[p].registration)&&delete i[p].registration,i[p].infoLink||delete i[p].infoLink,i[p].date=t.dateFormat(new Date(i[p].date)),i[p]["end-date"]=t.dateFormat(new Date(i[p]["end-date"]));var d=function(t,n){var r=e("#"+t);if(r!==a&&0!==r.length)return r[0].innerHTML;if(n)return'{{#events}}<div class="item block-summary-item match-height-item"><h3 class="h4">{{ title }}</h3><p>{{ locationName }}</p><p>{{ date }} - {{ end-date }}</p><p class="margin-bottom-0">{{#registration}}<a class="btn btn-secondary" href="{{ registration }}">Register Now</a>{{/registration}}{{#infoLink}}<a class="btn btn-secondary" href="{{ infoLink }}">More information</a>{{/infoLink}}</p></div>{{/events}}';return'{{#events}}<div class="col-sm-12 col-md-6 event item match-height-item-by-row flex-column"><h3 class="h4 flex-grow">{{ title }}</h3><p>{{ locationName }}</p><p class="flex-grow">{{ date }} - {{ end-date }}</p><p class="margin-bottom-0">{{#infoLink}}<a class="btn btn-secondary" href="{{ infoLink }}">More information</a>{{/infoLink}}{{^infoLink}}{{#registration}}<a class="btn btn-secondary" href="{{ registration }}">Register Now</a>{{/registration}}{{/infoLink}}</p></div>{{/events}}'}(l.data("template-id")||"template-event-items",l.data("archive")||!1),u=Mustache.render(d,{events:i});if(o.html(u),!0===l.data("pagination")&&0===l.find("nav").length){var g=new t.linkHeaderParser(s.getResponseHeader("Link")),h=g.getLastPageNum();g.getPageSize()!==t.settings.itemsPerPage&&(t.settings.itemsPerPage=g.getPageSize()),l.append(t.getPaginationBar(h*t.settings.itemsPerPage,o.attr("id")))}l.trigger("shown.ef.events")},error:function(){n.empty();var t=e("<div></div>");t.attr("class","alert alert-warning"),t.text("Unable to load events content currently."),n.append(t)}})}0===r.length&&((r=e("<div></div>")).attr({class:"events-container",id:"events-container"}),n.append(r)),!0===n.data("pagination")&&r.on("fetchPageItemsEvent",(function(e,t,n){s(e.target,t,n)})),s(r,1,5)},featuredStory:function(){var t=e(e(this)[0].element);c(t,"story",this.settings)},featuredFooter:function(){var t=e(e(this)[0].element);c(t,"footer",this.settings)},customFeaturedContent:function(){var t=e(e(this)[0].element);p(this.settings.featuredContent,t,this.settings.featuredContentType)},allPromos:function(){var t=e(e(this)[0].element),n=this,r=t.find("> div.promos-container");function s(t,r,s){var i=e(t),l=i.parent(),c=l.data("count")||s||10,p=n.settings.adsUrl,u="?page="+r;u+="&pagesize="+c,u+=d(l,"publish-target","publish_to",a),e.ajax(p+u,{dataType:"json",type:"GET",success:function(e){e.ads===a&&console.log("Could not load promotional content. AD-01");for(var t=0;t<e.ads.length;t++)e.ads[t].idx=t;if(o(i,e.ads,n.settings),!0===l.data("pagination")&&0===l.find("nav").length){var r=new n.linkHeaderParser(jqXHR.getResponseHeader("Link")),s=r.getLastPageNum();r.getPageSize()!==n.settings.itemsPerPage&&(n.settings.itemsPerPage=r.getPageSize()),l.append(n.getPaginationBar(s*n.settings.itemsPerPage,i.attr("id")))}},error:function(){console.log("Could not load promotional content. AD-02")}})}0===r.length&&((r=e("<div></div>")).attr({class:"promos-container",id:"promos-container-"+getPseudoRandomNumber()}),t.append(r)),!0===t.data("pagination")&&r.on("fetchPageItemsAd",(function(e,t,n){s(e.target,t,n)})),s(r,1,10)},singlePromo:function(){var n=this,r=e(e(n)[0].element),s=r.parent(),i=n.settings.adsUrl,l={host:t.location.host,source:t.location.pathname,publish_to:r.data("publish-target")};e.ajax(i,{dataType:"json",contentType:"application/json",type:"POST",data:JSON.stringify(l),success:function(e){e===a&&console.log("Could not load promotional content, bad content received. AD-03"),o(r,e,n.settings),s.trigger("shown.ef.ads")},error:function(){console.log("Could not load promotional content. AD-04")}})}}),e.fn[r]=function(t){return this.each((function(){e.data(this,"plugin_"+r)||e.data(this,"plugin_"+r,new i(this,t))}))};var o=function(e,t,n){var a=l(e.data("template-id"),n);e.html(Mustache.render(a,{content:t}))},l=function(e,t){return"allPromos"===t.type?u(e,'{{#content}}<p><a href="http://www.eclipse.org/home/index.php?ad_id={{ id }}">Ad ID: {{ id }}</a><span class="margin-left-10">prob: {{ weight }}%</span><div class="eclipsefnd-ad ad-strategic ad-strategic-default"><a href="{{ url }}" rel="nofollow" style="background-image: url(\'{{ image }}\')">{{ member_name }}</a></div></p>{{/content}}'):u(e,'{{#content}}<div class="eclipsefnd-ad ad-strategic ad-strategic-default"><a href="{{ url }}" rel="nofollow" style="background-image: url(\'{{ image }}\')">{{ member_name }}</a></div>{{/content}}')},c=function(t,n,r){var s=e(t),i=r.newsroomUrl+"/featured_story",o=s.data("id");o!==a&&(i+="/"+o),i+=d(s,"publish-target","publish_to",a,!0),e.ajax(i,{success:function(e){e.featured_story===a&&console.log("Could not load featured content, bad content recieved");var t=e.featured_story.filter((function(e){return new Date(e["end-date"])>new Date&&(e["start-date"]===a||new Date(e["start-date"])<new Date)})).filter((function(e){return e.type===n||"both"===e.type}));if(t.length>1&&g(t),t.length>0)p(t[0],s,n);else{p({id:"default-featured-story",layout:"light",title:"Eclipse Foundation Events",body:"Join the world’s leading technologists and open source leaders at Eclipse Foundation events to share ideas, learn and collaborate.",links:[{url:"https://events.eclipse.org",title:"View Events"}]},s,"both")}},error:function(){console.log("Could not load featured content!")}})},p=function(e,t,n){var a=t.find(".featured-container");t.addClass("featured-story-nid-"+e.id),t.addClass("featured-story-"+e.layout);var r=t.data("template-id")||"template-featured-"+n,s=u(r,'{{#content}}<h2 class="margin-top-30">{{ title }}</h2><p>{{ body }}</p><ul class="list-inline list-inline-xs-margin">{{#links}}<li><a class="btn btn-primary" href="{{ url }}">{{ title }}</a></li>{{/links}}</ul>{{/content}}'),i=Mustache.render(s,{content:e});a.html(i)},d=function(e,t,n,r,s){var i=e.data(t)||r,o="";if(Array.isArray(i))for(var l=0;l<i.length;l++)o+=s&&0===l?"?":"&",o+="parameters%5B"+n+"%5D%5B%5D="+i[l];else i!==a&&(o+=s?"?":"&",o+="parameters%5B"+n+"%5D="+i);return o},u=function(t,n){var r=e("#"+t);return r!==a&&0!==r.length?r[0].innerHTML:n},g=function(e){for(var t=e.length-1;t>0;t--){var n=Math.floor(Math.random()*(t+1)),a=e[t];e[t]=e[n],e[n]=a}}}(jQuery,window,document),function(e,t){"object"==typeof exports&&"undefined"!=typeof module?module.exports=t():"function"==typeof define&&define.amd?define(t):(e=e||self).Mustache=t()}(this,(function(){"use strict";var e=Object.prototype.toString,t=Array.isArray||function(t){return"[object Array]"===e.call(t)};function n(e){return"function"==typeof e}function a(e){return e.replace(/[\-\[\]{}()*+?.,\\\^$|#\s]/g,"\\$&")}function r(e,t){return null!=e&&"object"==typeof e&&t in e}var s=RegExp.prototype.test;var i=/\S/;function o(e){return!function(e,t){return s.call(e,t)}(i,e)}var l={"&":"&","<":"<",">":">",'"':""","'":"'","/":"/","`":"`","=":"="};var c=/\s*/,p=/\s+/,d=/\s*=/,u=/\s*\}/,g=/#|\^|\/|>|\{|&|=|!/;function h(e){this.string=e,this.tail=e,this.pos=0}function f(e,t){this.view=e,this.cache={".":this.view},this.parent=t}function m(){this.templateCache={_cache:{},set:function(e,t){this._cache[e]=t},get:function(e){return this._cache[e]},clear:function(){this._cache={}}}}h.prototype.eos=function(){return""===this.tail},h.prototype.scan=function(e){var t=this.tail.match(e);if(!t||0!==t.index)return"";var n=t[0];return this.tail=this.tail.substring(n.length),this.pos+=n.length,n},h.prototype.scanUntil=function(e){var t,n=this.tail.search(e);switch(n){case-1:t=this.tail,this.tail="";break;case 0:t="";break;default:t=this.tail.substring(0,n),this.tail=this.tail.substring(n)}return this.pos+=t.length,t},f.prototype.push=function(e){return new f(e,this)},f.prototype.lookup=function(e){var t,a,s,i=this.cache;if(i.hasOwnProperty(e))t=i[e];else{for(var o,l,c,p=this,d=!1;p;){if(e.indexOf(".")>0)for(o=p.view,l=e.split("."),c=0;null!=o&&c<l.length;)c===l.length-1&&(d=r(o,l[c])||(a=o,s=l[c],null!=a&&"object"!=typeof a&&a.hasOwnProperty&&a.hasOwnProperty(s))),o=o[l[c++]];else o=p.view[e],d=r(p.view,e);if(d){t=o;break}p=p.parent}i[e]=t}return n(t)&&(t=t.call(this.view)),t},m.prototype.clearCache=function(){void 0!==this.templateCache&&this.templateCache.clear()},m.prototype.parse=function(e,n){var r=this.templateCache,s=e+":"+(n||v.tags).join(":"),i=void 0!==r,l=i?r.get(s):void 0;return null==l&&(l=function(e,n){if(!e)return[];var r,s,i,l=!1,f=[],m=[],b=[],w=!1,_=!1,y="",x=0;function P(){if(w&&!_)for(;b.length;)delete m[b.pop()];else b=[];w=!1,_=!1}function k(e){if("string"==typeof e&&(e=e.split(p,2)),!t(e)||2!==e.length)throw new Error("Invalid tags: "+e);r=new RegExp(a(e[0])+"\\s*"),s=new RegExp("\\s*"+a(e[1])),i=new RegExp("\\s*"+a("}"+e[1]))}k(n||v.tags);for(var C,j,U,E,M,T,S=new h(e);!S.eos();){if(C=S.pos,U=S.scanUntil(r))for(var L=0,D=U.length;L<D;++L)o(E=U.charAt(L))?(b.push(m.length),y+=E):(_=!0,l=!0,y+=" "),m.push(["text",E,C,C+1]),C+=1,"\n"===E&&(P(),y="",x=0,l=!1);if(!S.scan(r))break;if(w=!0,j=S.scan(g)||"name",S.scan(c),"="===j?(U=S.scanUntil(d),S.scan(d),S.scanUntil(s)):"{"===j?(U=S.scanUntil(i),S.scan(u),S.scanUntil(s),j="&"):U=S.scanUntil(s),!S.scan(s))throw new Error("Unclosed tag at "+S.pos);if(M=">"==j?[j,U,C,S.pos,y,x,l]:[j,U,C,S.pos],x++,m.push(M),"#"===j||"^"===j)f.push(M);else if("/"===j){if(!(T=f.pop()))throw new Error('Unopened section "'+U+'" at '+C);if(T[1]!==U)throw new Error('Unclosed section "'+T[1]+'" at '+C)}else"name"===j||"{"===j||"&"===j?_=!0:"="===j&&k(U)}if(P(),T=f.pop())throw new Error('Unclosed section "'+T[1]+'" at '+S.pos);return function(e){for(var t,n=[],a=n,r=[],s=0,i=e.length;s<i;++s)switch((t=e[s])[0]){case"#":case"^":a.push(t),r.push(t),a=t[4]=[];break;case"/":r.pop()[5]=t[2],a=r.length>0?r[r.length-1][4]:n;break;default:a.push(t)}return n}(function(e){for(var t,n,a=[],r=0,s=e.length;r<s;++r)(t=e[r])&&("text"===t[0]&&n&&"text"===n[0]?(n[1]+=t[1],n[3]=t[3]):(a.push(t),n=t));return a}(m))}(e,n),i&&r.set(s,l)),l},m.prototype.render=function(e,t,n,a){var r=this.parse(e,a),s=t instanceof f?t:new f(t,void 0);return this.renderTokens(r,s,n,e,a)},m.prototype.renderTokens=function(e,t,n,a,r){for(var s,i,o,l="",c=0,p=e.length;c<p;++c)o=void 0,"#"===(i=(s=e[c])[0])?o=this.renderSection(s,t,n,a):"^"===i?o=this.renderInverted(s,t,n,a):">"===i?o=this.renderPartial(s,t,n,r):"&"===i?o=this.unescapedValue(s,t):"name"===i?o=this.escapedValue(s,t):"text"===i&&(o=this.rawValue(s)),void 0!==o&&(l+=o);return l},m.prototype.renderSection=function(e,a,r,s){var i=this,o="",l=a.lookup(e[1]);if(l){if(t(l))for(var c=0,p=l.length;c<p;++c)o+=this.renderTokens(e[4],a.push(l[c]),r,s);else if("object"==typeof l||"string"==typeof l||"number"==typeof l)o+=this.renderTokens(e[4],a.push(l),r,s);else if(n(l)){if("string"!=typeof s)throw new Error("Cannot use higher-order sections without the original template");null!=(l=l.call(a.view,s.slice(e[3],e[5]),(function(e){return i.render(e,a,r)})))&&(o+=l)}else o+=this.renderTokens(e[4],a,r,s);return o}},m.prototype.renderInverted=function(e,n,a,r){var s=n.lookup(e[1]);if(!s||t(s)&&0===s.length)return this.renderTokens(e[4],n,a,r)},m.prototype.indentPartial=function(e,t,n){for(var a=t.replace(/[^ \t]/g,""),r=e.split("\n"),s=0;s<r.length;s++)r[s].length&&(s>0||!n)&&(r[s]=a+r[s]);return r.join("\n")},m.prototype.renderPartial=function(e,t,a,r){if(a){var s=n(a)?a(e[1]):a[e[1]];if(null!=s){var i=e[6],o=e[5],l=e[4],c=s;return 0==o&&l&&(c=this.indentPartial(s,l,i)),this.renderTokens(this.parse(c,r),t,a,c,r)}}},m.prototype.unescapedValue=function(e,t){var n=t.lookup(e[1]);if(null!=n)return n},m.prototype.escapedValue=function(e,t){var n=t.lookup(e[1]);if(null!=n)return v.escape(n)},m.prototype.rawValue=function(e){return e[1]};var v={name:"mustache.js",version:"4.0.1",tags:["{{","}}"],clearCache:void 0,escape:void 0,parse:void 0,render:void 0,Scanner:void 0,Context:void 0,Writer:void 0,set templateCache(e){b.templateCache=e},get templateCache(){return b.templateCache}},b=new m;return v.clearCache=function(){return b.clearCache()},v.parse=function(e,t){return b.parse(e,t)},v.render=function(e,n,a,r){if("string"!=typeof e)throw new TypeError('Invalid template! Template should be a "string" but "'+((t(s=e)?"array":typeof s)+'" was given as the first argument for mustache#render(template, view, partials)'));var s;return b.render(e,n,a,r)},v.escape=function(e){return String(e).replace(/[&<>"'`=\/]/g,(function(e){return l[e]}))},v.Scanner=h,v.Context=f,v.Writer=m,v})); |
/* | ||
* jquery-eclipsefdn-api - v0.0.42 | ||
* jquery-eclipsefdn-api - v0.0.43 | ||
* Fetch and display data from various Eclipse Foundation APIs. | ||
@@ -11,803 +11,2 @@ * https://github.com/EclipseFdn/jquery-eclipsefdn-api | ||
*/ | ||
(function($, window, document, undefined) { | ||
"use strict"; | ||
var pluginName = "eclipseFdnIgc", | ||
defaults = { | ||
// connecting client should identify itself so that storage is separated in | ||
// multi-client configurations | ||
clientName: "unknown", | ||
// authorization URL. i.e. https://accounts.eclipse.org | ||
authUrl: "https://accounts.eclipse.org", | ||
// URL to API. i.e. https://api.eclipse.org | ||
apiUrl: "https://api.eclipse.org", | ||
// It should always come back to current site but path may change in the future | ||
redirectUri: [location.protocol, "//", location.host, "/site_login/implicit_grant/authorized"].join(""), | ||
// its now unnecessary for the connecting client to set storage name, clientID is appended to avoid multi-client collisions | ||
baseStorageName: "eclipseIGC", | ||
// redirect back to originating page after validation. Only disable for debugging validation flow | ||
redirectIfValid: true, | ||
// validate token issued to logged in user. extra validation step. Disabled by default. | ||
// tklanding will fill this in based on settings | ||
validateUser: true, | ||
// base64 encode stored items. | ||
encodeStorage: true, | ||
// used only by tklanding to validate token is for the current user, if validateUser enabled | ||
// tklanding will fill this in. | ||
username: "", | ||
// set to false to not store and complete the request after authorization | ||
completeOnAuthorization: true, | ||
}; | ||
function Plugin(element, options) { | ||
this.element = element; | ||
this.settings = $.extend({}, defaults, options); | ||
this._defaults = defaults; | ||
this._name = pluginName; | ||
this.init(); | ||
} | ||
// Avoid Plugin.prototype conflicts | ||
$.extend(Plugin.prototype, { | ||
/** | ||
* requests a token from oauth2 server using implicit grant flow | ||
*/ | ||
authorizeClient: function() { | ||
if (this.settings.authUrl.length === 0) { | ||
// can't continue without it. consider throwing error | ||
var error = { | ||
error: 400, | ||
error_description: "authorization end-point not defined", | ||
error_from: "authorizeClient" | ||
}; | ||
this.storeItem("error_msg", error); | ||
} | ||
// store the "return to" address | ||
this.storeItem("return_location", { | ||
prevLoc: window.location.href | ||
}); | ||
var state = this.getNewState(); | ||
var authURI = this.settings.authUrl + "/oauth2/authorize" + | ||
"?response_type=token" + | ||
"&client_id=" + this.request.cid + | ||
"&redirect_uri=" + encodeURIComponent(this.settings.redirectUri) + | ||
"&scope=" + encodeURIComponent(this.request.scope) + | ||
"&state=" + state; | ||
self.location = authURI; | ||
}, | ||
/** | ||
* retrieves stored action delayed by authorization request | ||
*/ | ||
getDelayedAction: function() { | ||
// in default standard mode, retrieve it from storage | ||
return this.getStoredItem("request", true); | ||
}, | ||
/** | ||
* Generates and stores a randomized string for verifying the token request | ||
* was expected and originated from us | ||
*/ | ||
getNewState: function() { | ||
// generates a random string | ||
var rand = function() { | ||
return Math.random().toString(36).substr(2); | ||
}; | ||
// generate a double-length string to use to validate the state (i.e., the request came from us) | ||
var newState = rand() + rand(); | ||
// store it for later. | ||
this.storeItem("state", { | ||
state: newState | ||
}); | ||
return newState; | ||
}, | ||
/** | ||
* reads item from storage and returns it | ||
*/ | ||
getStoredItem: function(itemName, burnAfterReading) { | ||
// add suffix based on item type | ||
var self = this; | ||
var storeName = this.getStoreName(itemName); | ||
if (typeof(burnAfterReading) === "undefined") { | ||
burnAfterReading = false; | ||
} | ||
var storedItem = null; | ||
switch (this.storage) { | ||
case "local": | ||
storedItem = localStorage.getItem(storeName); | ||
if (storedItem === null) { | ||
break; | ||
} | ||
var date = new Date(); | ||
// parse it and check if it's expired | ||
storedItem = decodeAndParse(storedItem); | ||
if (storedItem.expires_time <= date.getTime()) { | ||
// it's expired, remove it and pretend it doesn't exist | ||
this.removeStoredItem(itemName); | ||
storedItem = null; | ||
} | ||
break; | ||
case "cookie": | ||
var name = storeName + "="; | ||
var stored = document.cookie.split(";"); | ||
for (var i = 0; i < stored.length; i++) { | ||
var c = stored[i]; | ||
c = c.trim(); | ||
if (c.indexOf(name) === 0) { | ||
storedItem = c.substring(name.length, c.length); | ||
storedItem = decodeAndParse(storedItem); | ||
} | ||
} | ||
break; | ||
} | ||
// remove the item from storage before returning the value, if specified | ||
if (burnAfterReading) { | ||
this.removeStoredItem(itemName); | ||
} | ||
return storedItem; | ||
function decodeAndParse(item) { | ||
var retrievedItem; | ||
try { | ||
retrievedItem = self.settings.encodeStorage ? JSON.parse(atob(item)) : JSON.parse(item); | ||
return retrievedItem; | ||
} catch(e) { | ||
//Setting may have been changed while we still had stuff | ||
if (e instanceof DOMException) { | ||
// item was expected to be base64 encoded but isn't. | ||
return JSON.parse(item); | ||
} | ||
if (e instanceof SyntaxError) { | ||
// item was expected to be JSON encoded but isn't. | ||
return JSON.parse(atob(item)); | ||
} | ||
} | ||
} | ||
}, | ||
/** | ||
* formats the storage name using the base name and appending an identifier | ||
* based on item type | ||
*/ | ||
getStoreName: function(itemName) { | ||
if (typeof(itemName) === "undefined") { | ||
itemName = ""; | ||
} | ||
var baseName = this.settings.baseStorageName + "_"; | ||
// clientName is used to store settings individually per client | ||
baseName = baseName + this.settings.clientName; | ||
switch (itemName) { | ||
case "token": | ||
baseName = baseName + "_tk"; | ||
break; | ||
case "state": | ||
// generated state string for validation | ||
baseName = baseName + "_st"; | ||
break; | ||
// "return to" location | ||
case "return_location": | ||
baseName = baseName + "_cloc"; | ||
break; | ||
// delayed request due to requiring authorization | ||
case "request": | ||
baseName = baseName + "_req"; | ||
break; | ||
// delayed respone from action completed after authorization | ||
case "delayed_response": | ||
baseName = baseName + "_dlresp"; | ||
break; | ||
// delayed error from attempted action after authorization | ||
case "delayed_error": | ||
baseName = baseName + "_dlerr"; | ||
break; | ||
// This is not currently used, as we now trigger an event on auth return. | ||
case "feedback_msg": | ||
baseName = baseName + "_fbm"; | ||
break; | ||
// Typically for validation errors and such, event triggers on final redirect back. | ||
case "error_msg": | ||
baseName = baseName + "_err"; | ||
break; | ||
case "lastAuthReq": | ||
baseName = this.settings.baseStorageName + "_lreq"; | ||
break; | ||
default: | ||
// we shouldn't be here, give it a name anyways | ||
baseName = baseName + "_" + itemName; | ||
} | ||
return baseName; | ||
}, | ||
/** | ||
* checks storage and returns bool if a token is already in storage. | ||
*/ | ||
haveToken: function() { | ||
if (this.getStoredItem("token") !== null) { | ||
return true; | ||
} | ||
return false; | ||
}, | ||
/** | ||
* Initialize function for plugin | ||
*/ | ||
init: function() { | ||
var self = this; | ||
// expose responseHandler for tklanding page | ||
$.fn[this._name].responseHandler = function(value) { | ||
self.responseHandler(value); | ||
}; | ||
// we may want to expand this for additional callbacks / promises | ||
$.fn[this._name].makeRequest = function(requestOptions) { | ||
self.makeRequest(requestOptions); | ||
}; | ||
// expose storage save item to connecting clients | ||
$.fn[this._name].saveItem = function(itemName, item, expiresIn) { | ||
// check for reserved names and bail if they attempt it | ||
if (!isItemNameReserved(itemName)) { | ||
self.storeItem(itemName, item, expiresIn); | ||
return true; | ||
} | ||
return false; | ||
}; | ||
// expose storage retrieve item to connecting clients | ||
$.fn[this._name].retrieveItem = function(itemName, burnAfterReading) { | ||
// check for reserved names and bail if they attempt it | ||
if (!isItemNameReserved(itemName)) { | ||
return self.getStoredItem(itemName, burnAfterReading); | ||
} | ||
return false; | ||
}; | ||
// expose storage remove item to connecting clients | ||
$.fn[this._name].removeItem = function(itemName) { | ||
// check for reserved names and bail if they attempt it | ||
if (!isItemNameReserved(itemName)) { | ||
return self.removeStoredItem(itemName); | ||
} | ||
return false; | ||
}; | ||
// determine supported storage method | ||
this.storage = "none"; | ||
if (this.settings.baseStorageName.length === 0) { | ||
// we don't have a baseStorageName for some reason | ||
this.settings.baseStorageName = "eclipseIGC"; | ||
} | ||
// check if browser supports localStorage | ||
if (typeof(Storage) !== "undefined") { | ||
this.storage = "local"; | ||
} else if (navigator.cookieEnabled) { | ||
// if not, maybe cookies are enabled | ||
this.storage = "cookie"; | ||
} | ||
// without some kind of storage, we need to authenticate on each page | ||
// and lose what we get by the time we've finished authorizing / validating. | ||
// we currently do not support a non-storage workflow* | ||
// *the only way this could work is with open-window method and storing in vars | ||
// if no storage is available, we could throw feedback_msg that this would work better | ||
// with a modern browser/cookies enabled | ||
// check for any delayed action stored and send the results in an event | ||
var delayedResponse = this.getStoredItem("delayed_response", true); | ||
if (delayedResponse != null) { | ||
$(document).trigger("igcRequestComplete", delayedResponse); | ||
return; | ||
} | ||
var delayedError = this.getStoredItem("delayed_error", true); | ||
if (delayedError != null) { | ||
$(document).trigger("igcRequestFailed", delayedError); | ||
return; | ||
} | ||
var authError = this.getStoredItem("error_msg", true); | ||
if (authError != null) { | ||
$(document).trigger("igcAuthFailed", authError); | ||
return; | ||
} | ||
// check if the user is even logged in, if not we need to clear out tokens to prevent multi-user collisions | ||
$(document).ready(function() { | ||
// instead of calling Drupal.settings directly, | ||
// let's expect username to be filled and make this system agnostic. | ||
if (typeof(self.settings.username) === "undefined" || self.settings.username.length === 0) { | ||
// clean-up | ||
self.removeStoredItem("token"); | ||
return; | ||
} | ||
// do we have a last user? | ||
var lastUser = self.getStoredItem("session_user"); | ||
if (lastUser !== null && lastUser.username !== self.settings.username) { | ||
// we had a change of users. | ||
self.removeStoredItem("token"); | ||
// set the new user | ||
self.storeItem("session_user", {username : self.settings.username}, 3600); | ||
return; | ||
} | ||
if (lastUser === null) { | ||
// new user | ||
self.storeItem("session_user", {username : self.settings.username}, 3600); | ||
} | ||
}); | ||
/** | ||
* Checks if connecting client is trying to store an item using a reserved store name | ||
* | ||
* @param name | ||
* @returns boolean | ||
*/ | ||
function isItemNameReserved(name) { | ||
var reservedList = [ | ||
"token", | ||
"state", | ||
"return_location", | ||
"request", | ||
"delayed_response", | ||
"delayed_error", | ||
"feedback_msg", | ||
"error_msg", | ||
]; | ||
if (typeof(name) === "undefined") { | ||
name = ""; | ||
} | ||
name = name.toLowerCase(); | ||
if (reservedList.indexOf(name) > -1) { | ||
return true; | ||
} | ||
return false; | ||
} | ||
}, | ||
/** | ||
* Public method - if token is stored, makes the request. | ||
* If not, stores the request and fetches new token via implicit grant flow | ||
* request and callback should be completed on return | ||
*/ | ||
makeRequest: function(requestOptions, wasDelayed) { | ||
var self = this; | ||
if (typeof(wasDelayed) === "undefined") { | ||
wasDelayed = false; | ||
} | ||
if (this.haveToken()) { | ||
// do the request | ||
var defaultOptions = { | ||
path: "/", | ||
method: "GET", | ||
// default contentTypes don't play nice, even if we aren't sending data | ||
contentType: "application/json", | ||
context: $(document), | ||
successCallback: null, | ||
errorCallback: null | ||
}; | ||
var theOptions = $.extend({}, defaultOptions, requestOptions); | ||
$.ajax({ | ||
url: this.settings.apiUrl + theOptions.path, | ||
context: theOptions.context, | ||
method: theOptions.method, | ||
contentType: theOptions.contentType, | ||
beforeSend: function(xhr) { | ||
var token = self.getStoredItem("token"); | ||
xhr.setRequestHeader("Authorization", "Bearer " + token.access_token); | ||
} | ||
}) | ||
.done(function(data, textStatus, jqXHR) { | ||
// make sure callback exists, if so call it. | ||
if (typeof(theOptions.successCallback) === "function") { | ||
theOptions.successCallback(data, textStatus, jqXHR); | ||
return; | ||
} | ||
// if this was a delayed action, the callback would have been lost. | ||
// store the relevant data so that an event can be triggered on redirect finish | ||
if (wasDelayed) { | ||
// combine the requestOptions with data so caller can figure out what they did | ||
// include the response headers as the functions get stripped from the object on save. | ||
var combined = { | ||
clientName: self.settings.clientName, | ||
data: data, | ||
textStatus: textStatus, | ||
responseHeaders: jqXHR.getAllResponseHeaders(), | ||
requestOptions: theOptions | ||
}; | ||
self.storeItem("delayed_response", combined); | ||
self.redirectToStart(); | ||
} | ||
}) | ||
.fail(function(jqHXR) { | ||
// although our token *should* expire when it's due, | ||
// we need to trigger a re-auth in the event that it's not found and we're no longer authorized | ||
// or maybe we have the wrong one. | ||
if (jqHXR.status === 401) { | ||
triggerAuthorization(); | ||
return; | ||
} | ||
// if callback is defined, call it. | ||
if (typeof(theOptions.errorCallback) === "function") { | ||
requestOptions.errorCallback(jqHXR); | ||
return; | ||
} | ||
// if this was a delayed action, the callback was lost in the flow | ||
// save some relevant info to trigger an event on redirect finish. | ||
if (wasDelayed) { | ||
// combine the requestOptions with data so caller can figure out what they did | ||
var combined = { | ||
clientName: self.settings.clientName, | ||
requestOptions: theOptions, | ||
jqXHR: jqHXR | ||
}; | ||
self.storeItem("delayed_error", combined); | ||
self.redirectToStart(); | ||
} | ||
}); | ||
return; | ||
} | ||
triggerAuthorization(); | ||
/** | ||
* saves the current request and triggers a authorization | ||
* only needed within the makeRequest scope | ||
*/ | ||
function triggerAuthorization() { | ||
if (self.settings.completeOnAuthorization) { | ||
// remove the context to prevent "converting circular stucture to json" error | ||
requestOptions.context = null; | ||
// store the request to process on completion. | ||
self.storeItem("request", requestOptions); | ||
} | ||
// we'll need this information for the authorization request and to validate | ||
// the authorization response when it comes back | ||
self.request = { | ||
clientName : self.settings.clientName, | ||
cid : requestOptions.cid, | ||
scope : requestOptions.scope | ||
}; | ||
self.storeItem("lastAuthReq", self.request); | ||
self.authorizeClient(); | ||
} | ||
}, | ||
/** | ||
* pops the authorization into a new window - retains handle and context | ||
* but may be blocked by browser which breaks the asssociation | ||
*/ | ||
openWindow: function(url) { | ||
// set window size to pop in new window, login fits ok but auth screen doesn't fit well in smaller window | ||
// so using default - new tab | ||
var dialog = window.open(url, "Authorize", "height=720, width=1280"); | ||
if (window.focus && dialog) { | ||
dialog.focus(); | ||
} | ||
}, | ||
/** | ||
* redirects the browser back to the users starting point, if known | ||
* if not then it will go to home of current domain | ||
*/ | ||
redirectToStart: function() { | ||
// get the location the user left off on and go back | ||
if (this.settings.redirectIfValid === false) { | ||
// configured not to redirect and to stay on the landing page | ||
// there's no good reason for this aside from debugging purposes. | ||
return; | ||
} | ||
var prevLocation = this.getStoredItem("return_location", true); | ||
if (prevLocation === null) { | ||
// return them to home page then | ||
prevLocation = { | ||
prevLoc: [location.protocol, "//", location.host].join(""), | ||
}; | ||
} | ||
window.location.replace(prevLocation.prevLoc); | ||
}, | ||
/** | ||
* removes an item from storage | ||
*/ | ||
removeStoredItem: function(itemName) { | ||
var storeName = this.getStoreName(itemName); | ||
switch (this.storage) { | ||
case "local": | ||
localStorage.removeItem(storeName); | ||
break; | ||
case "cookie": | ||
var expires = "expires=Thu, 01 Jan 1970 00:00:00 UTC;"; | ||
document.cookie = storeName + "=;" + expires + "; path=/"; | ||
break; | ||
} | ||
}, | ||
/** | ||
* Public method - parses response, validates token if present and stores token in supported storage method | ||
* | ||
*/ | ||
responseHandler: function(hashValue) { | ||
var self = this; | ||
var nothingToDo = true; | ||
if (typeof(hashValue) === "undefined") { | ||
hashValue = ""; | ||
} | ||
if (typeof(this.settings.redirectIfValid) !== "boolean") { | ||
this.settings.redirectIfValid = true; | ||
} | ||
// parse the response | ||
var responseParts = parseResponse(hashValue); | ||
if (!$.isEmptyObject(responseParts)) { | ||
// check if there's a token in the response | ||
if (typeof(responseParts.access_token) !== "undefined") { | ||
this.request = this.getStoredItem("lastAuthReq", true); | ||
if (this.request == null) { | ||
// this is unexpected, we don't have a pending auth request | ||
this.redirectToStart(); | ||
return; | ||
} | ||
// restore the clientName so we can retrieve items stored for it | ||
this.settings.clientName = this.request.clientName; | ||
// check if we already have one | ||
if (this.haveToken()) { | ||
// We already have a token. This probably didn't come from a request | ||
this.redirectToStart(); | ||
return; | ||
} | ||
// we have something to do | ||
nothingToDo = false; | ||
// check for errors and validate it | ||
this.validateToken(responseParts, function(success, msg) { | ||
if (typeof(success) !== "boolean") { | ||
success = false; | ||
} | ||
// if validation passes, store it. Otherwise toss it away and don't even kick the callback (if specified) | ||
if (success === true) { | ||
self.storeItem("token", responseParts); | ||
// retrieve stored action and finalize | ||
var requestOptions = self.getDelayedAction(); | ||
if (requestOptions != null) { | ||
// will call redirect when it's done | ||
self.makeRequest(requestOptions, true); | ||
return; | ||
} | ||
} else { | ||
// remove the stored request | ||
self.removeStoredItem("request"); | ||
// store error message, if any, to display on the return | ||
if (typeof(msg) !== "undefined" && msg !== null) { | ||
// msgs passed back from validation, triggers event after final redirect back. | ||
self.storeItem("error_msg", msg); | ||
} | ||
} | ||
self.redirectToStart(); | ||
}); | ||
} | ||
if (typeof(responseParts.error) !== "undefined") { | ||
// access was denied, and likely because someone pressed cancel on the authorization page | ||
// or an invalid scope was requested | ||
this.removeStoredItem("request"); | ||
this.removeStoredItem("state"); | ||
this.storeItem("error_msg", responseParts); | ||
} | ||
} | ||
// nothing to do - redirect back to where they were and away from landing | ||
if (nothingToDo) { | ||
self.redirectToStart(); | ||
} | ||
/** | ||
* parse the response taken from the URI | ||
* | ||
* local to responseHandler method scope. | ||
* | ||
* @param response | ||
* | ||
* @returns object | ||
*/ | ||
function parseResponse(response) { | ||
// current implementation only checks/gets token and processes the rest if it needs to | ||
// we gain more in error conditions if we just parse the lot into a keyed array | ||
var values = {}; | ||
var hashString = response.substring(response.indexOf("?")); | ||
// don't process if there is no "query" string in the passed in response | ||
if (hashString) { | ||
var paramPattern = /([^#?&=]+)=([^&]*)/g; | ||
var param; | ||
// break it down, param[1] is name, param[2] is value | ||
while ((param = paramPattern.exec(hashString)) !== null) { | ||
values[decodeURIComponent(param[1])] = decodeURIComponent(param[2]); | ||
} | ||
} | ||
return values; | ||
} | ||
}, | ||
/** | ||
* store the token for use later, either in cookie or localStorage | ||
* | ||
*/ | ||
storeItem: function(itemName, item, expiresIn) { | ||
var storeName = this.getStoreName(itemName); | ||
var date; | ||
var expiry; | ||
if (typeof(item) === "undefined") { | ||
// nothing really we can do with this | ||
return; | ||
} | ||
switch (itemName) { | ||
case "token": | ||
// token will have expiry as part of response | ||
expiresIn = parseInt(item.expires_in) - 1; | ||
date = new Date(); | ||
expiry = expiresIn * 1000; | ||
break; | ||
default: | ||
// set an expiry for everything else | ||
// default to 5min if not specified. | ||
if (typeof(expiresIn) !== "number" || expiresIn < 1) { | ||
expiresIn = 3600; | ||
} | ||
date = new Date(); | ||
expiry = expiresIn * 1000; | ||
if (typeof(item) !== "object") { | ||
// this item is not an object, convert for consistent json storage | ||
item = { | ||
itemName: item | ||
}; | ||
} | ||
} | ||
date.setTime(date.getTime() + expiry); | ||
if (this.storage === "local") { | ||
item.expires_time = date.getTime(); | ||
} | ||
// prep the item | ||
var jsonItem = this.settings.encodeStorage ? btoa(JSON.stringify(item)) : JSON.stringify(item); | ||
switch (this.storage) { | ||
case "local": | ||
// add the expiry timestamp | ||
// we'll store the json string of the response here | ||
// consider only storing portion we need instead of response | ||
localStorage.setItem(storeName, jsonItem); | ||
break; | ||
case "cookie": | ||
// we're going to store the entire response, and set the cookie auto expiry. | ||
var expires = "; expires=" + date.toUTCString(); | ||
document.cookie = storeName + "=" + jsonItem + expires + "; path=/"; | ||
break; | ||
} | ||
}, | ||
/** | ||
* validates the token and token request client ID against the authorizing agent | ||
* returns bool on validation result | ||
*/ | ||
validateToken: function(tokenResponseParts, onValidated) { | ||
var self = this; | ||
// hopefully we have a state to compare if we have storage | ||
if (this.storage !== "none") { | ||
var storedState = this.getStoredItem("state", true); | ||
if (storedState === null || storedState.state !== tokenResponseParts.state) { | ||
if (onValidated && typeof(onValidated) === "function") { | ||
onValidated(false); | ||
} | ||
return; | ||
} | ||
} | ||
$.ajax({ | ||
url: this.settings.authUrl + "/oauth2/tokens/" + tokenResponseParts.access_token | ||
}).done(function(data) { | ||
// does the client ID and scope match ours? | ||
var valid = true; | ||
var msg = null; | ||
if (self.request.cid !== data.client_id) { | ||
valid = false; | ||
msg = { | ||
clientName: self.settings.clientName, | ||
error: 400, | ||
error_description: "Received token issued to unrecognized Client ID", | ||
error_from: "oauth2/tokens" | ||
}; | ||
} | ||
// so far so good, check the scopes | ||
if (valid) { | ||
// token response separates multi-scopes with '+' | ||
var grantedScopes = tokenResponseParts.scope.split("+"); | ||
var requestedScopes = self.request.scope.split(" "); | ||
var flaggedScope = []; | ||
$(grantedScopes).each(function(){ | ||
if (requestedScopes.indexOf(this) === -1) { | ||
// the granted scope is not in the list of expected scopes | ||
valid = false; | ||
flaggedScope.push(this); | ||
} | ||
if (!valid) { | ||
msg = { | ||
clientName: self.settings.clientName, | ||
error: 400, | ||
error_description: "Granted scope " + flaggedScope.join(" ") + "is not in the list of expected scopes", | ||
error_from: "oauth2/tokens" | ||
}; | ||
} | ||
}); | ||
} | ||
if (self.settings.validateUser && self.settings.username.length > 0 && valid) { | ||
var tokenUID; | ||
if (typeof(data.user_id) !== "undefined") { | ||
tokenUID = data.user_id; | ||
} | ||
// one more call, which will kick the callback for us | ||
validateTheUserID(tokenUID, onValidated); | ||
} else { | ||
// call the onValidated callback | ||
if (onValidated && typeof(onValidated) === "function") { | ||
onValidated(valid, msg); | ||
} | ||
} | ||
}).fail(function(jqXHR) { | ||
// error, we can assume it's no good but in case we want to log the attempt somewhere | ||
// 404's mean the token wasn't found on the authorizing system. | ||
var msg = { | ||
clientName: self.settings.clientName, | ||
error: jqXHR.status, | ||
error_description: "Error validating authorization response.", | ||
error_from: "validateToken" | ||
}; | ||
if (onValidated && typeof(onValidated) === "function") { | ||
onValidated(false, msg); | ||
} | ||
}); | ||
function validateTheUserID(tokenUID, onValidated) { | ||
// quick test against what api/account/profile returns | ||
var account = self.settings.apiUrl + "/account/profile/" + self.settings.username; | ||
$.ajax({ | ||
url: account | ||
}).done(function(data) { | ||
var isValid = true; | ||
var msg = null; | ||
if (typeof(data.name) !== "undefined") { | ||
// these should match | ||
if (data.uid !== tokenUID) { | ||
// hmm, the token's user_id and the logged in user_id do not match. | ||
msg = { | ||
clientName: self.settings.clientName, | ||
error: 400, | ||
error_description: "Authorizing account does not match the current logged in account on this site", | ||
error_from: "account/profile" | ||
}; | ||
isValid = false; | ||
} | ||
} | ||
// call the onValidated callback | ||
if (onValidated && typeof(onValidated) === "function") { | ||
onValidated(isValid, msg); | ||
} | ||
}).fail(function(jqXHR) { | ||
var msg = { | ||
clientName: self.settings.clientName, | ||
error: jqXHR.status, | ||
error_description: jqXHR.statusText, | ||
error_from: "account/profile" | ||
}; | ||
if (onValidated && typeof(onValidated) === "function") { | ||
onValidated(false, msg); | ||
} | ||
}); | ||
} | ||
} | ||
}); | ||
// A really lightweight plugin wrapper around the constructor, | ||
// preventing against multiple instantiations | ||
$.fn[pluginName] = function(options) { | ||
return this.each(function() { | ||
if (!$.data(this, "plugin_" + pluginName)) { | ||
$.data(this, "plugin_" + | ||
pluginName, new Plugin(this, options)); | ||
} | ||
}); | ||
}; | ||
})(jQuery, window, document); | ||
!function(e,t,r,o){"use strict";var i="eclipseFdnIgc",n={clientName:"unknown",authUrl:"https://accounts.eclipse.org",apiUrl:"https://api.eclipse.org",redirectUri:[location.protocol,"//",location.host,"/site_login/implicit_grant/authorized"].join(""),baseStorageName:"eclipseIGC",redirectIfValid:!0,validateUser:!0,encodeStorage:!0,username:"",completeOnAuthorization:!0};function s(t,r){this.element=t,this.settings=e.extend({},n,r),this._defaults=n,this._name=i,this.init()}e.extend(s.prototype,{authorizeClient:function(){if(0===this.settings.authUrl.length){this.storeItem("error_msg",{error:400,error_description:"authorization end-point not defined",error_from:"authorizeClient"})}this.storeItem("return_location",{prevLoc:t.location.href});var e=this.getNewState(),r=this.settings.authUrl+"/oauth2/authorize?response_type=token&client_id="+this.request.cid+"&redirect_uri="+encodeURIComponent(this.settings.redirectUri)+"&scope="+encodeURIComponent(this.request.scope)+"&state="+e;self.location=r},getDelayedAction:function(){return this.getStoredItem("request",!0)},getNewState:function(){var e=function(){return Math.random().toString(36).substr(2)},t=e()+e();return this.storeItem("state",{state:t}),t},getStoredItem:function(e,t){var o=this,i=this.getStoreName(e);void 0===t&&(t=!1);var n=null;switch(this.storage){case"local":if(null===(n=localStorage.getItem(i)))break;var s=new Date;(n=d(n)).expires_time<=s.getTime()&&(this.removeStoredItem(e),n=null);break;case"cookie":for(var a=i+"=",c=r.cookie.split(";"),l=0;l<c.length;l++){var u=c[l];0===(u=u.trim()).indexOf(a)&&(n=d(n=u.substring(a.length,u.length)))}}return t&&this.removeStoredItem(e),n;function d(e){try{return o.settings.encodeStorage?JSON.parse(atob(e)):JSON.parse(e)}catch(t){if(t instanceof DOMException)return JSON.parse(e);if(t instanceof SyntaxError)return JSON.parse(atob(e))}}},getStoreName:function(e){void 0===e&&(e="");var t=this.settings.baseStorageName+"_";switch(t+=this.settings.clientName,e){case"token":t+="_tk";break;case"state":t+="_st";break;case"return_location":t+="_cloc";break;case"request":t+="_req";break;case"delayed_response":t+="_dlresp";break;case"delayed_error":t+="_dlerr";break;case"feedback_msg":t+="_fbm";break;case"error_msg":t+="_err";break;case"lastAuthReq":t=this.settings.baseStorageName+"_lreq";break;default:t=t+"_"+e}return t},haveToken:function(){return null!==this.getStoredItem("token")},init:function(){var t=this;e.fn[this._name].responseHandler=function(e){t.responseHandler(e)},e.fn[this._name].makeRequest=function(e){t.makeRequest(e)},e.fn[this._name].saveItem=function(e,r,o){return!s(e)&&(t.storeItem(e,r,o),!0)},e.fn[this._name].retrieveItem=function(e,r){return!s(e)&&t.getStoredItem(e,r)},e.fn[this._name].removeItem=function(e){return!s(e)&&t.removeStoredItem(e)},this.storage="none",0===this.settings.baseStorageName.length&&(this.settings.baseStorageName="eclipseIGC"),"undefined"!=typeof Storage?this.storage="local":navigator.cookieEnabled&&(this.storage="cookie");var o=this.getStoredItem("delayed_response",!0);if(null==o){var i=this.getStoredItem("delayed_error",!0);if(null==i){var n=this.getStoredItem("error_msg",!0);null==n?e(r).ready((function(){if(void 0!==t.settings.username&&0!==t.settings.username.length){var e=t.getStoredItem("session_user");if(null!==e&&e.username!==t.settings.username)return t.removeStoredItem("token"),void t.storeItem("session_user",{username:t.settings.username},3600);null===e&&t.storeItem("session_user",{username:t.settings.username},3600)}else t.removeStoredItem("token")})):e(r).trigger("igcAuthFailed",n)}else e(r).trigger("igcRequestFailed",i)}else e(r).trigger("igcRequestComplete",o);function s(e){return void 0===e&&(e=""),e=e.toLowerCase(),["token","state","return_location","request","delayed_response","delayed_error","feedback_msg","error_msg"].indexOf(e)>-1}},makeRequest:function(t,o){var i=this;if(void 0===o&&(o=!1),this.haveToken()){var n={path:"/",method:"GET",contentType:"application/json",context:e(r),successCallback:null,errorCallback:null},s=e.extend({},n,t);e.ajax({url:this.settings.apiUrl+s.path,context:s.context,method:s.method,contentType:s.contentType,beforeSend:function(e){var t=i.getStoredItem("token");e.setRequestHeader("Authorization","Bearer "+t.access_token)}}).done((function(e,t,r){if("function"!=typeof s.successCallback){if(o){var n={clientName:i.settings.clientName,data:e,textStatus:t,responseHeaders:r.getAllResponseHeaders(),requestOptions:s};i.storeItem("delayed_response",n),i.redirectToStart()}}else s.successCallback(e,t,r)})).fail((function(e){if(401!==e.status)if("function"!=typeof s.errorCallback){if(o){var r={clientName:i.settings.clientName,requestOptions:s,jqXHR:e};i.storeItem("delayed_error",r),i.redirectToStart()}}else t.errorCallback(e);else a()}))}else a();function a(){i.settings.completeOnAuthorization&&(t.context=null,i.storeItem("request",t)),i.request={clientName:i.settings.clientName,cid:t.cid,scope:t.scope},i.storeItem("lastAuthReq",i.request),i.authorizeClient()}},openWindow:function(e){var r=t.open(e,"Authorize","height=720, width=1280");t.focus&&r&&r.focus()},redirectToStart:function(){if(!1!==this.settings.redirectIfValid){var e=this.getStoredItem("return_location",!0);null===e&&(e={prevLoc:[location.protocol,"//",location.host].join("")}),t.location.replace(e.prevLoc)}},removeStoredItem:function(e){var t=this.getStoreName(e);switch(this.storage){case"local":localStorage.removeItem(t);break;case"cookie":r.cookie=t+"=;expires=Thu, 01 Jan 1970 00:00:00 UTC;; path=/"}},responseHandler:function(t){var r=this,o=!0;void 0===t&&(t=""),"boolean"!=typeof this.settings.redirectIfValid&&(this.settings.redirectIfValid=!0);var i=function(e){var t={},r=e.substring(e.indexOf("?"));if(r)for(var o,i=/([^#?&=]+)=([^&]*)/g;null!==(o=i.exec(r));)t[decodeURIComponent(o[1])]=decodeURIComponent(o[2]);return t}(t);if(!e.isEmptyObject(i)){if(void 0!==i.access_token){if(this.request=this.getStoredItem("lastAuthReq",!0),null==this.request)return void this.redirectToStart();if(this.settings.clientName=this.request.clientName,this.haveToken())return void this.redirectToStart();o=!1,this.validateToken(i,(function(e,t){if("boolean"!=typeof e&&(e=!1),!0===e){r.storeItem("token",i);var o=r.getDelayedAction();if(null!=o)return void r.makeRequest(o,!0)}else r.removeStoredItem("request"),null!=t&&r.storeItem("error_msg",t);r.redirectToStart()}))}void 0!==i.error&&(this.removeStoredItem("request"),this.removeStoredItem("state"),this.storeItem("error_msg",i))}o&&r.redirectToStart()},storeItem:function(e,t,o){var i,n,s=this.getStoreName(e);if(void 0!==t){switch(e){case"token":o=parseInt(t.expires_in)-1,i=new Date,n=1e3*o;break;default:("number"!=typeof o||o<1)&&(o=3600),i=new Date,n=1e3*o,"object"!=typeof t&&(t={itemName:t})}i.setTime(i.getTime()+n),"local"===this.storage&&(t.expires_time=i.getTime());var a=this.settings.encodeStorage?btoa(JSON.stringify(t)):JSON.stringify(t);switch(this.storage){case"local":localStorage.setItem(s,a);break;case"cookie":var c="; expires="+i.toUTCString();r.cookie=s+"="+a+c+"; path=/"}}},validateToken:function(t,r){var o=this;if("none"!==this.storage){var i=this.getStoredItem("state",!0);if(null===i||i.state!==t.state)return void(r&&"function"==typeof r&&r(!1))}e.ajax({url:this.settings.authUrl+"/oauth2/tokens/"+t.access_token}).done((function(i){var n,s=!0,a=null;if(o.request.cid!==i.client_id&&(s=!1,a={clientName:o.settings.clientName,error:400,error_description:"Received token issued to unrecognized Client ID",error_from:"oauth2/tokens"}),s){var c=t.scope.split("+"),l=o.request.scope.split(" "),u=[];e(c).each((function(){-1===l.indexOf(this)&&(s=!1,u.push(this)),s||(a={clientName:o.settings.clientName,error:400,error_description:"Granted scope "+u.join(" ")+"is not in the list of expected scopes",error_from:"oauth2/tokens"})}))}o.settings.validateUser&&o.settings.username.length>0&&s?(void 0!==i.user_id&&(n=i.user_id),function(t,r){var i=o.settings.apiUrl+"/account/profile/"+o.settings.username;e.ajax({url:i}).done((function(e){var i=!0,n=null;void 0!==e.name&&e.uid!==t&&(n={clientName:o.settings.clientName,error:400,error_description:"Authorizing account does not match the current logged in account on this site",error_from:"account/profile"},i=!1),r&&"function"==typeof r&&r(i,n)})).fail((function(e){var t={clientName:o.settings.clientName,error:e.status,error_description:e.statusText,error_from:"account/profile"};r&&"function"==typeof r&&r(!1,t)}))}(n,r)):r&&"function"==typeof r&&r(s,a)})).fail((function(e){var t={clientName:o.settings.clientName,error:e.status,error_description:"Error validating authorization response.",error_from:"validateToken"};r&&"function"==typeof r&&r(!1,t)}))}}),e.fn[i]=function(t){return this.each((function(){e.data(this,"plugin_"+i)||e.data(this,"plugin_"+i,new s(this,t))}))}}(jQuery,window,document); |
/* | ||
* jquery-eclipsefdn-api - v0.0.42 | ||
* jquery-eclipsefdn-api - v0.0.43 | ||
* Fetch and display data from various Eclipse Foundation APIs. | ||
@@ -11,2 +11,2 @@ * https://github.com/EclipseFdn/jquery-eclipsefdn-api | ||
*/ | ||
!function(e,t,r,o){"use strict";var i="eclipseFdnIgc",n={clientName:"unknown",authUrl:"https://accounts.eclipse.org",apiUrl:"https://api.eclipse.org",redirectUri:[location.protocol,"//",location.host,"/site_login/implicit_grant/authorized"].join(""),baseStorageName:"eclipseIGC",redirectIfValid:!0,validateUser:!0,encodeStorage:!0,username:"",completeOnAuthorization:!0};function s(t,r){this.element=t,this.settings=e.extend({},n,r),this._defaults=n,this._name=i,this.init()}e.extend(s.prototype,{authorizeClient:function(){if(0===this.settings.authUrl.length){this.storeItem("error_msg",{error:400,error_description:"authorization end-point not defined",error_from:"authorizeClient"})}this.storeItem("return_location",{prevLoc:t.location.href});var e=this.getNewState(),r=this.settings.authUrl+"/oauth2/authorize?response_type=token&client_id="+this.request.cid+"&redirect_uri="+encodeURIComponent(this.settings.redirectUri)+"&scope="+encodeURIComponent(this.request.scope)+"&state="+e;self.location=r},getDelayedAction:function(){return this.getStoredItem("request",!0)},getNewState:function(){var e=function(){return Math.random().toString(36).substr(2)},t=e()+e();return this.storeItem("state",{state:t}),t},getStoredItem:function(e,t){var o=this,i=this.getStoreName(e);void 0===t&&(t=!1);var n=null;switch(this.storage){case"local":if(null===(n=localStorage.getItem(i)))break;var s=new Date;(n=d(n)).expires_time<=s.getTime()&&(this.removeStoredItem(e),n=null);break;case"cookie":for(var a=i+"=",c=r.cookie.split(";"),l=0;l<c.length;l++){var u=c[l];0===(u=u.trim()).indexOf(a)&&(n=d(n=u.substring(a.length,u.length)))}}return t&&this.removeStoredItem(e),n;function d(e){try{return o.settings.encodeStorage?JSON.parse(atob(e)):JSON.parse(e)}catch(t){if(t instanceof DOMException)return JSON.parse(e);if(t instanceof SyntaxError)return JSON.parse(atob(e))}}},getStoreName:function(e){void 0===e&&(e="");var t=this.settings.baseStorageName+"_";switch(t+=this.settings.clientName,e){case"token":t+="_tk";break;case"state":t+="_st";break;case"return_location":t+="_cloc";break;case"request":t+="_req";break;case"delayed_response":t+="_dlresp";break;case"delayed_error":t+="_dlerr";break;case"feedback_msg":t+="_fbm";break;case"error_msg":t+="_err";break;case"lastAuthReq":t=this.settings.baseStorageName+"_lreq";break;default:t=t+"_"+e}return t},haveToken:function(){return null!==this.getStoredItem("token")},init:function(){var t=this;e.fn[this._name].responseHandler=function(e){t.responseHandler(e)},e.fn[this._name].makeRequest=function(e){t.makeRequest(e)},e.fn[this._name].saveItem=function(e,r,o){return!s(e)&&(t.storeItem(e,r,o),!0)},e.fn[this._name].retrieveItem=function(e,r){return!s(e)&&t.getStoredItem(e,r)},e.fn[this._name].removeItem=function(e){return!s(e)&&t.removeStoredItem(e)},this.storage="none",0===this.settings.baseStorageName.length&&(this.settings.baseStorageName="eclipseIGC"),"undefined"!=typeof Storage?this.storage="local":navigator.cookieEnabled&&(this.storage="cookie");var o=this.getStoredItem("delayed_response",!0);if(null==o){var i=this.getStoredItem("delayed_error",!0);if(null==i){var n=this.getStoredItem("error_msg",!0);null==n?e(r).ready(function(){if(void 0!==t.settings.username&&0!==t.settings.username.length){var e=t.getStoredItem("session_user");if(null!==e&&e.username!==t.settings.username)return t.removeStoredItem("token"),void t.storeItem("session_user",{username:t.settings.username},3600);null===e&&t.storeItem("session_user",{username:t.settings.username},3600)}else t.removeStoredItem("token")}):e(r).trigger("igcAuthFailed",n)}else e(r).trigger("igcRequestFailed",i)}else e(r).trigger("igcRequestComplete",o);function s(e){return void 0===e&&(e=""),e=e.toLowerCase(),["token","state","return_location","request","delayed_response","delayed_error","feedback_msg","error_msg"].indexOf(e)>-1}},makeRequest:function(t,o){var i=this;if(void 0===o&&(o=!1),this.haveToken()){var n={path:"/",method:"GET",contentType:"application/json",context:e(r),successCallback:null,errorCallback:null},s=e.extend({},n,t);e.ajax({url:this.settings.apiUrl+s.path,context:s.context,method:s.method,contentType:s.contentType,beforeSend:function(e){var t=i.getStoredItem("token");e.setRequestHeader("Authorization","Bearer "+t.access_token)}}).done(function(e,t,r){if("function"!=typeof s.successCallback){if(o){var n={clientName:i.settings.clientName,data:e,textStatus:t,responseHeaders:r.getAllResponseHeaders(),requestOptions:s};i.storeItem("delayed_response",n),i.redirectToStart()}}else s.successCallback(e,t,r)}).fail(function(e){if(401!==e.status)if("function"!=typeof s.errorCallback){if(o){var r={clientName:i.settings.clientName,requestOptions:s,jqXHR:e};i.storeItem("delayed_error",r),i.redirectToStart()}}else t.errorCallback(e);else a()})}else a();function a(){i.settings.completeOnAuthorization&&(t.context=null,i.storeItem("request",t)),i.request={clientName:i.settings.clientName,cid:t.cid,scope:t.scope},i.storeItem("lastAuthReq",i.request),i.authorizeClient()}},openWindow:function(e){var r=t.open(e,"Authorize","height=720, width=1280");t.focus&&r&&r.focus()},redirectToStart:function(){if(!1!==this.settings.redirectIfValid){var e=this.getStoredItem("return_location",!0);null===e&&(e={prevLoc:[location.protocol,"//",location.host].join("")}),t.location.replace(e.prevLoc)}},removeStoredItem:function(e){var t=this.getStoreName(e);switch(this.storage){case"local":localStorage.removeItem(t);break;case"cookie":r.cookie=t+"=;expires=Thu, 01 Jan 1970 00:00:00 UTC;; path=/"}},responseHandler:function(t){var r=this,o=!0;void 0===t&&(t=""),"boolean"!=typeof this.settings.redirectIfValid&&(this.settings.redirectIfValid=!0);var i=function(e){var t={},r=e.substring(e.indexOf("?"));if(r)for(var o,i=/([^#?&=]+)=([^&]*)/g;null!==(o=i.exec(r));)t[decodeURIComponent(o[1])]=decodeURIComponent(o[2]);return t}(t);if(!e.isEmptyObject(i)){if(void 0!==i.access_token){if(this.request=this.getStoredItem("lastAuthReq",!0),null==this.request)return void this.redirectToStart();if(this.settings.clientName=this.request.clientName,this.haveToken())return void this.redirectToStart();o=!1,this.validateToken(i,function(e,t){if("boolean"!=typeof e&&(e=!1),!0===e){r.storeItem("token",i);var o=r.getDelayedAction();if(null!=o)return void r.makeRequest(o,!0)}else r.removeStoredItem("request"),null!=t&&r.storeItem("error_msg",t);r.redirectToStart()})}void 0!==i.error&&(this.removeStoredItem("request"),this.removeStoredItem("state"),this.storeItem("error_msg",i))}o&&r.redirectToStart()},storeItem:function(e,t,o){var i,n,s=this.getStoreName(e);if(void 0!==t){switch(e){case"token":o=parseInt(t.expires_in)-1,i=new Date,n=1e3*o;break;default:("number"!=typeof o||o<1)&&(o=3600),i=new Date,n=1e3*o,"object"!=typeof t&&(t={itemName:t})}i.setTime(i.getTime()+n),"local"===this.storage&&(t.expires_time=i.getTime());var a=this.settings.encodeStorage?btoa(JSON.stringify(t)):JSON.stringify(t);switch(this.storage){case"local":localStorage.setItem(s,a);break;case"cookie":var c="; expires="+i.toUTCString();r.cookie=s+"="+a+c+"; path=/"}}},validateToken:function(t,r){var o=this;if("none"!==this.storage){var i=this.getStoredItem("state",!0);if(null===i||i.state!==t.state)return void(r&&"function"==typeof r&&r(!1))}e.ajax({url:this.settings.authUrl+"/oauth2/tokens/"+t.access_token}).done(function(i){var n,s=!0,a=null;if(o.request.cid!==i.client_id&&(s=!1,a={clientName:o.settings.clientName,error:400,error_description:"Received token issued to unrecognized Client ID",error_from:"oauth2/tokens"}),s){var c=t.scope.split("+"),l=o.request.scope.split(" "),u=[];e(c).each(function(){-1===l.indexOf(this)&&(s=!1,u.push(this)),s||(a={clientName:o.settings.clientName,error:400,error_description:"Granted scope "+u.join(" ")+"is not in the list of expected scopes",error_from:"oauth2/tokens"})})}o.settings.validateUser&&o.settings.username.length>0&&s?(void 0!==i.user_id&&(n=i.user_id),function(t,r){var i=o.settings.apiUrl+"/account/profile/"+o.settings.username;e.ajax({url:i}).done(function(e){var i=!0,n=null;void 0!==e.name&&e.uid!==t&&(n={clientName:o.settings.clientName,error:400,error_description:"Authorizing account does not match the current logged in account on this site",error_from:"account/profile"},i=!1),r&&"function"==typeof r&&r(i,n)}).fail(function(e){var t={clientName:o.settings.clientName,error:e.status,error_description:e.statusText,error_from:"account/profile"};r&&"function"==typeof r&&r(!1,t)})}(n,r)):r&&"function"==typeof r&&r(s,a)}).fail(function(e){var t={clientName:o.settings.clientName,error:e.status,error_description:"Error validating authorization response.",error_from:"validateToken"};r&&"function"==typeof r&&r(!1,t)})}}),e.fn[i]=function(t){return this.each(function(){e.data(this,"plugin_"+i)||e.data(this,"plugin_"+i,new s(this,t))})}}(jQuery,window,document); | ||
!function(e,t,r,o){"use strict";var i="eclipseFdnIgc",n={clientName:"unknown",authUrl:"https://accounts.eclipse.org",apiUrl:"https://api.eclipse.org",redirectUri:[location.protocol,"//",location.host,"/site_login/implicit_grant/authorized"].join(""),baseStorageName:"eclipseIGC",redirectIfValid:!0,validateUser:!0,encodeStorage:!0,username:"",completeOnAuthorization:!0};function s(t,r){this.element=t,this.settings=e.extend({},n,r),this._defaults=n,this._name=i,this.init()}e.extend(s.prototype,{authorizeClient:function(){if(0===this.settings.authUrl.length){this.storeItem("error_msg",{error:400,error_description:"authorization end-point not defined",error_from:"authorizeClient"})}this.storeItem("return_location",{prevLoc:t.location.href});var e=this.getNewState(),r=this.settings.authUrl+"/oauth2/authorize?response_type=token&client_id="+this.request.cid+"&redirect_uri="+encodeURIComponent(this.settings.redirectUri)+"&scope="+encodeURIComponent(this.request.scope)+"&state="+e;self.location=r},getDelayedAction:function(){return this.getStoredItem("request",!0)},getNewState:function(){var e=function(){return Math.random().toString(36).substr(2)},t=e()+e();return this.storeItem("state",{state:t}),t},getStoredItem:function(e,t){var o=this,i=this.getStoreName(e);void 0===t&&(t=!1);var n=null;switch(this.storage){case"local":if(null===(n=localStorage.getItem(i)))break;var s=new Date;(n=d(n)).expires_time<=s.getTime()&&(this.removeStoredItem(e),n=null);break;case"cookie":for(var a=i+"=",c=r.cookie.split(";"),l=0;l<c.length;l++){var u=c[l];0===(u=u.trim()).indexOf(a)&&(n=d(n=u.substring(a.length,u.length)))}}return t&&this.removeStoredItem(e),n;function d(e){try{return o.settings.encodeStorage?JSON.parse(atob(e)):JSON.parse(e)}catch(t){if(t instanceof DOMException)return JSON.parse(e);if(t instanceof SyntaxError)return JSON.parse(atob(e))}}},getStoreName:function(e){void 0===e&&(e="");var t=this.settings.baseStorageName+"_";switch(t+=this.settings.clientName,e){case"token":t+="_tk";break;case"state":t+="_st";break;case"return_location":t+="_cloc";break;case"request":t+="_req";break;case"delayed_response":t+="_dlresp";break;case"delayed_error":t+="_dlerr";break;case"feedback_msg":t+="_fbm";break;case"error_msg":t+="_err";break;case"lastAuthReq":t=this.settings.baseStorageName+"_lreq";break;default:t=t+"_"+e}return t},haveToken:function(){return null!==this.getStoredItem("token")},init:function(){var t=this;e.fn[this._name].responseHandler=function(e){t.responseHandler(e)},e.fn[this._name].makeRequest=function(e){t.makeRequest(e)},e.fn[this._name].saveItem=function(e,r,o){return!s(e)&&(t.storeItem(e,r,o),!0)},e.fn[this._name].retrieveItem=function(e,r){return!s(e)&&t.getStoredItem(e,r)},e.fn[this._name].removeItem=function(e){return!s(e)&&t.removeStoredItem(e)},this.storage="none",0===this.settings.baseStorageName.length&&(this.settings.baseStorageName="eclipseIGC"),"undefined"!=typeof Storage?this.storage="local":navigator.cookieEnabled&&(this.storage="cookie");var o=this.getStoredItem("delayed_response",!0);if(null==o){var i=this.getStoredItem("delayed_error",!0);if(null==i){var n=this.getStoredItem("error_msg",!0);null==n?e(r).ready((function(){if(void 0!==t.settings.username&&0!==t.settings.username.length){var e=t.getStoredItem("session_user");if(null!==e&&e.username!==t.settings.username)return t.removeStoredItem("token"),void t.storeItem("session_user",{username:t.settings.username},3600);null===e&&t.storeItem("session_user",{username:t.settings.username},3600)}else t.removeStoredItem("token")})):e(r).trigger("igcAuthFailed",n)}else e(r).trigger("igcRequestFailed",i)}else e(r).trigger("igcRequestComplete",o);function s(e){return void 0===e&&(e=""),e=e.toLowerCase(),["token","state","return_location","request","delayed_response","delayed_error","feedback_msg","error_msg"].indexOf(e)>-1}},makeRequest:function(t,o){var i=this;if(void 0===o&&(o=!1),this.haveToken()){var n={path:"/",method:"GET",contentType:"application/json",context:e(r),successCallback:null,errorCallback:null},s=e.extend({},n,t);e.ajax({url:this.settings.apiUrl+s.path,context:s.context,method:s.method,contentType:s.contentType,beforeSend:function(e){var t=i.getStoredItem("token");e.setRequestHeader("Authorization","Bearer "+t.access_token)}}).done((function(e,t,r){if("function"!=typeof s.successCallback){if(o){var n={clientName:i.settings.clientName,data:e,textStatus:t,responseHeaders:r.getAllResponseHeaders(),requestOptions:s};i.storeItem("delayed_response",n),i.redirectToStart()}}else s.successCallback(e,t,r)})).fail((function(e){if(401!==e.status)if("function"!=typeof s.errorCallback){if(o){var r={clientName:i.settings.clientName,requestOptions:s,jqXHR:e};i.storeItem("delayed_error",r),i.redirectToStart()}}else t.errorCallback(e);else a()}))}else a();function a(){i.settings.completeOnAuthorization&&(t.context=null,i.storeItem("request",t)),i.request={clientName:i.settings.clientName,cid:t.cid,scope:t.scope},i.storeItem("lastAuthReq",i.request),i.authorizeClient()}},openWindow:function(e){var r=t.open(e,"Authorize","height=720, width=1280");t.focus&&r&&r.focus()},redirectToStart:function(){if(!1!==this.settings.redirectIfValid){var e=this.getStoredItem("return_location",!0);null===e&&(e={prevLoc:[location.protocol,"//",location.host].join("")}),t.location.replace(e.prevLoc)}},removeStoredItem:function(e){var t=this.getStoreName(e);switch(this.storage){case"local":localStorage.removeItem(t);break;case"cookie":r.cookie=t+"=;expires=Thu, 01 Jan 1970 00:00:00 UTC;; path=/"}},responseHandler:function(t){var r=this,o=!0;void 0===t&&(t=""),"boolean"!=typeof this.settings.redirectIfValid&&(this.settings.redirectIfValid=!0);var i=function(e){var t={},r=e.substring(e.indexOf("?"));if(r)for(var o,i=/([^#?&=]+)=([^&]*)/g;null!==(o=i.exec(r));)t[decodeURIComponent(o[1])]=decodeURIComponent(o[2]);return t}(t);if(!e.isEmptyObject(i)){if(void 0!==i.access_token){if(this.request=this.getStoredItem("lastAuthReq",!0),null==this.request)return void this.redirectToStart();if(this.settings.clientName=this.request.clientName,this.haveToken())return void this.redirectToStart();o=!1,this.validateToken(i,(function(e,t){if("boolean"!=typeof e&&(e=!1),!0===e){r.storeItem("token",i);var o=r.getDelayedAction();if(null!=o)return void r.makeRequest(o,!0)}else r.removeStoredItem("request"),null!=t&&r.storeItem("error_msg",t);r.redirectToStart()}))}void 0!==i.error&&(this.removeStoredItem("request"),this.removeStoredItem("state"),this.storeItem("error_msg",i))}o&&r.redirectToStart()},storeItem:function(e,t,o){var i,n,s=this.getStoreName(e);if(void 0!==t){switch(e){case"token":o=parseInt(t.expires_in)-1,i=new Date,n=1e3*o;break;default:("number"!=typeof o||o<1)&&(o=3600),i=new Date,n=1e3*o,"object"!=typeof t&&(t={itemName:t})}i.setTime(i.getTime()+n),"local"===this.storage&&(t.expires_time=i.getTime());var a=this.settings.encodeStorage?btoa(JSON.stringify(t)):JSON.stringify(t);switch(this.storage){case"local":localStorage.setItem(s,a);break;case"cookie":var c="; expires="+i.toUTCString();r.cookie=s+"="+a+c+"; path=/"}}},validateToken:function(t,r){var o=this;if("none"!==this.storage){var i=this.getStoredItem("state",!0);if(null===i||i.state!==t.state)return void(r&&"function"==typeof r&&r(!1))}e.ajax({url:this.settings.authUrl+"/oauth2/tokens/"+t.access_token}).done((function(i){var n,s=!0,a=null;if(o.request.cid!==i.client_id&&(s=!1,a={clientName:o.settings.clientName,error:400,error_description:"Received token issued to unrecognized Client ID",error_from:"oauth2/tokens"}),s){var c=t.scope.split("+"),l=o.request.scope.split(" "),u=[];e(c).each((function(){-1===l.indexOf(this)&&(s=!1,u.push(this)),s||(a={clientName:o.settings.clientName,error:400,error_description:"Granted scope "+u.join(" ")+"is not in the list of expected scopes",error_from:"oauth2/tokens"})}))}o.settings.validateUser&&o.settings.username.length>0&&s?(void 0!==i.user_id&&(n=i.user_id),function(t,r){var i=o.settings.apiUrl+"/account/profile/"+o.settings.username;e.ajax({url:i}).done((function(e){var i=!0,n=null;void 0!==e.name&&e.uid!==t&&(n={clientName:o.settings.clientName,error:400,error_description:"Authorizing account does not match the current logged in account on this site",error_from:"account/profile"},i=!1),r&&"function"==typeof r&&r(i,n)})).fail((function(e){var t={clientName:o.settings.clientName,error:e.status,error_description:e.statusText,error_from:"account/profile"};r&&"function"==typeof r&&r(!1,t)}))}(n,r)):r&&"function"==typeof r&&r(s,a)})).fail((function(e){var t={clientName:o.settings.clientName,error:e.status,error_description:"Error validating authorization response.",error_from:"validateToken"};r&&"function"==typeof r&&r(!1,t)}))}}),e.fn[i]=function(t){return this.each((function(){e.data(this,"plugin_"+i)||e.data(this,"plugin_"+i,new s(this,t))}))}}(jQuery,window,document); |
{ | ||
"name": "jquery-eclipsefdn-api", | ||
"version": "0.0.42", | ||
"version": "0.0.43", | ||
"description": "Fetch and display data from various Eclipse Foundation APIs.", | ||
@@ -26,5 +26,5 @@ "keywords": [ | ||
"build": "NODE_ENV=production eslint src/*.js && npm run build:webpack --production && npm run test", | ||
"build:webpack": "webpack --progress --hide-modules --config=node_modules/laravel-mix/setup/webpack.config.js", | ||
"build:webpack": "webpack --progress --config=node_modules/laravel-mix/setup/webpack.config.js", | ||
"dev": "NODE_ENV=development eslint src/*.js && npm run build:webpack --development && npm run test", | ||
"watch": "NODE_ENV=development webpack --watch --progress --hide-modules --config=node_modules/laravel-mix/setup/webpack.config.js" | ||
"watch": "NODE_ENV=development webpack --watch --progress --config=node_modules/laravel-mix/setup/webpack.config.js" | ||
}, | ||
@@ -49,4 +49,5 @@ "dependencies": { | ||
"karma-qunit": "^4.0.0", | ||
"laravel-mix": "^5.0.9", | ||
"laravel-mix": "^6.0.6", | ||
"polyjuice": "^2.2.4", | ||
"postcss": "^8.2.2", | ||
"prepend-file": "^1.3.1", | ||
@@ -53,0 +54,0 @@ "puppeteer": "^2.1.1", |
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is too big to display
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
227688
13
3089