function formatName(n,t,i,r){var a,h,o,c,l,v,y;n=$.trim(n);t=$.trim(t);i=$.trim(i);a=n.length+t.length+i.length+2;a>r&&(t="");var s="...",f=r/2,e="",u="";n.length<=f?e=n:(e=n.substring(0,f-1)+"-",u=n.substring(f-1,n.length),u.length>f&&(u=u.slice(0,f-s.length)+s));t!==""&&(h=t,o=t,e.length>0&&(h=" "+h),u.length>0&&(o=" "+o),e.length+h.length<=f?e+=h:u.length+o.length<=f&&u.length+o.length+i.length<f&&(u+=o));i!==""&&(c=i,l=i,e.length>0&&(c=" "+c),u.length>0&&(l=" "+l),v=u.length+l.length<=f,y=u.length+5+s.length+(u.length>0?1:0)<=f,e.length+c.length<=f&&u.length===0?e+=c:(v||y)&&(u+=l,u.length>f&&(u=u.slice(0,f-s.length)+s)));$("#nameline1").text(e);u!==""?$("#nameline2").text(u).show():$("#nameline2").text("").hide()}function formatLocation(n,t){return n&&n.trim().length>0&&t&&t.trim().length>0?n+", "+t:n&&n.trim().length>0?n:t&&t.trim().length>0?t:""}function formatNumber(n,t){var i=$.extend({thousandSeparator:",",decimalSeparator:"."},t),r=function(n){n+="";for(var r=n.split(i.decimalSeparator),t=r[0],f=r.length>1?i.decimalSeparator+r[1]:"",u=/(\d+)(\d{3})/;u.test(t);)t=t.replace(u,"$1"+i.thousandSeparator+"$2");return t+f};return r(n)}var Loop=Loop||{};Loop.viewModels=Loop.viewModels||{};Loop.viewModels.Brick=function(n){function v(n){Array.isArray(n)?n.length===0?t(Loop.Enum.BrickDataStatus.LoadedWithoutContent):t(Loop.Enum.BrickDataStatus.LoadedWithContent):n?t(Loop.Enum.BrickDataStatus.LoadedWithContent):t(Loop.Enum.BrickDataStatus.LoadedWithoutContent)}function y(n,r,u,f){return i(""),a.loadStatus={url:n,callback:r},Loop.BaseCommunicationService.loadData(n,function(n){typeof r=="function"&&r(n)},function(n,r){t(Loop.Enum.BrickDataStatus.LoadedWithErrors);i(r);typeof u=="function"&&u(n,r)},!1,f)}function p(n,i,r,u){Loop.BaseCommunicationService.deleteData(n,i,function(n){typeof r=="function"&&r(n)},function(n,i){typeof u=="function"&&(t(Loop.Enum.BrickDataStatus.LoadedWithErrors),u(n,i))})}function w(n,r,u,f,e){Loop.BaseCommunicationService.createData(n,r,function(n){typeof u=="function"&&u(n)},function(n,r){t(Loop.Enum.BrickDataStatus.LoadedWithErrors);e!==!0&&i(r);typeof f=="function"&&f(n,r)})}function b(n,r,u,f,e){Loop.BaseCommunicationService.updateData(n,r,function(n){typeof u=="function"&&u(n)},function(n,r){t(Loop.Enum.BrickDataStatus.LoadedWithErrors);e!==!0&&i(r);typeof f=="function"&&f(n,r)})}var t=ko.observable(Loop.Enum.BrickDataStatus.NotInitialized),f=ko.observable(Loop.Enum.BrickDataStatus.NotInitialized),u=$("#"+Loop.constants.PageElementNames.CURRENT_PROFILE_USER_ID_HIDDEN_CONTROL_ID).val(),e=$("#"+Loop.constants.PageElementNames.CURRENT_LOGGED_IN_USER_ID_HIDDEN_CONTROL_ID).val(),r=ko.observable(!1),i=ko.observable(),o=ko.observable(!1),s=ko.observable(!1),h=ko.observable(),c=ko.observable(!1),l=ko.observable(!0),a=this;return n=n||"brick-generic",t.subscribe(function(n){f(n)},this,"beforeChange"),u===e&&u!==undefined&&r(!0),{updateStatusByContent:v,loadData:y,updateData:b,createData:w,deleteData:p,userID:u,ownProfile:r,status:t,previousStatus:f,isDataLoaded:ko.computed(function(){return!(t()===Loop.Enum.BrickDataStatus.NotInitialized||t()===Loop.Enum.BrickDataStatus.Loading)},this),hasContent:ko.computed(function(){return t()===Loop.Enum.BrickDataStatus.LoadedWithContent},this),noContent:ko.computed(function(){return t()===Loop.Enum.BrickDataStatus.LoadedWithoutContent},this),noContentOwnProfile:ko.computed(function(){return t()===Loop.Enum.BrickDataStatus.LoadedWithoutContent&&r()},this),noContentOtherProfile:ko.computed(function(){return t()===Loop.Enum.BrickDataStatus.LoadedWithoutContent&&!r()},this),errorMessage:i,isVisible:o,isDisabled:s,bodyTemplate:h,showNoContentOtherProfile:!0,showErrorMessages:!0,isInSideBar:c,disableOnEdit:l,elementId:n,dataTestId:n,brickLoadedCallback:undefined,allowEmptyCase:!0}};Loop=Loop||{};Loop.viewModels=Loop.viewModels||{};Loop.viewModels.BrickConfig=function(n){var t=this;return t.viewModel=n.viewModel,t.alternative=n.alternative,t.templateId=n.templateId,t.templateName=n.templateName,t.sideBar=!1,t.id=n.id||"",t.dataTestId=n.dataTestId,t.initParams=n.initParams,n.sideBar&&(t.sideBar=n.sideBar),n.dataTestId||(t.dataTestId=t.templateId),t.templateId=t.templateId+"_"+Math.floor((Math.random()+1)*1e4),t};Loop=Loop||{};Loop.viewModels=Loop.viewModels||{};Loop.viewModels.BrickDispatcher=function(){function t(n,i){n.viewModel.templateId=n.templateId;n.dispatcherAlreadyLoaded||(n.dispatcherAlreadyLoaded=!1);r(n,n.dispatcherAlreadyLoaded);n.alternative&&(t(n.alternative,!1),n.viewModel.brick.statusSubscription||(n.viewModel.brick.statusSubscription=n.viewModel.brick.status.subscribe(function(t){t===Loop.Enum.BrickDataStatus.NotAvailable&&n.alternative.viewModel.init(n.alternative.initParams)})));n.viewModel.brick.status()!==Loop.Enum.BrickDataStatus.NotAvailable&&(n.viewModel.brick.status()===Loop.Enum.BrickDataStatus.Hidden?(n.viewModel.reload&&n.viewModel.reload(n.initParams),n.viewModel.brick.status(n.viewModel.brick.previousStatus())):n.viewModel.brick.status()===Loop.Enum.BrickDataStatus.ReadyToReload?n.viewModel.reload&&n.viewModel.reload(n.initParams):i&&n.viewModel.init(n.initParams));ko.applyBindings(n,document.getElementById(n.templateId));n.dispatcherAlreadyLoaded=!0}function r(n,t){var r,i="";r=n.sideBar?"#sideBar":"#mainColumn";i='<div class="template-container" id="'+n.templateId+'" data-bind="template: { name: \''+n.templateName+"', data: viewModel";t&&n.viewModel.reloadAfterRender?i=i+", afterRender:function(element,data){data.reloadAfterRender(element,data)}":!t&&n.viewModel.afterRender&&(i=i+", afterRender:function(element,data){data.afterRender(element,data)}");i=i+' }" data-test-id="'+n.dataTestId+'"><\/div>';$(r).append(i)}function i(n){n.viewModel.brick.status()!==Loop.Enum.BrickDataStatus.NotAvailable&&n.viewModel.brick.status()!==Loop.Enum.BrickDataStatus.NotInitialized&&n.viewModel.brick.status(Loop.Enum.BrickDataStatus.Hidden);$("#"+n.templateId).remove();n.alternative&&i(n.alternative);n.viewModel.onHideBrick&&n.viewModel.onHideBrick()}var n=this;n.bricks=[];n.addBrick=function(t){n.bricks.push(t)};n.loadAllBricks=function(){$(n.bricks).each(function(n,i){t(i,!0)});n.alreadyLoaded=!0};n.hideAllBricks=function(){$(n.bricks).each(function(n,t){i(t)})};n.alreadyLoaded=!1};Loop=Loop||{};Loop.BaseCommunicationService=function(){function e(n,t,i){if(n.customErrors){var u=i?"CODE_"+t+"_"+i.ErrorCode:"CODE_"+t,r=n.customErrors[u];if(r)return r}return undefined}function r(n,t){var i=Loop.constants.APIErrorMessages["HTTP"+n+"_"+Loop.Enum.APIActions.GetName(t)]||Loop.constants.APIErrorMessages["DEFAULT_"+Loop.Enum.APIActions.GetName(t)],r=Loop.constants.APIErrorMessagesTitles["HTTP"+n]||Loop.constants.APIErrorMessagesTitles.DEFAULT;return{title:r,message:i}}function o(n,t,i){var f=r(n,t),u=null,e=$("#"+Loop.constants.PageElementNames.LOGIN_PAGE_URL).val();switch(n){case 401:e=e+"?ReturnUrl="+document.location.href;u=function(){location.replace(e)};break;case 403:u=function(){location.reload()};break;case 404:(t===Loop.Enum.APIActions.Read||t===Loop.Enum.APIActions.Create||t===Loop.Enum.APIActions.Update)&&(u=function(){location.reload()})}return u!==null&&i!==!0&&Loop.Modals.showBlockingErrorModal(f.title,f.message,u),f.message}function s(n,t,i,u,f){var s=e(n,t,f),o=s?s:r(t,i);return t===401?Loop.Modals.showLoginRegisterModal(n.userID,n.loginAction,n.registerAction):t===403?Loop.Modals.showBlockingErrorModal(o.title,o.message,null,!1):t===412&&f.ErrorCode===Loop.constants.PreconditionFailErrors.SocialActionPrivateProfile?Loop.Modals.showSocialForbiddenModal(o.title,o.message):u!==!0&&Loop.Modals.showBlockingErrorModal(o.title,o.message,null,!1),o.message}function n(n,t,i,r,u){return n.type===Loop.constants.endpointType.SOCIAL?s(n,t,i,r,u):o(t,i,r)}function u(t,i,r){i&&(r===Loop.Enum.APIActions.Delete?setTimeout(function(){i(401,n(t,401,r))},500):i(401,n(t,401,r)))}function f(n){return n?Loop.BaseCommunicationService.isUserLogged():!0}function t(t,r,e,o,s,h,c,l,a,v){if(!1&&console.debug("Ajax call: ["+r+"] "+t.url),f(v)){var y=!0;return $("html").hasClass("ie9")&&(y=!1),isNaN(a)&&(a=15e3),$.ajax({type:r,url:t.url,async:s,timeout:a,tryCount:0,retryLimit:3,crossDomain:y,dataType:"json",contentType:"application/json; charset=utf-8",cache:!i,data:e,success:function(n){h(n)},error:function(i){var f,u;this.tryCount+=1;i.status===0&&i.statusText==="timeout"?this.tryCount<=this.retryLimit-1&&r==="GET"?$.ajax(this):(u=n(t,408,o,l),typeof c=="function"&&c(408,u)):(i.status===412&&(f=JSON.parse(i.responseText)),u=n(t,i.status,o,l,f),typeof c=="function"&&c(i.status,u,f))}})}u(t,c,o)}function h(t,i,r,u,f,e,o){return isNaN(o)&&(o=15e3),$.ajax({url:t.url,timeout:o,type:"POST",data:i,mimeType:"multipart/form-data",contentType:!1,cache:!1,processData:!1,success:function(n){u(n)},error:function(i){var u;i.status===0&&i.statusText==="timeout"&&f(408,n(t,408,r,e));i.status===412&&(u=JSON.parse(i.responseText));f(i.status,n(t,i.status,r,u),u)}})}$.support.cors=!0;var i=!0;return{forceNoCache:function(n){i=n},handleErrors:n,loadData:function(n,i,r,u,f){return t(n,"GET",null,Loop.Enum.APIActions.Read,!0,i,r,u,f,!1)},loadDataSync:function(n,i,r,u,f){t(n,"GET",null,Loop.Enum.APIActions.Read,!1,i,r,u,f,!1)},updateData:function(n,i,r,u,f,e){t(n,"PUT",i,Loop.Enum.APIActions.Update,!0,r,u,f,e,!0)},createData:function(n,i,r,u,f,e,o){typeof o!="boolean"&&(o=!0);t(n,"POST",i,Loop.Enum.APIActions.Create,!0,r,u,f,e,o)},deleteData:function(n,i,r,u,f,e){t(n,"DELETE",i,Loop.Enum.APIActions.Delete,!0,r,u,f,e,!0)},createMultipartData:function(n,t,i,r,e,o){f(!0)?h(n,t,Loop.Enum.APIActions.Update,i,r,e,o):u(n,r,Loop.Enum.APIActions.Update)}}}();Loop.BaseCommunicationService.isUserLogged=function(){var n=$("#"+Loop.constants.PageElementNames.CURRENT_LOGGED_IN_USER_ID_HIDDEN_CONTROL_ID).val();return isNaN(n)===!1&&parseInt(n,10)>=0};Loop.BaseCommunicationService.isBlockingError=function(n){return n===404||n===403||n===401};Loop=Loop||{};Loop.Cache=function(){function o(n){var r=[],t=0,f=n.length,u={},i;if(Object.prototype.toString.call(n)==="[object Array]"){for(;t<f;t++)r[t]=arguments.callee(n[t]);return r}if(typeof n=="object"){for(i in n)u[i]=arguments.callee(n[i]);return u}return n}var n=this,u=null,f=null,e=null,r=null,t={},i={};return n.getCountries=function(t){if(u===null&&Loop.BaseCommunicationService.loadDataSync(Loop.EndPoints.Countries(),function(n){n.sort(function(n,t){return n.Name===t.Name?0:n.Name>t.Name?1:-1});u=n},function(){}),t!==undefined&&t)return n.getArrayWithDefaultItem(u,{CountryId:0,Name:"Select"});return u},n.getPositions=function(t){if(f===null&&Loop.BaseCommunicationService.loadDataSync(Loop.EndPoints.Positions(),function(n){n.sort(function(n,t){return n.Position===t.Position?0:n.Position>t.Position?1:-1});f=n}),t!==undefined&&t)return n.getArrayWithDefaultItem(f,{PositionId:0,PositionName:"Select"});return f},n.getDegrees=function(t){if(e===null&&Loop.BaseCommunicationService.loadDataSync(Loop.EndPoints.Degrees(),function(n){n.sort(function(n,t){return n.Degree===t.Degree?0:n.Degree>t.Degree?1:-1});e=n}),t)return n.getArrayWithDefaultItem(e,{DegreeId:0,Name:"Select"});return e},n.getMonths=function(t){var i=[{Id:"1",Month:"January"},{Id:"2",Month:"February"},{Id:"3",Month:"March"},{Id:"4",Month:"April"},{Id:"5",Month:"May"},{Id:"6",Month:"June"},{Id:"7",Month:"July"},{Id:"8",Month:"August"},{Id:"9",Month:"September"},{Id:"10",Month:"October"},{Id:"11",Month:"November"},{Id:"12",Month:"December"}],r;return t!==undefined&&t?(r={Id:"",Month:"Month"},n.getArrayWithDefaultItem(i,r)):i},n.getYears=function(t,i,r,u){var e=[],f=0,o;if(t===undefined&&(t=(new Date).getFullYear()-100),i===undefined&&(i=(new Date).getFullYear()),t>i)console.warn("Loop.Cache.Years error. Invalid range");else if(u===undefined&&(u=!0),u)for(f=i;f>t;f--)e.push(f);else for(f=t;f<i;f++)e.push(f);return r!==undefined&&r?(o="Year",n.getArrayWithDefaultItem(e,"Year")):e},n.getArrayWithDefaultItem=function(n,t){var i=o(n);return i.unshift(t),i},n.getDomains=function(t){if(r===null&&Loop.BaseCommunicationService.loadDataSync(Loop.EndPoints.Domains(),function(n){n.sort(function(n,t){return n.Value===t.Value?0:n.Value>t.Value?1:-1});r=[];for(var t=0;t<n.length;t++)r[t]={DomainId:n[t].DomainId,Name:n[t].Name}}),t!==undefined&&t)return n.getArrayWithDefaultItem(r,{DomainId:0,Name:"Select"});return o(r)},n.getDomainName=function(n){for(var i=Loop.Cache.Domains(),t=0;t<i.length;t++)if(i[t].DomainId===n)return i[t].Name;return undefined},n.getFields=function(i,r){if(t[i]||(t[i]=[]),i>0&&t[i].length===0&&Loop.BaseCommunicationService.loadDataSync(Loop.EndPoints.FieldsByDomainId(i),function(n){n.sort(function(n,t){return n.Value===t.Value?0:n.Value>t.Value?1:-1});t[i]=[];$.each(n,function(n,r){t[i].push({FieldId:r.Key,Name:r.Value})})}),r!==undefined&&r)return n.getArrayWithDefaultItem(t[i],{FieldId:0,Name:"Select"});return o(t[i])},n.getFieldName=function(n,t){for(var r=Loop.Cache.Fields(n),i=0;i<r.length;i++)if(r[i].FieldId===t)return r[i].Name;return undefined},n.getSpecialties=function(t,r,u){if(i[r]||(i[r]=[]),r>0&&i[r].length===0&&Loop.BaseCommunicationService.loadDataSync(Loop.EndPoints.SpecialtiesByFieldId(t,r),function(n){n.sort(function(n,t){return n.Value===t.Value?0:n.Value>t.Value?1:-1});i[r]=[];$.each(n,function(n,t){i[r].push({SpecialtyId:t.Key,Name:t.Value})})}),u!==undefined&&u)return n.getArrayWithDefaultItem(i[r],{FieldId:0,Name:"Select"});return o(i[r])},n.getSpecialtyName=function(n,t,i){for(var u=Loop.Cache.Specialties(n,t),r=0;r<u.length;r++)if(u[r].SpecialtyId===i)return u[r].Name;return undefined},{Countries:n.getCountries,Positions:n.getPositions,Degrees:n.getDegrees,Months:n.getMonths,Years:n.getYears,Domains:n.getDomains,GetDomainName:n.getDomainName,Fields:n.getFields,GetFieldName:n.getFieldName,Specialties:n.getSpecialties,GetSpecialtyName:n.getSpecialtyName}}();Loop=Loop||{};Loop.EndPoints=function(){function e(n){var t=window.location.protocol+"//"+window.location.host,i=$("#"+Loop.constants.PageElementNames.LOGIN_URL).val()+"?returnUrl=";return n=n?n:window.location,n=encodeURI(t+n),i+n}function o(n){var t=window.location.protocol+"//"+window.location.host,i=$("#"+Loop.constants.PageElementNames.REGISTER_PAGE_URL).val()+"?returnUrl=";return n=n?n:window.location,n=encodeURI(t+n),i+n}function n(){var t="",n=$("#"+Loop.constants.PageElementNames.API_BASE_ADDRESS);return n&&n.length>0?t=n.val():console.warn("apiBaseAddress is not defined"),t}function t(n,t,i){return{type:t,url:n,customErrors:i}}var i="Private profile",r="This user has a private profile and",u="Public profile required",f="Actions for users with a private profile are limited. Please set your profile to public",s={FollowUser:{CODE_403:{title:i,message:r+" their research activity cannot be followed."},CODE_412_29:{title:u,message:f+" to follow this user's research activity."}},Comment:{CODE_403:{title:i,message:r+" their content cannot be commented on."},CODE_412_29:{title:u,message:f+" to comment this content."}},Like:{CODE_403:{title:i,message:r+" their content cannot be liked."},CODE_412_29:{title:u,message:f+" to like this content."}},Share:{CODE_403:{title:i,message:r+" their content cannot be shared."},CODE_412_29:{title:u,message:f+" to share this content."}},SendMessage:{CODE_403:{title:i,message:r+" cannot receive messages."},CODE_412_29:{title:u,message:f+" to send this user a message."}}};return{Experience:function(i,r){var u=n()+"/users/"+i+"/positions";return r&&(u+="/"+r),t(u,Loop.constants.endpointType.PRIVATE)},Expertise:function(i){var r=n()+"/users/"+i+"/expertise";return t(r,Loop.constants.endpointType.PRIVATE)},Education:function(i,r){var u=n()+"/users/"+i+"/educations";return r&&(u+="/"+r),t(u,Loop.constants.endpointType.PRIVATE)},MainInfo:function(i){var r=n()+"/users/"+i+"/main-info";return t(r,Loop.constants.endpointType.PRIVATE)},Keywords:function(i,r){var u=n()+"/suggest/keywords";return i&&(r||(r=10),u+="?prefix="+i+"&limit="+r),t(u,Loop.constants.endpointType.PRIVATE)},Countries:function(){var i=n()+"/info/countries";return t(i,Loop.constants.endpointType.PUBLIC)},Positions:function(){var i=n()+"/info/Positions";return t(i,Loop.constants.endpointType.PUBLIC)},Degrees:function(){var i=n()+"/info/degrees";return t(i,Loop.constants.endpointType.PUBLIC)},Followers:function(i,r,u,f,e){var o=n()+"/users/"+i+"/followers?limit="+r+"&offset="+u+"&search="+f+"&sortby="+e;return t(o,Loop.constants.endpointType.PRIVATE)},Following:function(i,r,u,f,e){var o=n()+"/users/"+i+"/following?limit="+r+"&offset="+u+"&search="+f+"&sortby="+e;return t(o,Loop.constants.endpointType.PRIVATE)},PeopleYouMayKnow:function(i,r){(!i||isNaN(i))&&(i=5);(!r||isNaN(r))&&(r=0);var u=n()+"/profile/people-you-may-know?limit="+i+"&offset="+r;return t(u,Loop.constants.endpointType.PRIVATE)},RelatedPeople:function(i,r,u){var f=n()+"/users/"+i+"/related-people?limit="+r+"&offset="+u;return t(f,Loop.constants.endpointType.PRIVATE)},NotificationSettings:function(i){var r=n()+"/settings/"+i+"/notifications";return t(r,Loop.constants.endpointType.PRIVATE)},ProfilePrivacySettings:function(i){var r=n()+"/settings/"+i+"/profileprivacy";return t(r,Loop.constants.endpointType.PRIVATE)},ChangePassword:function(i){var r=n()+"/settings/"+i+"/changepassword";return t(r,Loop.constants.endpointType.PRIVATE)},EmailSettings:function(i){var r=n()+"/settings/"+i+"/secondaryemail";return t(r,Loop.constants.endpointType.PRIVATE)},VerifyEmailSettings:function(i){var r=n()+"/settings/"+i+"/validatesecondaryemail";return t(r,Loop.constants.endpointType.PRIVATE)},SaveAuthoringNamesSettings:function(i){var r=n()+"/settings/"+i+"/authoringNames";return t(r,Loop.constants.endpointType.PRIVATE)},MakePrimaryEmailSettings:function(i){var r=n()+"/settings/"+i+"/makeprimaryemail";return t(r,Loop.constants.endpointType.PRIVATE)},BriefBio:function(i){var r=n()+"/users/"+i+"/briefbio";return t(r,Loop.constants.endpointType.PRIVATE)},Specialties:function(i){var r=n()+"/users/"+i+"/specialties";return t(r,Loop.constants.endpointType.PRIVATE)},Domains:function(){var i=n()+"/info/domains";return t(i,Loop.constants.endpointType.PRIVATE)},FieldsByDomainId:function(i){var r=n()+"/info/fields?domainId="+i;return t(r,Loop.constants.endpointType.PRIVATE)},SpecialtiesByFieldId:function(i,r){var u=n()+"/info/specialties?domainId="+i+"&fieldId="+r;return t(u,Loop.constants.endpointType.PRIVATE)},PublicationCounts:function(i,r){var u=n()+"/users/"+r+"/publications/totals?showAll="+(i?"true":"false");return t(u,Loop.constants.endpointType.PRIVATE)},Publications:function(i,r,u,f,e,o,s,h,c){var l=n()+"/users/"+i+"/publications/GetPublications?currentTab="+o+"&requestStartIndex="+r+"&requestEndIndex="+u+"&searchKey="+h+"&isCommunity="+e+"&profileUserId="+i+"&pageStartIndex=1&pageEndIndex="+f+"&pageSize="+f+"&currentPageIndex=1&searchBy="+c+"&repositoryIds="+s+"&showAll=True";return t(l,Loop.constants.endpointType.PRIVATE)},CoAuthors:function(i,r,u){var f=n()+"/users/"+i+"/co-authors?offset="+r+"&limit="+u;return t(f,Loop.constants.endpointType.PRIVATE)},ConfirmPublication:function(i,r){var u=n()+"/users/"+i+"/publications/confirm/"+r;return t(u,Loop.constants.endpointType.PRIVATE)},ConfirmAllPublications:function(i){var r=n()+"/users/"+i+"/publications/ConfirmAll";return t(r,Loop.constants.endpointType.PRIVATE)},RemovePublication:function(i,r){var u=n()+"/users/"+i+"/publications/remove/"+r;return t(u,Loop.constants.endpointType.PRIVATE)},RemoveAllPublications:function(i){var r=n()+"/users/"+i+"/publications/RemoveAll";return t(r,Loop.constants.endpointType.PRIVATE)},GetOtherAuthoringNamesByUserId:function(i){var r=n()+"/users/"+i+"/authoringNames";return t(r,Loop.constants.endpointType.PRIVATE)},SaveAuthoringNames:function(i){var r=n()+"/settings/"+i+"/authoringNames";return t(r,Loop.constants.endpointType.PRIVATE)},UpdateUserNewPublications:function(i){var r=n()+"/users/"+i+"/publications/UpdateUserNewPublications";return t(r,Loop.constants.endpointType.PRIVATE)},NetworkingTotals:function(i){var r=n()+"/users/"+i+"/network-totals?totals=Network";return t(r,Loop.constants.endpointType.PRIVATE)},ResearchTopics:function(i){var r=n()+"/users/"+i+"/topics";return t(r,Loop.constants.endpointType.PRIVATE)},ProfilePicture:function(i){var r=n()+"/"+i+"/profile/picture";return t(r,Loop.constants.endpointType.PRIVATE)},ProfilePictureBase64:function(){var i=n()+"/profile/picturebase64";return t(i,Loop.constants.endpointType.PRIVATE)},ImpactTracking:function(){var i=n()+"/impact";return t(i,Loop.constants.endpointType.PRIVATE)},GetPublicationAuthors:function(i,r,u,f){var e=n()+"/users/"+i+"/publications/GetPublicationsAuthors?tag="+r+"&tab="+u+"&listId="+f;return t(e,Loop.constants.endpointType.PRIVATE)},ImpactData:function(i){var r=n()+"/impact/"+i;return t(r,Loop.constants.endpointType.PRIVATE)},PeopleAlsoLookedAt:function(i,r,u){var f=n()+"/users/"+i+"/people-also-looked-at?offset="+r+"&limit="+u;return t(f,Loop.constants.endpointType.PRIVATE)},FollowUser:function(i){var h=n()+"/userslists/addfollow/"+i,r=t(h,Loop.constants.endpointType.SOCIAL,s.FollowUser),u,f;return u=function(){location.replace(e("/social/follow/"+i))},f=function(){location.replace(o("/social/follow/"+i))},r.userID=i,r.loginAction=u,r.registerAction=f,r},UnfollowUser:function(i){var s=n()+"/following-people/"+i,r=t(s,Loop.constants.endpointType.SOCIAL),u,f;return u=function(){location.replace(e("/people/"+i))},f=function(){location.replace(o("/people/"+i))},r.userID=i,r.loginAction=u,r.registerAction=f,r},UserListItems:function(i){var r=n()+"/users-lists/items/"+i+"/lists?limit=1&timestamp="+(new Date).getTime();return t(r,Loop.constants.endpointType.SOCIAL)},TrackEvents:function(){var i=n()+"/tracking/events";return t(i,Loop.constants.endpointType.PRIVATE)},IbarImpact:function(i){var r=n()+"/users/"+i+"/ibar/impact";return t(r,Loop.constants.endpointType.PRIVATE)},IbarNotifications:function(i){var r=n()+"/users/"+i+"/ibar/notifications";return t(r,Loop.constants.endpointType.PRIVATE)},IbarFrontiers:function(i){var r=n()+"/users/"+i+"/ibar/frontiers";return t(r,Loop.constants.endpointType.PRIVATE)},HonorsAndAwards:function(i,r){var u=n()+"/users/"+i+"/honors-and-awards";return r&&(u+="/"+r),t(u,Loop.constants.endpointType.PRIVATE)},EmailInvitation:function(i){var r=n()+"/users/"+i+"/email/invitation";return t(r,Loop.constants.endpointType.PRIVATE)}}}();Loop=Loop||{};Loop.services=Loop.services||{};Loop.services.Suggestions=function(){return{getKeywordsSuggestions:function(){}}};Loop=Loop||{};Loop.Models=Loop.Models||{};Loop.Models.Profile=Loop.Models.Profile||{};Loop.Models.Profile.Name=function(){var n,t,i;return{firstName:n,middleName:t,lastName:i}};Loop=Loop||{};Loop.Models=Loop.Models||{};Loop.Models.Profile=Loop.Models.Profile||{};Loop.Models.Profile.Picture=function(){this.pictureName=ko.observable("");this.profilePicture=ko.observable("")};Loop=Loop||{};Loop.Models=Loop.Models||{};Loop.Models.Profile=Loop.Models.Profile||{};Loop.Models.Profile.pictureMoreInfo=function(){var n,t,i,r;return{jobTitle:n,affiliation:t,locationCity:i,countryId:r}};Loop=Loop||{};Loop.Models=Loop.Models||{};Loop.Models.Profile=Loop.Models.Profile||{};Loop.Models.Profile.Location=function(){var n,t;return{locationCity:n,countryId:t}};Loop=Loop||{};Loop.Models=Loop.Models||{};Loop.Models.Profile=Loop.Models.Profile||{};Loop.Models.Profile.Specialty=function(){var u=this,n,t,i,r;return{expertiseId:n,domainId:t,fieldId:i,specialtyId:r}};Loop=Loop||{};Loop.Models=Loop.Models||{};Loop.Models.PeriodDate=function(n,t){function r(){i.date="";i.month="";i.year=""}var i=this;i.date=null;i.month=null;i.year=null;i.format=t;i.setDate=function(n){if(i.isValidDate(n))if(i.format!==Loop.Helpers.PeriodDateHelper.Empty){r();var t=new Date(Date.parse(n));i.format===Loop.Helpers.PeriodDateHelper.DateMonthYear?(i.date=t.getDate(),i.month=t.getMonth()+1,i.year=t.getFullYear()):i.format===Loop.Helpers.PeriodDateHelper.MonthYear?(i.month=t.getMonth()+1,i.year=t.getFullYear()):i.format===Loop.Helpers.PeriodDateHelper.Year&&(i.year=t.getFullYear())}else r();else i.format=Loop.Helpers.PeriodDateHelper.Empty,r()};i.isValidDate=function(n){return isNaN(Date.parse(n))?!1:new Date(n).getFullYear()!==1};i.getPeriodDateAsString=function(){var n=Loop.Helpers.PeriodDateHelper.GetAsPeriod(i.date,i.month,i.year);return moment(n.Date).format("YYYY/MM/DD")};r();i.setDate(n)};Loop=Loop||{};Loop.Models=Loop.Models||{};Loop.Models.Profile=Loop.Models.Profile||{};Loop.Models.Profile.Degree=function(){var n;return{degreeId:n}};Loop=Loop||{};Loop.Models=Loop.Models||{};Loop.Models.Profile=Loop.Models.Profile||{};Loop.Models.Profile.JobTitle=function(){var n;return{JobTitle:n}};Loop=Loop||{};Loop.Models=Loop.Models||{};Loop.Models.Profile=Loop.Models.Profile||{};Loop.Models.Profile.Affiliation=function(){var n;return{Affiliation:n}};Loop=Loop||{};Loop.Models=Loop.Models||{};Loop.Models.Profile=Loop.Models.Profile||{};Loop.Models.Profile.Bio=function(){var n;return{Biography:n}},function(n){n.clickDisabled=null;n.event.special.click={add:function(t){var i=t.handler,r=n(this);t.handler=function(t){if(n.clickDisabled&&r.is(n.clickDisabled))Loop.Common.PreventNavigation(),t.preventDefault();else return i.apply(this,arguments)}}};n("html").on("mouseup",function(t){if(!n(t.target).closest(".popover").length){var i=n(t.target).parent().attr("id");n(".popover").each(function(){n(this).parent().find("*[data-onclickout='hide']").each(function(){i!==n(this).attr("id")&&n(this).popover("hide")})})}});n("html").on("mouseup",function(t){if(!n(t.target).closest(".hide-on-clickout").length){var i=n(t.target).parent().attr("id");n(".hide-on-clickout").each(function(){i!==n(this).attr("id")&&n(this).css("display")!=="none"&&n(this).fadeOut(500,"easeOutExpo")})}});n(document.body).on("click",function(t){var i=t.target,r,u=function(){};n(i).data("track")&&(r=Loop.tracking.Events.createEventJson(i),Loop.BaseCommunicationService.createData(Loop.EndPoints.TrackEvents(),r,u,u,!0,null,!1))})}(jQuery);Loop=Loop||{};Loop.Common=function(){function u(){return $("#"+Loop.constants.PageElementNames.PITS_BASE_URL).val()+"/Profile/PublicationDetails.aspx"}function h(){return $("#"+Loop.constants.PageElementNames.PITS_BASE_URL).val()+"/MyFrontiers/Impact/ArticleImpact.aspx?ART_ARTICLEID="}function e(n){var t=Loop.constants.natureDoiCode;return!!n&&n.indexOf(t)>-1}function t(){return Math.floor((1+Math.random())*65536).toString(16).substring(1)}function f(){if(Loop.Common.IsEditMode){var n=$("#"+r);n.length>0&&Loop.Helpers.Utils.scrollToElement(n);i&&typeof i.UIMessage=="function"&&i.UIMessage("Please click Cancel or Save before continuing.")}return!1}function o(t){var i=$(t.target);i.find(".disable-on-edit").addClass("disabled");i.find(".disable-on-edit a").addClass(n);i.find(".disable-on-edit i").addClass(n);i.find(".disable-on-edit span").addClass(n);Loop.Common.DeactivateAnchors(i)}var n="disabled-click",s="http://dx.doi.org/",r=null,i=null;return $.clickDisabled="."+n,{Location:window.location.href,IsEditMode:!1,PreventNavigation:f,DisableClickClass:n,ActivateIcons:function(t,i,r,u){u||(u=$(document));u.find(t).addClass(i).removeClass(r).removeClass(n)},DeactivateIcons:function(t,i,r,u){u||(u=$(document));u.find(t).addClass(i).removeClass(r).addClass(n)},DeactivateAnchors:function(t){t||(t=$(document));var i="."+n;t.find(i).on("click",f)},ActivateAnchors:function(t){t||(t=$(document));var i="."+n;t.find(i).off("click",f)},ActivateAllIcons:function(){Loop.Common.IsEditMode=!1;r=null;i=null;Loop.Common.ActivateAnchors();$(".disable-on-edit").removeClass("disabled");$(".disable-on-edit a").removeClass(n);$(".disable-on-edit i").removeClass(n);$(".disable-on-edit span").removeClass(n);$("button.disable-on-edit").removeClass(n);$("#profile-navigation a").removeClass(n);$("body").off("DOMNodeInserted",o);Loop.publish(Loop.constants.Events.EDIT_MODE_DEACTIVATED)},DeactivateAllIcons:function(t,u){Loop.Common.IsEditMode=!0;r=t;i=u;$(".disable-on-edit").addClass("disabled");$(".disable-on-edit a").addClass(n);$(".disable-on-edit i").addClass(n);$(".disable-on-edit span").addClass(n);$("button.disable-on-edit").addClass(n);$("#profile-navigation a").addClass(n);Loop.Common.DeactivateAnchors();$("body").on("DOMNodeInserted",o);var f=i.brick!==undefined?i.brick.elementId:t;Loop.publish(Loop.constants.Events.EDIT_MODE_ACTIVATED,f)},SetExternalPublicationsLinks:function(){$(".externalPublicationSite").attr("href",function(n,t){var i=$("#PitsBaseUrl").val();return t.indexOf(i)<0?i+t:t})},generateUUID:function(){return t()+t()+"-"+t()+"-"+t()+"-"+t()+"-"+t()+t()+t()},updateNetworkingTotals:function(){var n=$("#"+Loop.constants.PageElementNames.CURRENT_PROFILE_USER_ID_HIDDEN_CONTROL_ID).val();return Loop.BaseCommunicationService.loadData(Loop.EndPoints.NetworkingTotals(n),function(n){n&&($("#"+Loop.constants.PageElementNames.CURRENT_PROFILE_FOLLOWERS_COUNT_HIDDEN_CONTROL_ID).val(n.TotalNetwork.numberOfFollowers),$("#"+Loop.constants.PageElementNames.CURRENT_PROFILE_FOLLOWING_COUNT_HIDDEN_CONTROL_ID).val(n.TotalNetwork.numberOfFollowing),$("#"+Loop.constants.PageElementNames.CURRENT_PROFILE_COAUTHORS_COUNT_HIDDEN_CONTROL_ID).val(n.TotalNetwork.numberOfCoAuthors),$("#"+Loop.constants.PageElementNames.CURRENT_PROFILE_NETWORK_COUNT_HIDDEN_CONTROL_ID).val(n.TotalNetwork.numberOfConnections),Loop.viewModels.Main.profileNavigationViewModel.numberOfConnections(n.TotalNetwork.numberOfConnections))})},getPublicationLink:function(n){return e(n.DoiLink)?s+n.DoiLink:n.ArticleId===0?u()+"?PubId="+n.PublicationId:u()+"?ArtId="+n.ArticleId},getPublicationTarget:function(n){return n.ArticleId===0&&!e(n.Doi)?"_self":"_blank"},getImpactLink:function(n){return n.ArticleId===0?h()+n.PublicationId+"&type=2":u()+"?ArtId="+n.ArticleId+"#impact"},getImpactTarget:function(n){return n.ArticleId===0?"_self":"_blank"},getAddPublicationsUrl:function(){var t="",n=$("#"+Loop.constants.PageElementNames.ADD_PUBLICATIONS_EXTERNAL_SITE_URL);return n&&n.length>0&&(t=n.val()),t}}}();Loop=Loop||{};Loop.Helpers=Loop.Helpers||{};Loop.Helpers.ConfirmDialog=function(){function t(){$("#remove").prop("disabled",!1);$("#remove").text("Remove");$("#error-msg-modal").hide()}function i(){$("#remove-confirm-modal").length===0&&$("body").append('<div class="modal hide fade in" id="remove-confirm-modal" aria-hidden="false">   <div class="modal-body">       <button type="button" class="close pull-right" data-dismiss="modal" aria-hidden="true">×<\/button>       <h1>Remove Content Confirmation<\/h1>       <p>Are you sure you want to remove this permanently?<\/p>       <button class="btn btn-grey btn-flat pull-left" type="button" data-dismiss="modal" id="cancel">Cancel<\/button>       <button class="btn btn-blue btn-flat pull-right" type="button" id="remove">Remove<\/button>       <div class="clearfix"><\/div>       <div id="error-msg-modal" class="help-block text-error panel-navigate-away-error" style="display: none">           <i class="icon-error-small"><\/i><span><\/span>       <\/div>   <\/div><\/div>')}var n=this;n.showDeleteConfirmation=function(n,i){$("#remove-confirm-modal").modal().on("click","#remove",function(){$("#error-msg-modal").hide();$("#remove").prop("disabled",!0);n()}).on("hidden.bs.modal",function(){t();$("#remove-confirm-modal").off("click","#remove");i&&i()})};n.hide=function(){t();$("#remove-confirm-modal").modal("hide")};n.showError=function(n){t();$("#error-msg-modal").show();$("#error-msg-modal").css("display","block");$("#error-msg-modal span").text(n)};i()};ko.bindingHandlers.editPopover={init:function(n,t,i,r){$(n).popover({html:!0,trigger:"manual",content:function(){return $(t()).html()}});$(n).click(function(){return $(this).hasClass("disabled")||(Loop.Common.DeactivateAllIcons("profile-header",r),r.openEditPopover(this,t())),!1})}};ko.bindingHandlers.getTarget=function(n){var t=$(n).data("target");return t?t:n};ko.bindingHandlers.stopBinding={init:function(){return{controlsDescendantBindings:!0}}};ko.bindingHandlers.collapseToggle={update:function(n,t){var i=t(),u=$(n).height(),r;i!==undefined&&(r=$(n).height("auto").height(),$(n).height(u).animate({height:i==="auto"?r:i},"slow"))}};ko.observableArray.fn.replaceIndex=function(n,t){this.splice(n,1);this.splice(n,0,t)};ko.observableArray.fn.spliceWithoutUpdate=function(n,t){this().splice(n,t)};ko.bindingHandlers.insertNetworkButton={init:function(n,t,i,r){var u=t(),f;u.initialState=r.followState||undefined;r.isProfilePrivate!==!0&&(f=new Loop.controls.NetworkButton(document.getElementById(Loop.constants.PageElementNames.CURRENT_LOGGED_IN_USER_ID_HIDDEN_CONTROL_ID).value,r.userId,n.id,u))}};ko.bindingHandlers.fadeIf={init:function(n,t,i,r,u){var f=t();return $(n).toggle(ko.utils.unwrapObservable(f)),ko.bindingHandlers["if"].init(n,t,i,r,u)},update:function(n,t){var i=t();ko.utils.unwrapObservable(i)?$(n).slideDown(200).animate({opacity:"1"},200):$(n).animate({opacity:"0"},200).slideUp(200)}};ko.bindingHandlers.fadeRotateIf={init:function(n,t,i,r,u){var f=t();return $(n).toggle(ko.utils.unwrapObservable(f)),ko.bindingHandlers["if"].init(n,t,i,r,u)},update:function(n,t){var i=t();ko.utils.unwrapObservable(i)?$(n).fadeIn().addClass("animated_rotateI01").animate({opacity:"1"},200,function(){$(n).removeClass("animated_rotateI01")}):$(n).animate({opacity:"0"},200).fadeOut(200)}};ko.bindingHandlers.fadeVisible={init:function(n,t){var i=t();$(n).toggle(ko.utils.unwrapObservable(i))},update:function(n,t){var i=t();ko.utils.unwrapObservable(i)?$(n).slideDown(500,"easeInOutExpo").animate({opacity:"1"},500):$(n).animate({opacity:"0"},300).slideUp(500,"easeInOutExpo")}};ko.bindingHandlers.customImg={init:function(n){var t=$(n);t.on("error",function(){var n=$("#hdnDefaultProfilePicture");t.attr("src",n.val())})},update:function(n,t){var u=ko.utils.unwrapObservable(t()),i=ko.utils.unwrapObservable(u.src),f=$("#hdnDefaultProfilePicture").val(),r=$(n);i?r.attr("src",i):r.attr("src",f)}};ko.bindingHandlers.cropbox={init:function(n,t,i){var u=$(n),r=t();u.cropbox({width:r.width,height:r.height,showControls:"auto",zoom:15}).on("cropbox",function(n,t,i){if(r.croppedImageData!==undefined&&r.croppedImageData!==null){var f=i.getDataURL(),u=f.split(",");if(u.length!==2)return;u=u[1];ko.isObservable(r.croppedImageData)?r.croppedImageData(u):r.croppedImageData=u}});i.get("attr").src.subscribe(function(){u.data("cropbox")&&u.data("cropbox").remove();u.cropbox({width:r.width,height:r.height,showControls:"auto",zoom:15})})}};ko.bindingHandlers.onEnterKeyPress={init:function(n,t,i,r){var u=i();$(n).keypress(function(n){var t=n.which?n.which:n.keyCode;return t===13?(u.onEnterKeyPress.call(r),!1):!0})}};ko.bindingHandlers.fadeOutIf={update:function(n,t){var i=t();ko.utils.unwrapObservable(i)&&$(n).fadeOut(800)}};Loop=Loop||{};Loop.viewControls=Loop.viewControls||{};Loop.viewControls.EditForm=function(n,t,i,r,u,f){function v(n){e.dataBackup=jQuery.extend(!0,{},ko.toJS(n))}function y(n,t){o=t;e.dataItem=n;e.dataIndex=parseInt(o.attr("data-index"),10);e.divID=e.getEditItemDivID();var i=$('<div id="'+e.divID+'">'+c+"<\/div>");i.appendTo(t);typeof u=="function"&&u();e.dataItem&&e.dataItem.isEditing(!1);ko.applyBindings(e,$("#"+e.divID)[0]);e.dataItem&&e.dataItem.isEditing(!0)}function p(){return $("#"+e.getEditItemDivID(e.divID))}function w(){return e.dataItem.IsNew?$("#"+a).attr("id"):o.attr("id")}function l(){o=null;e.dataItem=null;e.dataBackup=null;e.dataIndex=-1;e.resetButtons();s=null;h=null}var e=this,c=null,o=null,a=null,s=null,h=null;n&&(c=$("#"+n).html());e.setDataItem=function(n,t){Loop.Common.DeactivateAllIcons(t.attr("id"),n);v(n);y(n,t);Loop.Helpers.Utils.scrollTo(t.attr("id"))};e.saveItem=function(n,i){s=$(i.target);s.prop("disabled",!0);typeof t=="function"&&t(n.dataItem,n.dataIndex)};e.cancelEdition=function(){typeof i=="function"&&i(e.dataBackup,e.dataIndex);e.disposeForm()};e.disposeForm=function(){var t=p(),n;typeof r=="function"&&r();Loop.Common.ActivateAllIcons();o&&(n=w(),Loop.Helpers.Utils.scrollTo(n));l()};e.getEditItemDivID=function(){return o?o.attr("id")+"_EM":null};e.deleteItem=function(n,t){h=$(t.target);h.prop("disabled",!0);typeof f=="function"&&f(n.dataItem,n.dataIndex)};e.resetButtons=function(n){n=n||!1;s&&(s.text("Save"),n&&s.removeAttr("disabled"));h&&n&&h.removeAttr("disabled")};l()};Loop=Loop||{};Loop.Helpers=Loop.Helpers||{};Loop.Helpers.Utils=function(){return{removeBraces:function(n){var t=n.match(/.+?(?=[(])/g);return t?$.trim(t[0]):n},scrollTo:function(){},scrollToElement:function(n){var t=null;t=typeof n=="string"?$("#"+n):n;t&&t.offset()&&!$("body, html").is(":animated")&&($(window).bind("mousewheel",function(){$("html, body").stop()}),$("body, html").animate({scrollTop:t.offset().top+100},"slow",function(){$(window).unbind("mousewheel")}))},stringFormat:function(n){var t=Array.prototype.slice.call(arguments,1);return n.replace(/{(\d+)}/g,function(n,i){return typeof t[i]!="undefined"?t[i]:n})},formatNumber:function(n){if($(n).hasClass("formatted-number"))$(n).formatNumber();else if(typeof n=="string")return formatNumber(n)}}}();Loop=Loop||{};Loop.Helpers=Loop.Helpers||{};Loop.Helpers.PeriodDateHelper=function(){};Loop.Helpers.PeriodDateHelper.DateMonthYear=0;Loop.Helpers.PeriodDateHelper.MonthYear=1;Loop.Helpers.PeriodDateHelper.Year=2;Loop.Helpers.PeriodDateHelper.Empty=3;Loop.Helpers.PeriodDateHelper.FormatDate=function(n,t){var i;switch(t){case Loop.Helpers.PeriodDateHelper.Empty:i="";break;case Loop.Helpers.PeriodDateHelper.DateMonthYear:i=moment(n).format("D MMM YYYY");break;case Loop.Helpers.PeriodDateHelper.MonthYear:i=moment(n).format("MMM YYYY");break;case Loop.Helpers.PeriodDateHelper.Year:i=moment(n).format("YYYY");break;default:i=moment(n).format("MMM YYYY")}return i};Loop.Helpers.PeriodDateHelper.isValidNumber=function(n){return!isNaN(n)&&n!==null&&n!==undefined&&n!==""};Loop.Helpers.PeriodDateHelper.GetAsPeriod=function(n,t,i){var u=Loop.Helpers.PeriodDateHelper.isValidNumber(n),f=Loop.Helpers.PeriodDateHelper.isValidNumber(t),e=Loop.Helpers.PeriodDateHelper.isValidNumber(i),r=Loop.Helpers.PeriodDateHelper.DateMonthYear;if(u||(n=1),f||(t=1),!e)throw new Error("Invalid year");if(moment(n+"-"+t+"-"+i,"DD-MM-YYYY").isValid())return u||(r=Loop.Helpers.PeriodDateHelper.MonthYear),f||(r=Loop.Helpers.PeriodDateHelper.Year),{Date:new Date(Date.parse(i+"/"+t+"/"+n)),Format:r};r=Loop.Helpers.PeriodDateHelper.Empty;throw new Error('Invalid inputs to create a date object. Inputs: "'+n+"-"+t+"-"+i+'"');};Loop.Helpers.PeriodDateHelper.IsValidYear=function(n){return Loop.Helpers.PeriodDateHelper.isValidNumber(n)?!0:!1};Loop=Loop||{};Loop.Helpers=Loop.Helpers||{};Loop.Helpers.SelectDate=function(n){function i(){var n=Loop.Helpers.PeriodDateHelper.Empty;t.Year()>0&&(n=t.Month()>0?t.Day()>0?Loop.Helpers.PeriodDateHelper.DateMonthYear:Loop.Helpers.PeriodDateHelper.MonthYear:Loop.Helpers.PeriodDateHelper.Year);t.Format(n)}function r(){var n=t.Day()!==undefined?t.Day():1,i=t.Month()!==undefined?t.Month()-1:0,r=t.Year()!==undefined?t.Year():1970;isNaN(n)&&(n=undefined);t.Date(new Date(r,i,n));t.Month()===undefined||t.Date().getMonth()===undefined||isNaN(t.Date().getMonth())||t.Date().getMonth()===t.Month()-1||t.Day(undefined)}function u(n){if(n!==undefined){t.Date(new Date(n.Date));switch(n.Format){case Loop.Helpers.PeriodDateHelper.Year:t.Year(t.Date().getFullYear());break;case Loop.Helpers.PeriodDateHelper.MonthYear:t.Month(t.Date().getMonth()+1);t.Year(t.Date().getFullYear());break;case Loop.Helpers.PeriodDateHelper.DateMonthYear:t.Day(t.Date().getDate());t.Month(t.Date().getMonth()+1);t.Year(t.Date().getFullYear())}t.Format(n.Format);t.updateDate()}}function f(){var i=t.dateErrorCode().errorCode,n=0;return t.Date()>new Date?n=Loop.Enum.SelectDateErrors.DateInFuture:t.Day()!==undefined&&t.Month()===undefined&&t.Year()!==undefined?n=Loop.Enum.SelectDateErrors.MonthNotSet:t.Day()===undefined&&isNaN(t.Day())||t.Month()!==undefined||t.Year()!==undefined?t.Day()===undefined&&t.Month()!==undefined&&t.Year()===undefined?n=Loop.Enum.SelectDateErrors.SetYear:t.Day()!==undefined&&t.Month()!==undefined&&t.Year()===undefined&&(n=Loop.Enum.SelectDateErrors.SetYear):n=Loop.Enum.SelectDateErrors.SetMonthAndYear,i!==n.errorCode&&(t.dateErrorCode(n),t.dateErrorCode.valueHasMutated()),t.dateErrorCode()===0?!0:!1}var t=this;t.Date=ko.observable();t.Day=ko.observable();t.Month=ko.observable();t.Year=ko.observable();t.Format=ko.observable();t.updateDate=function(){t.getDays();i();r();f()};t.getDays=function(){var r=t.Day(),i=new Date(t.Year(),t.Month(),0).getDate(),n,u=[];if(isNaN(i))for(n=1;n<=31;n++)u.push(n);else for(n=1;n<=i;n++)u.push(n);return r===undefined?t.Day(undefined):r<=i||isNaN(i)?t.Day(r):t.Day(i),u};t.getMonths=function(){for(var t=[],n=1;n<13;n++)t.push(n);return t};t.getYears=function(){for(var t=[],n=(new Date).getFullYear();n>(new Date).getFullYear()-100;n--)t.push(n);return t};t.getDayName=function(n){return n.length<2&&(n="0"+n),n};t.getMonthName=function(n){return["January","February","March","April","May","June","July","August","September","October","November","December"][n-1]};t.dateErrorCode=ko.observable("");u(n)},function(n,t){var i=n({});t.subscribe=function(t,r,u){return n.isArray(t)||(t=[t]),n.each(t,function(n,t){if(u)setTimeout(function(){i.on(t,function(){setTimeout(r,u)})});else i.on(t,r)}),!0};t.unsubscribe=function(n,t){return i.off(n,t),undefined};t.publish=function(n,t){i.trigger(n,t)}}(jQuery,window.Loop=window.Loop||{});Loop=Loop||{};Loop.helpers=Loop.helpers||{};Loop.helpers.UserProfileViewModelHelper=function(){function r(n,t){if(n!==undefined&&n.trim()!=="")return n.length<=t?n:u(n,t)}function u(t,i){return t.substring(0,i-n.length)+n}function s(t,r){var u=i/2;return t.length+r.length<=u?!0:t.length+o+n.length+(t.length>0?1:0)<=u?!0:!1}var i=32,f=25,e=45,o=5,n="...",t=", ";return{getLocation:function(n,i,e){e=typeof e=="boolean"?e:!0;var o="",h="",s=e?f:1e3;return i===undefined||i.trim()===""?n!==undefined&&n.trim()!==""&&(o=r(n,s)):i.length+t.length+n.length<=s?o=i+t+n:(o=i.length+t.length<=s?i+t:u(i,s-t.length)+t,h=r(n,s)),o===""&&(o=undefined),h===""&&(h=undefined),{line1:o,line2:h}},getFullName:function(n,t,r,u){u=typeof u=="boolean"?u:!0;n===undefined&&(n="");t===undefined&&(t="");r===undefined&&(r="");var f=n.length+t.length+r.length;return f>i&&u?this.getFullNameLines(n,undefined,r,!0):this.getFullNameLines(n,t,r,u)},getFullNameLines:function(t,r,u,f){f=typeof f=="boolean"?f:!0;var o="",e="",h=f?i/2:1e3,c=r,l=r,a=u,v=u;return t.length<=h?o=t:(o=t.substring(0,h-1)+"-",e=t.substring(h-1),e.length>h&&(e=e.substring(0,h-n.length)+n)),r!==undefined&&r.length>0&&(o.length>0&&(c=" "+c),e.length>0&&(l=" "+l),o.length+c.length<=h?o+=c:e.length+l.length+u.length<h&&(e+=l)),u!==undefined&&u.length>0&&(o.length>0&&e.length===0&&(a=" "+a),e.length>0&&(v=" "+v),o.length+a.length<=h&&e.length===0?o+=a:s(e,v)&&(e+=v,e.length>h&&(e=e.substring(0,h-n.length)+n))),o===""&&(o=undefined),e===""&&(e=undefined),{line1:o,line2:e}},getAffiliation:function(n,t){return t=typeof t=="boolean"?t:!0,n===undefined?undefined:t?r(n,e):n}}}();Loop=Loop||{};Loop.helpers=Loop.helpers||{};Loop.helpers.ViewModelViewBinding=function(){function n(n,t){var i=jQuery("#"+Loop.constants.PageElementNames.PAGE_BODY_CONTAINER),r=i[0];ko.cleanNode(r);i.html(jQuery("#"+n).html());Loop.viewModels.Main.bodyViewModel=t}return{loadPage:function(t,i){n(t,i,!1)},loadPageWithValidations:function(t,i){n(t,i,!0)},loadTabs:function(n,t){var r=jQuery("#"+Loop.constants.PageElementNames.PAGE_BODY_CONTAINER),i=r[0];ko.cleanNode(i);Loop.viewModels.Main.bodyViewModel=n;t?ko.applyBindingsWithValidation(null,i):ko.applyBindings(null,i)}}}();Loop=Loop||{};Loop.constants=Loop.constants||{};Loop.constants.APIErrorMessages={HTTP401_READ:"Your session has expired. Please login to continue.",HTTP403_READ:"You are not allowed to perform this action. Please refresh the page and try again.",HTTP404_READ:"This resource is temporarily unavailable. Please refresh the page and try again.",HTTP408_READ:"Sorry, something went wrong and this content could not be loaded. Please refresh the page and try again.",DEFAULT_READ:"Sorry, something went wrong and this content could not be loaded. Please refresh the page and try again.",HTTP401_CREATE:"Your session has expired. Please login to continue.",HTTP403_CREATE:"You are not allowed to perform this action. Please refresh the page and try again.",HTTP404_CREATE:"The resource you’re editing is temporarily unavailable. Please refresh the page and try again.",HTTP408_CREATE:"Sorry, something went wrong and your changes could not be saved. Please try again.",DEFAULT_CREATE:"Sorry, something went wrong and your changes could not be saved. Please try again.",HTTP401_UPDATE:"Your session has expired. Please login to continue.",HTTP403_UPDATE:"You are not allowed to perform this action. Please refresh the page and try again.",HTTP404_UPDATE:"The resource you’re editing is temporarily unavailable. Please refresh the page and try again.",HTTP408_UPDATE:"Sorry, something went wrong and your changes could not be saved. Please try again.",DEFAULT_UPDATE:"Sorry, something went wrong and your changes could not be saved. Please try again.",HTTP401_DELETE:"Your session has expired. Please login to continue.",HTTP403_DELETE:"You are not allowed to perform this action. Please refresh the page and try again.",HTTP408_DELETE:"Sorry, something went wrong and your changes could not be saved. Please try again.",DEFAULT_DELETE:"Sorry, something went wrong and your changes could not be saved. Please try again.",HTTP412_7_UPDATE:"The resource you’re editing is temporarily unavailable."};Loop.constants.APIErrorMessagesTitles={HTTP401:"Authentication required",HTTP403:"Authorization required",HTTP404:"Resource not found",HTTP412_7:"Resource not found",DEFAULT:""};Loop.constants.UIMessages={titlePage:"Loop",required:"Please fill in this field.",yearRequired:"Please select a year.",invalidEmail:"Please enter a valid email address.",pleaseRefresh:"Please refresh the page to see the changes.",nameAlreadyExists:"Name already exists.",invalidYearRange:"From date should be earlier than to date.",emailAlreadyAssociatedValidator:"This email is already associated to this account. ",emailAlreadyAssociated:function(n){return"Sorry, the email "+n+" is already associated to this account. "+Loop.constants.UIMessages.pleaseRefresh},emailNotAssociated:function(n){return"Sorry, the email "+n+" is not associated to this account. "+Loop.constants.UIMessages.pleaseRefresh},emailDifferentUser:function(n){return"Sorry, the email "+n+" is already used by another user. "+Loop.constants.UIMessages.pleaseRefresh},emailCharacterLimitExceded:function(n){return"The email has exceeded the "+n+" character limit."},emailNotVerified:"Sorry, this email is not verified.",emailAlreadyValidated:function(n){return"Sorry, the email "+n+" is already validated. "+Loop.constants.UIMessages.pleaseRefresh},emailAlreadyPrimary:function(n){return"Sorry, the email "+n+" is already primary. "+Loop.constants.UIMessages.pleaseRefresh},emailValidationSent:function(n){return"Validation email sent to "+n+". Please click on the link in the email to complete the validation process."},emailRemovedCorrectly:function(n){return"The email "+n+" has been removed successfully."},emailCannotBeValidatedBecausePrimary:function(n){return"Sorry, the email "+n+" can't be validated because it is primary. "+Loop.constants.UIMessages.pleaseRefresh},emailCannotBeRemovedBecausePrimary:function(n){return"Sorry, the email "+n+" can't be removed because it is primary. "+Loop.constants.UIMessages.pleaseRefresh},emailAddSuccess:function(n){return"The email "+n+" has been succesfully associated to this account."},emailInProcessForPrimary:function(n){return"Your request to change your primary email to "+n+" has been received and will be processed shortly."},emailValidationSuccess:"Your email has been validated successfully.",emailGenericValidationError:"Sorry, something went wrong and your email could not be verified. Please try again.",limitExceded:function(n){return n+" character limit exceeded."},existingLoopAccount:"There is an existing Loop account associated with this name and date of birth.",firstNameLimitExceded:function(n){return"First name has exceeded the "+n+" character limit."},middleNameLimitExceded:function(n){return"Middle name has exceeded the "+n+" character limit."},lastNameLimitExceded:function(n){return"Last name has exceeded the "+n+" character limit."},passwordInvalid:"Sorry, invalid password. Please try again.",passwordNewInvalid:"Sorry, new password is not valid. Please try again.",passwordLengthInvalid:"Password length is not valid.",passwordDontMatch:"Passwords don't match.",changesSavedSuccesfully:"Your changes have been saved successfully.",genericErrorSaving:"Sorry, something went wrong and your changes could not be saved. Please try again.",tagCloudInvalidCharacters:"The input data contains invalid characters. The following characters are not allowed: ",selectRequired:"Please select an option.",tagsCloudBlankNewTag:"The tag cannot be blank.",tagsCloudTagExistingTag:"The tag is already in the list.",tagsCloudTagHasInvalidCharacters:function(n){return"Invalid characters: "+n.join(",")},tagsCloudXXLNewTag:function(n){return"The tag cannot exceed "+n+" characters."},tagsCloudXXLTags:function(n){return"There are tags bigger than "+n+" characters."},tagsCloudEmptyCloud:"The tags cloud is empty.",tagsCloudBlankTags:"Some of the tags are empty.",tagsCloudDuplicatedTags:"The tags cloud contains duplicated items.",expertiseBlankNewTag:"Please fill in this field.",expertiseAlreadyUsed:"This expertise is already in your list.",expertiseXXLNewTag:function(n){return""+n+" characters limit exceeded."},expertiseXXLTags:function(n){return"Invalid expertise: "+n+" characters limit exceeded."},expertiseNoTags:"Your expertise can't be empty. Please add at least one keyword.",expertiseBlankTags:"Invalid expertise: empty keywords.",expertiseDuplicatedTags:"Invalid expertise: duplicated keywords.",bioHtmlValidationError:"Sorry, the text includes invalid characters: <, >.",notificationsSuccessOperation:"Your changes have been saved successfully.",notificationErrorOperation:"Sorry, something went wrong and your changes could not be saved. Please try again",emailInvitationSuccess:"Your invitation has been sent successfully.",emailInvitationFail:"Sorry, something went wrong and your invitation could not be sent. Please try again.",emailAlreadyAssociated2:"This email is already associated to an existing user.",dateInFuture:"Selected date exceeds the current date.",monthNotSet:"Please select a month.",setMonthAndYear:"Please select month and year.",setYear:"Please select a year."};Loop.constants.PreconditionFailErrors={ItemNotFound:7,AtLeastOneItem:10,SocialActionPrivateProfile:29};Loop=Loop||{};Loop.Enum=Loop.Enum||{};Loop.Enum.BrickStatus=function(){return{Collapsed:1,Expanded:2,Fixed:3}}();Loop.Enum.BrickDataStatus=function(){return{NotInitialized:0,Loading:1,LoadedWithContent:2,LoadedWithoutContent:3,LoadedWithErrors:4,NotAvailable:5,Hidden:6,ReadyToReload:7}}();Loop.Enum.APIActions=function(){return{Read:0,Create:1,Update:2,Delete:3,GetName:function(n){var t;switch(n){case Loop.Enum.APIActions.Read:t="READ";break;case Loop.Enum.APIActions.Create:t="CREATE";break;case Loop.Enum.APIActions.Update:t="UPDATE";break;case Loop.Enum.APIActions.Delete:t="DELETE"}return t}}}();Loop.Enum.SelectDateErrors=function(){return{DateInFuture:{errorCode:1,errorMessage:Loop.constants.UIMessages.dateInFuture},MonthNotSet:{errorCode:2,errorMessage:Loop.constants.UIMessages.monthNotSet},SetMonthAndYear:{errorCode:3,errorMessage:Loop.constants.UIMessages.setMonthAndYear},SetYear:{errorCode:4,errorMessage:Loop.constants.UIMessages.setYear}}}();Loop=Loop||{};Loop.constants=Loop.constants||{};Loop.constants.endpointType={PRIVATE:0,PUBLIC:1,SOCIAL:2};Loop.constants.paginationMode={NONE:0,SCROLL_DOCUMENT:1,SCROLL_ELEMENT:2,SHOW_MORE:3,POOL:4};Loop.constants.modalType={DEFAULT:0,LOGIN_OR_REGISTER:1};Loop.constants.natureDoiCode="10.1038";Loop=Loop||{};Loop.constants=Loop.constants||{};Loop.constants.Events={FOLLOWING_FOLLOWER_VISIBILITY_CHANGED:"followingFollowersVisibilityChanged",USER_FOLLOW_STATE_CHANGED:"userFollowStateChanged",MODAL_DIALOG_DESTROY:"destroyDialog",PUBLICATIONS_COUNT_CHANGED:"publicationsCountChanged",ACTIVATE_ALL:"activateAll",DEACTIVATE_ALL:"deactivateAll",PYMK_VISIBILITY_CHANGED:"pymkVisibilityChanged",NAME_UPDATED:"nameUpdated",AUTHORING_NAMES_CHANGED:"authoringNamesChanged",BRIEF_BIO_MODIFIED:"briefBioModified",PUBLICATION_CONFIRMED:"publicationConfirmed",PUBLICATION_REJECTED:"publicationRejected",EDIT_MODE_ACTIVATED:"editModeActivated",EDIT_MODE_DEACTIVATED:"editModeDeactivated",PROFILE_PICTURE_UPDATED:"profilePictureUpdated"};Loop=Loop||{};Loop.constants=Loop.constants||{};Loop.constants.PageElementNames={PAGE_BODY_CONTAINER:"knockoutWrapper",CURRENT_PROFILE_USER_ID_HIDDEN_CONTROL_ID:"hdnCurrentProfileUserId",CURRENT_LOGGED_IN_USER_ID_HIDDEN_CONTROL_ID:"hdnCurrentLoggedInUserId",CURRENT_PROFILE_PUBLICATIONS_COUNT_HIDDEN_CONTROL_ID:"hdnPublicationsCount",API_BASE_ADDRESS:"hdApiBaseAddress",CURRENT_PROFILE_FOLLOWERS_COUNT_HIDDEN_CONTROL_ID:"hdnFollowersCount",CURRENT_PROFILE_FOLLOWING_COUNT_HIDDEN_CONTROL_ID:"hdnFollowingCount",CURRENT_PROFILE_COAUTHORS_COUNT_HIDDEN_CONTROL_ID:"hdnCoAuthorsCount",CURRENT_PROFILE_NETWORK_COUNT_HIDDEN_CONTROL_ID:"hdnNetworkCount",SHOW_AS_PUBLIC_PROFILE:"hdnShowAsPublicProfile",RESEARCH_TOPIC_ADDRESS:"hdnResearchTopicAddress",RESEARCH_TOPICS_GUIDELINES_URL:"hdnResearchTopicsGuidelines",RESEARCH_TOPICS_SUGGEST_URL:"hdnResearchTopicsSuggest",LOGIN_PAGE_URL:"hdnLoginPageUrl",REGISTER_PAGE_URL:"hdnRegisterPageUrl",PITS_BASE_URL:"PitsBaseUrl",JOB_TITLE_HIDDEN_CONTROL_ID:"hdnJobTitle",AFFILIATION_HIDDEN_CONTROL_ID:"hdnAffiliation",COUNTRY_HIDDEN_CONTROL_ID:"hdnCountry",CITY_HIDDEN_CONTROL_ID:"hdnCity",CURRENT_PROFILE_TOPICS_COUNT_HIDDEN_CONTROL_ID:"hdnTopicsCount",PAGE_DEFAULT_TITLE:"hdnPageDefaultTitle",LOGIN_URL:"hdnLoginUrl",ADD_PUBLICATIONS_EXTERNAL_SITE_URL:"hdnAddPublicationsExternalSite",IBAR_CURRENT_LOGGED_IN_USER:"hdnIbarCurrentLoggedInUser"};Loop=Loop||{};Loop.constants=Loop.constants||{};Loop.constants.FloatPosition={NONE:"none",LEFT:"left",RIGHT:"right"};Loop=Loop||{};Loop.constants=Loop.constants||{};Loop.constants.ButtonTypes={DEFAULT:"default",CONFIRM:"confirm",CANCEL:"cancel"};Loop=Loop||{};Loop.constants=Loop.constants||{};Loop.constants.Delays={REFRESH_PUBLICATION_DELAY:2e3};Loop=Loop||{};Loop.constants=Loop.constants||{};Loop.constants.Triggers={BRICK_NOT_LOADED:"BrickNotLoaded"};Loop=Loop||{};Loop.constants=Loop.constants||{};Loop.constants.TabNames={OVERVIEW:"overview",BIO:"BIO",NETWORK:"NETWORK",PUBLICATIONS:"PUBLICATIONS",TOPICS:"TOPICS"};Loop=Loop||{};Loop.viewModels=Loop.viewModels||{};Loop.viewModels.ProfilePicture=function(){function r(n){var t=new Loop.Models.Profile.pictureMoreInfo;t.jobTitle=$("#"+Loop.constants.PageElementNames.JOB_TITLE_HIDDEN_CONTROL_ID).val();t.affiliation=$("#"+Loop.constants.PageElementNames.AFFILIATION_HIDDEN_CONTROL_ID).val();t.locationCity=$("#"+Loop.constants.PageElementNames.CITY_HIDDEN_CONTROL_ID).val();t.countryId=$("#"+Loop.constants.PageElementNames.COUNTRY_HIDDEN_CONTROL_ID).val();Loop.BaseCommunicationService.updateData(w,ko.toJSON(t),function(){n&&n()},function(){n&&n()})}function y(){var n=$('input[type="file"]#upload').clone(!0);$('input[type="file"]#upload').replaceWith(n)}function b(){n.profilePictureUrl("");y();n.currentPicture($("#profile-picture").attr("src"));n.isProfilePictureEdited(!1);n.isUploading(!1);n.isProfilePictureDeleted(!1);n.UIMessage("")}function p(){try{f[0].submit()}catch(n){p()}}var n=this,c=$("#"+Loop.constants.PageElementNames.CURRENT_PROFILE_USER_ID_HIDDEN_CONTROL_ID).val(),l=Loop.EndPoints.ProfilePicture(c),w=Loop.EndPoints.MainInfo(c),a=Loop.EndPoints.ProfilePictureBase64().url,e="Sorry, something went wrong and your changes could not be saved. Please try again.",o,v,s,h,i,u,f,t;if(n.deferredSave=null,n.pictureModel=new Loop.Models.Profile.Picture,window.FileReader===undefined){$("#upload_iframe_myFile").remove();$("#upload_form_myFile").remove();try{t=document.createElement('<iframe name="upload_iframe_myFile"/>')}catch(k){t=document.createElement("iframe")}t.id="upload_iframe_myFile";t.name="upload_iframe_myFile";t.width=0;t.height=0;t.border=0;u=$(t);f=$("<form/>",{target:"upload_iframe_myFile",id:"upload_form_myFile",action:a,method:"post",enctype:"text/plain",encoding:"text/plain"});u.hide();f.hide();$("body").append(f);$("body").append(u);u.on("load",function(){n.isUploading(!1);try{if(o=u[0].contentDocument,s=$('input[type="file"]#upload'),h=o.body.innerHTML,s.length===0)return;if(h.slice(0,5).toLowerCase()==="<pre>"&&h.slice(-6).toLowerCase()==="<\/pre>"){v=o.body.firstChild.firstChild.nodeValue;n.profilePictureUrl(v);i=s[0].value.split("\\");i=i[i.length-1];i=i.replace(/ /g,"");n.pictureModel.pictureName(i);n.isProfilePictureEdited(!0);return}n.currentPicture($("#profile-picture").attr("src"));n.UIMessage(e)}catch(t){n.currentPicture($("#profile-picture").attr("src"));n.UIMessage(e)}})}n.save=function(t){if(n.UIMessage(""),n.isUploading(!0),n.deferredSave=$.Deferred(),n.isProfilePictureDeleted()){n.isProfilePictureDeleted(!1);Loop.BaseCommunicationService.deleteData(l,null,function(){r();var t=$("#hdnDefaultProfilePicture").val();$("#profile-picture").attr("src",t);Loop.publish(Loop.constants.Events.PROFILE_PICTURE_UPDATED,t);n.deferredSave.resolve()},function(i,u){typeof t=="function"&&t(i,u);r();n.isProfilePictureDeleted(!0);n.isUploading(!1);n.UIMessage(u);n.deferredSave.reject()},!1,3e4);return}n.isProfilePictureEdited(!1);n.currentPicture("data:image/jpg;base64,"+n.pictureModel.profilePicture());Loop.BaseCommunicationService.createData(l,ko.toJSON(n.pictureModel),function(t){var i=function(){$("#profile-picture").attr("src","data:image/jpg;base64,"+n.pictureModel.profilePicture());Loop.publish(Loop.constants.Events.PROFILE_PICTURE_UPDATED,this.Value);n.deferredSave.resolve()};r(i.bind(t))},function(i,u){typeof t=="function"&&t(i,u);r();n.isProfilePictureEdited(!0);n.isUploading(!1);n.UIMessage(u);n.deferredSave.reject()},!1,3e4)};n.deletePicture=function(){n.isUploading()||(n.isProfilePictureDeleted(!0),n.isProfilePictureEdited(!1),y(),n.currentPicture($("#hdnDefaultProfilePicture").val()))};n.cancel=function(){b()};n.IsRemoveVisible=$("#profile-picture").attr("src")!==$("#hdnDefaultProfilePicture").val();n.profilePictureUrl=ko.observable("");n.currentPicture=ko.observable($("#profile-picture").attr("src"));n.isProfilePictureEdited=ko.observable(!1);n.isProfilePictureDeleted=ko.observable(!1);n.isUploading=ko.observable(!1);n.saving=ko.computed(function(){return n.isUploading()});n.isFormEnabled=ko.computed(function(){return!n.isUploading()});n.isBusy=ko.computed(function(){return!n.isProfilePictureEdited()&&!n.isProfilePictureDeleted()});n.isModalCloseButtonEnabled=ko.computed(function(){return!n.isUploading()});n.UIMessage=ko.observable("");n.css=ko.observable();n.uploadPicture=function(){if(!n.isUploading()){$('input[type="file"]#upload').one("change",n.getSelectedPicture);$("input[type='file']#upload:hidden").click()}};n.getSelectedPicture=function(t){n.UIMessage("");n.isProfilePictureDeleted(!1);var u=t.target,o,i,s,h;if(window.FileReader!==undefined&&u.files.length>0){if(!n.isSupportedFileExtension(u.files[0].name))return;if(o=u.files[0],s=o.name.split("."),s=s[s.length-1].toLowerCase(),n.pictureModel.pictureName(o.name.replace(/ /g,"")),["tif","tiff"].indexOf(s.toLowerCase())!==-1){n.currentPicture("data:image/jpg;base64,"+n.pictureModel.profilePicture());n.isUploading(!0);h=new FormData;h.append("profileimage",o);Loop.BaseCommunicationService.createMultipartData(a,h,function(t){r();n.profilePictureUrl(t);n.isProfilePictureEdited(!0);n.isUploading(!1)},function(){r();n.isUploading(!1);n.currentPicture($("#profile-picture").attr("src"));n.UIMessage(e)},!0,3e4);return}i=new FileReader;i.onload=function(){if(i.error!==null||i.result===undefined||i.result===null||i.result===""||i.result.toLowerCase()==="data:"){n.currentPicture($("#profile-picture").attr("src"));n.UIMessage(e);return}n.profilePictureUrl(i.result);n.pictureModel.profilePicture(i.result.split(",")[1]);n.isProfilePictureEdited(!0)};i.readAsDataURL(o)}else if(u.value!==""){if(!n.isSupportedFileExtension(u.value))return;n.currentPicture("data:image/jpg;base64,"+n.pictureModel.profilePicture());n.isUploading(!0);f.append(u);p()}};n.isSupportedFileExtension=function(t){var i=t.split(".");return(i=i[i.length-1].toLowerCase(),["jpg","jpeg","png","gif","tif","tiff","bmp","pjpeg"].indexOf(i)===-1)?(n.UIMessage('The file extension "'+i+'" is not supported. Our supported image formats are: jpg, jpeg, pjpeg, png, gif, tif and bmp.'),!1):!0}};Loop=Loop||{};Loop.viewModels=Loop.viewModels||{};Loop.viewModels.Name=function(n){function r(){t.nameModel.firstName=ko.observable().extend({required:{message:Loop.constants.UIMessages.required,onlyIf:function(){return t.saveNameIsInvoked()}},maxLength:{params:150,message:Loop.constants.UIMessages.limitExceded(150),onlyIf:function(){return t.saveNameIsInvoked()}}});t.nameModel.middleName=ko.observable().extend({maxLength:{params:50,message:Loop.constants.UIMessages.limitExceded(50),onlyIf:function(){return t.saveNameIsInvoked()}}});t.nameModel.lastName=ko.observable().extend({required:{message:Loop.constants.UIMessages.required,onlyIf:function(){return t.saveNameIsInvoked()}},maxLength:{params:150,message:Loop.constants.UIMessages.limitExceded(150),onlyIf:function(){return t.saveNameIsInvoked()}}});i=ko.validation.group([t.nameModel.firstName,t.nameModel.middleName,t.nameModel.lastName])}var t=this,i=null;t.userId=n?n:-1;t.nameModel=new Loop.Models.Profile.Name;t.saveNameIsInvoked=ko.observable(!1);t.nameAPIError=ko.observable("");t.status=ko.observable("none");t.enterKeyOnFullName=function(n,i){if(i.keyCode===13)t.saveName();else return!0};t.isValidName=function(){return i().length===0};t.saveName=function(){t.status("none");t.nameAPIError("");t.saveNameIsInvoked(!0);t.isValidName()&&(t.status("saving"),t.nameModel.firstName(t.nameModel.firstName().trim()),t.nameModel.middleName(t.nameModel.middleName()?t.nameModel.middleName().trim():""),t.nameModel.lastName(t.nameModel.lastName().trim()),Loop.BaseCommunicationService.updateData(Loop.EndPoints.MainInfo(t.userId),ko.toJSON(t.nameModel),function(){t.nameModel.firstName.startTrackingChanges();t.nameModel.middleName.startTrackingChanges();t.nameModel.lastName.startTrackingChanges();t.status("success");Loop.publish(Loop.constants.Events.NAME_UPDATED,{firstName:t.nameModel.firstName(),middleName:t.nameModel.middleName(),lastName:t.nameModel.lastName()})},function(n,i,r){if(t.status("error"),n===412&&r)switch(r.ErrorCode){case 3:t.nameAPIError(Loop.constants.UIMessages.existingLoopAccount);break;case 23:t.nameAPIError(Loop.constants.UIMessages.firstNameLimitExceded(150));break;case 24:t.nameAPIError(Loop.constants.UIMessages.middleNameLimitExceded(50));break;case 25:t.nameAPIError(Loop.constants.UIMessages.lastNameLimitExceded(150));break;default:t.nameAPIError(Loop.constants.UIMessages.genericErrorSaving)}else t.nameAPIError(i)}))};t.saving=ko.computed(function(){return t.status()==="saving"});t.reset=function(){t.nameModel.firstName.rollbackChanges();t.nameModel.middleName.rollbackChanges();t.nameModel.lastName.rollbackChanges();t.saveNameIsInvoked(!1);t.nameAPIError("");t.status("none")};r()};Loop=Loop||{};Loop.viewModels=Loop.viewModels||{};Loop.viewModels.ProfileNavigation=function(){function s(){var t=$("#"+Loop.constants.PageElementNames.CURRENT_PROFILE_USER_ID_HIDDEN_CONTROL_ID).val();$.ajax({type:i,url:Loop.EndPoints.PublicationCounts(!0,t).url,contentType:r,dataType:u,processdata:f,success:function(t){!t||t.length!==4?n(""):n(t[0]+t[1])},error:function(){n("")}})}function v(){$.ajax({type:i,url:Loop.EndPoints.Publications(t,1,1,1,h,2,"0,9,58,23","",0).url,contentType:r,dataType:u,processdata:f,success:function(t){!t||!t[0]||!t[0].IsPublicationDisabled?!t||!t[0]?n(0):n(t[0].TotalCount):n("")},error:function(){n("")}})}var i="GET",r="application/json; charset=utf-8",u="json",h=!0,f=!0,n=ko.observable(""),c=ko.observable($("#"+Loop.constants.PageElementNames.CURRENT_PROFILE_TOPICS_COUNT_HIDDEN_CONTROL_ID).val()),l=ko.observable($("#"+Loop.constants.PageElementNames.CURRENT_PROFILE_NETWORK_COUNT_HIDDEN_CONTROL_ID).val()),t=$("#"+Loop.constants.PageElementNames.CURRENT_PROFILE_USER_ID_HIDDEN_CONTROL_ID).val(),a=$("#"+Loop.constants.PageElementNames.CURRENT_LOGGED_IN_USER_ID_HIDDEN_CONTROL_ID).val(),e=ko.observable(!1),o=ko.observable();return t&&t===a&&e(!0),o.subscribe(function(n){$.sammy.apps&&$.sammy.apps.body.setLocation(n);Loop.Ibar&&Loop.Ibar.Events&&Loop.Ibar.Events.updateMobileMenu()},this),$(document).ready(function(){e()?(s(),Loop.subscribe(Loop.constants.Events.PUBLICATIONS_COUNT_CHANGED,s)):v()}),{numberOfConnections:l,numberOfPublications:n,numberOfTopics:c,currentTab:o}};Loop=Loop||{};Loop.viewModels=Loop.viewModels||{};Loop.viewModels.Header=function(){function c(){Loop.subscribe(Loop.constants.Events.NAME_UPDATED,l)}function l(){formatName(n.viewModelName.nameModel.firstName(),n.viewModelName.nameModel.middleName(),n.viewModelName.nameModel.lastName(),48);n.hideEditPopover()}var t=new Loop.Models.Profile.Location,u=new Loop.Models.Profile.Degree,i=new Loop.Models.Profile.JobTitle,r=new Loop.Models.Profile.Affiliation,n=this,e=null,o=null,s=null,h=null,f=null;n.viewModelName=new Loop.viewModels.Name;n.profilePictureViewModel=null;n.saveLocationIsInvoked=ko.observable(!1);n.saveJobTitleIsInvoked=ko.observable(!1);n.saveAffiliationIsInvoked=ko.observable(!1);t.locationCity=ko.observable().extend({maxLength:{params:60,message:Loop.constants.UIMessages.limitExceded(60),onlyIf:function(){return n.saveLocationIsInvoked()}}});t.countryId=ko.observable().extend({required:{message:Loop.constants.UIMessages.selectRequired,onlyIf:function(){return n.saveLocationIsInvoked()}}});u.degreeId=ko.observable();i.JobTitle=ko.observable().extend({maxLength:{params:100,message:Loop.constants.UIMessages.limitExceded(100),onlyIf:function(){return n.saveJobTitleIsInvoked()}}});r.Affiliation=ko.observable().extend({required:{message:Loop.constants.UIMessages.required,onlyIf:function(){return n.saveAffiliationIsInvoked()}},maxLength:{params:100,message:Loop.constants.UIMessages.limitExceded(100),onlyIf:function(){return n.saveAffiliationIsInvoked()}}});e=ko.validation.group([t.locationCity,t.countryId]);o=ko.validation.group([i.JobTitle]);s=ko.validation.group([r.Affiliation]);n.popOverItem=null;this.locationModel=t;this.degreeModel=u;this.jobTitleModel=i;this.affiliationModel=r;this.degreeText=ko.observable();this.jobTitleText=ko.observable();this.affiliationText=ko.observable();this.location=ko.observable();this.userId=-1;this.locationAPIError=ko.observable("");this.saving=ko.observable(!1);this.degreeAPIError=ko.observable("");this.jobTitleAPIError=ko.observable("");this.affiliationAPIError=ko.observable("");this.openEditPopover=function(t,i){n.popOverItem=i;$(i).fadeIn(500,"easeOutQuint")};this.UIMessage=function(t){n.popOverItem==="#edit-name"?n.viewModelName.nameAPIError(t):(n.locationAPIError(t),n.degreeAPIError(t),n.jobTitleAPIError(t),n.affiliationAPIError(t))};this.hideEditPopover=function(){$(n.popOverItem).fadeOut({duration:500,easing:"easeInOutExpo",done:function(){setTimeout(function(){n.saving(!1)},200)}});Loop.Common.ActivateAllIcons();n.viewModelName.reset();t.locationCity.rollbackChanges();t.countryId.rollbackChanges();u.degreeId.rollbackChanges();i.JobTitle.rollbackChanges();r.Affiliation.rollbackChanges();n.saveLocationIsInvoked(!1);n.saveJobTitleIsInvoked(!1);n.saveAffiliationIsInvoked(!1);n.locationAPIError("");n.degreeAPIError("");n.jobTitleAPIError("");n.affiliationAPIError("")};this.saveLocation=function(){if(n.locationAPIError(""),n.saveLocationIsInvoked(!0),n.IsValidLocation()){n.saving(!0);h=$("#country option:selected").text();var i=Loop.EndPoints.MainInfo(n.userId);t.locationCity(t.locationCity().trim());Loop.BaseCommunicationService.updateData(i,ko.toJSON(t),function(){$("#"+Loop.constants.PageElementNames.COUNTRY_HIDDEN_CONTROL_ID).val(t.countryId());$("#"+Loop.constants.PageElementNames.CITY_HIDDEN_CONTROL_ID).val(t.locationCity());n.saving(!1);t.locationCity.startTrackingChanges();t.countryId.startTrackingChanges();n.location(formatLocation(t.locationCity(),h));n.hideEditPopover()},function(t,i){n.saving(!1);n.locationAPIError(i)})}};this.saveDegree=function(){n.degreeAPIError("");n.saving(!0);f=u.degreeId()===0?"":Loop.Helpers.Utils.removeBraces($("#degreeSelect option:selected").text());var t=Loop.EndPoints.MainInfo(n.userId);Loop.BaseCommunicationService.updateData(t,ko.toJSON(u),function(){u.degreeId.startTrackingChanges();n.degreeText(f);n.hideEditPopover()},function(t,i){n.saving(!1);n.degreeAPIError(i)})};this.saveJobTitle=function(){if(n.jobTitleAPIError(""),n.saveJobTitleIsInvoked(!0),n.isValidJobTitle()){n.saving(!0);var t=Loop.EndPoints.MainInfo(n.userId);i&&i.JobTitle()&&i.JobTitle(i.JobTitle().trim());Loop.BaseCommunicationService.updateData(t,ko.toJSON(i),function(){$("#"+Loop.constants.PageElementNames.JOB_TITLE_HIDDEN_CONTROL_ID).val(i.JobTitle());n.saving(!1);i.JobTitle.startTrackingChanges();n.jobTitleText(i.JobTitle());n.hideEditPopover()},function(t,i){n.saving(!1);n.jobTitleAPIError(i)})}};this.saveAffiliation=function(){if(n.affiliationAPIError(""),n.saveAffiliationIsInvoked(!0),n.isValidAffiliation()){n.saving(!0);r.Affiliation(r.Affiliation().trim());var t=Loop.EndPoints.MainInfo(n.userId);Loop.BaseCommunicationService.updateData(t,ko.toJSON(r),function(){$("#"+Loop.constants.PageElementNames.AFFILIATION_HIDDEN_CONTROL_ID).val(r.Affiliation());n.saving(!1);r.Affiliation.startTrackingChanges();n.affiliationText(r.Affiliation());n.hideEditPopover()},function(t,i,r){r&&r.ErrorCode===5?n.affiliationAPIError(Loop.constants.UIMessages.limitExceded(100)):n.affiliationAPIError(i);n.saving(!1)})}};this.IsValidLocation=function(){return e().length===0};this.isValidJobTitle=function(){return o().length===0};this.isValidAffiliation=function(){return s().length===0};this.degreesLoaded=ko.computed(function(){return Loop.Cache.Degrees(!0).length>1});this.enterKeyOnJobTitle=function(t,i){if(i.keyCode===13)n.saveJobTitle();else return!0};this.enterKeyOnAffiliation=function(t,i){if(i.keyCode===13)n.saveAffiliation();else return!0};this.showProfilePicture=function(){function e(n,i){Loop.BaseCommunicationService.isBlockingError(n)?t.destroy():t.actionButtonError(i)}var t=new Loop.Modals.getModal("editProfilePictureDialog","Profile Picture","",null,!0,!0),i,r,u,f;n.profilePictureViewModel=new Loop.viewModels.ProfilePicture;u=function(){t.actionButtonError("");(n.profilePictureViewModel.isProfilePictureEdited()||n.profilePictureViewModel.isProfilePictureDeleted())&&(n.profilePictureViewModel.save(e),$.when(n.profilePictureViewModel.deferredSave).then(function(){t.destroy()}))};f=function(){n.profilePictureViewModel.cancel()};i=new Loop.controls.Button(Loop.constants.ButtonTypes.CONFIRM,"Save",Loop.constants.FloatPosition.RIGHT,u,!1,n.profilePictureViewModel.saving,null,n.profilePictureViewModel.isBusy);r=new Loop.controls.Button(Loop.constants.ButtonTypes.CANCEL,"Cancel",Loop.constants.FloatPosition.LEFT,f,!0,n.profilePictureViewModel.saving);t.hideCloseButton(!1);t.buttons=[i,r];t.viewModelTemplate="profile-picture-editor";t.viewModelData=n.profilePictureViewModel;t.show()};c()};Loop=Loop||{};Loop.viewModels=Loop.viewModels||{};Loop.viewModels.Main=function(){var n=new Loop.viewModels.Header,t=new Loop.viewModels.ProfileNavigation,i;return{headerViewModel:n,profileNavigationViewModel:t,bodyViewModel:i}}();Loop=Loop||{};Loop.viewModels=Loop.viewModels||{};Loop.viewModels.partials=Loop.viewModels.partials||{};Loop.viewModels.partials.BriefBioEditor=function(n){function u(n){if(n){var i=t.toMarkdown(n);return i||t.setText(""),i}return n}var i=new Loop.markdownControl.toMD,r=n,t=this;t.control=null;t.stylesheets=["/Content/v5/fonts/font.css","/Content/v5/css/rich-text-editor.css"];t.start=function(n,i){t.control?(t.control.enable(),typeof n=="function"&&n(),t.setText(i),t.resize()):(t.control=new wysihtml5.Editor(r,{toolbar:"toolbar",stylesheets:t.stylesheets,parserRules:Loop.markdownControl.parserRules,sync:!0,useLineBreaks:!1,cleanUp:!0}).on("load",function(){setTimeout(function(){$(t.control.composer.iframe).autoResize&&$(t.control.composer.iframe).autoResize();typeof n=="function"&&n()},1e3)}),t.setText(i),t.control.enable())};t.getHTMLFromEditor=function(){var n=t.control.getValue();return t.control.parse(n)};t.getMarkdownFromEditor=function(){return u(t.getHTMLFromEditor())};t.toMarkdown=function(n){return i.toMD(n)};t.resize=function(){var n=$(t.control.composer.iframe);n.trigger("resize")};t.disableControl=function(){t.control.disable()};t.setText=function(n){t.control.setValue(n)}};Loop=Loop||{};Loop.controls=Loop.controls||{};Loop.controls.endpointProxy=function(n,t){function o(n,t,u,f,e){var o=[],c=h(t);i.noContent||(o=s(c),i.currentItemOffset+=c);o.length===0&&(i.currentItemOffset=r,i.currentEndpointOffset=r);o.length!==0||i.noContent?(n.errorMessage(""),typeof f=="function"&&f(o)):i.getItems(n,t,u,f,e)}function s(n){return u.slice(i.currentItemOffset,i.currentItemOffset+n)}function c(n){return i.onlyOnePage&&s(h(n)).length===0?(i.currentItemOffset=r,!1):i.currentEndpointOffset===r&&!i.noContent?!0:i.currentItemOffset>=i.options.endpointLimit?!0:u.length===0&&!i.noContent?!0:!1}function h(n){var t=n;return isNaN(n)&&(t=i.options.visibleItems),i.currentItemOffset+n>i.options.endpointLimit&&(t=i.options.endpointLimit-i.currentItemOffset),t}function l(n,t,i){var r="",u;try{r=a(n)}catch(f){if(typeof i=="function"){i(404,Loop.constants.APIErrorMessages.HTTP404_READ);return}}u=Loop.BaseCommunicationService.loadData(r,function(n){typeof t=="function"&&t(n)},function(n,t){typeof i=="function"&&i(n,t)},!1)}function a(n){if(i.endpoint===Loop.EndPoints.RelatedPeople){if(!n.userID)throw new Error("UserID was not provided for the related people endpoint call.");return Loop.EndPoints.RelatedPeople(n.userID,i.options.endpointLimit,i.currentEndpointOffset)}if(i.endpoint===Loop.EndPoints.CoAuthors){if(!n.userID)throw new Error("UserID was not provided for the coauthors endpoint call.");return Loop.EndPoints.CoAuthors(n.userID,i.currentEndpointOffset,i.options.endpointLimit)}if(i.endpoint===Loop.EndPoints.PeopleYouMayKnow)return Loop.EndPoints.PeopleYouMayKnow(i.options.endpointLimit,i.currentEndpointOffset);if(i.endpoint===Loop.EndPoints.PeopleAlsoLookedAt){if(n.userID===void 0)throw new Error("UserID was not provided for the people also looked at endpoint call.");return Loop.EndPoints.PeopleAlsoLookedAt(n.userID,i.currentEndpointOffset,i.options.endpointLimit)}}function v(n,t){var r=_.findWhere(u,{userId:t.userId});r&&(i.endpoint===Loop.EndPoints.RelatedPeople&&(r.followState=t.userIsBeingFollowed),i.endpoint===Loop.EndPoints.CoAuthors&&(r.following=t.userIsBeingFollowed),i.endpoint===Loop.EndPoints.PeopleYouMayKnow&&(r.followState=t.userIsBeingFollowed),i.endpoint===Loop.EndPoints.PeopleAlsoLookedAt&&(r.followState=t.userIsBeingFollowed?"following":"follow"))}var i=this,r=0,f={visibleItems:5,endpointLimit:50},u=[],e;i.options=$.extend({},f,t||{});i.currentItemOffset=r;i.currentEndpointOffset=r;i.endpoint=n;i.noContent=!1;i.onlyOnePage=!1;i.options.visibleItems>i.options.endpointLimit&&(i.options.visibleItems=i.options.endpointLimit);i.options.visibleItems<=0&&(i.options.visibleItems=f.visibleItems);i.options.endpointLimit<=0&&(i.options.endpointLimit=f.endpointLimit);i.getItems=function(n,t,f,s,h){var a=[];e&&!_.isEqual(e,f)&&i.resetCounters();c(t)?(n.isDataLoaded()&&n.status(Loop.Enum.BrickDataStatus.ReadyToReload),n.status()===Loop.Enum.BrickDataStatus.NotInitialized?n.allowEmptyCase&&n.status(Loop.Enum.BrickDataStatus.Loading):n.status(Loop.Enum.BrickDataStatus.Loading),l(f,function(e){n.status()===Loop.Enum.BrickDataStatus.NotInitialized&&e.length>0&&n.status(Loop.Enum.BrickDataStatus.Loading);e.length===0&&i.currentEndpointOffset===r&&(i.noContent=!0);e.length>0&&e.length<i.options.endpointLimit&&i.currentEndpointOffset===r&&(i.onlyOnePage=!0);u=e;i.currentEndpointOffset+=i.options.endpointLimit;i.currentItemOffset=r;a=o(n,t,f,s,h)},function(t,i){n.errorMessage(i);n.status(Loop.Enum.BrickDataStatus.LoadedWithErrors);typeof h=="function"&&h(t,i);return})):a=o(n,t,f,s,h);e=f};i.resetCounters=function(){i.currentItemOffset=r;i.currentEndpointOffset=r};Loop.subscribe(Loop.constants.Events.USER_FOLLOW_STATE_CHANGED,v)};Loop=Loop||{};Loop.GlobalEndpoints=function(){var n=new Loop.controls.endpointProxy(Loop.EndPoints.RelatedPeople,{visibleItems:5,endpointLimit:25}),t=new Loop.controls.endpointProxy(Loop.EndPoints.CoAuthors,{visibleItems:5,endpointLimit:50}),i=new Loop.controls.endpointProxy(Loop.EndPoints.PeopleYouMayKnow,{visibleItems:5,endpointLimit:50}),r=new Loop.controls.endpointProxy(Loop.EndPoints.PeopleAlsoLookedAt,{visibleItems:5,endpointLimit:20});return{relatedPeople:n,coAuthors:t,peopleYouMayKnow:i,peopleAlsoLookedAt:r}}();Loop=Loop||{};Loop.tracking=Loop.tracking||{};Loop.tracking.impact=Loop.tracking.impact||{};Loop.tracking.impact.track=function(){var n=Loop.EndPoints.ImpactTracking().url;jQuery.post(n)};Loop.tracking.Events=Loop.tracking.Events||{};Loop.tracking.Events=function(){return{createEventJson:function(n){var i=ko.contextFor(n),r=$(n).closest(".brick-content"),t={eventType:"LoopTrackingEvent",action:$(n).attr("data-track"),brick:r?r.attr("id"):"",page:window.location.pathname.replace(/\/\d+/,""),host:window.location.hostname,userId:$("#"+Loop.constants.PageElementNames.CURRENT_PROFILE_USER_ID_HIDDEN_CONTROL_ID).val(),loggedUserId:$("#"+Loop.constants.PageElementNames.CURRENT_LOGGED_IN_USER_ID_HIDDEN_CONTROL_ID).val()};return t.userId<0&&(t.userId=0),t.loggedUserId<0&&(t.loggedUserId=0),i&&(i.$data&&i.$data.trackingData&&$.extend(t,i.$data.trackingData()),i.$parents.forEach(function(n){n&&n.trackingData&&$.extend(t,n.trackingData())})),JSON.stringify(t)}}}(),function(n){function o(i,r,f,o){var s={data:o||o===0||o===!1?o:r?r.data:{},_wrap:r?r._wrap:null,tmpl:null,parent:r||null,nodes:[],calls:d,nest:g,wrap:nt,html:tt,update:it};return i&&n.extend(s,i,{nodes:[],parent:r}),f&&(s.tmpl=f,s._ctnt=s._ctnt||s.tmpl(n,s),s.key=++e,(c.length?u:t)[e]=s),s}function s(t,i,u){var f,e=u?n.map(u,function(n){return typeof n=="string"?t.key?n.replace(/(<\w+)(?=[\s>])(?![^>]*_tmplitem)([^>]*)/g,"$1 "+r+'="'+t.key+'" $2'):n:s(n,t,n._ctnt)}):t;return i?e:(e=e.join(""),e.replace(/^\s*([^<\s][^<]*)?(<[\w\W]+>)([^>]*[^>\s])?\s*$/,function(t,i,r,u){f=n(r).get();b(f);i&&(f=l(i).concat(f));u&&(f=f.concat(l(u)))}),f?f:l(e))}function l(t){var i=document.createElement("div");return i.innerHTML=t,n.makeArray(i.childNodes)}function p(t){return new Function("jQuery","$item","var $=jQuery,call,__=[],$data=$item.data;with($data){__.push('"+n.trim(t).replace(/([\\'])/g,"\\$1").replace(/[\r\t\n]/g," ").replace(/\$\{([^\}]*)\}/g,"{{= $1}}").replace(/\{\{(\/?)(\w+|.)(?:\(((?:[^\}]|\}(?!\}))*?)?\))?(?:\s+(.*?)?)?(\(((?:[^\}]|\}(?!\}))*?)\))?\s*\}\}/g,function(t,i,r,u,f,e,o){var c=n.tmpl.tag[r],l,s,a;if(!c)throw"Unknown template tag: "+r;return l=c._default||[],e&&!/\w$/.test(f)&&(f+=e,e=""),f?(f=h(f),o=o?","+h(o)+")":e?")":"",s=e?f.indexOf(".")>-1?f+h(e):"("+f+").call($item"+o:f,a=e?s:"(typeof("+f+")==='function'?("+f+").call($item):("+f+"))"):a=s=l.$1||"null",u=h(u),"');"+c[i?"close":"open"].split("$notnull_1").join(f?"typeof("+f+")!=='undefined' && ("+f+")!=null":"true").split("$1a").join(a).split("$1").join(s).split("$2").join(u||l.$2||"")+"__.push('"})+"');}return __;")}function w(t,i){t._wrap=s(t,!0,n.isArray(i)?i:[v.test(i)?i:n(i).html()]).join("")}function h(n){return n?n.replace(/\\'/g,"'").replace(/\\\\/g,"\\"):null}function k(n){var t=document.createElement("div");return t.appendChild(n.cloneNode(!0)),t.innerHTML}function b(f){function p(f){function p(n){n=n+a;s=v[n]=v[n]||o(s,t[s.parent.key+a]||s.parent)}var y,h=f,c,s,l;if(l=f.getAttribute(r)){while(h.parentNode&&(h=h.parentNode).nodeType===1&&!(y=h.getAttribute(r)));y!==l&&(h=h.parentNode?h.nodeType===11?0:h.getAttribute(r)||0:0,(s=t[l])||(s=u[l],s=o(s,t[h]||u[h]),s.key=++e,t[e]=s),i&&p(l));f.removeAttribute(r)}else i&&(s=n.data(f,"tmplItem"))&&(p(s.key),t[s.key]=s,h=n.data(f.parentNode,"tmplItem"),h=h?h.key:0);if(s){for(c=s;c&&c.key!=h;)c.nodes.push(f),c=c.parent;delete s._ctnt;delete s._wrap;n.data(f,"tmplItem",s)}}for(var a="_"+i,c,l,v={},h,s=0,y=f.length;s<y;s++)if((c=f[s]).nodeType===1){for(l=c.getElementsByTagName("*"),h=l.length-1;h>=0;h--)p(l[h]);p(c)}}function d(n,t,i,r){if(!n)return c.pop();c.push({_:n,tmpl:t,item:this,data:i,options:r})}function g(t,i,r){return n.tmpl(n.template(t),i,r,this)}function nt(t,i){var r=t.options||{};return r.wrapped=i,n.tmpl(n.template(t.tmpl),t.data,r,t.item)}function tt(t,i){var r=this._wrap;return n.map(n(n.isArray(r)?r.join(""):r).filter(t||"*"),function(n){return i?n.innerText||n.textContent:n.outerHTML||k(n)})}function it(){var t=this.nodes;n.tmpl(null,null,null,this).insertBefore(t[0]);n(t).remove()}var a=n.fn.domManip,r="_tmplitem",v=/^[^<]*(<[\w\W]+>)[^>]*$|\{\{\! /,t={},u={},f,y={key:0,data:{}},e=0,i=0,c=[];n.each({appendTo:"append",prependTo:"prepend",insertBefore:"before",insertAfter:"after",replaceAll:"replaceWith"},function(r,u){n.fn[r]=function(e){var o=[],h=n(e),c,s,a,v,l=this.length===1&&this[0].parentNode;if(f=t||{},l&&l.nodeType===11&&l.childNodes.length===1&&h.length===1)h[u](this[0]),o=this;else{for(s=0,a=h.length;s<a;s++)i=s,c=(s>0?this.clone(!0):this).get(),n(h[s])[u](c),o=o.concat(c);i=0;o=this.pushStack(o,r,h.selector)}return v=f,f=null,n.tmpl.complete(v),o}});n.fn.extend({tmpl:function(t,i,r){return n.tmpl(this[0],t,i,r)},tmplItem:function(){return n.tmplItem(this[0])},template:function(t){return n.template(t,this[0])},domManip:function(r,u,e){if(r[0]&&n.isArray(r[0])){for(var o=n.makeArray(arguments),s=r[0],l=s.length,h=0,c;h<l&&!(c=n.data(s[h++],"tmplItem")););c&&i&&(o[2]=function(t){n.tmpl.afterManip(this,t,e)});a.apply(this,o)}else a.apply(this,arguments);return i=0,f||n.tmpl.complete(t),this}});n.extend({tmpl:function(i,r,f,e){var h,c=!e;if(c)e=y,i=n.template[i]||n.template(null,i),u={};else if(!i)return i=e.tmpl,t[e.key]=e,e.nodes=[],e.wrapped&&w(e,e.wrapped),n(s(e,null,e.tmpl(n,e)));return i?(typeof r=="function"&&(r=r.call(e||{})),f&&f.wrapped&&w(f,f.wrapped),h=n.isArray(r)?n.map(r,function(n){return n?o(f,e,i,n):null}):[o(f,e,i,r)],c?n(s(e,null,h)):h):[]},tmplItem:function(t){var i;for(t instanceof n&&(t=t[0]);t&&t.nodeType===1&&!(i=n.data(t,"tmplItem"))&&(t=t.parentNode););return i||y},template:function(t,i){return i?(typeof i=="string"?i=p(i):i instanceof n&&(i=i[0]||{}),i.nodeType&&(i=n.data(i,"tmpl")||n.data(i,"tmpl",p(i.innerHTML))),typeof t=="string"?n.template[t]=i:i):t?typeof t!="string"?n.template(null,t):n.template[t]||n.template(null,v.test(t)?t:n(t)):null},encode:function(n){return(""+n).split("<").join("&lt;").split(">").join("&gt;").split('"').join("&#34;").split("'").join("&#39;")}});n.extend(n.tmpl,{tag:{tmpl:{_default:{$2:"null"},open:"if($notnull_1){__=__.concat($item.nest($1,$2));}"},wrap:{_default:{$2:"null"},open:"$item.calls(__,$1,$2);__=[];",close:"call=$item.calls();__=call._.concat($item.wrap(call,__));"},each:{_default:{$2:"$index, $value"},open:"if($notnull_1){$.each($1a,function($2){with(this){",close:"}});}"},"if":{open:"if(($notnull_1) && $1a){",close:"}"},"else":{_default:{$1:"true"},open:"}else if(($notnull_1) && $1a){"},html:{open:"if($notnull_1){__.push($1a);}"},"=":{_default:{$1:"$data"},open:"if($notnull_1){__.push($.encode($1a));}"},"!":{open:""}},complete:function(){t={}},afterManip:function(t,r,u){var f=r.nodeType===11?n.makeArray(r.childNodes):r.nodeType===1?[r]:[];u.call(t,r);b(f);i++}})}(jQuery);window.matchMedia||(window.matchMedia=function(){"use strict";var t=window.styleMedia||window.media;if(!t){var n=document.createElement("style"),i=document.getElementsByTagName("script")[0],r=null;n.type="text/css";n.id="matchmediajs-test";i.parentNode.insertBefore(n,i);r="getComputedStyle"in window&&window.getComputedStyle(n,null)||n.currentStyle;t={matchMedium:function(t){var i="@media "+t+"{ #matchmediajs-test { width: 1px; } }";return n.styleSheet?n.styleSheet.cssText=i:n.textContent=i,r.width==="1px"}}}return function(n){return{matches:t.matchMedium(n||"all"),media:n||"all"}}}())