const queryString = window.location.search; const parameters = new URLSearchParams(queryString); let asset_id = parameters.get('asset'); const GetRequest = (url) => { return new Promise((resolve, reject)=>{ fetch(url, { method: "GET", mode: 'cors' }).then(res=>{ if (res.status >= 200 && res.status <= 299) res.text().then(res2 => {resolve(res2);}) else reject(new Error()); }).catch(err => reject(err)); }) } const JSONPostRequest = (url, body) => { return new Promise((resolve, reject)=>{ fetch(url, { method: "POST", headers: {'Content-Type': 'application/json'}, body: body, mode: 'cors' }).then(res=>{ if (res.status >= 200 && res.status <= 299) res.json().then(res2 => {resolve(res2);}) else reject(new Error()); }).catch(err => reject(err)); }) } class Action{ _subs=[]; constructor(...subs){ this._subs = subs; } AddCallback(callback){ if (typeof callback !== 'function') throw new Error("Invalid parameter type for 'callback': "+typeof callback+". Expected 'function'.") this._subs.push(callback); } RemoveCallback(callback){ this._subs.splice(this._subs.findIndex(x=> x == callback)); } Invoke(data){ for (let i=0; i< this._subs.length; i++){ if (this._subs[i] != undefined){ this._subs[i](data); } } } } if (asset_id == null){ let popupFunc = () => {ShowPopupModal("Asset not found!", popupFunc);} popupFunc(); location.replace("https://isotopic.io/asset-store"); } let firstLoad = true; const APIBaseURL = "https://dapp.isotopic.io"; const API = { GetAssetDetails : () => { return new Promise((resolve, reject) => { GetRequest(`${APIBaseURL}/api/v1/assets/details/${asset_id}`).then(res => { resolve(JSON.parse(res)); }).catch(err => {reject(err);}); }) }, GetAssetImageSrcURL : (index) => `${APIBaseURL}/api/v1/assets/files/${asset_id}/page_images/?index=${index}`, GetAssetMainImageSrcURL : () => `${APIBaseURL}/api/v1/assets/files/${asset_id}/page_main_image`, GetAssetWeb3Details : () => { return new Promise((resolve, reject) => { GetRequest(`${APIBaseURL}/api/v1/assets/web3/${asset_id}`).then(res => { resolve(JSON.parse(res)); }).catch(err => {reject(err);}); }) }, GetUserWallets : () => JSONPostRequest(`${APIBaseURL}/api/v1/wallet/get`, JSON.stringify({session_id: User.GetSessionID()})), GetUserRating : () => new Promise((res, rej) => { GetRequest(`${APIBaseURL}/api/v1/assets/rating/?user_id=${User.GetUserID()}&asset_id=${asset_id}`).then(result => { res(JSON.parse(result)); }).catch(err => {rej(err);}); }), SetUserRating : (rating) => JSONPostRequest(`${APIBaseURL}/api/v1/assets/rate`, JSON.stringify({session_id: User.GetSessionID(), asset_id: asset_id, rating: rating})), GetAssetCategories : () => new Promise((res, rej) => { GetRequest(`${APIBaseURL}/api/v1/assets/categories`).then(categoriesResText => {res(JSON.parse(categoriesResText)); }).catch(err => rej(err)); }), GetComments : () => new Promise((res, rej) => { GetRequest(`${APIBaseURL}/api/v1/assets/comments/${asset_id}`).then(result => { res(JSON.parse(result)); }).catch(err => {rej(err);}); }), AddNewComment : (content, parent_id = null) => JSONPostRequest(`${APIBaseURL}/api/v1/assets/comments/${asset_id}/post`, JSON.stringify({session_id: User.GetSessionID(), content: content, parent_id: parent_id})), Analytics : () => { JSONPostRequest(`${APIBaseURL}/api/v1/analytics/entry`, JSON.stringify({session_id: MyAccount.session_id, action: firstLoad == true ? "visit" : "stay", asset_id: asset_id, data: {userAgent: navigator?.userAgent}})); firstLoad = false; }, GetAssocGames : (asset_uuid) => new Promise((res, rej) => { GetRequest(`${APIBaseURL}/api/v1/assets/get-assoc-games/?uuid=${asset_uuid}`).then(result => { res(JSON.parse(result)); }).catch(err => {rej(err);}); }), } //Opens Login Panel, waits for login, and returns session_id const OpenAndWaitForLogin = () => { return new Promise((resolve, reject)=>{ $("body").addClass("edgtf-right-side-menu-opened"); $(".edgtf-side-menu-button-opener, .edgtf-icon-has-hover, .edgtf-side-menu-button-opener-svg-path").addClass("opened"); const resolveLoginCallback = (value) => { resolve(value); MyAccount.OnAccountSet.RemoveCallback(resolveLoginCallback); } MyAccount.OnAccountSet.AddCallback(resolveLoginCallback); }) } let storesidebarRes = GetRequest(`${APIBaseURL}/asset-store/sidebar`).catch(err => {throw err}); let OnAssetReady = new Action(); let details; let web3details; let games_assoc; const assetPagePromises = [ API.GetAssetDetails().then(res => { details = res; window.details = res; document.title = details.title}).catch(err => {console.log(err);}), API.GetAssetWeb3Details().then(res => {web3details = res; window.web3details = res;}).catch(err => {console.log(err);}), //API.GetICPUploads(asset_id).then(res => {icpUploads = res; window.icpUploads = res;}).catch(err => {console.log(err)}) ] const getAssetCategoriesPromise = API.GetAssetCategories(); $('head').append(''); $(document).ready(async ()=> { let isotopicSvg=` `; const SetElementHTMLFromWeb = async (element, htmlURL) => { let htmlString = await GetRequest(htmlURL).catch(err => {throw err}); element.html(htmlString); } // const storeSidebar = $("#store-sidebar"); //SetElementHTMLFromWeb( storeSidebar, "https://dapp.isotopic.io/assets-page/sidebar"); const sidebarElement = $('#store-sidebar'); let htmlString = await storesidebarRes; sidebarElement.html(htmlString); try{ $("#nav-menu-item-11384").addClass("edgtf-active-item"); } catch {} await Promise.all(assetPagePromises); asset_id = details.id; OnAssetReady.Invoke(details); let IsWeb3Available = true; if (details == null || details.result == "fail"){ return setTimeout(() => {setTimeout(() => {window.location.href = "https://isotopic.io/asset-store/";}, 200)}, 2000); } let assocGamesPromise = API.GetAssocGames(details.uuid); /* MyAccount.OnReady.then(() => { API.Analytics(); setInterval(() => { API.Analytics(); }, 60000); }); */ if (web3details.web3_enabled == null || web3details.web3_enabled == false){ IsWeb3Available = false; } const TimeoutPromise = (timeout) => new Promise((res, rej) => {setTimeout(res, timeout);}); /*RETURN ALL ASSETS*/ const SearchStore = (body) => { return JSONPostRequest("https://dapp.isotopic.io/api/v1/assets/search", JSON.stringify(body)); } const GetThumbnailSrcURL = (asset_id) => `https://dapp.isotopic.io/api/v1/assets/files/${asset_id}/thumbnail`; const GetThumbnailSrcURL_Game = (game_id) => `https://dapp.isotopic.io/api/v1/store/files/${game_id}/thumbnail`; /*DEFINED FROM ELEMENTOR */ const singleAssetMainDiv = $("#single-game"); /*HTML GETTERS*/ const GetCategories = (categoryName, categoryID) =>{ return` ${categoryName}, `; } const GetKeywords = (keyword) =>{ return` ${keyword}, `; } /*related assets item*/ const GetRelatedAssets = (asset) =>{ return ` `; } const GetRelatedGames = (game) =>{ return ` `; } const loadingSVG =` `; /*HTML SETTER*/ const SetAssetInfoPanel = async () => { const GetRatingStarHTML = ( fullStar = 1) => { if (fullStar === 1) return `` //else if (fullStar === 0.5) return `` else if (fullStar === 0) return `` } singleAssetMainDiv.append(`

