transmission/web/public_html/transmission-app.js

5 lines
113 KiB
JavaScript
Raw Normal View History

(()=>{var Vt=Object.create;var et=Object.defineProperty;var Nt=Object.getOwnPropertyDescriptor;var _t=Object.getOwnPropertyNames;var Dt=Object.getPrototypeOf,Et=Object.prototype.hasOwnProperty;var Ht=(s,e)=>()=>(e||s((e={exports:{}}).exports,e),e.exports);var Jt=(s,e,t,r)=>{if(e&&typeof e=="object"||typeof e=="function")for(let o of _t(e))!Et.call(s,o)&&o!==t&&et(s,o,{get:()=>e[o],enumerable:!(r=Nt(e,o))||r.enumerable});return s};var zt=(s,e,t)=>(t=s!=null?Vt(Dt(s)):{},Jt(e||!s||!s.__esModule?et(t,"default",{value:s,enumerable:!0}):t,s));var Ot=Ht((q,M)=>{var jt=200,Pe="__lodash_hash_undefined__",Ie=1,ut=2,pt=9007199254740991,de="[object Arguments]",De="[object Array]",Mt="[object AsyncFunction]",mt="[object Boolean]",bt="[object Date]",ht="[object Error]",It="[object Function]",Pt="[object GeneratorFunction]",ge="[object Map]",Ct="[object Number]",Kt="[object Null]",j="[object Object]",tt="[object Promise]",$t="[object Proxy]",ft="[object RegExp]",ue="[object Set]",At="[object String]",qt="[object Symbol]",er="[object Undefined]",Ee="[object WeakMap]",Gt="[object ArrayBuffer]",pe="[object DataView]",tr="[object Float32Array]",rr="[object Float64Array]",sr="[object Int8Array]",or="[object Int16Array]",nr="[object Int32Array]",ir="[object Uint8Array]",ar="[object Uint8ClampedArray]",cr="[object Uint16Array]",lr="[object Uint32Array]",dr=/[\\^$.*+?()[\]{}|]/g,gr=/^\[object .+?Constructor\]$/,ur=/^(?:0|[1-9]\d*)$/,Z={};Z[tr]=Z[rr]=Z[sr]=Z[or]=Z[nr]=Z[ir]=Z[ar]=Z[cr]=Z[lr]=!0;Z[de]=Z[De]=Z[Gt]=Z[mt]=Z[pe]=Z[bt]=Z[ht]=Z[It]=Z[ge]=Z[Ct]=Z[j]=Z[ft]=Z[ue]=Z[At]=Z[Ee]=!1;var Bt=typeof global=="object"&&global&&global.Object===Object&&global,pr=typeof self=="object"&&self&&self.Object===Object&&self,T=Bt||pr||Function("return this")(),vt=typeof q=="object"&&q&&!q.nodeType&&q,rt=vt&&typeof M=="object"&&M&&!M.nodeType&&M,yt=rt&&rt.exports===vt,Ve=yt&&Bt.process,st=function(){try{return Ve&&Ve.binding&&Ve.binding("util")}catch{}}(),ot=st&&st.isTypedArray;function mr(s,e){for(var t=-1,r=s==null?0:s.length,o=0,n=[];++t<r;){var i=s[t];e(i,t,s)&&(n[o++]=i)}return n}function br(s,e){for(var t=-1,r=e.length,o=s.length;++t<r;)s[o+t]=e[t];return s}function hr(s,e){for(var t=-1,r=s==null?0:s.length;++t<r;)if(e(s[t],t,s))return!0;return!1}function Ir(s,e){for(var t=-1,r=Array(s);++t<s;)r[t]=e(t);return r}function Cr(s){return function(e){return s(e)}}function fr(s,e){return s.has(e)}function Ar(s,e){return s?.[e]}function Gr(s){var e=-1,t=Array(s.size);return s.forEach(function(r,o){t[++e]=[o,r]}),t}function Br(s,e){return function(t){return s(e(t))}}function vr(s){var e=-1,t=Array(s.size);return s.forEach(function(r){t[++e]=r}),t}var yr=Array.prototype,xr=Function.prototype,Ce=Object.prototype,Ne=T["__core-js_shared__"],xt=xr.toString,R=Ce.hasOwnProperty,nt=function(){var s=/[^.]+$/.exec(Ne&&Ne.keys&&Ne.keys.IE_PROTO||"");return s?"Symbol(src)_1."+s:""}(),Zt=Ce.toString,Zr=RegExp("^"+xt.call(R).replace(dr,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$"),it=yt?T.Buffer:void 0,me=T.Symbol,at=T.Uint8Array,Xt=Ce.propertyIsEnumerable,Xr=yr.splice,_=me?me.toStringTag:void 0,ct=Object.getOwnPropertySymbols,Fr=it?it.isBuffer:void 0,Wr=Br(Object.keys,Object),He=P(T,"DataView"),ee=P(T,"Map"),Je=P(T,"Promise"),ze=P(T,"Set"),je=P(T,"WeakMap"),te=P(Object,"create"),Lr=H(He),Qr=H(ee),wr=H(Je),Ur=H(ze),kr=H(je),lt=me?me.prototype:void 0,_e=lt?lt.valueOf:void 0;function D(s){var e=-1,t=s==null?0:s.length;for(this.clear();++e<t;){var r=s[e];this.set(r[0],r[1])}}function Or(){this.__data__=te?te(null):{},this.size=0}function Rr(s){var e=this.has(s)&&delete this.__data__[s];return this.size-=e?1:0,e}function Tr(s){var e=this.__data__;if(te){var t=e[s];return t===Pe?void 0:t}return R.call(e,s)?e[s]:void 0}function Yr(s){var e=this.__data__;return te?e[s]!==void 0:R.call(e,s)}function Sr(s,e){var t=this.__data__;return this.size+=this.has(s)?0:1,t[s]=te&&e===void 0?Pe:e,this}D.prototype.clear=Or;D.prototype.delete=Rr;D.prototype.get=Tr;D.prototype.has=Yr;D.prototype.set=Sr;function Y(s){var e=-1,t=s==null?0:s.length;for(this
`)}_updatePeers(){let e=G,{elements:t,torrents:r}=this,{tbody:o}=t.peers,n=[(a,l)=>{l.dataset.encrypted=a.isEncrypted},(a,l)=>h(l,a.rateToPeer?e.speedBps(a.rateToPeer):""),(a,l)=>h(l,a.rateToClient?e.speedBps(a.rateToClient):""),(a,l)=>h(l,`${Math.floor(a.progress*100)}%`),(a,l)=>{h(l,a.flagStr),l.setAttribute("title",s._peerStatusTitle(a.flagStr))},(a,l)=>{h(l,a.address),l.setAttribute("title",a.address)},(a,l)=>{h(l,a.clientName),l.setAttribute("title",a.clientName)}],i=[];for(let a of r){let l=document.createElement("tr");l.classList.add("torrent-row");let c=document.createElement("td");c.setAttribute("colspan",n.length),h(c,a.getName()),l.append(c),i.push(l);for(let u of a.getPeers()){let g=document.createElement("tr");g.classList.add("peer-row");for(let[d,p]of n.entries()){let b=document.createElement("td");b.classList.add(Yt[d]),p(u,b),g.append(b)}i.push(g)}for(;o.firstChild;)o.firstChild.remove();o.append(...i)}}static getAnnounceState(e){switch(e.announceState){case f._TrackerActive:return"Announce in progress";case f._TrackerWaiting:{let t=Math.max(0,e.nextAnnounceTime-Date.now()/1e3);return`Next announce in ${G.timeInterval(t)}`}case f._TrackerQueued:return"Announce is queued";case f._TrackerInactive:return e.isBackup?"Tracker will be used as a backup":"Announce not scheduled";default:return`unknown announce state: ${e.announceState}`}}static lastAnnounceStatus(e){let t="Last Announce",r=["N/A"];if(e.hasAnnounced){let o=G.timestamp(e.lastAnnounceTime);e.lastAnnounceSucceeded?r=[o," (got ",G.countString("peer","peers",e.lastAnnouncePeerCount),")"]:(t="Announce error",r=[e.lastAnnounceResult?`${e.lastAnnounceResult} - `:"",o])}return{label:t,value:r.join("")}}static lastScrapeStatus(e){let t="Last Scrape",r="N/A";if(e.hasScraped){let o=G.timestamp(e.lastScrapeTime);e.lastScrapeSucceeded?r=o:(t="Scrape error",r=(e.lastScrapeResult?`${e.lastScrapeResult} - `:"")+o)}return{label:t,value:r}}static _getOrigin(e){try{let t="udp://";if(e.announce.startsWith(t)){let o="http://",n=e.announce.replace(t,o);return new URL(n).origin.replace(o,t)}return new URL(e.announce).origin}catch{return[e.sitename||e.host||e.announce]}}_updateTiers(){let e="N/A",{list:t}=this.elements.tiers,{torrents:r}=this,o=[];for(let n of r){if(r.length>1){let i=document.createElement("div");i.classList.add("tier-list-torrent"),h(i,n.getName()),o.push(i)}for(let i of n.getTrackers()){let a=s.getAnnounceState(i),l=s.lastAnnounceStatus(i),c=s.lastScrapeStatus(i),u=document.createElement("div");u.classList.add("tier-list-row");let g=document.createElement("div"),d=s._getOrigin(i);g.classList.add("tier-list-tracker"),h(g,`${d} - tier ${i.tier+1}`),g.setAttribute("title",i.announce),u.append(g),g=document.createElement("div"),g.classList.add("tier-announce"),h(g,`${l.label}: ${l.value}`),u.append(g),g=document.createElement("div"),g.classList.add("tier-seeders"),h(g,`Seeders: ${i.seederCount>-1?i.seederCount:e}`),u.append(g),g=document.createElement("div"),g.classList.add("tier-state"),h(g,a),u.append(g),g=document.createElement("div"),g.classList.add("tier-leechers"),h(g,`Leechers: ${i.leecherCount>-1?i.leecherCount:e}`),u.append(g),g=document.createElement("div"),g.classList.add("tier-scrape"),h(g,`${c.label}: ${c.value}`),u.append(g),g=document.createElement("div"),g.classList.add("tier-downloads"),h(g,`Downloads: ${i.downloadCount>-1?i.downloadCount:e}`),u.append(g),o.push(u)}}for(;t.firstChild;)t.firstChild.remove();t.append(...o)}_changeFileCommand(e,t){let{controller:r,file_torrent:o}=this,n=o.getId();r.changeFileCommand(n,e,t)}_onFileWantedToggled(e){let{indices:t,wanted:r}=e;this._changeFileCommand(t,r?"files-wanted":"files-unwanted")}_onFilePriorityToggled(e){let{indices:t,priority:r}=e,o=null;switch(r.toString()){case"-1":o="priority-low";break;case"1":o="priority-high";break;default:o="priority-normal";break}this._changeFileCommand(t,o)}_clearFileList(){let{list:e}=this.elements.files;for(;e.firstChild;)e.firstChild.remove();this.file_torrent=null,this.file_torrent_n=null,this.file_rows=null}static createFileTreeModel(e){let t=[],r={children:
`).map(i=>i.trim()).filter(i=>s._isValidURL(i)))this.remote.addTorrentByUrl(n,t);let{files:o}=e.dataTransfer;return o.length>0&&(this.openDialog=new $(this,this.remote,"",o)),e.preventDefault(),!1}togglePeriodicSessionRefresh(e){!e&&this.sessionInterval&&(clearInterval(this.sessionInterval),delete this.sessionInterval),e&&(this.loadDaemonPrefs(),this.sessionInterval||(this.sessionInterval=setInterval(this.loadDaemonPrefs.bind(this),8e3)))}_setFilterText(e){this.filterText=e?e.trim():null,this.refilterAllSoon()}_onTorrentChanged(e){this.changeStatus&&(this._dispatchSelectionChanged(),this.changeStatus=!1);let t=e.currentTarget;this.dirtyTorrents.add(t.getId()),this.refilterSoon()}updateTorrents(e,t){this.remote.updateTorrents(e,t,(r,o)=>{let n=[],i=r.shift(),a={};for(let l of r){for(let[g,d]of i.entries())a[d]=l[g];let{id:c}=a,u=this._torrents[c];if(u){let g=u.needsMetaData();u.refresh(a),g&&!u.needsMetaData()&&n.push(c)}else u=this._torrents[c]=new f(a),u.addEventListener("dataChanged",this._onTorrentChanged.bind(this)),this.dirtyTorrents.add(c),(!("name"in u.fields)||!("status"in u.fields))&&n.push(c)}if(n.length>0){let l=["id",...f.Fields.Metadata,...f.Fields.Stats];this.updateTorrents(n,l),this.refilterSoon()}o&&(this._deleteTorrents(o),this.refilterSoon())})}refreshTorrents(){let e=["id",...f.Fields.Stats];this.updateTorrents("recently-active",e)}_initializeTorrents(){let e=["id",...f.Fields.Metadata,...f.Fields.Stats];this.updateTorrents(null,e)}_onRowClicked(e){let t=e.metaKey||e.ctrlKey,{row:r}=e.currentTarget;if(this.popup&&this.popup.name!=="inspector"&&this.setCurrentPopup(null),e.target.classList.contains("torrent-pauseresume-button"))switch(e.target.dataset.action){case"pause":this._stopTorrents([r.getTorrent()]);break;case"resume":this._startTorrents([r.getTorrent()]);break;default:break}e.stopPropagation(),e.shiftKey?(this._selectRange(r),window.focus()):!r.isSelected()&&t?this._selectRow(r):r.isSelected()?r.isSelected()&&t?this._deselectRow(r):r.isSelected()&&this._setSelectedRow(r):this._setSelectedRow(r),this._last_torrent_clicked=r.getTorrentId()}_deleteTorrents(e){if(e&&e.length>0){for(let t of e)this.dirtyTorrents.add(t),delete this._torrents[t];this.refilterSoon()}}_removeSelectedTorrents(e){let t=this.getSelectedTorrents();t.length>0&&this.setCurrentPopup(new Qe({remote:this.remote,torrents:t,trash:e}))}_startSelectedTorrents(e){this._startTorrents(this.getSelectedTorrents(),e)}_startTorrents(e,t){this.changeStatus=!0,this.remote.startTorrents(s._getTorrentIds(e),t,this.refreshTorrents,this)}_verifyTorrents(e){this.remote.verifyTorrents(s._getTorrentIds(e),this.refreshTorrents,this)}_reannounceTorrents(e){this.remote.reannounceTorrents(s._getTorrentIds(e),this.refreshTorrents,this)}_stopTorrents(e){this.changeStatus=!0,this.remote.stopTorrents(s._getTorrentIds(e),()=>{setTimeout(()=>{this.refreshTorrents()},500)},this)}changeFileCommand(e,t,r){this.remote.changeFileCommand(e,t,r)}_moveTop(){this.remote.moveTorrentsToTop(this._getSelectedTorrentIds(),this.refreshTorrents,this)}_moveUp(){this.remote.moveTorrentsUp(this._getSelectedTorrentIds(),this.refreshTorrents,this)}_moveDown(){this.remote.moveTorrentsDown(this._getSelectedTorrentIds(),this.refreshTorrents,this)}_moveBottom(){this.remote.moveTorrentsToBottom(this._getSelectedTorrentIds(),this.refreshTorrents,this)}_updateGuiFromSession(e){let[,t,r]=e.version.match(/(.*)\s\(([\da-f]+)\)/);this.version_info={checksum:r,version:t},document.querySelector("#toolbar-overflow").classList.toggle("alt-speed-enabled",e[X._TurtleState])}_updateStatusbar(){let e=G,t=this._getAllTorrents(),r=t.reduce((i,a)=>i+a.getUploadSpeed(),0),o=t.reduce((i,a)=>i+a.getDownloadSpeed(),0),n=e.countString("Transfer","Transfers",this._rows.length);h(document.querySelector("#speed-up-label"),e.speedBps(r)),h(document.querySelector("#speed-dn-label"),e.speedBps(o)),h(document.querySelector("#filter-count"),n)}static _displayName(e){let t=e;return t.length>0&&(t=t.charAt(0).toUpperCase()+t.slice(1)),t}_updateFilterSelect(){let e=this._getTrackerCounts(),t=Object.keys(e).sort(),r
//# sourceMappingURL=transmission-app.js.map