HEX
Server: Apache/2.4.46 (Win64) OpenSSL/1.1.1j PHP/8.4.25
System: Windows NT DESKTOP-4TAV2RJ 10.0 build 19045 (Windows 10) AMD64
User: fred (0)
PHP: 8.4.25
Disabled: NONE
Upload Files
File: C:/Users/fred/AppData/Local/Microsoft/OneDrive/26.168.0830.0006/WebAssets/static/views/memories.js
(function(){Od4Strings.load();var x=ViewLib.Messages.beginViewLoaded();ViewLib.Messages.onMessageType("page-visibility",function(e){e.visible&&(x.beginRevisit(),x.revisitCached())}),document.documentElement.classList.add("skin-od4");var C=document.getElementById("loading"),P=document.getElementById("container"),k=document.getElementById("signin-prompt"),me=document.getElementById("signinBtn");function ce(){return!(window.ViewLib&&ViewLib.ECS)||ViewLib.ECS.isKillswitchSafe(7537)}function R(e){return ce()?e:null}typeof initMemoriesSignInPrompt=="function"&&initMemoriesSignInPrompt(k,me),Od4Strings.applyToDOM(document.getElementById("momentsPageHeader"));function A(e){try{return sessionStorage.getItem(e)==="1"}catch{return!1}}var B=A("od4-dbg-mem-skip-otd"),F=A("od4-dbg-mem-skip-moments"),q=A("od4-dbg-mem-skip-shuffle"),fe=B||F||q;function L(e){return"memories_"+e}function H(e){if(fe)return null;try{return JSON.parse(sessionStorage.getItem(L(e))).data}catch{return null}}function w(e,n){try{sessionStorage.setItem(L(e),JSON.stringify({data:n,ts:Date.now()}))}catch{}}function U(e){try{return Date.now()-JSON.parse(sessionStorage.getItem(L(e))).ts<3e5}catch{return!1}}var V={},z={};function he(e,n){var t=e.match(/\/_api\/(.+)/);if(!t)return"";var r=t[1],i=ViewLib.Ids.parseDriveId(n);return i&&(r=r.replace(/^v2\.1\/drive\/items\//,"v2.1/drives/"+i+"/items/")),OD4_API_ORIGIN+"/SharePoint/_api/"+r}function X(e){if(!e||!e.large)return"";var n=e.large.sourceItemId;return n&&V[n]?OD4_API_ORIGIN+"/api/thumbnail/"+V[n]:e.large.url?he(e.large.url,n):""}function N(e,n){let t=X(e);if(!t)return null;let r=document.createElement("img");return r.src=t,r.alt="",n||(r.loading="lazy"),r.onload=function(){r.classList.add("loaded")},r.onerror=function(){r.style.display="none"},r}var ve=function(e,n,t){if(t&&!(t.boundingBoxX==null||t.boundingBoxY==null||t.boundingBoxWidth==null||t.boundingBoxHeight==null)){var r=n&&n.width,i=n&&n.height;if(!(!r||!i)){var u=(t.boundingBoxX+t.boundingBoxWidth/2)/r*100,h=(t.boundingBoxY+t.boundingBoxHeight/2)/i*100;e.style.objectPosition=u+"% "+h+"%"}}};function j(e){return(e||[]).map(function(n){var t=n.large&&n.large.sourceItemId||"",r=V[t],i=z[t];return{id:r?String(r):t,thumbnailId:r,driveItemId:t,driveId:ViewLib.Ids.parseDriveId(t),width:i?i.width:null,height:i?i.height:null}})}var f=[],W=new Map;function pe(){W.clear();for(var e=0;e<f.length;e++){var n=f[e];if(n){var t=n.id||n.thumbnailId||n.driveItemId;t!=null&&W.set(t,e)}}}function J(e){if(!e)return null;var n=e.driveItemId||"";return{id:e.id||e.thumbnailId||e.driveItemId,thumbnailId:Od4Shared.NumericUtils.toPositiveInt(e.thumbnailId),driveId:e.driveId||ViewLib.Ids.parseDriveId(n),driveItemId:n||null,isVideo:e.isVideo||0,width:e.width||null,height:e.height||null,isFavorite:e.isFavorite||0}}function ge(e){if(!e)return null;var n=e.driveItemId||"";return{id:e.id||e.thumbnailId||e.driveItemId,thumbnailId:Od4Shared.NumericUtils.toPositiveInt(e.thumbnailId),driveId:e.driveId||ViewLib.Ids.parseDriveId(n),driveItemId:n||null,isVideo:e.isVideo||0,width:e.width||null,height:e.height||null,isFavorite:e.isFavorite||0,name:"",date:""}}ViewLib.OneUpNeighbors.install(ViewLib.OneUpNeighbors.arrayResolver({getItems:function(){return f},indexOfId:function(e){return W.get(e)},makeItem:function(e,n){return n?ge(e):J(e)}})),window.addEventListener("message",function(e){if(e.data){if(e.data.type==="favorite-changed"){for(var n=0;n<f.length;n++)if(f[n]&&f[n].driveItemId===e.data.driveItemId){f[n].isFavorite=e.data.isFavorite;break}}if(e.data.type==="photo-deleted"){for(var t=e.data.driveItemId,r=0;r<f.length;r++)if(f[r]&&(f[r].driveItemId===t||String(f[r].driveItemId)===String(t))){f.splice(r,1);break}}}});function $(e,n,t,r){ViewLib.Messages.sendVpAction("activatePhotoPile",{ksId:6069,extraData:Object.assign({count:(n||[]).length},typeof Od4Shared<"u"&&Od4Shared.FileDimensions?Od4Shared.FileDimensions.extraDataFor(e):null)}),f=n||[],pe();var i=t>0&&n[t-1]?J(n[t-1]):null,u=t<n.length-1&&n[t+1]?J(n[t+1]):null,h=r.currentTarget.getBoundingClientRect();ViewLib.Messages.sendToShell({type:"photo-selected",photo:e,prevItem:i,nextItem:u,thumbRect:{x:h.left,y:h.top,w:h.width,h:h.height}})}function Q(e){var n=[];if((e.value||[]).forEach(function(i){(i.thumbnails||[]).forEach(function(u){u.large&&u.large.sourceItemId&&n.push(u.large.sourceItemId)})}),!n.length)return Promise.resolve();for(var t=[],r=0;r<n.length;r+=200)t.push(n.slice(r,r+200));return t.reduce(function(i,u){return i.then(function(){return ViewLib.SQL.namedRaw("memories_thumbnails",{params:{ids:JSON.stringify(u)},with:{largest:{}}}).then(function(h){(h.rows||[]).forEach(function(l){l[1]&&(V[l[0]]=l[1]),l[2]>0&&l[3]>0&&(z[l[0]]={width:l[2],height:l[3]})})})})},Promise.resolve()).catch(function(){})}var Z=null,ee=null,ne=null,te=0,ie=initPhotoShuffle({apiImg:N,apiCluster:j,applyCropRegion:ve,pc:$}),re=initSlideshow(),E=[],Ie=4e3;function oe(e){if(e){if(e._slideshowMediaItems){re.viewMemory(e,E);return}var n=!1,t=function(){n||(n=!0,re.viewMemory(e,E))},r=setTimeout(function(){n||console.warn("[Moments] photoRecommendations fetch slow, opening with thumbnails"),t()},Ie);le(e.id).then(function(i){i&&i.length&&(e._slideshowMediaItems=i)}).catch(function(i){console.warn("[Moments] photoRecommendations fetch failed, falling back to thumbnails:",i)}).then(function(){clearTimeout(r),t()})}}window.addEventListener("message",function(e){var n=e&&e.data;if(!(!n||n.type!=="fetch-play-next-items"||!n.recId)){var t=n.recId,r=(E||[]).find(function(i){return i&&i.id===t});if(r&&r._slideshowMediaItems){ViewLib.Messages.sendToShell({type:"play-next-items-response",recId:t,items:r._slideshowMediaItems});return}le(t).then(function(i){r&&i&&i.length&&(r._slideshowMediaItems=i),ViewLib.Messages.sendToShell({type:"play-next-items-response",recId:t,items:i||null})}).catch(function(i){console.warn("[Moments] play-next photoRecommendations fetch failed:",i),ViewLib.Messages.sendToShell({type:"play-next-items-response",recId:t,items:null})})}});var ae=initMemoriesHeroRenderer({apiCluster:j,apiImg:N,pc:$,resolvedUrl:X,setCurrentHero:function(e,n){Z=e,ee=n},setPileAnimEnd:function(e){te=Date.now()+500+e+50},slideshowRec:R,viewMemory:oe}),se=ae.renderPile,ye=ae.renderDP,we=initMemoriesMomentRenderer({apiCluster:j,apiImg:N,pc:$,slideshowRec:R,setCurrentMoments:function(e){ne=e},viewMemory:oe}),de=we.renderMoments,be=0;function p(){++be>=1&&(C.style.display="none",P.style.display="block",x.firstLoad())}function De(e,n,t){var r=H(n);if(r){t(r),p(),U(n)||fetch(e).then(function(i){return i.json()}).then(function(i){w(n,i),t(i)}).catch(function(){});return}fetch(e).then(function(i){return i.json()}).then(function(i){w(n,i),t(i),p()}).catch(function(){p()})}function D(e){var n=ViewLib.Auth;return n.getDriveId().then(function(t){if(!t||!n||!n.fetch)throw new Error("no driveId");var r=new Date().toISOString().replace(/T.*/,"T00:00:00.000Z"),i="https://onedrive.live.com/_api/v2.1/drives/"+t+"/oneDrive.recommendedItems?expand=thumbnails&prefer=getStaticThumbnailUrls&targetDate="+encodeURIComponent(r)+"&otdLookBackDays=6";return e&&(i+="&"+e),n.fetch(i,{headers:{Accept:"application/json","Accept-Language":Od4Strings.resolveLocale()}})}).then(function(t){if(!t.ok)throw new Error("API returned "+t.status);return t.json()})}function le(e){var n=ViewLib.Auth;return n.getDriveId().then(function(t){if(!t||!n||!n.fetch)throw new Error("no driveId");var r="createdDateTime,fileSystemInfo,lastModifiedDateTime,photo",i=!(window.ViewLib&&ViewLib.ECS)||ViewLib.ECS.isKillswitchSafe(7584)?","+r:"",u=encodeURIComponent("slideshows($expand=slideshowItems($expand=item(select=id,image(select=height,width)"+i+")))"),h="https://onedrive.live.com/_api/v2.1/drives/"+t+"/photoRecommendations/"+encodeURIComponent(e)+"?$expand="+u;return n.fetch(h,{headers:{Accept:"application/json","Accept-Language":Od4Strings.resolveLocale()}}).then(function(l){if(!l.ok)throw new Error("photoRecommendations API "+l.status);return l.json()}).then(function(l){var y=l&&l.slideshows&&l.slideshows[0],b=y&&y.slideshowItems;return!b||!b.length?null:b.map(function(S){var _=S.item||{},G=_.image||{};if(!_.id)return null;var o=window.OD4_API_ORIGIN+"/SharePoint/_api/v2.1/drives/"+t+"/items/"+_.id+"/thumbnails/0/c2560x2560/content?prefer=noredirect,closestavailablesize";return{id:o,dimensions:{width:G.width||1920,height:G.height||1080},takenDateTime:Od4Shared.PhotoDate.resolveAsRecorded(_)||void 0}}).filter(function(S){return!!S})})})}var I=initMemoriesFallback();function O(e){var n=e==="error"?"error":"empty";console.log("[Moments] no recommendations available ("+n+")"),document.getElementById("od4Hero").style.display="none",I.setRecsState(n),p()}ViewLib.AuthState.isAuthenticated()?Se():(C&&(C.style.display="none"),P&&(P.style.display="none"),k&&(k.style.display="flex"),ViewLib.Auth.postSignInEvent("promptShown","viewCTA.memories"));function Se(){try{["memories_od4_recs","memories_od4_shuffle","memories_moments","memories_onthisday"].forEach(function(o){localStorage.removeItem(o)})}catch{}var e=performance.now(),n=!1,t=null,r=3;function i(o,m){if(!n){n=!0;var s=Math.round(performance.now()-e),a=ViewLib.ECS&&ViewLib.ECS.isKillswitchSafe(6410)?{subScenario:"momentsview",recommendationType:"moj"}:void 0;m!=null&&(a=a||{},a.count=m),ViewLib.Messages.sendVpScenario("recommendationsLoaded",{duration:s,resultCode:m!=null?"loaded":o,extraData:a}),o==="empty"||o==="no-thumbs"?ViewLib.Messages.sendVpScenario("emptyMoments",{ksId:6069,duration:s,resultCode:o}):o==="fetch-failed"?ViewLib.Messages.sendVpScenario("errorMoments",{ksId:6069,duration:s,resultType:"unexpected-failure",resultCode:o}):m!=null&&m>0&&m<r&&ViewLib.Messages.sendVpScenario("lowContentMoments",{ksId:6069,duration:s,resultCode:String(m)})}}function u(o){if((B||F)&&o&&Array.isArray(o.value)){var m=["Memories","RecentTrip","RecentHighlights","PreviousMonth","Birthday","OnLastWeek"];o={value:o.value.filter(function(a){var c=a.recommendation&&a.recommendation.recommendationType;return!(B&&c==="OnThisDay"||F&&m.indexOf(c)!==-1)})}}if(!o||!Array.isArray(o.value)){try{sessionStorage.removeItem(L("od4_recs"))}catch{}i("empty"),O("empty");return}if(!o.value.length){i("empty"),O("empty");return}if(!o.value.some(function(a){return a.thumbnails&&a.thumbnails.length>1})){i("no-thumbs"),O("empty");return}I.setRecsState("ok"),document.getElementById("od4Hero").style.display="",p(),console.log("[Moments] got recs, value count:",o.value.length),i("loaded",o.value.length);var s=JSON.stringify((o.value||[]).map(function(a){return[a.recommendation&&a.recommendation.id,a.recommendation.title,a.recommendation.subtitle,(a.thumbnails||[]).map(function(c){return c.large&&c.large.sourceItemId})]}));if(s===t){console.log("[Moments] skip re-render: data unchanged");return}t=s,Q(o).then(function(){l(o)}).catch(function(){l(o)})}var h=H("od4_recs");h?(u(h),p(),U("od4_recs")||D().then(function(o){w("od4_recs",o),u(o)}).catch(function(){})):D().then(function(o){w("od4_recs",o),u(o),p()}).catch(function(){i("fetch-failed"),O("error"),p()});function l(o){var m=performance.now();console.log("[Moments] renderFromRecs called");var s=(o.value||[]).filter(function(d){return d.thumbnails&&d.thumbnails.length>1});s.sort(function(d,T){return new Date(T.recommendation.startDate).getTime()-new Date(d.recommendation.startDate).getTime()}),E=s;var a=[],c=[],M=null,v=null,ue=s.filter(function(d){return d.recommendation.recommendationType==="OnThisDay"});ue.length&&(a=ue);var Me=s.filter(function(d){return d.recommendation.recommendationType==="Memories"}),_e=6-(a.length>0?1:0);Me.slice(0,_e).forEach(function(d){a.length?c.push(d):a.push(d)});var Te=s.filter(function(d){return d.recommendation.recommendationType==="RecentTrip"}).slice(0,3);Te.forEach(function(d){a.length?c.push(d):a.push(d)}),["RecentHighlights","PreviousMonth"].forEach(function(d){var T=s.find(function(Ee){return Ee.recommendation.recommendationType===d});T&&(a.length?c.push(T):a.push(T))});var K=s.find(function(d){return d.recommendation.recommendationType==="Birthday"});K&&(a.length?M=K:a.push(K));var Y=s.find(function(d){return d.recommendation.recommendationType==="OnLastWeek"});if(Y&&(a.length?v=Y:a.push(Y)),console.log("[Moments] arrangement: hero:",a.length,"moments:",c.length,"celeb:",!!M,"lwty:",!!v),a.length>0){var g=a[0];if(document.getElementById("od4HeroTitle").textContent=g.recommendation.recommendationType==="OnThisDay"?Od4Strings.t("memoriesOnThisDay"):g.recommendation.title||Od4Strings.t("momentsTitle"),document.getElementById("od4HeroSubtitle").textContent=g.recommendation.recommendationType==="OnThisDay"?Od4Strings.t("memoriesThroughTheYears"):g.recommendation.subtitle||"",g.recommendation.recommendationType==="OnThisDay"){var Le=performance.now();ye(a),ViewLib.Messages.sendVpScenario("OnThisDay",{ksId:6069,duration:Math.round(performance.now()-Le),extraData:{count:a.length,recommendationType:g.recommendation.recommendationType}})}else document.getElementById("od4DP").style.display="none",se(g.thumbnails,R(g))}var Ve=performance.now();de(c,M,v),v&&v.thumbnails&&ViewLib.Messages.sendVpScenario("OnLastWeek",{ksId:6069,duration:Math.round(performance.now()-Ve),extraData:{count:v.thumbnails.length,recommendationType:v.recommendation.recommendationType}}),ViewLib.Messages.sendVpScenario("renderComponentOnExecute",{duration:Math.round(performance.now()-m),extraData:{count:s.length}})}{let o=function(s){if(!s||!Array.isArray(s.value)){y||I.setShuffleState("empty");return}Q(s).then(function(){var a=(s.value||[]).find(function(v){return v.recommendation.recommendationType==="PhotoShuffle"}),c=a&&a.thumbnails?a.thumbnails:[];if(c.length>=6)ie.renderSh(c),y=!0,I.setShuffleState("ok");else{var M=document.getElementById("od4Sh");M&&(M.style.display="none"),y=!1,I.setShuffleState("empty")}})},m=function(){y||I.setShuffleState("error")};var _=o,G=m,y=!1;if(q){var b=document.getElementById("od4Sh");b&&(b.style.display="none"),I.setShuffleState("empty")}else{var S=H("od4_shuffle");S?(o(S),U("od4_shuffle")||D("$filter="+encodeURIComponent("(recommendation/recommendationtype eq 'PhotoShuffle')")).then(function(s){w("od4_shuffle",s),o(s)}).catch(m)):D("$filter="+encodeURIComponent("(recommendation/recommendationtype eq 'PhotoShuffle')")).then(function(s){w("od4_shuffle",s),o(s)}).catch(m)}}ie.attachReshuffle()}typeof initMemoriesViewListeners=="function"?initMemoriesViewListeners({getHeroThumbs:function(){return Z},getHeroRec:function(){return ee},getMoments:function(){return ne},getPileAnimEnd:function(){return te},renderPile:se,renderMoments:de}):ViewLib.Messages.sendViewReadyToShell()})();