${details.title}

${details.title}
Publisher: ${details.publisher_name}
${GetRatingStarHTML(0)}
${GetRatingStarHTML(0)}
${GetRatingStarHTML(0)}
${GetRatingStarHTML(0)}
${GetRatingStarHTML(0)}

${details.short_description}

Categories: Tags:

Description
${details.details_html}

`); $("body").append(` `); const SpecialTagsContainer = $("#special-tags-container"); const GetSpecialTagHTML = (name, url) =>`

${name}

`; SpecialTagsContainer.append(GetSpecialTagHTML(details.platform.toUpperCase(), `https://isotopic.io/asset-store/?platform=${details.platform}`)); details.special_tags.split("-").forEach(tag => { if (tag != ""){ SpecialTagsContainer.append(GetSpecialTagHTML(tag.toUpperCase().replace(/_/g, " "), `https://isotopic.io/asset-store/?special=${tag}`)); } }) const RatingSideText = $("#rating-text"); let myRating; API.GetUserRating().then(result => {myRating = result?.rating}).catch(err => {}); MyAccount.OnAccountSet.AddCallback(async acc => { myRating = (await API.GetUserRating().catch(err => {}))?.rating; }) const SetRatingFromDetails = () => { if (details.rating.rating == null || details.rating.rating_count == 0){ for (let i=1; i<=5; i++){ $(`#rating-star-${i}`).html(GetRatingStarHTML(0)); } RatingSideText.text("(Not enough ratings)"); } else { let rating = details.rating.rating; let floored = Math.round(rating); let i=1; for (; i<= floored; i++){ $(`#rating-star-${i}`).html(GetRatingStarHTML(1)); } if (rating - floored >= 0.5){ $(`#rating-star-${i}`).html(GetRatingStarHTML(0)); //replace with 0.5 for half } else { if (floored < 5){ $(`#rating-star-${i}`).html(GetRatingStarHTML(0)); } } for (let i2=1; i2<6-i; i2++){ $(`#rating-star-${i+i2}`).html(GetRatingStarHTML(0)); } RatingSideText.text(`${Number.parseFloat(details.rating.rating).toFixed(1)}/5.0 (${details.rating.rating_count} ratings)`); } } SetRatingFromDetails(); let ratingPending = false; const SetClickEvent = () => { $("div .rating-star").on('click touchstart', function (event){ if (ratingPending == true) return; let session_id = MyAccount.session_id ?? getCookie('session_id'); let isLoggedIn = ![undefined, null, ""].includes(session_id); if (!isLoggedIn) return ShowPopupModal("You must be logged in to rate this!", ()=>{OpenAndWaitForLogin()}); let elem = $(event.target); //let elem = $(event.target)[0].tagName == "div" ? $(event.target) : $(event.target)[0].tagName == "svg" ? $(event.target).parent() : $(event.target).parent().parent(); let index = Number.parseInt(elem.attr('id').slice(-1)); if (index == null) return; ratingPending = true; elem.removeClass("clickable"); API.SetUserRating(index).then(result => { elem.addClass("clickable"); if (result.result == "success"){ ShowPopupModal("Rating success!"); ratingPending = false; myRating = index; API.GetAssetDetails().then(newDetails => { details = newDetails; SetRatingFromDetails(); }) } else { ShowPopupModal(result.error); ratingPending = false; } }).catch(err => {console.log(err); ratingPending = false;}); }); } SetClickEvent(); const CheckHoveringOverRating = () => { if ($('#rating-panel-parent:hover').length == 0) { SetRatingFromDetails(); clearInterval(CheckRatingHoverInterval); CheckRatingHoverInterval = null; } } let CheckRatingHoverInterval = setInterval(CheckHoveringOverRating, 250); const SetHoverEvent = () => { $(".rating-star").mouseenter(function () { let index = Number.parseInt($(this).attr('id').slice(-1)); let i=1; for (; i<=index; i++){ $(`#rating-star-${i}`).html(GetRatingStarHTML(1)); } for (let i2 = 0; i2 < 5-index; i2++){ $(`#rating-star-${i+i2}`).html(GetRatingStarHTML(0)); } if (CheckRatingHoverInterval === null){ CheckRatingHoverInterval = setInterval(CheckHoveringOverRating, 250); } if (typeof myRating == "number"){ RatingSideText.text(`Your rating: ${myRating}/5`); } else { let session_id = MyAccount.session_id ?? getCookie('session_id'); let isLoggedIn = ![undefined, null, ""].includes(session_id); if (isLoggedIn){ RatingSideText.text(`Rate this!`); } else { RatingSideText.text(`Login to rate this!`); } } }); $("#rating-panel-parent").mouseleave(() => { SetRatingFromDetails(); }); }; SetHoverEvent(); var currentImageIndex = 0; var imageURLS = [API.GetAssetMainImageSrcURL(), API.GetAssetImageSrcURL(0), API.GetAssetImageSrcURL(1), API.GetAssetImageSrcURL(2)]; console.log("imageURLS: " + imageURLS.length); $('.myImg').click(function(){ let modal = document.getElementById("myModal"); //modal.style.display = "flex"; modal.style.visibility = "visible"; let newSrc = this.src; let modalImg = document.getElementById("img01"); let url = this.getAttribute("imageurl"); currentImageIndex = this.getAttribute("image-index"); modalImg.src = url; //captionText.innerHTML = this.alt; }); $('#modal-next-btn').click(function(){ if(currentImageIndex0){ currentImageIndex--; }else{ currentImageIndex = imageURLS.length-1; } console.log("Prev button clicked Image index: " + currentImageIndex); let modalImg = document.getElementById("img01"); modalImg.src = imageURLS[currentImageIndex]; }); $("#close-modal").click(()=>{ let modal = document.getElementById("myModal"); //modal.style.display = "none"; modal.style.visibility = "hidden"; }); (async () => { let assets = (await SearchStore({orderby: "RAND()", limit: 5}).catch(err => {throw err;})).results; let relatedAssetsPanel = $("#related-games-panel"); let forLoopLimit = 4; for(let i=0; i { let assocGames = await assocGamesPromise; if (assocGames.result != "success" || assocGames.games.length == 0){ return; } let relatedGamesUse = $("#games-panel-use-in"); let relatedGamesReward = $("#games-panel-earn-in"); assocGames.games.forEach(game => { $(GetRelatedGames(game.game)).appendTo(relatedGamesUse); if (game.can_earn){ $(GetRelatedGames(game.game)).appendTo(relatedGamesReward); } }); $("#asset-games-parent").css("display", ""); })(); /*dot menu controller*/ $('#dropdown-dots').click(function(){ $(".dropdown-content").slideToggle( 300, "linear" ); $('.icons').toggleClass('active'); }); // Close the dropdown if the user clicks outside of it window.addEventListener("click", function(event) { if (!event.target.matches(".dropbtn")) { var dropdowns = document.getElementsByClassName("dropdown-content"); var i; for (i = 0; i < dropdowns.length; i++) { var openDropdown = dropdowns[i]; if (openDropdown.classList.contains("show")) { openDropdown.classList.remove("show"); } } } }); } let BuyPlayBusy = false; const SetBuyPlayButtons = async () => { if (BuyPlayBusy || navigator?.userAgent?.indexOf('Electron') >= 0) return; const AssetButtonsContainer = $("#game-buttons-container"); const dotMenuContainer = $("#myDropdown"); AssetButtonsContainer.html(""); dotMenuContainer.html(""); /******************** */ const GetButtonHTML = (id, text, enabled, href = null, _class = null) => ` ${href != null ? `` : ""}
${text}
${href != null ? `
` : ""}`; const GetAndInjectButton = (id, text, enabled, href=null, _class=null) => { let html = GetButtonHTML(id, text, enabled, href, _class); $(html).appendTo(AssetButtonsContainer); return $(`#${id}`); } /*DOT MENU*/ const GetDotEntryHTML = (id, text, enabled, href = null, _class = null) => ` ${href != null ? `` : ""}
${text}
${href != null ? `
` : ""}`; const GetAndInjectButtonToDotMenu = (id, text, enabled, href=null, _class=null) => { console.log("GetAndInjectButtonToDotMenu: " + text); let html = GetDotEntryHTML(id, text, enabled, href, _class); $(html).appendTo(dotMenuContainer); return $(`#${id}`); } const SetButtonActive = (button, active) => { if (active){ button.removeClass("single-game-btn-disabled"); button.addClass("single-asset-btn"); button.removeClass("remove-animations"); } else{ button.addClass("single-game-btn-disabled"); button.removeClass("single-asset-btn"); button.addClass("remove-animations"); } button.active=active; } const SetButtonText = (button, text) => { button.children().first().children().first().text(text); } const SetButtonVisible = (button, value) => { button.css("visibility", value ? "visible": "hidden"); } if (!details.available_to_play){ let unavailable_button = GetAndInjectButton("game-unavailable-button", details.special_tags?.includes("coming_soon") ? "COMING SOON" : "NOT AVAILABLE", false, null, "single-game-btn-desc"); return; } let notMobile = (/Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(navigator.userAgent)) ? false : true; let downloadClientButton = GetAndInjectButtonToDotMenu("game-download-button-2", "VIEW IN CLIENT", notMobile, "isotopic-client://asset?asset="+asset_id, "dot-menu-entry"); /*Paid assets*/ if (!IsWeb3Available || (IsWeb3Available && web3details.license_contract == null) ){ if (details.platform != null && notMobile){ let downloadsButton = GetAndInjectButton("game-buy-button", "DOWNLOAD ASSET", true, null, "single-game-btn-desc"); if (details.special_tags?.includes("cross_game_support") && notMobile){ let useAssetButton = GetAndInjectButton("asset-integrate-button", "USE ASSET", true, null, "single-game-btn-desc"); useAssetButton.click(()=>{ ShowPopupModal(`
Add this asset to your game!

