From 7284593eb8fd66e006b52caa80d40ac50139eb41 Mon Sep 17 00:00:00 2001 From: vict0rsch Date: Tue, 27 Feb 2024 14:45:31 -0500 Subject: [PATCH] build --- src/popup/min/popup.min.html | 2 +- src/popup/min/popup.min.js | 6 +++--- src/shared/min/utils.min.js | 12 ++++++------ 3 files changed, 10 insertions(+), 10 deletions(-) diff --git a/src/popup/min/popup.min.html b/src/popup/min/popup.min.html index dd25c286..d47d45db 100755 --- a/src/popup/min/popup.min.html +++ b/src/popup/min/popup.min.html @@ -1,3 +1,3 @@
\ No newline at end of file diff --git a/src/popup/min/popup.min.js b/src/popup/min/popup.min.js index aa74ab4d..4d4cdc3e 100644 --- a/src/popup/min/popup.min.js +++ b/src/popup/min/popup.min.js @@ -1,3 +1,3 @@ -const handleBackToFocus=e=>{const t=eventId(e);setTimeout(()=>{dispatch("memory-container--"+t,"focus")},250)},handleDeleteItem=e=>{e=eventId(e);showConfirmDeleteModal(e)},handleOpenItemLink=e=>{e=eventId(e);focusExistingOrCreateNewPaperTab(global.state.papers[e],!0)},handleOpenItemScirate=e=>{var e=eventId(e),t="https://scirate.com/arxiv/"+arxivIdFromPaperID(global.state.papers[e].id);focusExistingOrCreateNewCodeTab(t),global.state.papers[e]=updatePaperVisits(global.state.papers[e]),setStorage("papers",global.state.papers)},handleOpenItemVanity=e=>{var e=eventId(e),t="https://www.arxiv-vanity.com/papers/"+arxivIdFromPaperID(global.state.papers[e].id);focusExistingOrCreateNewCodeTab(t),global.state.papers[e]=updatePaperVisits(global.state.papers[e]),setStorage("papers",global.state.papers)},handleOpenItemAr5iv=e=>{var e=eventId(e),t="https://ar5iv.labs.arxiv.org/html/"+arxivIdFromPaperID(global.state.papers[e].id);focusExistingOrCreateNewCodeTab(t),global.state.papers[e]=updatePaperVisits(global.state.papers[e]),setStorage("papers",global.state.papers)},handleOpenItemHuggingface=e=>{var e=eventId(e),t="https://huggingface.co/papers/"+arxivIdFromPaperID(global.state.papers[e].id);focusExistingOrCreateNewCodeTab(t),global.state.papers[e]=updatePaperVisits(global.state.papers[e]),setStorage("papers",global.state.papers)},handleOpenItemCodeLink=async e=>{e=eventId(e),e=global.state.papers[e].codeLink;await focusExistingOrCreateNewCodeTab(e)},handleOpenItemWebsiteURL=async e=>{var e=eventId(e),t=global.state.papers[e].pdfLink;global.state.papers[e]=updatePaperVisits(global.state.papers[e]),await setStorage("papers",global.state.papers),await focusExistingOrCreateNewCodeTab(t)},handleCopyMarkdownLink=async e=>{var e=eventId(e),t=global.state.prefs,a=t.checkPreferPdf?"PDF":"Abstract",o=global.state.papers[e],o=makeMdLink(o,t);await copyAndConfirmMemoryItem(e,o,`Markdown ${a} link copied!`)},handleCopyBibtex=async e=>{var e=eventId(e),t=global.state.papers[e].bibtex,t=bibtexToObject(t);t.hasOwnProperty("url")||(t.url=paperToAbs(global.state.papers[e])),t.hasOwnProperty("pdf")||"website"===global.state.papers[e].source||(t.pdf=paperToPDF(global.state.papers[e])),await copyAndConfirmMemoryItem(e,bibtexToString(t),"Bibtex copied!")},handleCopyPDFLink=async e=>{var e=eventId(e),t=global.state.prefs,a=global.state.papers[e],a=(t.checkPreferPdf?paperToPDF:paperToAbs)(a),t=t.checkPreferPdf?"PDF":"Abstract";await copyAndConfirmMemoryItem(e,a,t+" link copied!")},handleCopyHyperLink=async e=>{var e=eventId(e),t=global.state.prefs,a=global.state.papers[e],t=(t.checkPreferPdf?paperToPDF:paperToAbs)(a);await copyAndConfirmMemoryItem(e,t,"Hyperlink copied!",!1,a.title)},handleAddItemToFavorites=e=>{var e=eventId(e),t=hasClass("memory-container--"+e,"favorite");saveFavoriteItem(e,!t)},handleMemoryOpenLocal=e=>{var e=eventId(e),t=global.state.files[e],a=global.state.papers[e];global.state.papers[e]=updatePaperVisits(a),setStorage("papers",global.state.papers),t&&(t.id||0===t.id)&&chrome.downloads.open(t.id),window?.close&&window.close()},handleTextareaFocus=()=>{textareaFocusEnd(this)},handleMemorySaveEdits=e=>{var{note:t,codeLink:a}=getPaperEdits(e);saveNote(e,t),saveCodeLink(e,a),updatePaperTags(e,"memory-item-tags")},handleCancelPaperEdit=e=>{e.preventDefault();var e=eventId(e),t=global.state.papers[e];val(findEl(e,"form-note-textarea"),t.note),setHTML(findEl(e,"memory-item-tags"),getTagsOptions(t)),dispatch(findEl(e,"memory-item-edit"),"click")},handleTogglePaperEdit=e=>{e.preventDefault();var e=eventId(e),t=findEl("memory-container--"+e),a=findEl(e,"code-and-note"),o=findEl(e,"extended-item"),s=findEl(e,"tag-list"),r=findEl(e,"memory-authors"),i=findEl(e,"edit-tags"),l=findEl(e,"memory-item-actions");const n=$(findEl(e,"memory-item-tags"));hasClass(t,"expand-open")?(removeClass(t,"expand-open"),slideDown(a,150),slideDown(s,150),slideDown(l,150),slideDown(r,150),slideUp(o,150),slideUp(i,150),setTimeout(()=>{n.select2("destroy")},500)):(addClass(t,"expand-open"),n.select2({...global.select2Options,width:"86%"}),hasClass(t,"has-monitoring")||n.on("change",monitorPaperEdits(e,!1)),t.classList.add("has-monitoring"),slideUp(a,150),slideUp(s,150),slideUp(l,150),slideUp(r,150),slideDown(o,150),slideDown(i,150))},handleMemorySelectChange=e=>{e=e.target.value;global.state.sortKey=e,sortMemory(),displayMemoryTable(),setMemorySortArrow("down")},handleMemorySortArrow=e=>{"memory-sort-arrow-down"===querySelector("#memory-sort-arrow svg").id?setMemorySortArrow("up"):setMemorySortArrow("down"),reverseMemory(),displayMemoryTable()},handleFilterFavorites=()=>{var e=!global.state.showFavorites;(global.state.showFavorites=e)?(addClass(findEl("filter-favorites").querySelector("svg"),"favorite"),sortMemory(),global.state.papersList=global.state.papersList.filter(e=>e.favorite),displayMemoryTable(),setMemorySortArrow("down"),findEl("memory-select").innerHTML+='',e=global.state.papersList.length,setPlaceholder("memory-search",`Search ${e} entries...`)):(removeClass(findEl("filter-favorites").querySelector("svg"),"favorite"),"favoriteDate"===val("memory-select")&&(val("memory-select","lastOpenDate"),global.state.sortKey="lastOpenDate"),querySelector('#memory-select option[value="favoriteDate"]').remove(),sortMemory(),setMemorySortArrow("down"),val("memory-search").trim()?dispatch("memory-search","keypress"):(global.state.papersList=global.state.sortedPapers,displayMemoryTable()),e=global.state.sortedPapers.length,setPlaceholder("memory-search",`Search ${e} entries...`))},handleMemorySearchKeyPress=a=>e=>{var t=val("memory-search").trim();if(log(t),t||setTimeout(()=>{style("memory-search-clear-icon","visibility","hidden")},0),!t){if(global.state.papersList.length!==global.state.sortedPapers.length)return global.state.papersList=global.state.sortedPapers,void displayMemoryTable();if(!a&&"Backspace"!==e.key)return}style("memory-search-clear-icon","visibility","visible"),(t.startsWith("t:")?searchMemoryByTags:t.startsWith("c:")?searchMemoryByCode:t.startsWith("y:")?searchMemoryByYear:searchMemory)(t),toggleTagsCollapse(t.startsWith("t:")),displayMemoryTable()},handleMemorySearchKeyUp=e=>{var t;"Backspace"==e.key&&((t=new Event("keypress")).key="Backspace",dispatch("memory-search",t)),"memory-search"===e.target.id&&dispatch("memory-search","keypress")},handleCancelModalClick=()=>{hideId("delete-paper-modal")},handleConfirmDeleteModalClick=async e=>{var t=findEl("delete-paper-modal-hidden-id").innerHTML,a=global.state.papers[t].title,o=global.state.papers[t].pdfLink;await deletePaperInStorage(t,global.state.papers),displayMemoryTable(),hideId("delete-paper-modal"),info(`Successfully deleted "${a}" (${t}) from PaperMemory`),global.state.currentId===t&&await updatePopupPaperNoMemory(o),setPlaceholder("memory-search",`Search ${global.state.papersList.length} entries ...`),addListener("memory-switch","click",handleMemorySwitchClick)},handleTagClick=e=>{e=e.target.textContent;val("memory-search","t: "+e),dispatch("memory-search","keypress")},handleClearSearch=e=>{val("memory-search",""),dispatch("memory-search","clear-search"),style("memory-search-clear-icon","visibility","hidden")},handleMemorySwitchClick=()=>{(global.state.memoryIsOpen?closeMemory:openMemory)()},handlePopupKeydown=t=>{var a=t.key;if(!(["Backspace","Enter","Escape","a","e"].indexOf(a)<0))if(global.state.prefsIsOpen)"Escape"===a?(t.preventDefault(),closeMenu()):"Enter"===a&&querySelector("#menu-switch:focus")&&closeMenu();else if(global.state.memoryIsOpen){if("Enter"===a){if(querySelector("#filter-favorites:focus"))return void dispatch("filter-favorites","click");if(querySelector("#memory-sort-arrow:focus")&&"Enter"===a)return void dispatch("memory-sort-arrow","click")}let e;var o,s=querySelector(".memory-container:focus");if("Escape"!==a){if(!s)return;e=s.id.split("--")[1]}"Backspace"===a?dispatch(findEl(e,"memory-delete"),"click"):"Enter"===a?(o="website"===global.state.papers[e].source?findEl(e,"memory-website-url"):global.state.prefs.checkEnterLocalPdf&&findEl(e,"memory-item-openLocal")||findEl(e,"memory-item-link"),dispatch(o,"click")):"Escape"===a?(t.preventDefault(),s&&hasClass(s,"expand-open")?handleTogglePaperEdit(t):closeMemory()):"e"===a&&dispatch(findEl(e,"memory-item-edit"),"click")}else if("a"===a){if(queryAll(":focus").some(e=>["INPUT","TEXTAREA"].includes(e.tagName)))return;global.state.papers&&dispatch("memory-switch","click")}else"Enter"===a&&("memory-switch-open"===(o=querySelector(":focus")).id?dispatch("memory-switch","click"):"menu-switch"===o.id?(dispatch("menu-switch","click"),dispatch("menu-switch","blur")):hasClass(o,"memory-item-svg-div")&&dispatch(o,"click"))},handlePrefsCheckChange=async e=>{const t=e.target.id,a=findEl(t).checked;global.state&&global.state.prefs?(global.state.prefs[t]=a,setStorage("prefs",global.state.prefs,function(){log(`Settings saved for ${t} (${a})`)})):((e=await getStorage("prefs")??{})[t]=a,setStorage("prefs",e,function(){log(`Settings saved for ${t} (${a})`)})),a&&"checkNoAuto"===t&&chrome.commands.getAll(e=>{e=e.find(e=>"manualParsing"===e.name).shortcut;console.log("shortcut: ",e),e||showPopupModal("manualParsing")})},handlePopupSaveEdits=e=>{var{note:t,codeLink:a,favorite:o}=getPaperEdits(e,!0);updatePaperTags(e,"#popup-item-tags--"+e),saveNote(e,t),saveCodeLink(e,a),saveFavoriteItem(e,o)},handlePopupDeletePaper=e=>()=>{showConfirmDeleteModal(e)},showTitleTooltip=(e,t)=>{t=t?findEl("popup-title-tooltip"):findEl(e,".title-tooltip");style(t,"display","block")},hideTitleTooltip=(e,t)=>{t=t?findEl("popup-title-tooltip"):findEl(e,".title-tooltip");style(t,"display","none")},getHandleTitleTooltip=(o,s,r)=>e=>{const t=r?global.state.currentId:eventId(e);var a=global.state.timerIdMap.get(e.target)??0;clearTimeout(a),a=setTimeout(()=>o(t,r),s),global.state.timerIdMap.set(e.target,a)},handleExpandAuthors=e=>{var e=eventId(e),t=findEl(e,"memory-authors");setHTML(t,cutAuthors(global.state.papers[e].author,1e5))},getPaperInfoTable=e=>{var t=new Date(e.addDate).toLocaleString().replace(",",""),a=new Date(e.lastOpenDate).toLocaleString().replace(",",""),t=[["Added",t],["Last open",a],["Visits",e.count],["Source",global.knownPaperPages[e.source].name]];return e.venue&&t.push(["Publication",`${e.venue} ${e.year}`]),`${t.map(e=>``).join("")}
${e[0]}
${e[1]}
`},getMemoryItemHTML=(e,t)=>{var a=getDisplayId(e.id),o=e.note||"",s=e.id,r=new Set(e.tags),i=getTagsOptions(e),l=e.favorite?"favorite":"",n=(t.pdfLink="Open tab to "+e.title,t.copyLink="Copy URL to the paper's "+(global.state.prefs.checkPreferPdf?"PDF":"abstract"),`
${"website"==e.source&&e.pdfLink.replace(/^https?:\/\//,"")||""}
`);let d='
';e.note&&(d=`
Note: ${o}
`);var p=global.state.files.hasOwnProperty(e.id)?`
${tablerSvg("vocabulary","",["memory-icon-svg"])}
`:"",c="website"===e.source?"":``;let m="",y=(global.state.prefs.checkScirate&&"arxiv"===e.source&&(m=`
${tablerSvg("messages","",["memory-icon-svg"])}
`),""),g=(global.state.prefs.checkVanity&&"arxiv"===e.source&&(y=`
${tablerSvg("vanity","",["memory-icon-svg"])}
`),""),v=(global.state.prefs.checkAr5iv&&"arxiv"===e.source&&(g=`
${tablerSvg("ar5iv","",["memory-icon-svg"])}
`),"");global.state.prefs.checkHuggingface&&"arxiv"===e.source&&(v=`
${tablerSvg("huggingface","",["memory-icon-svg"])}
`);var h=getPaperInfoTable(e);return`

${tablerSvg("star","",["memory-item-favorite-svg",l])} ${e.title}

${[...r].map(e=>`${e}`).join("")}
${cutAuthors(e.author)}
${n} ${d}
${tablerSvg("writing","",["memory-icon-svg"])}
${a}
${p} ${c} ${v} ${m} ${y} ${g}
${tablerSvg("markdown","",["memory-icon-svg"])}
${tablerSvg("math-function","",["memory-icon-svg"])}
-
`},getPopupEditFormHTML=e=>{var t=e.id,a=getTagsOptions(e),o=e.note||"",s=getDisplayId(e.id);return`
Tags:
${s}
`},getPopupPaperIconsHTML=(e,t,a)=>{var o=e.id,t=isPdfUrl(t)?"HTML":"PDF";let s="",r=(global.state.prefs.checkScirate&&"arxiv"===e.source&&(s=``),""),i=(global.state.prefs.checkVanity&&"arxiv"===e.source&&(r=``),""),l=(global.state.prefs.checkAr5iv&&"arxiv"===e.source&&(i=``),"");global.state.prefs.checkHuggingface&&"arxiv"===e.source&&(l=``);a=global.state.prefs.checkStore&&(a.localFile||a.stored||global.state.files.hasOwnProperty(e.id))?``:``;return("website"===e.source?"":``)+` ${l} ${s} ${r} ${i}`+a},getTagsOptions=e=>{const o=new Set(e.tags);return[...global.state.paperTags].sort().map((e,t)=>{let a='