본문 바로가기

[Recoeve.net]

Recoeve.net page loading and scrollTop Error

728x90
반응형
# Recoeve.net page loading and scrollTop Error 전체 코드는 Github 에 있음. ## PH
  • 2023-05-23 : First posting.
## TOC ## Initial open: m.initialOpenfn() ```[.linenums.lang-js] //////////////////////////////////////////////// // Initial open :: Lang : set cookie, Cat : get and show recos //////////////////////////////////////////////// m.initialOpen=true; console.log(m.initialOpen); m.initialOpenfn=async function () { return new Promise(async function (resolve, reject) { console.log("m.initialOpenfn"); let vars=m.getSearchVars(window.location.search); let hashURI=decodeURIComponent(window.location.hash.substring(1)); if (vars.lang!==undefined) { m.docCookies.setItem("lang", vars.lang.val, Infinity, "/", false, true); console.log("vars.lang.val", vars.lang.val); } m.currentCat=vars?.cat?.val||""; if (m.recoMode==="") { console.log("recoMode 0: ", m.currentCat); await console.log(m.openCat(m.currentCat)); console.log("m.openCat passed"); } else if (m.recoMode==="multireco") { await m.toggleMultirecoMode(); } else if (m.recoMode==="neighbors") { await m.toggleNeighborsMode(); } if (vars.title!==undefined) { let title=vars.title.val; $input_title[0].value=title; } if (vars.uri!==undefined) { $new_reco.show(); let uri=vars.uri.val; console.log("vars.uri: ", uri); $input_uri[0].value=uri; await $input_uri.trigger("input.rd"); } if (window.location.pathname==="/reco") { $new_reco.show(); } $title.html(`${m.userId}'s recoeve.net`); let fs=m.fsGo; console.log(fs); console.log(m.fsToRs); console.log(hashURI); if (hashURI) { setTimeout(function () { console.log(m.fsGo.fullList[hashURI]); if (m.fsGo.fullList[hashURI]) { let k=m.fsGo.fullList[hashURI].i; console.log(k); console.log($(`#li-${k}`)); $(`#li-${k}`).trigger("click"); } m.initialOpen=false; resolve(); }, 1000); } else { resolve(); } });}; console.log(m.initialOpenfn()); $document.ready(async function () { console.log("document ready"); await m.initialOpenfn(); console.log(m.fsGo); console.log(m.fsToRs); }); ```/ ### console.log in chrome browser Access to http://recoeve.net/user/kipid?cat=%5BMusic%2FBreak%5D--K-Pop#someHash ```[.linenums] true recoeve?cat=%5BMusic%2FBreak%5D--K-Pop:5304 m.initialOpenfn recoeve?cat=%5BMusic%2FBreak%5D--K-Pop:5313 recoMode 0: [Music/Break]--K-Pop recoeve?cat=%5BMusic%2FBreak%5D--K-Pop:5314 Promise {<pending>} [[Prototype]] : Promise [[PromiseState]] : "pending" [[PromiseResult]] : undefined recoeve?cat=%5BMusic%2FBreak%5D--K-Pop:5359 Promise {<pending>} [[Prototype]] : Promise [[PromiseState]] : "fulfilled" [[PromiseResult]] : undefined recoeve?cat=%5BMusic%2FBreak%5D--K-Pop:5315 m.openCat passed recoeve?cat=%5BMusic%2FBreak%5D--K-Pop:5339 (2) [Array(0), Array(0), fullList: Array(0), $fs: n.fn.init(1), $fsl: n.fn.init(1)] recoeve?cat=%5BMusic%2FBreak%5D--K-Pop:5340 (2) [Array(0), Array(0), fixed: false, fullList: Array(0), $fs: n.fn.init(1), $fsl: n.fn.init(1), skip: true, …] recoeve?cat=%5BMusic%2FBreak%5D--K-Pop:5341 someHash recoeve?cat=%5BMusic%2FBreak%5D--K-Pop:5344 undefined ```/ Server 에 $.ajax({type:"POST"}) request 가 http://recoeve.net/user/kipid/get-Recos 로 요청해서 recos 를 받아야 하는데 server log 에 이런 요청 자체가 안뜸. 어딘가에서 await 로 끝나지 않는 function 이 있는거 같은데 중간에... 어딘지 모르겠음. ## m.openCat(cat, event) ```[.linenums.lang-js] ///////////////////////////////////////// // Open Cat ///////////////////////////////////////// m.doNotOpenCat=true; m.openCat=async function (cat, e) { return new Promise(async function (resolve, reject) { if (e?.which===2) { // wheel click. resolve(true); // return true; } m.currentCat=cat; let fs1=m.fsToRs; fs1.shuffled=null; for (let l=0;l<m.fsGo.fullList.length;l++) { m.fsGo.fullList[l].$listI=null; } await m.getUriListAndShowRecosOnCat(cat); if (!m.initialOpen) { m.doNotOpenCat=false; window.history.pushState({cat:m.currentCat, mode:m.recoMode, goOn:m.goOn, ToRsOn:m.ToRsOn}, "", m.pathOfCat(m.currentCat, m.recoMode)); } $title.html(`${cat?`${m.escapeHTML(cat)} of `:""}${m.userId}'s recoeve.net`); resolve(false); // return false; });}; ```/ ## m.getUriListAndShowRecosOnCat(cat) ```[.linenums.lang-js] m.getUriListAndShowRecosOnCat=async function (cat) { return new Promise(async function (resolve, reject) { switch (m.recoMode) { case "neighbors": $numbers_of_recos.html("Loading neighbors, and plotting charts."); $contents.html(""); resolve(); return; case "multireco": case "": default: $numbers_of_recos.html(`Loading recos in cat=${m.escapeHTML(cat)}...`); let catI=m.catList[cat]; if (catI) { $catList.find(".cat").removeClass("selected"); let $cat=$("#cat-"+catI.i); $cat.addClass("selected"); let $parents=$cat.parents(".subCat"); for (let i=$parents.length-1;i>=0;i--) { if (!$parents.eq(i).is(":visible")) { $parents.eq(i).prev().find(">.EC").trigger("click"); } } let catUriList=m.catUriList[cat]=m.catUriList[cat]||{};; if (catUriList.down) { await m.getAndShowRecosOnCat(cat); } else { await m.getUriList( "cat\n"+(cat===""?"\tp":cat), async function () { return new Promise(async function (resolve, reject) { $numbers_of_recos.html(`get-UriList on cat=${m.escapeHTML(cat)} has failed.`); $contents.html(""); resolve(); }); }, async function () { return new Promise(async function (resolve, reject) { catUriList.down=true; await m.getAndShowRecosOnCat(cat); resolve(); }); } ); } } else { $numbers_of_recos.html(`Category "${m.escapeHTML(cat)}" does not exist.`); $contents.html(""); } resolve(); return; } });}; ```/ ## m.getUriList(getUriListStr, failFn, doneFn) ```[.linenums.lang-js] m.getUriList=async function (getUriListStr, failFn, doneFn) { return new Promise(async function (resolve, reject) { $.ajax({ type:"POST", url:m.userPath+"/get-UriList", data:getUriListStr , dataType:"text" }).fail(async function () { // if (typeof failFn==="function") { await failFn(); // } resolve(); }).done(async function (resp) { resp=m.strToJSON(resp); for (let i=1;i<resp.length;i++) { let catUL=m.catUriList[resp[i].cat]; catUL.down=true; catUL.has=true; for (let p in resp[i]) { if (isNaN(p)) { catUL[p]=resp[i][p]; // cat, UriList } } catUL.uris=[]; if (catUL.UriList?.length!==0) { catUL.uris=catUL.UriList.split("\n"); } } // if (typeof doneFn==="function") { await doneFn(); // } resolve(); }); return; });}; ```/ ## RRA
  1. github.com/kipid/Recoeve :: user-page.html
728x90
반응형