Download the files, create your own version, connect with the Isotopic SDK,
and let users who own this asset unlock it inside your game!

${GetButtonHTML("integrate-asset-SDK-github-button", "Isotopic SDK", true, "https://github.com/IsotopicIO/isotopic-sdk-unity/", "single-game-btn-desc")} ${GetButtonHTML("integrate-asset-download-files-button", "Download Asset Files", true, `https://dapp.isotopic.io/assets/${asset_id}/download.zip?user=isotopic-tester`, "single-game-btn-desc")} ${GetButtonHTML("integrate-asset-copy-UUID", "Copy UUID", true, null, "single-game-btn-desc")}
`); $("#integrate-asset-copy-UUID").click(()=>{ navigator.clipboard.writeText(details.uuid); SetButtonText($("#integrate-asset-copy-UUID"), "UUID Copied!"); }) }); } let storesHtml = ""; downloadsButton.click(async () => { DownloadsHTML = `
DOWNLOAD ASSET
`; if (details.platform.includes("pc")){ let downloadIsoURL = `https://dapp.isotopic.io/assets/${asset_id}/download.zip?user=isotopic-tester`; DownloadsHTML += `
`; } DownloadsHTML += `
${storesHtml}
`; ShowPopupModal(DownloadsHTML); }); } /* ****** */ let originalPrice=``; if(details.discount!=null && details.discount!=0){ originalPrice = details.price/(details.discount/100); originalPrice=`${originalPrice}$` } let priceValue = ""; if(details.price=="0"){ priceValue = "FREE"; }else{ priceValue = details.price+"$"; } const priceTag = `

