-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbundle.js
1 lines (1 loc) · 19.2 KB
/
bundle.js
1
function scrollToTop(){window.scrollTo({top:0,behavior:"smooth"})}var resultSkeleton='\n <div class="[INIT_ANIM] column is-one-fifth-desktop is-one-fifth-tablet is-full-mobile card-anim-component" id="[UUID]">\n <div class="card [ITEM_CLASS]">\n <header class="card-header">\n <p class="card-header-title">[HEADER_PLACEHOLDER]</p>\n <span class="icon" style="margin-top: 8px; margin-right: 10px;">\n [GENDER_ICON]\n </span>\n </header>\n <div class="card-image">\n <figure class="image is-4by3 lazyloadbg">\n <img id="img-[UUID2]" style="object-fit: cover;" class="img-lazyload" src="[IMAGE_PLACEHOLDER]" alt="">\n </figure>\n </div>\n <div class="card-content">\n <div class="media">\n <div class="media-content">\n <p style="font-size: 10;">[ITEM_TYPE]</p>\n <p class="title is-6">[NAME_PLACEHOLDER]</p>\n </div>\n </div>\n <div class="content">\n [DESC_PLACEHOLDER]\n </div>\n </div>\n </div>\n <footer class="card-footer" style="background-color: lightgray; border-radius: 0 0 10px 10px;">\n <a onclick="objectView(\'[UUID3]\');" class="card-footer-item">View</a>\n <a onclick="objectSave(\'[UUID4]\');" class="card-footer-item save-button">Save</a>\n <a onclick="objectCopy(\'[UUID5]\', \'[ITEM_TYPE_2]\');" class="card-footer-item">Copy</a>\n </footer>\n </div>\n ',result_save="",results_loaded=0,results_total=0,loadingtime=0;function showToast(){var e=document.getElementById("toast");e&&e.classList.add("show")}function hideToast(){var e=document.getElementById("toast");e&&e.classList.remove("show")}function fetchFeatured(){var e=["B9764582-CAFF40D1-8401E815-35A4B0E0","4E4CB6B1-B6744089-BEAA19FB-54B82C40","94038602-245D4D83-BF79F6F6-99FEC5A4","9461D3BB-329A4BF7-B769AA94-743438F2","E60A3DB3-F791437F-BC98D55F-4E1D150D"];e.forEach((function(t){var a=new XMLHttpRequest;a.open("POST","https://catalogue.destinationhome.live",!0);var n={"Accept-Encoding":"gzip, deflate, br","Content-Type":"application/json",Accept:"application/json",Connection:"keep-alive",DNT:"1",Origin:"https://catalogue.destinationhome.live"};for(var s in n)a.setRequestHeader(s,n[s]);a.onreadystatechange=function(){if(a.readyState===XMLHttpRequest.DONE&&200===a.status){var n=JSON.parse(a.responseText).data.search[0],s=n.uuid,i="https://raw.githubusercontent.com/DestinationHome/ImageArchive/master/"+s+"/"+(i=n.images.small.replace("[THUMBNAIL_ROOT]","")),o="No description available.";null!==n.description&&(o=n.description.replace("[#Legal]","")),o.length>100&&(o=o.substring(0,100)+"...");var l=n.type,r=l.toLowerCase().charAt(0).toUpperCase()+l.slice(1).toLowerCase(),c="";"REWARD"==l&&(c="isRewardCard",!1),null!=n.name&&(n.name.toLowerCase().includes("bundle")||n.name.toLowerCase().includes("pack")||n.name.toLowerCase().includes("set"))&&(c="isRewardCard",!1);var d=e.indexOf(t)+1,m=resultSkeleton.replace("[IMAGE_PLACEHOLDER]",i).replace("[NAME_PLACEHOLDER]",n.name).replace("[UUID]",s).replace("[UUID2]",s).replace("[UUID3]",s).replace("[UUID4]",s).replace("[UUID5]",s).replace("[GENDER_ICON]","").replace("[ITEM_CLASS]","isFeaturedItem").replace("[ITEM_TYPE]",r).replace("[ITEM_TYPE_2]",c).replace("[INIT_ANIM]","init-element-anim-"+d).replace("[HEADER_PLACEHOLDER]","✨ Featured").replace("[DESC_PLACEHOLDER]",o);document.getElementById("search-container").innerHTML+=m,setTimeout(removeImgLoading,500,s)}};var i=JSON.stringify({query:'{\n search(query:"'+t+'", locale:DEFAULT) {\n uuid\ntype\nname\ndescription\nimages{\nsmall\n}\nmetadata {\ntype\ngenders\n}\n }\n}'});a.send(i)}))}function fetchData(e){var t=new XMLHttpRequest;t.open("POST","https://catalogue.destinationhome.live",!0);var a={"Accept-Encoding":"gzip, deflate, br","Content-Type":"application/json",Accept:"application/json",Connection:"keep-alive",DNT:"1",Origin:"https://catalogue.destinationhome.live"};for(var n in a)t.setRequestHeader(n,a[n]);t.onreadystatechange=function(){if(t.readyState===XMLHttpRequest.DONE&&200===t.status){document.getElementById("result-amount").style.display="block",document.getElementById("search-container").innerHTML="",document.getElementById("no-result-text").style.display="none";var e=JSON.parse(t.responseText).data.search;result_save=e,results_loaded=0,results_total=e.length;var a=e.length;0===a&&(document.getElementById("no-result-text").style.display="block"),document.getElementById("result-amount").textContent="Total of "+a+" results",document.getElementById("loading-spinner").style.display="none",document.getElementById("loading-text").style.display="none",document.getElementById("loading-text").classList.remove("loading-text-anim"),document.getElementById("loading-text").classList.contains("loading-text-color")||document.getElementById("loading-text").classList.add("loading-text-color"),document.getElementById("featured-objects-title").style.display="none";for(var n=0;n<20;n++){results_loaded++;var s=e[n].uuid,i=(i=e[n].images.small).replace("[THUMBNAIL_ROOT]",""),o=(i="https://raw.githubusercontent.com/DestinationHome/ImageArchive/master/"+s+"/"+i,"No description available.");null!==e[n].description&&(o=(o=e[n].description).replace("[#Legal]","")),o.length>100&&(o=o.substring(0,100)+"...");var l="",r="";if(null!==e[n].metadata){var c=e[n].metadata;c.genders&&Array.isArray(c.genders)&&(l=c.genders[0])}"FEMALE"==l&&(r='<img src="female.png" width="50px">'),"MALE"==l&&(r='<img src="male.png" width="50px">');var d=e[n].type,m=d.toLowerCase().charAt(0).toUpperCase()+d.slice(1).toLowerCase(),u="";"REWARD"==d&&(u="isRewardCard",!1),null!=e[n].name&&(e[n].name.toLowerCase().includes("bundle")||e[n].name.toLowerCase().includes("pack")||e[n].name.toLowerCase().includes("set"))&&(u="isRewardCard",!1);var g=n+1,p=result_save.findIndex((e=>e.uuid===s))+1,v=resultSkeleton.replace("[IMAGE_PLACEHOLDER]",i).replace("[NAME_PLACEHOLDER]",e[n].name).replace("[UUID]",s).replace("[UUID2]",s).replace("[UUID3]",s).replace("[UUID4]",s).replace("[UUID5]",s).replace("[GENDER_ICON]",r).replace("[ITEM_CLASS]",u).replace("[ITEM_TYPE]",m).replace("[ITEM_TYPE_2]",u).replace("[INIT_ANIM]","init-element-anim-"+g).replace("[HEADER_PLACEHOLDER]","Result "+p).replace("[DESC_PLACEHOLDER]",o);document.getElementById("search-container").innerHTML+=v,setTimeout(removeImgLoading,500,s)}}};var s=JSON.stringify({query:'{\n search(query:"'+e+'", locale:DEFAULT) {\n uuid\ntype\nname\ndescription\nimages{\nsmall\n}\nmetadata {\ntype\ngenders\n}\n }\n}'});document.getElementById("result-amount").style.display="none",document.getElementById("loading-spinner").style.display="block",document.getElementById("loading-text").classList.contains("loading-text-color")||document.getElementById("loading-text").classList.add("loading-text-color");var i=["Running through the mall...","Loading a million results...","Almost there! Almost...","Searching. Really. Fast...","😴...","Searching as fast as we can...","Waking up our database...","Forcing Mari to hurry...","Assembling the results...","Just a moment...","Loading results...","Almost there...","Asking the database to hurry up...","Exploring the depths of our database..."],o=i[Math.floor(Math.random()*i.length)];document.getElementById("loading-text").textContent=o,document.getElementById("loading-text").style.display="block",setTimeout(showLoadingText,5e3),t.send(s)}document.getElementById("search-btn").addEventListener("click",(function(){fetchData(document.querySelector(".input").value)}));var loadingResults=!1;function showLoadingText(){document.getElementById("loading-text").classList.contains("loading-text-color")&&(document.getElementById("loading-text").classList.remove("loading-text-color"),document.getElementById("loading-text").classList.add("loading-text-anim"))}function loadMoreResults(){if(loadingResults=!0,results_loaded>=results_total)loadingResults=!1;else{for(var e=Math.min(10,results_total-results_loaded),t=results_loaded;t<results_loaded+e;t++){var a=result_save[t].uuid,n=result_save.findIndex((e=>e.uuid===a))+1;smallImageNull=!1,largeImageNull=!1,thisDescription="No description available.",result_save[t].images&&null==result_save[t].images.small&&(smallImageNull=!0),result_save[t].images&&null==result_save[t].images.large&&(largeImageNull=!0),d="",!smallImageNull&&result_save[t].images&&null!==result_save[t].images.small&&(d=result_save[t].images.small),!largeImageNull&&result_save[t].images&&null!==result_save[t].images.large&&(d=result_save[t].images.large),null!==result_save[t].description&&(thisDescription=result_save[t].description,thisDescription=thisDescription.replace("[#Legal]",""),thisDescription.length>100&&(thisDescription=thisDescription.substring(0,100)+"..."));var s="",i="";if(null!==result_save[t].metadata){var o=result_save[t].metadata;o.genders&&Array.isArray(o.genders)&&(s=o.genders[0])}"FEMALE"==s&&(i='<img src="female.png" width="50px">'),"MALE"==s&&(i='<img src="male.png" width="50px">');var l=result_save[t].type,r=l.toLowerCase().charAt(0).toUpperCase()+l.slice(1).toLowerCase(),c="";"REWARD"==l&&(c="isRewardCard",!1),null!=result_save[t].name&&(result_save[t].name.toLowerCase().includes("bundle")||result_save[t].name.toLowerCase().includes("pack")||result_save[t].name.toLowerCase().includes("set"))&&(c="isRewardCard",!1);var d=d.replace("[THUMBNAIL_ROOT]",""),m=(d="https://raw.githubusercontent.com/DestinationHome/ImageArchive/master/"+a+"/"+d,resultSkeleton.replace("[IMAGE_PLACEHOLDER]",d).replace("[NAME_PLACEHOLDER]",result_save[t].name).replace("[UUID]",a).replace("[UUID2]",a).replace("[UUID3]",a).replace("[UUID4]",a).replace("[UUID5]",a).replace("[GENDER_ICON]",i).replace("[ITEM_CLASS]",c).replace("[ITEM_TYPE]",r).replace("[ITEM_TYPE_2]",c).replace("[INIT_ANIM]","").replace("[HEADER_PLACEHOLDER]","Result "+n).replace("[DESC_PLACEHOLDER]",thisDescription));document.getElementById("search-container").innerHTML+=m,setTimeout(removeImgLoading,500,a)}results_loaded+=e,loadingResults=!1}}window.onscroll=function(e){if(!loadingResults&&results_loaded!=results_total){var t=document.getElementById("search-container").lastElementChild;if(t)t.getBoundingClientRect().bottom<=2*window.innerHeight&&loadMoreResults()}};var removed_init_anim=!1;function removeImgLoading(e){var t=document.getElementById("img-"+e);if(t&&t.classList.remove("img-lazyload"),0==removed_init_anim){for(var a=document.getElementsByClassName("init-element-anim");a.length>0;)a[0].classList.remove("init-element-anim");removed_init_anim=!0}for(a=document.getElementsByClassName("init-element-anim-1");a.length>0;)a[0].classList.remove("init-element-anim-1");for(a=document.getElementsByClassName("init-element-anim-2");a.length>0;)a[0].classList.remove("init-element-anim-2");for(a=document.getElementsByClassName("init-element-anim-3");a.length>0;)a[0].classList.remove("init-element-anim-3");for(a=document.getElementsByClassName("init-element-anim-4");a.length>0;)a[0].classList.remove("init-element-anim-4");for(a=document.getElementsByClassName("init-element-anim-5");a.length>0;)a[0].classList.remove("init-element-anim-5")}function objectCopy(e,t){if("isRewardCard"!=t){var a=document.createElement("textarea");a.value=e,document.body.appendChild(a),a.select(),document.execCommand("copy"),document.body.removeChild(a),(new Notyf).success("UUID copied to clipboard!")}else{(new Notyf).error("You cannot copy reward or bundle items!")}}function objectViewFromSaved(e){for(var t=document.getElementsByClassName("modal"),a=0;a<t.length;a++)t[a].classList.remove("is-active");objectView(e)}function objectView(e){if(document.querySelector(".object-title").textContent="",document.querySelector(".object-type").textContent="",document.querySelector(".object-description").textContent="",document.querySelector(".object-image img").src="resc/gray.webp",document.querySelector(".object-age-rating").textContent="",document.querySelector(".object-obtain-instructions").textContent="",null!=e){var t=new XMLHttpRequest;t.open("POST","https://catalogue.destinationhome.live",!0);var a={"Accept-Encoding":"gzip, deflate, br","Content-Type":"application/json",Accept:"application/json",Connection:"keep-alive",DNT:"1",Origin:"https://catalogue.destinationhome.live"};for(var n in a)t.setRequestHeader(n,a[n]);t.onreadystatechange=function(){if(t.readyState===XMLHttpRequest.DONE&&200===t.status){var a=JSON.parse(t.responseText).data.object,n=a.name,s=a.description,i=a.type;if(null==a.images||null==a.images.small)o="resc/gray.webp";else{var o=a.images.small.replace("[THUMBNAIL_ROOT]","");o="https://raw.githubusercontent.com/DestinationHome/ImageArchive/master/"+e+"/"+o}if(null==a.legal||null==a.legal.ageRating)l=0;else{var l=a.legal.ageRating.minimumAge;a.metadata}var r="<img height='40' src='resc/E.webp'>";l>=3&&(r="<img height='40' src='resc/E.webp'>"),l>=7&&(r="<img height='40' src='resc/E.webp'>"),l>=12&&(r="<img height='40' src='resc/T.webp'>"),l>=16&&(r="<img height='40' src='resc/M.webp'>"),l>=18&&(r="<img height='40' src='resc/AO.webp'>");s=(s=(s=s.replace("[#Legal]","")).replace(/\\n/g,"\n")).replace(/\n/g,"<br>"),document.querySelector(".object-title").textContent=n,document.querySelector(".object-type").textContent="Type: "+i,document.querySelector(".object-description").innerHTML=s,document.querySelector(".object-image img").src=o,document.querySelector(".object-age-rating").innerHTML=r,document.querySelector(".object-obtain-instructions").textContent="No obtain instructions found.",document.getElementById("obj-detail-save").setAttribute("onclick",'objectSave("'+e+'")'),document.getElementById("obj-detail-copy").setAttribute("onclick",'objectCopy("'+e+'", "'+i+'")'),document.querySelector(".object-title").style.animation="fadeIn",document.querySelector(".object-title").style.animationDuration="0.4s",document.querySelector(".object-type").style.animation="fadeIn",document.querySelector(".object-type").style.animationDuration="0.4s",document.querySelector(".object-description").style.animation="fadeIn",document.querySelector(".object-description").style.animationDuration="0.4s",document.querySelector(".object-image img").style.animation="fadeIn",document.querySelector(".object-image img").style.animationDuration="0.4s",document.querySelector(".object-age-rating").style.animation="fadeIn",document.querySelector(".object-age-rating").style.animationDuration="0.4s"}};var s=JSON.stringify({query:'{\n object(uuid:"'+e+'", locale:DEFAULT) {\n type\nname\ndescription\nmaker images{\nsmall\nmaker\n}\nlegal {\nageRating{\nminimumAge\n}\n}\nmetadata {\ntype\ngenders\n}\n }\n}'});t.send(s),setTimeout(toggleDetails,300)}}function objectSave(e){var t=localStorage.getItem("savedItems");(t=null==t?[]:JSON.parse(t)).includes(e)?(new Notyf).error("Item already saved!"):(t.push(e),localStorage.setItem("savedItems",JSON.stringify(t)),(new Notyf).success("Item saved!"))}function showSavedItems(){var e=localStorage.getItem("savedItems");e=null==e?[]:JSON.parse(e);var t=document.getElementById("modal-list").querySelector(".modal-card-body");if(t.innerHTML="",0==e.length)t.innerHTML="<p>No saved items yet!</p>";else{var a=.1;e.forEach((function(e){0;var n='\n <div id="saved-item-'+e+'" style="animation: fadeInLeft; animation-duration: '+(a+=.02)+'s; width: 100%; margin-bottom: 10px; background-color: rgb(236, 235, 235); border-radius: 10px; padding: 10px; display: flex; justify-content: space-between; align-items: center;">\n <div style="display: flex; align-items: center;">\n <img id="saved-item-img-'+e+'" class="preview" src="resc/gray.webp" width="50" height="50" style="animation: fadeIn; animation-duration: 2s; border-radius: 10px;">\n <p style="margin-left: 10px; animation: fadeIn; animation-duration: 0.5s;"><b id="saved-item-name-'+e+'"></b><br><span style="font-size: 13px;">'+e+'</span></p>\n </div>\n <div>\n <button style="margin-right: 5px;" class="button" onclick="objectViewFromSaved(\''+e+'\');">View</button>\n <button class="button" onclick="removeSpecificItemFromList(\''+e+"');\">Remove</button>\n </div>\n </div>\n ";t.innerHTML+=n}))}}function populateSavedItems(){var e=localStorage.getItem("savedItems");null==e?e=[]:(e=JSON.parse(e)).forEach((function(e){var t=new XMLHttpRequest;t.open("POST","https://catalogue.destinationhome.live",!0);var a={"Accept-Encoding":"gzip, deflate, br","Content-Type":"application/json",Accept:"application/json",Connection:"keep-alive",DNT:"1",Origin:"https://catalogue.destinationhome.live"};for(var n in a)t.setRequestHeader(n,a[n]);t.onreadystatechange=function(){if(t.readyState===XMLHttpRequest.DONE&&200===t.status){var a=JSON.parse(t.responseText).data.search[0],n="https://raw.githubusercontent.com/DestinationHome/ImageArchive/master/"+a.uuid+"/"+(n=a.images.small.replace("[THUMBNAIL_ROOT]","")),s=a.name;s.length>15&&(s=s.substring(0,25)+"..."),document.getElementById("saved-item-name-"+e).textContent=s,document.getElementById("saved-item-img-"+e).src=n,document.getElementById("saved-item-img-"+e).style.animation="fadeIn",document.getElementById("saved-item-img-"+e).style.animationDuration="2s"}};var s=JSON.stringify({query:'{\n search(query:"'+e+'", locale:DEFAULT) {\n uuid\nname\nimages{\nsmall\n}\n }\n}'});t.send(s)}))}function clearSavedItems(){localStorage.removeItem("savedItems"),(new Notyf).success("Cleared saved items!"),showSavedItems()}function removeSpecificItemFromList(e){var t=localStorage.getItem("savedItems");if(null==t)t=[];else{var a=(t=JSON.parse(t)).indexOf(e);a>-1&&t.splice(a,1),localStorage.setItem("savedItems",JSON.stringify(t)),(new Notyf).success("Removed item from list!"),showSavedItems(),populateSavedItems()}}function exportList(){var e=localStorage.getItem("savedItems");if(null==e)e=[];else{e=JSON.parse(e);var t="";e.forEach((function(a){e.indexOf(a)==e.length-1?t+=a:t+=a+",\n"}));var a=document.createElement("a");a.href="data:text/plain;charset=utf-8,"+encodeURIComponent(t),a.target="_blank",a.download="saved-items.txt",a.click(),(new Notyf).success("Exported saved items!")}0==e.length&&(new Notyf).error("No saved items to export!")}function handleFilterClick(e){var t=e.target;t.classList.contains("button-filter-a")?(t.classList.remove("button-filter-a"),t.classList.add("button-filter-a-sel"),t.textContent="✓ "+t.textContent):(t.classList.remove("button-filter-a-sel"),t.classList.add("button-filter-a"),t.textContent=t.textContent.replace("✓ ",""))}document.addEventListener("error",(function(e){var t=e.target;"img"===t.tagName.toLowerCase()&&(t.src.includes("small")?t.src=t.src.replace("small","large"):t.src="https://via.placeholder.com/300x200")}),!0);var filterElements=document.querySelectorAll(".filter-button");function toggleDetails(){var e=document.getElementById("modal-details");e.classList.contains("is-active")?e.classList.remove("is-active"):e.classList.add("is-active")}function toggleList(){var e=document.getElementById("modal-list");e.classList.contains("is-active")?e.classList.remove("is-active"):(showSavedItems(),e.classList.add("is-active"),populateSavedItems())}filterElements.forEach((function(e){e.addEventListener("click",handleFilterClick)}));var closeModals=document.querySelectorAll("#close-modal");closeModals.forEach((function(e){e.addEventListener("click",(function(){var e=document.getElementById("modal-details"),t=document.getElementById("modal-list");e.classList.remove("is-active"),t.classList.remove("is-active")}))})),fetchFeatured();