|
82 | 82 | .copy-modal-box textarea{width:100%;height:300px;font-family:monospace;font-size:12px;border:1px solid var(--border);border-radius:4px;padding:8px;background:var(--input-bg);color:var(--text);resize:vertical} |
83 | 83 | .copy-modal-box .modal-btns{display:flex;gap:8px;justify-content:flex-end} |
84 | 84 | .copy-modal-box button{padding:6px 16px;border:1px solid var(--border);border-radius:5px;background:var(--btn-bg);color:var(--btn-text);cursor:pointer;font-size:12px} |
85 | | -.session-link{margin-bottom:6px;font-size:12px;display:flex;align-items:center;gap:8px} |
86 | | -.session-link a{font-weight:500} |
87 | | -.session-link .spacer{flex:1} |
| 85 | +.search-bar{margin-bottom:6px;display:flex;align-items:center;justify-content:flex-end} |
88 | 86 | .col-resize-handle{position:absolute;top:0;right:-2px;width:4px;height:100%;cursor:col-resize;z-index:5;user-select:none} |
89 | 87 | .col-resize-handle:hover{background:var(--accent);opacity:.3} |
90 | 88 | body.col-resizing,body.col-resizing *{cursor:col-resize!important;user-select:none!important} |
|
111 | 109 | .settings-drop input[type="radio"]{margin:0} |
112 | 110 | .settings-drop .drop-sep{border-top:1px solid var(--border-light);margin:4px 0} |
113 | 111 | </style></head><body> |
114 | | -<div id="sessionLink" class="session-link"><span class="spacer"></span><input id="globalSearch" type="text" placeholder="Search all columns..."></div> |
| 112 | +<div class="search-bar"><input id="globalSearch" type="text" placeholder="Search all columns..."></div> |
115 | 113 | <div id="toolbar"> |
116 | 114 | <span id="sum">Loading...</span> |
117 | 115 | <button id="selAllBtn">Select all</button> |
|
145 | 143 | const copyModal=document.getElementById("copyModal"); |
146 | 144 | const copyArea=document.getElementById("copyArea"); |
147 | 145 | const closeCopyModal=document.getElementById("closeCopyModal"); |
148 | | -const sessionLinkEl=document.getElementById("sessionLink"); |
149 | 146 |
|
150 | | -let sessionUrl="",csvUrl="",pollToken="",downloadTokenUrl=""; |
| 147 | +let csvUrl="",pollToken="",downloadTokenUrl=""; |
151 | 148 | const TRUNC=200; |
152 | 149 | let didDrag=false; |
153 | 150 | let copyFmt="csv"; |
|
674 | 671 | } |
675 | 672 | return csvUrl; |
676 | 673 | } |
677 | | -function updateDownloadLink(){updateSessionLink();} |
678 | 674 | document.getElementById("exportLink")?.addEventListener("click",async()=>{ |
679 | 675 | if(!csvUrl&&!downloadTokenUrl){showToast("No download link yet");return;} |
680 | 676 | const url=await getFreshDownloadUrl(); |
|
719 | 715 | document.removeEventListener("mouseup",onRowResizeUp); |
720 | 716 | } |
721 | 717 |
|
722 | | -/* --- session URL display --- */ |
723 | | -const linksEl=document.createElement("span");linksEl.id="sessionLinks"; |
724 | | -sessionLinkEl.insertBefore(linksEl,sessionLinkEl.querySelector(".spacer")); |
725 | | -function updateSessionLink(){ |
726 | | - let h=""; |
727 | | - if(sessionUrl)h+='<a href="#" id="sessionOpenLink">Open FutureSearch session ↗</a>'; |
728 | | - if(csvUrl){if(h)h+=" | ";h+='<a href="#" id="csvOpenLink">Download CSV ⤓</a>';} |
729 | | - linksEl.innerHTML=h; |
730 | | - document.getElementById("sessionOpenLink")?.addEventListener("click",e=>{ |
731 | | - e.preventDefault(); |
732 | | - if(!/^https?:\\/\\//i.test(sessionUrl))return;app.openLink({url:sessionUrl}).catch(()=>window.open(sessionUrl,"_blank")); |
733 | | - }); |
734 | | - document.getElementById("csvOpenLink")?.addEventListener("click",async e=>{ |
735 | | - e.preventDefault(); |
736 | | - const url=await getFreshDownloadUrl(); |
737 | | - if(!url||!/^https?:\\/\\//i.test(url))return; |
738 | | - app.openLink({url}).catch(()=>window.open(url,"_blank")); |
739 | | - }); |
740 | | -} |
741 | | -
|
742 | 718 | /* --- data loading --- */ |
743 | 719 | async function fetchFullResultsWithFreshToken(hasPreview,total){ |
744 | 720 | const base=await getFreshDownloadUrl(); |
|
767 | 743 | if(!isWidget){return;} |
768 | 744 | widgetActive=true; |
769 | 745 | document.body.style.height="auto";document.body.style.overflow="visible";document.body.style.padding="12px"; |
770 | | - if(meta.session_url&&!sessionUrl){sessionUrl=meta.session_url;updateSessionLink();} |
771 | 746 | if(meta.poll_token){pollToken=meta.poll_token;} |
772 | 747 | if(meta.download_token_url){downloadTokenUrl=meta.download_token_url;} |
773 | | - if(meta.csv_url){csvUrl=meta.csv_url;updateDownloadLink();} |
| 748 | + if(meta.csv_url){csvUrl=meta.csv_url;} |
774 | 749 | if(meta.fetch_full_results){ |
775 | 750 | if(meta.preview)processData(meta.preview); |
776 | 751 | fetchFullResultsWithFreshToken(!!meta.preview,meta.total); |
|
815 | 790 | import{App}from"SCRIPT_SRC"; |
816 | 791 | const app=new App({name:"FutureSearch Session",version:"1.0.0"}); |
817 | 792 | const el=document.getElementById("c"); |
818 | | -let pollUrl=null,pollToken=null,pollTimer=null,sessionUrl="",wasDone=false; |
| 793 | +let pollUrl=null,pollToken=null,pollTimer=null,wasDone=false; |
819 | 794 | function esc(s){const d=document.createElement("div");d.textContent=String(s);return d.innerHTML;} |
820 | 795 |
|
821 | 796 | app.ontoolresult=({content})=>{ |
822 | 797 | const t=content?.find(c=>c.type==="text");if(!t)return; |
823 | 798 | try{ |
824 | | - const d=JSON.parse(t.text);sessionUrl=d.session_url||"";render(d); |
| 799 | + const d=JSON.parse(t.text);render(d); |
825 | 800 | if(d.progress_url&&!pollTimer){pollUrl=d.progress_url;pollToken=d.poll_token||null;startPoll()} |
826 | 801 | }catch{el.textContent=t.text} |
827 | 802 | }; |
|
830 | 805 | const comp=d.completed||0,tot=d.total||0,fail=d.failed||0,run=d.running||0; |
831 | 806 | const pend=Math.max(0,tot-comp-fail-run); |
832 | 807 | const done=["completed","failed","revoked"].includes(d.status); |
833 | | - const url=d.session_url||sessionUrl; |
834 | 808 | const elapsed=d.elapsed_s||0; |
835 | 809 |
|
836 | | - let h=url?`<a href="#" class="session-open">Open FutureSearch session ↗</a>`:""; |
| 810 | + let h=""; |
837 | 811 |
|
838 | 812 | if(tot>0){ |
839 | 813 | const pDone=comp/tot*100,pRun=run/tot*100,pFail=fail/tot*100; |
|
871 | 845 |
|
872 | 846 | el.innerHTML=h; |
873 | 847 |
|
874 | | - const link=el.querySelector(".session-open"); |
875 | | - if(link){link.addEventListener("click",e=>{ |
876 | | - e.preventDefault(); |
877 | | - if(!/^https?:\\/\\//i.test(url))return;app.openLink({url:url}).catch(()=>window.open(url,"_blank")); |
878 | | - });} |
879 | | -
|
880 | 848 | if(done&&!wasDone){wasDone=true;el.classList.add("flash")} |
881 | 849 | if(done&&pollTimer){clearInterval(pollTimer);pollTimer=null} |
882 | 850 | } |
|
0 commit comments