${priceValue}

` let originalPriceHolder = $("#original-price"); originalPriceHolder.text(originalPrice); $(priceTag).appendTo(AssetButtonsContainer); } else { try{ if (!MyAccount.IsLoggedIn){ if (MyAccount.IsReady == true){ let buyButton = GetAndInjectButton("game-buy-button", "LOGIN TO BUY", true, null, "single-game-btn-desc"); buyButton.click(()=>{ MyAccount.OpenMyAccount(); MyAccount.OnAccountSet.AddCallbackOneOff(()=>{ MyAccount.CloseMyAccount(); }); }); let priceValue = ""; if(details.price=="0"){ priceValue = "FREE"; }else{ priceValue = details.price+"$"; } const priceTag = `

${priceValue}

`; $(priceTag).appendTo(AssetButtonsContainer); return; } else { let buyButton = GetAndInjectButton("game-buy-button", "BUY FILES", false, null, "single-game-btn-desc"); await MyAccount.OnReady; SetBuyPlayButtons(); } return; } let buyButton = GetAndInjectButton("game-buy-button", "BUY FILES", false, null, "single-game-btn-desc"); let notMobile = (/Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(navigator.userAgent)) ? false : true; let downloadsButton = GetAndInjectButton("game-download-button", "DOWNLOAD", false, null, "single-game-btn-desc"); if (details.special_tags?.includes("cross_game_support") && notMobile){ let useAssetButton = GetAndInjectButton("asset-integrate-button", "USE ASSET", true, null, "single-game-btn-desc"); useAssetButton.click(()=>{ ShowPopupModal(`
Add this asset to your game!

Download the files, create your own version, connect with the Isotopic SDK,
and let users who own this asset unlock it inside your game!

${GetButtonHTML("integrate-asset-SDK-github-button", "Isotopic SDK", true, "https://github.com/IsotopicIO/isotopic-sdk-unity/", "single-game-btn-desc")} ${GetButtonHTML("integrate-asset-copy-UUID", "Copy UUID", true, null, "single-game-btn-desc")}
`); $("#integrate-asset-copy-UUID").click(()=>{ navigator.clipboard.writeText(details.uuid); SetButtonText($("#integrate-asset-copy-UUID"), "UUID Copied!"); }) }); } SetButtonActive(downloadsButton, false); let priceValue = ""; if(details.price=="0"){ priceValue = "FREE"; }else{ priceValue = details.price+"$"; } /* ****** */ let originalPrice=``; if(details.discount!=null && details.discount!=0){ originalPrice = details.price/(details.discount/100); originalPrice=`

${originalPrice}$

` } const priceTag = `

${priceValue}

`; let originalPriceHolder = $("#original-price"); originalPriceHolder.text(originalPrice); $(priceTag).appendTo(AssetButtonsContainer); await Web3Bundle.OnReady; let web3Client = Web3Bundle.Web3Client; let seqClient = Web3Bundle.Sequence; let web3ContractInterface = new web3Client.Web3AppContractInterface(web3details.license_contract, web3details.license_contract_abi, web3details.payment_contract_address, web3details.payment_contract_abi); let priceWei = await web3ContractInterface.GetCost(); let decimals = await web3ContractInterface.GetPaymentTokenDecimals(); let priceEth = (parseInt(priceWei)/10**(parseInt(decimals))).toFixed(2); let ASSET_OWNED = false; try { let linkedWallets = await MyAccount.GetLinkedWallets(); let assetIsOwned = false; for (let i=0; i < linkedWallets.length; i++){ try{ let owned = await web3ContractInterface.BalanceOf(linkedWallets[i].address); if (parseInt(owned) > 0){ assetIsOwned = true; ASSET_OWNED = true; break; } } catch { } } //if owned display info here } catch {} downloadsButton.click(() => { if (!downloadsButton.active) return; DownloadsHTML = `
DOWNLOAD ASSET
`; if (details.platform.includes("pc")){ let downloadIsoURL = `https://dapp.isotopic.io/assets/${asset_id}/download.zip?user=${MyAccount.session_id}`; DownloadsHTML += `
`; } ShowPopupModal(DownloadsHTML); }); SetButtonActive(downloadsButton, notMobile && ASSET_OWNED); let metamaskIcon = ` `; let creditCardIcon = ` `; SetButtonActive(buyButton, true); buyButton.click(() => { if (!buyButton.active) return; function ShowPopupModalLarge(html) { return ShowPopupModal(`
${html}
`); } function SelectMethodPage(){ let selectMethodHTML = `

${details.title}

Total:
${priceEth} USD

Payment options:

${GetButtonHTML("buy-with-sequence", creditCardIcon+"CREDIT CARD", false, null, "single-game-btn-buy")} ${GetButtonHTML("buy-with-injected", metamaskIcon+"WEB3 WALLET", false, null, "single-game-btn-buy")}

By buying this asset, you accept our Terms And Conditions.
Payment in Polygon USDC. View License on PolygonScan.

`; ShowPopupModalLarge(selectMethodHTML); let buyInjectedButton = $("#buy-with-injected"); let buySequenceButton = $("#buy-with-sequence"); buyInjectedButton.click(async () => { if (!buyInjectedButton.active) return; $("#popup-modal-close").css("color", "unset"); $("#popup-modal-close").off("click"); SetButtonActive(buyInjectedButton, false); SetButtonActive(buySequenceButton, false); $("#mint-checks-container").css("display", "unset"); const connWalletP = $("#connect-acc-p"); const balP = $("#connect-bal-p"); const approveP = $("#approve-con-p"); const mintP = $("#mint-p"); connWalletP.html(`Connect Account ${loadingSVG}`); balP.html(`Balance Available ${loadingSVG}`); approveP.html(`Approve Contract ${loadingSVG}`); mintP.html(`Mint NFT ${loadingSVG}`); let userAddress = await web3Client.ConnectWallet(); if (userAddress == null) { connWalletP.text("Connect Account ❌"); balP.text("Balance Available ❌") approveP.text("Approve Contract ❌"); mintP.text("Mint NFT ❌"); await TimeoutPromise(2000); return SelectMethodPage(); } connWalletP.text("Connect Account ✅"); let cost = await web3ContractInterface.GetCost(); let paymentTokenBal = await web3ContractInterface.PaymentBalanceOf(userAddress); if (BigInt(paymentTokenBal) < BigInt(cost)){ balP.text("Balance Available ❌"); approveP.text("Approve Buying ❌"); mintP.text("Buy Asset ❌"); await TimeoutPromise(3000); ShowPopupModal("Not enough balance,
Please add funds to your wallet first, or use a different option.", SelectMethodPage); return; } else { balP.text("Balance Available ✅"); } let isApproved = await web3ContractInterface.IsApprovedFor(cost); if (!isApproved){ let approvedNow = await web3ContractInterface.Approve(cost); if (!approvedNow){ approveP.text("Approve Contract ❌"); mintP.text("Mint NFT ❌"); await TimeoutPromise(2000); return SelectMethodPage(); } } approveP.text("Approve Contract ✅"); let result = await web3ContractInterface.Buy(1); if (!result){ mintP.text("Mint NFT ❌"); await TimeoutPromise(2000); return SelectMethodPage(); } await TimeoutPromise(1500); mintP.text("Mint NFT ✅"); let wallets = await MyAccount.GetLinkedWallets(); let isWalletLinked = wallets.filter(x => x.address == userAddress).length == 1; if (!isWalletLinked) { ShowPopupModal("You can download this asset after linking the wallet to your account.", () => { MyAccount.OpenWallets(); }); } else { ClosePopupModal(); SetBuyPlayButtons(); } ShowNotification(`Succesfully bought:
${details.title}`); }); buySequenceButton.click(async () => { if (!buySequenceButton.active) return; $("#popup-modal-close").css("color", "unset"); $("#popup-modal-close").off("click"); $("#mint-checks-container").css("display", "unset"); const connWalletP = $("#connect-acc-p"); const balP = $("#connect-bal-p"); const approveP = $("#approve-con-p"); const mintP = $("#mint-p"); connWalletP.html(`Connect to Sequence ${loadingSVG}`); balP.html(`Balance Available ${loadingSVG}`); balP.css("display", "unset"); approveP.html(`Approve Buying ${loadingSVG}`); mintP.html(`Buy Asset ${loadingSVG}`); SetButtonActive(buyInjectedButton, false); SetButtonActive(buySequenceButton, false); if (seqClient?.connectDetails?.connected == undefined){ let conPromise = await seqClient.ConnectAndAuthWallet(); if (seqClient?.connectDetails?.connected != true){ connWalletP.text("Connect to Sequence ❌"); balP.text("Balance Available ❌"); approveP.text("Approve Buying ❌"); mintP.text("Buy Asset ❌"); await TimeoutPromise(2000); return SelectMethodPage(); } } let seqAddress = await seqClient.Wallet.getAddress(); connWalletP.text("Connect to Sequence ✅"); let seqContractInterface = seqClient.GetAppContractInterface(web3details.license_contract, web3details.license_contract_abi, web3details.payment_contract_address, web3details.payment_contract_abi); let cost = await seqContractInterface.GetCost(); let paymentTokenBal = await seqContractInterface.PaymentBalanceOf(seqAddress); if (paymentTokenBal < cost){ balP.text("Balance Available ❌"); approveP.text("Approve Buying ❌"); mintP.text("Buy Asset ❌"); await TimeoutPromise(3000); ShowPopupModal("Not enough balance,
Please add funds to your wallet first.", SelectMethodPage); seqClient.AskForFunds(); return; } else { balP.text("Balance Available ✅"); } let isApproved = await seqContractInterface.IsApprovedFor(seqAddress, cost); if (!isApproved){ let approvedNow = await seqContractInterface.Approve(cost); if (!approvedNow){ approveP.text("Approve Buying ❌"); mintP.text("Buy Asset ❌"); await TimeoutPromise(2000); return SelectMethodPage(); } } approveP.text("Approve Contract ✅"); let result = true; result = await seqContractInterface.Buy(seqAddress, 1).catch(err => result = false); if (!result){ mintP.text("Buy Asset ❌"); await TimeoutPromise(2000); return SelectMethodPage(); } await TimeoutPromise(1500); mintP.text("Buy Asset ✅"); let wallets = await MyAccount.GetLinkedWallets(); let isWalletLinked = wallets.filter(x => x.address == seqAddress).length == 1; if (!isWalletLinked) { ShowPopupModal("You can download this asset after linking Sequence to your account.", () => { MyAccount.OpenWallets(); SetBuyPlayButtons(); }); } else { ClosePopupModal(); SetBuyPlayButtons(); } ShowNotification(`Succesfully bought:
${details.title}`); }); if (web3Client.IsWeb3BrowserCompatible){ SetButtonActive(buyInjectedButton, true); } SetButtonActive(buySequenceButton, true); } SelectMethodPage(); }) } catch (err){ console.log(err); ShowNotification("An error occured while getting asset's info.
Some data or functionalities might be missing from this page.", "error-web3-retrieval", null, 10000); } } } MyAccount.OnAccountSet.AddCallback(SetBuyPlayButtons); /*APPEND CATEGORIES TO AssetInfoPanel*/ const SetCategories = async () =>{ const categoriesDiv = $("#single-game-categories"); const genres = JSON.parse(details.genres) ; let allCategories = await getAssetCategoriesPromise; genres.forEach(genre => { let genreName = ""; allCategories.forEach(category => {if (category.id == genre) genreName = category.title}) $(GetCategories(genreName, genre)).appendTo(categoriesDiv); }); } /*APPEND KEYWORDS TO AssetInfoPanel*/ const SetKeywords = () =>{ const keywordsDiv = $("#single-game-keywords"); const keywords = JSON.parse(details.keywords); keywords.forEach(keyword => { $(GetKeywords(keyword)).appendTo(keywordsDiv); }); } const SetComments = () => { const commentSection = $("#comment-section-div"); const GetCommentHTML = (user_id, username, comment_id, content, created_at) => { let commentJquery = $( `

Reply
`); commentJquery.find(`#comment-username-${comment_id}`).html(`${username} - ${created_at}`); commentJquery.find(`#comment-content-${comment_id}`).text(content); return commentJquery.html(); } const AppendReply = (user_id, username, comment_id, parent_id, content, created_at) => { let commentJquery = $( `

`); commentJquery.find(`#comment-username-${comment_id}`).html(`${username} - ${created_at}`); commentJquery.find(`#comment-content-${comment_id}`).text(content); let html = commentJquery.html(); $(html).insertAfter($(`#comment-id-${parent_id}`)); } API.GetComments().then(result => { if (result == "fail"){ return commentSection.append("

An issue occured while loading comments.

"); } result.comments.forEach(comment => { if (comment.parent_id != null) return; commentSection.append(GetCommentHTML(comment.user_id, comment.username, comment.comment_id, comment.content, comment.created_at)); }); result.comments.forEach(comment => { if (comment.parent_id == null) return; if (result.comments.find(com => com.comment_id == comment.parent_id) == null) return; AppendReply(comment.user_id, comment.username, comment.comment_id, comment.parent_id, comment.content, comment.created_at); }); $(".reply-comment-button").click(function(){ $(".replying-comment-container").remove(); let id = $(this).attr("comment_id"); let username = result.comments.find(com => com.comment_id == id)?.username; let commentJquery = $( `
POST
`); commentJquery.find(`#comment-username-reply-${id}`).html(`Replying to ${username}:`); let html = commentJquery.html(); let nextNonReply = $(`#comment-id-${id}`).next(":not(.indented-comment-container)"); if (nextNonReply.length == 0){ commentSection.append($(html)); } else { $(html).insertBefore(nextNonReply); } const AppendAfterSend = (content, parent_id, comment_id, created_at) => { $(".replying-comment-container").remove(); AppendReply(MyAccount.user_id, MyAccount.username, comment_id, parent_id, content, created_at); } $("#post-reply-button").click(()=>{ let content = $("#new-reply-content").val(); $("#new-reply-content").attr("disabled", true); API.AddNewComment(content, id).then((res)=>{ if (res.result == "fail"){ $(".replying-comment-container").remove(); ShowNotification(`Reply Failed: ${res.error}`, "reply-sent", null, 4000, false); return; } AppendAfterSend(content, id, res.comment_id, "Just now"); }).catch(err => { ShowNotification("Reply failed, try again later!", "reply-sent", null, 3000, false); $(".replying-comment-container").remove(); }) }); }) }); const SetProfilePicOnNewComment = () => { $("#new-comment-profile-img").attr("src", `https://dapp.isotopic.io/api/v1/user/profile/pic/get?user_id=${MyAccount.user_id}`) } MyAccount.OnAccountSet.AddCallback(SetProfilePicOnNewComment); $('#post-comment-button').click(()=> { if (MyAccount.session_id == null){ return ShowPopupModal("You must be logged in to comment!", OpenAndWaitForLogin); } API.AddNewComment($("#new-comment-content").val()).then(newCommentRes => { if (newCommentRes.result == "fail"){ return ShowPopupModal(newCommentRes.error); } $('.other-game-comment').remove(); SetComments(); }); $("#new-comment-content").val(""); }) } const SetLinks = () => { if (typeof details?.asset_links != "string") return; let links = {}; try { links = JSON.parse(details.asset_links); } catch { return; } let linksSvg = ` `; let demoSvg = ` `; let htmlInside = ``; if (typeof links["demo"] == "string"){ htmlInside+=` `; } if (typeof links["full_version"] == "string"){ htmlInside+=` `; } if (links["socials"] != null){ htmlInside+=` `; } if (htmlInside == "") return; let htmlFinal = `
${htmlInside}
`; $(htmlFinal).insertBefore("div.single-game-details.flex-column.span-width"); if (links["socials"] != null){ let linksHTMLs = []; let linksSeperator = "

|

"; links["socials"].forEach(link => { linksHTMLs.push(`

${link.title}

`) }) $("#view-links-button").click(() => { ShowPopupModal( `
Socials/Links:
${linksHTMLs.join(linksSeperator)}
` ); }); } } //wp override const cssRuleHeaderUnderline = '.edgtf-main-menu > ul > li > a::after { background-color: var(--assetstore-main) !important; }'; // Append the CSS rule to the head of the document $('