From 2dc746a7b6bf26d7887de75835facc03623a7b06 Mon Sep 17 00:00:00 2001 From: Jordan Lee Date: Wed, 24 Aug 2011 02:04:35 +0000 Subject: [PATCH] (trunk web) A lot of web cleanup, refactoring, bugfixes, and probably new breakage. Filterbar/statusbar has been reworked. Added filter-by-tracker. Compact mode now works in "iPhone" mode. --- web/images/graphics/chrome.png | Bin 3536 -> 5741 bytes web/index.html | 36 +- web/javascript/common.js | 129 +- web/javascript/dialog.js | 30 +- web/javascript/file-row.js | 70 +- web/javascript/formatter.js | 94 +- web/javascript/torrent-row.js | 260 ++- web/javascript/torrent.js | 459 +++--- web/javascript/transmission.js | 2097 +++++++++++++------------ web/javascript/transmission.remote.js | 157 +- web/stylesheets/Makefile.am | 1 - web/stylesheets/common.css | 399 ++--- web/stylesheets/ie6.css | 89 -- web/stylesheets/iphone.css | 404 +++-- 14 files changed, 2108 insertions(+), 2117 deletions(-) delete mode 100644 web/stylesheets/ie6.css diff --git a/web/images/graphics/chrome.png b/web/images/graphics/chrome.png index febebc1f092dabe69d789f35afca28f15fe6a6ee..6cc61536884baf73f86ecebc75bf4e887265e135 100644 GIT binary patch literal 5741 zcmb7IcQ{;4`#zSiYSt1h!D@+KqDNoC>LiFxqC_ImONbh)1tEGTdRA{i^b#Ukq6E<* z>SkGCiOzT4?|ZN7_xJD2wP((mYj)1eGxI#pec#ardK%OeEEE6$P-~*p?t!&301yFC z2>2AsyTLyL8j67n7&bI3SaBW*tO~vTNk8P_!HzVUzrNfTtyyM^KB040(hWm*!q==DO z^sQ!hf+#W6w46(zUnLa7Dp(dib&vUmw_0Rot&x_AbK#L>W)IQiH(&@+1MN$I5)}kc zb7RxJe5J7HA}oG-XQ4jW(kZiu&>bmP=Q+kci5tZc@H@Glc!k5m(RNs5FHuwd=k4w7 zCTT#et&+%~d1UPa8Nw1}s{FsAV-E?5BBJfoFB;)?8k1Jk2F(X40TS-pd zKNC*LDCN31Y|-XCU3GGDa&+{f-C7^Yfu65%R8v#CYj_saIe``A<9mzy{rk(8FSl>s zh8a#YSUAka#>Re%VeCA`w*ue{!ujr(^!4|%#Hnj0x|C!w*=3d-pI^iO!M*a zd1z=1lo=Kp8B=#g-!nHhHny~+0$v{C&j5bwS zT7?+2jsCfkKRudlf9b2I_ojE*pju<*nx>Z4>zJ6B`1mGM!Kh~cgWvuA{qysdRZ7y* zO|`Y|2fwFc#fEHqQu+o420ne_;o%YM|D4F9eeow!3H|5VwQGLzY{tfvl$7x|WFbJ( zE&Yq%<<<6PZ{p*X+&psTZ8SNnJZMzn{txHsN{gnd`g+1}hPdVB zZ2e<8I9!ln$a73#y8NK?Y)wQ?POi5zIy(AzvoIdYVR?)59ssp|Tc{C#63~$${+K1M z->lxz_`jAL&XgQ-k{HdFo!B{KSMZl$y15i|y4@2_sbTrH#dAITjyL~VM8dlu%alJFmK!T<_|`ieWql6D16Ne09Z5Xx=NwG8Rm-jZEqquPPDTXzN=@1>@u zqS5G)Ea}Lrq`;r8`msGHHpPG!mX2EK~mIXPCbHE=gzB_4D(?rRvH`T|GVP#;4bSw!JR`;GA5VM6BDG zfTR1>gJgVhadF#tJYFvD?BcMKETo~KAvrmDW@ct`(nt&YI4{uW>}VH!1sxUA_2K!P zuytE{UY?TcqC8E7ZyjQYOXJP6Cr`*pAZ>Dx&@Rv=bMzj2dJ-g61c&yH2^;#k@_a*} zQxVz^7b$^^jEtK}*ww)#U0q!>GqYt{_QVe#K3tH-xlwv~d!OrD%)P%~YH#M^>Kgp} zeJS!pKj)65&v5!`aZc`RBZ#4-VG9cj!HXY_OD8f$*8l5m0s`g5#h-Q#Fa2=e$=CzjzCKKr zmbnc8FR;aFi!XQD!F9rs*8W%?pn0d`6y`qn;kko@gLU=c$8l;JghZoe;(i~Ue!#`? zhWO)AwZ6SQ4UI`|wX60{q$zP_&F{WP;bQpVVr)^I(Psb^tgqTUNTUR5Pr zIx$#!4z3uqaItpUho+__Wt^WA-|GTiisFX%@1Nl3TZGff>+6$nzA`r$VjRGCaC>Oa z>(li5O;H@2i34mew?^f5bTl=w-sRTS`dV7Q0RK37Rr=BiGb<}<09@|i;NZ7!-_#4= zjya)W^|SK+`%Zw2FFt!3$Li1jg^6%_4t5ew6OfWhZ980id3v}b!p~o4UfCp?o0e1q>V@599 z$9e{%?VmEQG*P6>(z$7t>N*~7WGu-<1tcUVullq)L&v|}I(6-Ssouf(aTN@l;t^nSq-p z(qUsXCwY8x)5$Eg_aKrW9QA@);M)W1pkoIl>e(~FowkI>`dL!j9bkrBc_Vk^U-lq# zmR+EGLHaD>s^XEdA$`&yJ>IHLkddB#9*omcS#ctpJ=jX?3iR+s_ytg5(S!%5?Ao@g zenc#xtF5DRL+p`Su=8;gLlo3@3Ipa)V=!pq56b)c`jV5u1IS!^A6Xe+a}&?Q7C(SH z03))}-e<0NB3D`O?C%YU`1<%Lo@^GX+Dw*XwD=ri!wsBoLy`rLkL$*Z&rPBfy|X0Ucnw-`?ur>EG?sWm9ssvtKbH@@!Y7uRP{) z>4$Kb{2DLT26N0MV?`f`X=>oFQeYKmTb`iF3KC9E2(c|RDg=rKIF!i^LJYJ|K0Jx4 zAb}uYz-#3rjjAYsSlQ#40U_P5g(!%~7c*ckV|kip{7y%uM6EzsHeCSa-_4YqqD;b_ z%<)i}$$*-ilY@lE7Onz8L1D^}wv7-=MuBb%_DMt;tqqKr1;g?U#trdjK7fDIMrflU zTJ+rh%<3Xk#5M4!t~pk!8=_Qnre4-fzItI6_B2z87qKoYP?|I#xhCFbWOV>L= z4GpVALgw*~tYV*sdBY4z+evQU%}9J#1Ba4?Vo+!N+vMZ*an0u<)Z5#vXb7Im?s*}D zAS!k|R3&wv{(#=gh>IQy5N&f@` z?oTBJ)&@^K$vzQS(`%4jeLmM4lpJap0gsm9bzfQwBjHd}#c-ZTzSrok*FEYUSh`)1 z4o@(!XOW$oX?`x3C4Otyb?J$PQgtUT&*KZjmoBDz$yF6tRTuVI$h=>G%5QxBrP&jS zn___y_cCC}gisEK%sb1om!g_?Vs-5zObwC|cS$I^BKowPl*4$h82#~@h*vz;drk5C z0L8udscU%k74GzbR3nUhxYywEK3UjJq;Wn~D0OrS^l83RKJR{S&Tc>V(*|J5YTLY> z)Ql@%A~KGBB=&Y)e!K&b`P1S3+VAd# zx;I%l&@WzoWPXZ?K+PnWM(2~Ns7u5tUgYn54lnDJ(2^LImbfN#li}LL)FeyPcd?{c z(u^lmp@nTg3I>h|+iFr6tEICL1gQo@i}yWxpx;^M+JQO(TIr*|-7_D~j@ zw<%wlM7fg<<4fyHwOL%nMABDP+vc0?;`YAZ@zjs`Sk`Qzu1>3RH%@d*JofK^mS{ee zr1Cm;%Ms(gg~C01Nd-}fKqn?Ko~0O9{w^+S3D0URSipR_2{MtJ1_*UR5lN6sz7)<8 z9FUO(5TlHKfQgvf9@+?hFg>cwMEuIAg?^tSom?gQkG;;p zvAMZCTqOf>yPvm=1&(assE0$l5)ki5!WLb^Im9>-@LX|{wzO<(1bVP5L6n*q&OJS( zh1eTL8|0>2W+?h8YQlI`5K$qSq_LLL0^KkG3a5Z3TjE)oJyf7TLH~wxmw~+%7=^`U z5$L9qJuczPFlZORO!PzFN0wJ0)Kc3Nry4jwWT_eH0w&AE-lV8tm9HcM9RJIqzt&C3 ziGJ?zHC-3=wteRJ}Q4z7LO>iEF5kIp=tj#{dkd8Cyon^UyQ?5C{}>{B#vvWP?tD*KZ8 zzI7vXGD&!NL|xgK;=-gGs%ZEHmVc@^J?;5cIQZeY!tz*{vojA{u>1pKk@Z#jneCFE zp3cpKlLS}G!1&8j!#Pmv#iILOi3FWBZ1u+yPqDRy+k`5l=_NTs~QBR zg6i3as5dk=0Yt%PTqI$lK7upbqMkPgN7~ohgO|*sQv?QH%Kvoh3MI~2TN{XZoqKXT zrs;oD6@?GlG{9=G=a9^^ygskkV3zerl`~I79rjH-1`bZs}e_f;j5fRA)%O?G&cezXvZ6=%r7j5#N zhlo3uek{7MnksR?{B_w|Opw)))`g;+lapQeg|Fkku8Z}cp(7)U!^36c_n4Fvkypc= zaTWr!hQZ#FTQj?X&baSIMK58smD?-(`*pIO6?8ZEsbkAsbGW9pHVI!Oa{K zmWGFhh>s`$rqja{|CzetcLhj`2HrWBPK**0T3MO34D{Fh*6S=R`6Z-(w+VVVER7F) zzke&#AfBfUnga>KEqz6h&sbPrY|gnl^YDxx?IvVWh>5+m;x!WB82WjDR3$cg(7V`P z9e4fkbDaa(__#2_F(N3cdDf9j>Uy?f;K@q-WnkeryM7%IP(D^VHB(nt-^{gY z_2Kwc^RO3$t;Z3YZEbB}2LmlJO-%xOei;Tcwh`lo2_3WtDTqn=6i6!qI#vea(^68*1XDqLKDYgMb=4jj zHMd=b!T4|F_$DSLX=`hX_c)Q~=t(mPJRHY*ahxv&5JpZ8a3hX{1>dFT^|Np|9LmAU z%6f2ckdl%DQX)zQ!Ov8MJjmWIpaQM9s;6G)ezK39DAfn)zy-c_#|J-;^=N@|^hQt* zfqUB#;CGMRynrzTRe`qdKx#9^^)rh*4yTKS#iKRe+<4;Zx}j?Cu z2?=qj$13-MtZ{gFczk?(H}Kzu(W(S{dmp@El>_}CDKQcB(@G%)g+Ndjp*#5s54irl z3tWiAGrre#!Iu}HI3>ZwWw-VvCD1fly6M@h$L0AUi0sinxHZRZE6{wFmmPtpA6%DQ z8qGJx^77Ks7{_gFY&so=QeVG*eK&?-cKdI_1*kzlNk|=eia;Mlhg&5Jdj8$ zC3x6A0V!JjV|^>DoZjV{*=J))mjRplfnzBzmctq8?`rDmjtmaA5Ju&WYg>u6|M5ZH z5%8pd%9M%8cTh6x8T%h3|2J>WXG``47jgZQD*w%x|L>}6oAZ+LhO7uXJ--wqs09O> MclFe&khZV>1Fc-$j{pDw literal 3536 zcmV;>4KMPEP)UQzD2L19{J`MSI6qLhXMYZ8002N3hRwgNA798I zOQ?e~av!)x<@|xjvFy(Q4FCWL!?5``bwC+1$P((HBS*{m10_e~K5%WRpA!K902qj2 z^*6eGY~yGQ!pX66jGRBva+DmA^8XvFf$e|?94?FV1A|L(eBjxi0~!DT5Qbs%FXkW-8Dz=ppsZX2-xxU} zN92zBIUoQ406_rc|0~u#NNg{jo9TCLfSw`Ep|c_8!HR3 z5YaUsdoiR7H!;OM)wd%YoMpNl=Htq_{?%jbj$#1PG>zl<;UJ)b5L(Fp+kaEnbx{;i z6q%;UvMh51gb)lsmSx+v;fSZWvMd!v;d%Z<`L%hY%=0`=Q`dDt5S-9T7>1T*F-KEX zRi5VvxF^?jMNt$4f#bNpToWN=U03}5FbtR<-}l+R?+wFPzJdM_un>4lLD-9z0c}rl z97oeMUDxj^=P-`rBL!hE{>+yFLeKLcX9;E5Y1`JeZM=ZXvV2EDz!61!S}uX?sH!SS z5=ICr3_y}3P1B&OvmXIR6hA39m(VnVFpk?|YXeGKNNH&=X=o2AK|#%-*C3<;YrxzB z0rlWjbF2YF5Oc~QB$$BYtX3C??RxgrF$|@nG%immOSYl@jtl z4Bz+7=WiY7C9}I^UN}xbLxjZzwplS;z?uJd}m`;vIUb!cdaDbd&0cT*7t zE)t7W&_yZHpEdZ`u7>)@MACLo{yf(3rm zfStDZ3=gz3E(Zq({eJ&vMHsjQsRFtq>EPhN?RH;l>#oyTtJUNL;D|nq$K(9<<(FPt zTbr7i0!SPh!oVd+6+QD@5?6P*Tq^(0$Oy0QaUu;0AXp$ekH@p!mY5>otX69#lli6y z1DBwv-PWp7sW_cZ5*!W(lcb{-I0}cuD=RB}Kbg;OMVzHx&IGUcGURqj8BoZ=beSLjH z5r!P!(2B3iBkB_q6FgzbNhlF|5)?qN!1ZEZ&?$<=VwA~blD?atpAQCuxb!=d&t|ic zjVqF6vEVQ@>-9QQynElF{H=(znVA_j0qzTBvsorF!w&$*gYeB}GouBUm9Yb|x3?Dv z1a^0K1z(^96aG;HST01WUa#NU+REi}7>wZY@o|Fe&^;8dCrIHF%X`%tAMFWHyjmGlwGFv^9on^tS z2m_ZORV1`dBH-#Jap@(-1f5_s8Z8!!;A7wtq>2_E%Y;U$HsBxoW)iAY6vlBan`|N} z3xXhs5GjbFw@@DxX_ItK}efufLcYHMhc3cX&2R770plv zX_K#U_`wIK)8%!2danz?Z*e*Ipx-^ickX{c|Cs$ z#RPP8%jfeT7r+9Ik^IqUlv_G;xtvVZB=iArOY%ul)~Xj^9~l{8i>V5D3qgZhI$6Jt zMz2nbwB;$(VJsGd$$;yUp9Tw0Cyj6I0wm?C5;6g2CX*Q&8iHLIDi2TutEIkWD4hmu zk(VG1W)9?0C%`AAB81fKc7tES`KZi^Q&G?tGDl8;5`yUDmBf$Ohlhu~UayUGx?ZpI z_lj^hOdE(5E+lM}(KC*&>9nxXMx(*L0TE7Q0llCskCeRDgCVjU!C+8sc_fUQ{9|Kd zhS7ALAI`#?oooM#`cr)#eeOyOT#11zF>obZ%9XHv0^&;05LW^$1AT3oK&#b)z=|v3 zqD#WjgOIdPaCEKI4W17eL!q*5JpEwyLKg}nFi(x>;vl6kt?AD zO`B>i6bguASyZGMw-a12uG9=+a(od_hz&H8+{WW^2(}52AS5UGU38gG0LhD=O4)fl z9==HlA_D1$*(1rb*(`z;f6}~=q;?4zfnoGWO$aG;RX&U#!N?HosCYyOQWN(QdG^k)^tg4WojbjjSBAFG$n+)cXQpsWifrH)^i$(ge=p?^~qbS3-4K z%&9j>?&7#$(26TzZ?L~4ry;H*`%c>g(K>P^NQlBFzYF7^6Vp3af=2>OmD+<9`-VK$sB#N(u=II+X36fG6OS6cHo= zjEw?7QeS`ntr9g^C9D!wiI-UOX|b!yqWD_--1o1l5=-+3v6FxyrAZ`$L{CNkRZ2Xh|TKWTk+WN=W`ODxoD2FoD&y z3Pc1Tc3%P4rV=c#fe#%zbkn_;_* zCw}41`!#Z}25M^6P*0^;OUjIyDH-f$26{QdiU9{h)(P|6+OUP-g`Z+_GQW3wW7`%s zOf-R!8Awl5DWfP=r=s7X5+N0iMdw@xQ*EBTkdAzYsp|!kPJC^9cBEHFeW+gAU?YoW zhEnx}%#<1Xp%MZGE5vqTbGeO;>%_^QuU@@IgTCVKo!br^*f>~2BTIEt-B2^9fdHYt zs6-L!IOlUtw|VBj+2P}0)7NitCPfir|JRXE(u>b6o;_VV`p?Fb5BgiLw3Q(&l-LiI za9JU>JUn8v&Bw^B{(w?sMZbaInmK=ef=9F{AUDW+!aR=PSqXP;0}c`jwf*R`P~<%{&x>>lVEdz4Aba7B)3CJvWo~ z3=bT5XhG_FI6a;n`(a@2Qt`r*vzfvq6mo_LlDFuUFtdmt8L*H;F*Q9KMRWJo&Cl*# zCr}|8f4tZ}_1$DKKls;uk)j}6;SQ1V9>#HN0}2>|HSp1q>8y6+^5umH2?Q{5XXCwt z10@=mn_Vcjzhz-2DFAW+~6l`<+(8I>5xV9;tUV;FE1|k3wfP~5d1?xJJ zJA!L6m0l`gX6|0)3IU*K5RA)PvpgUH$sr*C8GCj%qF*W@Ndm~K>TZheLjnQ{!pJ{H zB~(S}seU5D)~VB!yg5`4nG84l}ngmX%;7 zSc%`_*tr7}0DuU9qPPD-mn2EDmNE3p8{{?I#o62VZF9i!$5(^ncbx*quL`G~J2(LV zgrOMv_g_R2r9$a`4&kAE$QvVvlsTn24o}_q3w6^n$Clv}RpJ5F(|mi#O;6+i0000< KMNUMnLSTYvdri{- diff --git a/web/index.html b/web/index.html index c0e6f792e..a2658e2bd 100755 --- a/web/index.html +++ b/web/index.html @@ -9,13 +9,17 @@ + + + - @@ -34,7 +38,7 @@ -
+
  • @@ -45,26 +49,23 @@
  • -
-
-
0 Transfers
-
0 B/s
-
0 B/s
+
+ +
+
+ 0 B/s + 0 B/s +
-
- - + diff --git a/web/javascript/common.js b/web/javascript/common.js index 8273ff477..153ee1e7a 100644 --- a/web/javascript/common.js +++ b/web/javascript/common.js @@ -8,7 +8,6 @@ var transmission; var dialog; -var resizeTimer = null; // Test for a Webkit build that supports box-shadow: 521+ (release Safari 3 is // actually 523.10.3). We need 3.1 for CSS animation (dialog sheets) but as it // degrades gracefully let's not worry too much. @@ -16,11 +15,11 @@ var Safari3 = testSafari3(); var iPhone = RegExp("(iPhone|iPod|Android)").test(navigator.userAgent); if (iPhone) var scroll_timeout; -if(!Array.indexOf){ +if (!Array.indexOf){ Array.prototype.indexOf = function(obj){ var i, len; - for(i=0, len=this.length; i that ) return 1; + if (this < that) return -1; + if (this > that) return 1; return 0; } @@ -183,7 +175,7 @@ String.prototype.compareTo = function( that ) { * @brief Switch between different dialog tabs */ function changeTab(tab, id) { - for ( var x = 0, node; tab.parentNode.childNodes[x]; x++ ) { + for (var x = 0, node; tab.parentNode.childNodes[x]; x++) { node = tab.parentNode.childNodes[x]; if (node == tab) { node.className = "prefs_tab_enabled"; @@ -191,7 +183,7 @@ function changeTab(tab, id) { node.className = "prefs_tab_disabled"; } } - for ( x = 0; tab.parentNode.parentNode.childNodes[x]; x++ ) { + for (x = 0; tab.parentNode.parentNode.childNodes[x]; x++) { node = tab.parentNode.parentNode.childNodes[x]; if (node.tagName == "DIV") { if (node.id == id) { @@ -213,8 +205,6 @@ Prefs.prototype = { }; Prefs._RefreshRate = 'refresh_rate'; Prefs._SessionRefreshRate = 'session_refresh_rate'; -Prefs._ShowFilter = 'show_filter'; - Prefs._ShowInspector = 'show_inspector'; Prefs._FilterMode = 'filter'; @@ -257,10 +247,10 @@ Prefs._Defaults = /* * Set a preference option */ -Prefs.setValue = function( key, val ) +Prefs.setValue = function(key, val) { - if( Prefs._Defaults[key] == undefined ) - console.warn( "unrecognized preference key '%s'", key ); + if (Prefs._Defaults[key] == undefined) + console.warn("unrecognized preference key '%s'", key); var days = 30; var date = new Date(); @@ -274,25 +264,25 @@ Prefs.setValue = function( key, val ) * @param key the preference's key * @param fallback if the option isn't set, return this instead */ -Prefs.getValue = function( key, fallback ) +Prefs.getValue = function(key, fallback) { var val; - if( Prefs._Defaults[key] == undefined ) - console.warn( "unrecognized preference key '%s'", key ); + if (Prefs._Defaults[key] == undefined) + console.warn("unrecognized preference key '%s'", key); - var lines = document.cookie.split( ';' ); - for( var i=0, len=lines.length; !val && i + * MIT License + */ +function parseUri (str) { + var o = parseUri.options, + m = o.parser[o.strictMode ? "strict" : "loose"].exec(str), + uri = {}, + i = 14; + + while (i--) uri[o.key[i]] = m[i] || ""; + + uri[o.q.name] = {}; + uri[o.key[12]].replace(o.q.parser, function ($0, $1, $2) { + if ($1) uri[o.q.name][$1] = $2; + }); + + return uri; +}; + +parseUri.options = { + strictMode: false, + key: ["source","protocol","authority","userInfo","user","password","host","port","relative","path","directory","file","query","anchor"], + q: { + name: "queryKey", + parser: /(?:^|&)([^&=]*)=?([^&]*)/g + }, + parser: { + strict: /^(?:([^:\/?#]+):)?(?:\/\/((?:(([^:@]*)(?::([^:@]*))?)?@)?([^:\/?#]*)(?::(\d*))?))?((((?:[^?#\/]*\/)*)([^?#]*))(?:\?([^#]*))?(?:#(.*))?)/, + loose: /^(?:(?![^:@]+:[^:@\/]*@)([^:\/?#.]+):)?(?:\/\/)?((?:(([^:@]*)(?::([^:@]*))?)?@)?([^:\/?#]*)(?::(\d*))?)(((\/(?:[^?#](?![^?#\/]*\.[^?#\/.]+(?:[?#]|$)))*\/?)?([^?#\/]*))(?:\?([^#]*))?(?:#(.*))?)/ + } +}; diff --git a/web/javascript/dialog.js b/web/javascript/dialog.js index 0ba65a2ed..50e9cfe48 100644 --- a/web/javascript/dialog.js +++ b/web/javascript/dialog.js @@ -29,8 +29,8 @@ Dialog.prototype = { this._callback_data = null; // Observe the buttons - this._cancel_button.bind('click', {dialog: this}, this.onCancelClicked ); - this._confirm_button.bind('click', {dialog: this}, this.onConfirmClicked ); + this._cancel_button.bind('click', {dialog: this}, this.onCancelClicked); + this._confirm_button.bind('click', {dialog: this}, this.onConfirmClicked); }, @@ -43,7 +43,7 @@ Dialog.prototype = { * *--------------------------------------------*/ - hideDialog: function( ) + hideDialog: function() { $('body.dialog_showing').removeClass('dialog_showing'); if (Safari3) { @@ -56,16 +56,16 @@ Dialog.prototype = { transmission.updateButtonStates(); }, - onCancelClicked: function( event ) + onCancelClicked: function(event) { - event.data.dialog.hideDialog( ); + event.data.dialog.hideDialog(); }, - onConfirmClicked: function( event ) + onConfirmClicked: function(event) { var dialog = event.data.dialog; - eval( dialog._callback_function + "(dialog._callback_data)" ); - dialog.hideDialog( ); + eval(dialog._callback_function + "(dialog._callback_data)"); + dialog.hideDialog(); }, /*-------------------------------------------- @@ -86,10 +86,10 @@ Dialog.prototype = { } else if (!iPhone) { $('.dialog_container').hide(); } - setInnerHTML( this._heading[0], dialog_heading ); - setInnerHTML( this._message[0], dialog_message ); - setInnerHTML( this._cancel_button[0], (cancel_button_label == null) ? 'Cancel' : cancel_button_label ); - setInnerHTML( this._confirm_button[0], confirm_button_label ); + setInnerHTML(this._heading[0], dialog_heading); + setInnerHTML(this._message[0], dialog_message); + setInnerHTML(this._cancel_button[0], (cancel_button_label == null) ? 'Cancel' : cancel_button_label); + setInnerHTML(this._confirm_button[0], confirm_button_label); this._confirm_button.show(); this._callback_function = callback_function; this._callback_data = callback_data; @@ -115,11 +115,11 @@ Dialog.prototype = { } else if (!iPhone) { $('.dialog_container').hide(); } - setInnerHTML( this._heading[0], dialog_heading ); - setInnerHTML( this._message[0], dialog_message ); + setInnerHTML(this._heading[0], dialog_heading); + setInnerHTML(this._message[0], dialog_message); // jquery::hide() doesn't work here in Safari for some odd reason this._confirm_button.css('display', 'none'); - setInnerHTML( this._cancel_button[0], cancel_button_label ); + setInnerHTML(this._cancel_button[0], cancel_button_label); // Just in case if (!iPhone && Safari3) { $('div#upload_container div.dialog_window').css('top', '-205px'); diff --git a/web/javascript/file-row.js b/web/javascript/file-row.js index ee7328603..58f053384 100644 --- a/web/javascript/file-row.js +++ b/web/javascript/file-row.js @@ -4,48 +4,48 @@ * */ -function FileRow( controller, torrent, i ) +function FileRow(torrent, i) { - this.initialize( controller, torrent, i ); + this.initialize(torrent, i); } FileRow.prototype = { - initialize: function( controller, torrent, i ) + initialize: function(torrent, i) { this._torrent = torrent; this._index = i; - this.createRow( torrent, i ); + this.createRow(torrent, i); }, - getTorrent: function( ) + getTorrent: function() { return this._torrent; }, - getIndex: function( ) + getIndex: function() { return this._index; }, readAttributes: function(file) { - if( file.index !== undefined && file.index !== this._index ) { + if (file.index !== undefined && file.index !== this._index) { this._index = file.index; this._dirty = true; } - if( file.bytesCompleted !== undefined && file.bytesCompleted !== this._done ) { + if (file.bytesCompleted !== undefined && file.bytesCompleted !== this._done) { this._done = file.bytesCompleted; this._dirty = true; } - if( file.length !== undefined && file.length !== this._size ) { + if (file.length !== undefined && file.length !== this._size) { this._size = file.length; this._dirty = true; } - if( file.priority !== undefined && file.priority !== this._prio ) { + if (file.priority !== undefined && file.priority !== this._prio) { this._prio = file.priority; this._dirty = true; } - if( file.wanted !== undefined && file.wanted !== this._wanted ) { + if (file.wanted !== undefined && file.wanted !== this._wanted) { this._wanted = file.wanted; this._dirty = true; } @@ -54,22 +54,22 @@ FileRow.prototype = refreshWantedHTML: function() { var e = this.getElement(); var c = [ e.classNameConst ]; - if(!this._wanted) { c.push( 'skip' ); } - if(this.isDone()) { c.push( 'complete' ); } + if (!this._wanted) { c.push('skip'); } + if (this.isDone()) { c.push('complete'); } e.className = c.join(' '); }, refreshPriorityHTML: function() { var e = this._priority_control; var c = [ e.classNameConst ]; - switch( this._prio ) { - case 1 : c.push( 'high' ); break; - case -1 : c.push( 'low' ); break; - default : c.push( 'normal' ); break; + switch(this._prio) { + case -1 : c.push('low'); break; + case 1 : c.push('high'); break; + default : c.push('normal'); break; } e.className = c.join(' '); }, refreshProgressHTML: function() { - var pct = 100 * (this._size ? ( this._done / this._size ) : 1.0); + var pct = 100 * (this._size ? (this._done / this._size) : 1.0); var c = [ Transmission.fmt.size(this._done), ' of ', Transmission.fmt.size(this._size), @@ -79,18 +79,18 @@ FileRow.prototype = setInnerHTML(this._progress[0], c); }, refreshHTML: function() { - if( this._dirty ) { + if (this._dirty) { this._dirty = false; this.refreshProgressHTML(); this.refreshWantedHTML(); this.refreshPriorityHTML(); } }, - refresh: function( ) + refresh: function() { - var i = this.getIndex( ); - var t = this.getTorrent( ); - this.readAttributes( t._files[i] ); + var i = this.getIndex(); + var t = this.getTorrent(); + this.readAttributes(t._files[i]); this.refreshHTML(); }, @@ -101,7 +101,7 @@ FileRow.prototype = return (this.getTorrent()._files.length>1) && !this.isDone(); }, - createRow: function( torrent, i ) + createRow: function(torrent, i) { var me = this; var file = torrent._files[i]; @@ -114,7 +114,7 @@ FileRow.prototype = var wanted_div = document.createElement('div'); wanted_div.className = "file_wanted_control"; - $(wanted_div).bind('click',function(e){ me.fireWantedChanged( !me._wanted ); }); + $(wanted_div).bind('click',function(){ me.fireWantedChanged(!me._wanted); }); var pri_div = document.createElement('div'); pri_div.classNameConst = "file_priority_control"; @@ -122,21 +122,21 @@ FileRow.prototype = $(pri_div).bind('click',function(ev){ var x = ev.pageX; var e = ev.target; - while (e !== null) { + while (e) { x -= e.offsetLeft; e = e.offsetParent; } var prio; - if(iPhone) { - if( x < 8 ) prio = -1; - else if( x < 27 ) prio = 0; + if (iPhone) { + if (x < 8) prio = -1; + else if (x < 27) prio = 0; else prio = 1; } else { - if( x < 12 ) prio = -1; - else if( x < 23 ) prio = 0; + if (x < 12) prio = -1; + else if (x < 23) prio = 0; else prio = 1; } - me.firePriorityChanged( prio ); + me.firePriorityChanged(prio); }); var file_div = document.createElement('div'); @@ -159,16 +159,16 @@ FileRow.prototype = return root; }, - getElement: function( ) + getElement: function() { return this._element; }, - fireWantedChanged: function( do_want ) + fireWantedChanged: function(do_want) { $(this).trigger('wantedToggled',[ this, do_want ]); }, - firePriorityChanged: function( priority ) + firePriorityChanged: function(priority) { $(this).trigger('priorityToggled',[ this, priority ]); } diff --git a/web/javascript/formatter.js b/web/javascript/formatter.js index fb984173f..4a28e992d 100644 --- a/web/javascript/formatter.js +++ b/web/javascript/formatter.js @@ -30,8 +30,9 @@ Transmission.fmt = (function() return { - updateUnits: function( u ) + updateUnits: function(u) { +/* speed_K = u['speed-bytes']; speed_K_str = u['speed-units'][0]; speed_M_str = u['speed-units'][1]; @@ -49,30 +50,31 @@ Transmission.fmt = (function() mem_M_str = u['memory-units'][1]; mem_G_str = u['memory-units'][2]; mem_T_str = u['memory-units'][3]; +*/ }, /* * Format a percentage to a string */ - percentString: function( x ) { - if( x < 10.0 ) - return x.toTruncFixed( 2 ); - else if( x < 100.0 ) - return x.toTruncFixed( 1 ); + percentString: function(x) { + if (x < 10.0) + return x.toTruncFixed(2); + else if (x < 100.0) + return x.toTruncFixed(1); else - return x.toTruncFixed( 0 ); + return x.toTruncFixed(0); }, /* * Format a ratio to a string */ - ratioString: function( x ) { - if( x == -1 ) + ratioString: function(x) { + if (x == -1) return "None"; - else if( x == -2 ) + else if (x == -2) return '∞'; else - return this.percentString( x ); + return this.percentString(x); }, /** @@ -80,32 +82,32 @@ Transmission.fmt = (function() * @param {Number} bytes the filesize in bytes * @return {String} human-readable string */ - mem: function( bytes ) + mem: function(bytes) { - if( bytes < mem_K ) + if (bytes < mem_K) return [ bytes, mem_B_str ].join(' '); var convertedSize; var unit; - if( bytes < Math.pow( mem_K, 2 ) ) + if (bytes < Math.pow(mem_K, 2)) { convertedSize = bytes / mem_K; unit = mem_K_str; } - else if( bytes < Math.pow( mem_K, 3 ) ) + else if (bytes < Math.pow(mem_K, 3)) { - convertedSize = bytes / Math.pow( mem_K, 2 ); + convertedSize = bytes / Math.pow(mem_K, 2); unit = mem_M_str; } - else if( bytes < Math.pow( mem_K, 4 ) ) + else if (bytes < Math.pow(mem_K, 4)) { - convertedSize = bytes / Math.pow( mem_K, 3 ); + convertedSize = bytes / Math.pow(mem_K, 3); unit = mem_G_str; } else { - convertedSize = bytes / Math.pow( mem_K, 4 ); + convertedSize = bytes / Math.pow(mem_K, 4); unit = mem_T_str; } @@ -119,32 +121,32 @@ Transmission.fmt = (function() * @param {Number} bytes the filesize in bytes * @return {String} human-readable string */ - size: function( bytes ) + size: function(bytes) { - if( bytes < size_K ) + if (bytes < size_K) return [ bytes, size_B_str ].join(' '); var convertedSize; var unit; - if( bytes < Math.pow( size_K, 2 ) ) + if (bytes < Math.pow(size_K, 2)) { convertedSize = bytes / size_K; unit = size_K_str; } - else if( bytes < Math.pow( size_K, 3 ) ) + else if (bytes < Math.pow(size_K, 3)) { - convertedSize = bytes / Math.pow( size_K, 2 ); + convertedSize = bytes / Math.pow(size_K, 2); unit = size_M_str; } - else if( bytes < Math.pow( size_K, 4 ) ) + else if (bytes < Math.pow(size_K, 4)) { - convertedSize = bytes / Math.pow( size_K, 3 ); + convertedSize = bytes / Math.pow(size_K, 3); unit = size_G_str; } else { - convertedSize = bytes / Math.pow( size_K, 4 ); + convertedSize = bytes / Math.pow(size_K, 4); unit = size_T_str; } @@ -153,22 +155,22 @@ Transmission.fmt = (function() : [ convertedSize.toTruncFixed(1), unit ].join(' '); }, - speedBps: function( Bps ) + speedBps: function(Bps) { - return this.speed( this.toKBps( Bps ) ); + return this.speed(this.toKBps(Bps)); }, - toKBps: function( Bps ) + toKBps: function(Bps) { - return Math.floor( Bps / speed_K ); + return Math.floor(Bps / speed_K); }, - speed: function( KBps ) + speed: function(KBps) { var speed = KBps; - if (speed <= 999.95) // 0 KBps to 999.9 K - return [ speed.toTruncFixed(1), speed_K_str ].join(' '); + if (speed <= 999.95) // 0 KBps to 999 K + return [ speed.toTruncFixed(0), speed_K_str ].join(' '); speed /= speed_K; @@ -182,7 +184,7 @@ Transmission.fmt = (function() return [ speed.toTruncFixed(2), speed_G_str ].join(' '); }, - timeInterval: function( seconds ) + timeInterval: function(seconds) { var result; var days = Math.floor(seconds / 86400); @@ -208,9 +210,9 @@ Transmission.fmt = (function() return result.join(' '); }, - timestamp: function( seconds ) + timestamp: function(seconds) { - if( !seconds ) + if (!seconds) return 'N/A'; var myDate = new Date(seconds*1000); @@ -223,11 +225,11 @@ Transmission.fmt = (function() var sameMonth = now.getMonth() == myDate.getMonth(); var dateDiff = now.getDate() - myDate.getDate(); - if(sameYear && sameMonth && Math.abs(dateDiff) <= 1){ - if(dateDiff == 0){ + if (sameYear && sameMonth && Math.abs(dateDiff) <= 1){ + if (dateDiff == 0){ date = "Today"; } - else if(dateDiff == 1){ + else if (dateDiff == 1){ date = "Yesterday"; } else{ @@ -240,22 +242,22 @@ Transmission.fmt = (function() var hours = myDate.getHours(); var period = "AM"; - if(hours > 12){ + if (hours > 12){ hours = hours - 12; period = "PM"; } - if(hours == 0){ + if (hours == 0){ hours = 12; } - if(hours < 10){ + if (hours < 10){ hours = "0" + hours; } var minutes = myDate.getMinutes(); - if(minutes < 10){ + if (minutes < 10){ minutes = "0" + minutes; } var seconds = myDate.getSeconds(); - if(seconds < 10){ + if (seconds < 10){ seconds = "0" + seconds; } @@ -264,7 +266,7 @@ Transmission.fmt = (function() return [date, time, period].join(' '); }, - plural: function( i, word ) + plural: function(i, word) { return [ i, ' ', word, (word==1?'':'s') ].join(''); } diff --git a/web/javascript/torrent-row.js b/web/javascript/torrent-row.js index fb23b10d6..330b7ac99 100644 --- a/web/javascript/torrent-row.js +++ b/web/javascript/torrent-row.js @@ -13,26 +13,26 @@ function TorrentRendererHelper() { } -TorrentRendererHelper.getProgressInfo = function( controller, t ) +TorrentRendererHelper.getProgressInfo = function(controller, t) { - var seed_ratio_limit = t.seedRatioLimit( controller ); + var seed_ratio_limit = t.seedRatioLimit(controller); var pct = 0; - if( t.needsMetaData( ) ) + if (t.needsMetaData()) pct = t.getMetadataPercentComplete() * 100; - else if( !t.isDone( ) ) - pct = Math.round( t.getPercentDone() * 100 ); - else if( seed_ratio_limit > 0 ) - pct = Math.round( t.getUploadRatio() * 100 / seed_ratio_limit ); + else if (!t.isDone()) + pct = Math.round(t.getPercentDone() * 100); + else if (seed_ratio_limit > 0) + pct = Math.round(t.getUploadRatio() * 100 / seed_ratio_limit); else pct = 100; var extra; - if( t.isStopped( ) ) + if (t.isStopped()) extra = 'paused'; - else if( t.isSeeding( ) ) + else if (t.isSeeding()) extra = 'seeding'; - else if( t.needsMetaData( ) ) + else if (t.needsMetaData()) extra = 'magnet'; else extra = 'leeching'; @@ -42,24 +42,24 @@ TorrentRendererHelper.getProgressInfo = function( controller, t ) complete: [ 'torrent_progress_bar', 'complete', extra ].join(' '), incomplete: [ 'torrent_progress_bar', 'incomplete', extra ].join(' ') }; -} +}; -TorrentRendererHelper.createProgressbar = function( classes ) +TorrentRendererHelper.createProgressbar = function(classes) { - var complete = document.createElement( 'div' ); + var complete = document.createElement('div'); complete.className = 'torrent_progress_bar complete'; - var incomplete = document.createElement( 'div' ); + var incomplete = document.createElement('div'); incomplete.className = 'torrent_progress_bar incomplete'; - var progressbar = document.createElement( 'div' ); + var progressbar = document.createElement('div'); progressbar.className = 'torrent_progress_bar_container ' + classes; - progressbar.appendChild( complete ); - progressbar.appendChild( incomplete ); - return { 'element': progressbar, 'complete': complete, 'incomplete': incomplete } -} + progressbar.appendChild(complete); + progressbar.appendChild(incomplete); + return { 'element': progressbar, 'complete': complete, 'incomplete': incomplete }; +}; -TorrentRendererHelper.renderProgressbar = function( controller, t, progressbar ) +TorrentRendererHelper.renderProgressbar = function(controller, t, progressbar) { - var info = TorrentRendererHelper.getProgressInfo( controller, t ); + var info = TorrentRendererHelper.getProgressInfo(controller, t); var e; e = progressbar.complete; e.style.width = '' + info.percent + "%"; @@ -68,17 +68,17 @@ TorrentRendererHelper.renderProgressbar = function( controller, t, progressbar ) e = progressbar.incomplete; e.className = info.incomplete; e.style.display = info.percent>=100 ? 'none' : 'block'; -} +}; -TorrentRendererHelper.formatUL = function( t ) +TorrentRendererHelper.formatUL = function(t) { - return 'UL: ' + Transmission.fmt.speedBps( t.getUploadSpeed( ) ); -} + return '↑ ' + Transmission.fmt.speedBps(t.getUploadSpeed()); +}; -TorrentRendererHelper.formatDL = function( t ) +TorrentRendererHelper.formatDL = function(t) { - return 'DL: ' + Transmission.fmt.speedBps( t.getDownloadSpeed( ) ); -} + return '↓ ' + Transmission.fmt.speedBps(t.getDownloadSpeed()); +}; /**** ***** @@ -90,31 +90,31 @@ function TorrentRendererFull() } TorrentRendererFull.prototype = { - createRow: function( ) + createRow: function() { - var root = document.createElement( 'li' ); + var root = document.createElement('li'); root.className = 'torrent'; - var name = document.createElement( 'div' ); + var name = document.createElement('div'); name.className = 'torrent_name'; - var peers = document.createElement( 'div' ); + var peers = document.createElement('div'); peers.className = 'torrent_peer_details'; - var progressbar = TorrentRendererHelper.createProgressbar( 'full' ); + var progressbar = TorrentRendererHelper.createProgressbar('full'); - var details = document.createElement( 'div' ); + var details = document.createElement('div'); details.className = 'torrent_progress_details'; - var image = document.createElement( 'div' ); - var button = document.createElement( 'a' ); - button.appendChild( image ); + var image = document.createElement('div'); + var button = document.createElement('a'); + button.appendChild(image); - root.appendChild( name ); - root.appendChild( peers ); - root.appendChild( button ); - root.appendChild( progressbar.element ); - root.appendChild( details ); + root.appendChild(name); + root.appendChild(peers); + root.appendChild(button); + root.appendChild(progressbar.element); + root.appendChild(details); root._name_container = name; root._peer_details_container = peers; @@ -126,13 +126,13 @@ TorrentRendererFull.prototype = return root; }, - getPeerDetails: function( t ) + getPeerDetails: function(t) { var err; - if(( err = t.getErrorMessage())) + if ((err = t.getErrorMessage())) return err; - if( t.isDownloading( ) ) + if (t.isDownloading()) return [ 'Downloading from', t.getPeersSendingToUs(), 'of', @@ -142,7 +142,7 @@ TorrentRendererFull.prototype = TorrentRendererHelper.formatDL(t), TorrentRendererHelper.formatUL(t) ].join(' '); - if( t.isSeeding( ) ) + if (t.isSeeding()) return [ 'Seeding to', t.getPeersGettingFromUs(), 'of', @@ -151,85 +151,85 @@ TorrentRendererFull.prototype = '-', TorrentRendererHelper.formatUL(t) ].join(' '); - if( t.isChecking( ) ) + if (t.isChecking()) return [ 'Verifying local data (', - Transmission.fmt.percentString( 100.0 * t.getRecheckProgress() ), + Transmission.fmt.percentString(100.0 * t.getRecheckProgress()), '% tested)' ].join(''); - return t.getStateString( ); + return t.getStateString(); }, - getProgressDetails: function( controller, t ) + getProgressDetails: function(controller, t) { - if( t.needsMetaData() ) { + if (t.needsMetaData()) { var percent = 100 * t.getMetadataPercentComplete(); return [ "Magnetized transfer - retrieving metadata (", - Transmission.fmt.percentString( percent ), + Transmission.fmt.percentString(percent), "%)" ].join(''); } var c; - var sizeWhenDone = t.getSizeWhenDone() - var totalSize = t.getTotalSize() - var is_done = ( t.isDone( ) ) || ( t.isSeeding() ) + var sizeWhenDone = t.getSizeWhenDone(); + var totalSize = t.getTotalSize(); + var is_done = t.isDone() || t.isSeeding(); - if( is_done ) { - if( totalSize == sizeWhenDone ) // seed: '698.05 MiB' - c = [ Transmission.fmt.size( totalSize ) ]; + if (is_done) { + if (totalSize == sizeWhenDone) // seed: '698.05 MiB' + c = [ Transmission.fmt.size(totalSize) ]; else // partial seed: '127.21 MiB of 698.05 MiB (18.2%)' - c = [ Transmission.fmt.size( sizeWhenDone ), + c = [ Transmission.fmt.size(sizeWhenDone), ' of ', - Transmission.fmt.size( t.getTotalSize() ), + Transmission.fmt.size(t.getTotalSize()), ' (', t.getPercentDoneStr(), '%)' ]; // append UL stats: ', uploaded 8.59 GiB (Ratio: 12.3)' - c.push( ', uploaded ', - Transmission.fmt.size( t.getUploadedEver() ), + c.push(', uploaded ', + Transmission.fmt.size(t.getUploadedEver()), ' (Ratio ', - Transmission.fmt.ratioString( t.getUploadRatio() ), - ')' ); + Transmission.fmt.ratioString(t.getUploadRatio()), + ')'); } else { // not done yet - c = [ Transmission.fmt.size( sizeWhenDone - t.getLeftUntilDone() ), - ' of ', Transmission.fmt.size( sizeWhenDone ), + c = [ Transmission.fmt.size(sizeWhenDone - t.getLeftUntilDone()), + ' of ', Transmission.fmt.size(sizeWhenDone), ' (', t.getPercentDoneStr(), '%)' ]; } // maybe append eta - if( !t.isStopped() && ( !is_done || t.seedRatioLimit(controller)>0 ) ) { + if (!t.isStopped() && (!is_done || t.seedRatioLimit(controller)>0)) { c.push(' - '); - var eta = t.getETA() - if (eta < 0 || eta >= (999*60*60) /* arbitrary */ ) - c.push( 'remaining time unknown' ); + var eta = t.getETA(); + if (eta < 0 || eta >= (999*60*60) /* arbitrary */) + c.push('remaining time unknown'); else - c.push( Transmission.fmt.timeInterval(t.getETA()), - ' remaining' ); + c.push(Transmission.fmt.timeInterval(t.getETA()), + ' remaining'); } return c.join(''); }, - render: function( controller, t, root ) + render: function(controller, t, root) { // name - setInnerHTML( root._name_container, t.getName() ); + setInnerHTML(root._name_container, t.getName()); // progressbar - TorrentRendererHelper.renderProgressbar( controller, t, root._progressbar ); + TorrentRendererHelper.renderProgressbar(controller, t, root._progressbar); // peer details var has_error = t.getError() !== Torrent._ErrNone; var e = root._peer_details_container; $(e).toggleClass('error',has_error); - setInnerHTML( e, this.getPeerDetails( t ) ); + setInnerHTML(e, this.getPeerDetails(t)); // progress details e = root._progress_details_container; - setInnerHTML( e, this.getProgressDetails( controller, t ) ); + setInnerHTML(e, this.getProgressDetails(controller, t)); // pause/resume button - var is_stopped = t.isStopped() - e = root._pause_resume_button_image - e.alt = is_stopped ? 'Resume' : 'Pause' - e.className = is_stopped ? 'torrent_resume' : 'torrent_pause' + var is_stopped = t.isStopped(); + e = root._pause_resume_button_image; + e.alt = is_stopped ? 'Resume' : 'Pause'; + e.className = is_stopped ? 'torrent_resume' : 'torrent_pause'; } }; @@ -243,20 +243,20 @@ function TorrentRendererCompact() } TorrentRendererCompact.prototype = { - createRow: function( ) + createRow: function() { - var progressbar = TorrentRendererHelper.createProgressbar( 'compact' ); + var progressbar = TorrentRendererHelper.createProgressbar('compact'); - var details = document.createElement( 'div' ); + var details = document.createElement('div'); details.className = 'torrent_peer_details compact'; - var name = document.createElement( 'div' ); + var name = document.createElement('div'); name.className = 'torrent_name compact'; - var root = document.createElement( 'li' ); - root.appendChild( progressbar.element ); - root.appendChild( details ); - root.appendChild( name ); + var root = document.createElement('li'); + root.appendChild(progressbar.element); + root.appendChild(details); + root.appendChild(name); root.className = 'torrent compact'; root._progressbar = progressbar; root._details_container = details; @@ -264,35 +264,35 @@ TorrentRendererCompact.prototype = return root; }, - getPeerDetails: function( t ) + getPeerDetails: function(t) { var c; - if(( c = t.getErrorMessage())) + if ((c = t.getErrorMessage())) return c; - if( t.isDownloading( ) ) + if (t.isDownloading()) return [ TorrentRendererHelper.formatDL(t), TorrentRendererHelper.formatUL(t) ].join(' '); - if( t.isSeeding( ) ) + if (t.isSeeding()) return TorrentRendererHelper.formatUL(t); - return t.getStateString( ); + return t.getStateString(); }, - render: function( controller, t, root ) + render: function(controller, t, root) { // name - var is_stopped = t.isStopped() + var is_stopped = t.isStopped(); var e = root._name_container; - $(e).toggleClass( 'paused', is_stopped ); - setInnerHTML( e, t.getName() ); + $(e).toggleClass('paused', is_stopped); + setInnerHTML(e, t.getName()); // peer details var has_error = t.getError() !== Torrent._ErrNone; e = root._details_container; - $(e).toggleClass('error', has_error ); - setInnerHTML( e, this.getPeerDetails( t ) ); + $(e).toggleClass('error', has_error); + setInnerHTML(e, this.getPeerDetails(t)); // progressbar - TorrentRendererHelper.renderProgressbar( controller, t, root._progressbar ); + TorrentRendererHelper.renderProgressbar(controller, t, root._progressbar); } }; @@ -301,54 +301,48 @@ TorrentRendererCompact.prototype = ***** ****/ -function TorrentRow( view ) +function TorrentRow(view, controller, torrent, selected) { - this.initialize( view ); + this.initialize(view, controller, torrent, selected); } TorrentRow.prototype = { - initialize: function( view ) { + initialize: function(view, controller, torrent, selected) { this._view = view; - this._element = view.createRow( ); + this._element = view.createRow(); + this.setTorrent(controller, torrent); + if (selected) + this.setSelected(selected); + this.render(controller); }, - getElement: function( ) { + getElement: function() { return this._element; }, - render: function( controller ) { - var tor = this.getTorrent( ); - if( tor !== null ) - this._view.render( controller, tor, this.getElement( ) ); + render: function(controller) { + var tor = this.getTorrent(); + if (tor) + this._view.render(controller, tor, this.getElement()); }, - isSelected: function( ) { - return this.getElement().className.indexOf('selected') != -1; + isSelected: function() { + return this.getElement().className.indexOf('selected') !== -1; }, - setSelected: function( flag ) { - $(this.getElement()).toggleClass( 'selected', flag ); + setSelected: function(flag) { + $(this.getElement()).toggleClass('selected', flag); }, - getToggleRunningButton: function( ) { + getToggleRunningButton: function() { return this.getElement()._toggle_running_button; }, - setVisible: function( visible ) { - this.getElement().style.display = visible ? 'block' : 'none'; - - if( !visible ) - this.setSelected( false ); - }, - isVisible: function( visible ) { - return this.getElement().style.display === 'block'; - }, - - setTorrent: function( controller, t ) { - if( this._torrent !== t ) { - var row = this + setTorrent: function(controller, t) { + if (this._torrent !== t) { + var row = this; var key = 'dataChanged.torrentRowListener'; - if(this._torrent) + if (this._torrent) $(this._torrent).unbind(key); - if((this._torrent = t)) - $(this._torrent).bind(key,function(){row.render(controller)}) + if ((this._torrent = t)) + $(this._torrent).bind(key,function(){row.render(controller);}); } }, getTorrent: function() { @@ -357,8 +351,8 @@ TorrentRow.prototype = isEven: function() { return this.getElement().className.indexOf('even') != -1; }, - setEven: function( even ) { - if( this.isEven() != even ) + setEven: function(even) { + if (this.isEven() != even) $(this.getElement()).toggleClass('even', even); } }; diff --git a/web/javascript/torrent.js b/web/javascript/torrent.js index b570cd41f..23a774e7e 100644 --- a/web/javascript/torrent.js +++ b/web/javascript/torrent.js @@ -7,9 +7,9 @@ */ -function Torrent(controller, data) +function Torrent(data) { - this.initialize(controller, data) + this.initialize(data); } /*** @@ -19,41 +19,41 @@ function Torrent(controller, data) ***/ // Torrent.fields.status -Torrent._StatusStopped = 0 -Torrent._StatusCheckWait = 1 -Torrent._StatusCheck = 2 -Torrent._StatusDownloadWait = 3 -Torrent._StatusDownload = 4 -Torrent._StatusSeedWait = 5 -Torrent._StatusSeed = 6 +Torrent._StatusStopped = 0; +Torrent._StatusCheckWait = 1; +Torrent._StatusCheck = 2; +Torrent._StatusDownloadWait = 3; +Torrent._StatusDownload = 4; +Torrent._StatusSeedWait = 5; +Torrent._StatusSeed = 6; // Torrent.fields.seedRatioMode -Torrent._RatioUseGlobal = 0 -Torrent._RatioUseLocal = 1 -Torrent._RatioUnlimited = 2 +Torrent._RatioUseGlobal = 0; +Torrent._RatioUseLocal = 1; +Torrent._RatioUnlimited = 2; // Torrent.fields.error -Torrent._ErrNone = 0 -Torrent._ErrTrackerWarning = 1 -Torrent._ErrTrackerError = 2 -Torrent._ErrLocalError = 3 +Torrent._ErrNone = 0; +Torrent._ErrTrackerWarning = 1; +Torrent._ErrTrackerError = 2; +Torrent._ErrLocalError = 3; // TrackerStats' announceState -Torrent._TrackerInactive = 0 -Torrent._TrackerWaiting = 1 -Torrent._TrackerQueued = 2 -Torrent._TrackerActive = 3 +Torrent._TrackerInactive = 0; +Torrent._TrackerWaiting = 1; +Torrent._TrackerQueued = 2; +Torrent._TrackerActive = 3; // fields whose values never change and are always known Torrent._StaticFields = [ - 'hashString', 'id' ] + 'hashString', 'id' ]; // fields whose values never change and are known upon constructon OR // when a magnet torrent finishes downloading its metadata Torrent._MetaDataFields = [ 'addedDate', 'comment', 'creator', 'dateCreated', - 'isPrivate', 'name', 'totalSize', 'pieceCount', 'pieceSize' ] + 'isPrivate', 'name', 'totalSize', 'pieceCount', 'pieceSize' ]; // torrent fields whose values change all the time Torrent._DynamicFields = [ @@ -63,7 +63,7 @@ Torrent._DynamicFields = [ 'peersGettingFromUs', 'peersSendingToUs', 'queuePosition', 'rateDownload', 'rateUpload', 'recheckProgress', 'seedRatioLimit', 'seedRatioMode', 'sizeWhenDone', 'status', 'trackerStats', - 'uploadedEver', 'uploadRatio', 'webseedsSendingToUs' ] + 'uploadedEver', 'uploadRatio', 'webseedsSendingToUs' ]; /*** **** @@ -73,99 +73,133 @@ Torrent._DynamicFields = [ Torrent.prototype = { - initialize: function(controller, data) + initialize: function(data) { - this.fields = {} - this._files = [] + this.fields = {}; + this._files = []; // these fields are set in the ctor and never change - for(var i=0, key; key=Torrent._StaticFields[i]; ++i) - if(key in data) - this.fields[key] = data[key] + for (var i=0, key; key=Torrent._StaticFields[i]; ++i) { + if (key in data) { + this.fields[key] = data[key]; + } + } - this.initMetaData(data) - this._trackerStats = this.buildTrackerStats(data.trackerStats) - this.refresh(data) + this.initMetaData(data); + this._trackerStats = this.buildTrackerStats(data.trackerStats); + this.refresh(data); }, buildTrackerStats: function(trackerStats) { - result = [] - for(var i=0, tracker; tracker=trackerStats[i]; ++i) { - tier = result[tracker.tier] || [] - tier.push(tracker) - result[tracker.tier] = tier + var announce = []; + var result = []; + for (var i=0, tracker; tracker=trackerStats[i]; ++i) { + var tier = result[tracker.tier] || []; + tier.push(tracker); + result[tracker.tier] = tier; + announce.push(tracker.announce); } - return result + this.fields.collatedTrackers = announce.join('\t'); + return result; }, initMetaData: function(data) { - var f = this.fields + var f = this.fields; + var changed = false; // populate the metadata fields - for(var i=0, key; key=Torrent._MetaDataFields[i]; ++i) { - if(key in data) { - f[key] = data[key] - if(key === 'name') - f.collatedName = data.name.toLowerCase() + for (var i=0, key; key=Torrent._MetaDataFields[i]; ++i) { + if (key in data) { + if (f[key] !== data[key]) { + f[key] = data[key]; + if (key === 'name') + f.collatedName = data.name.toLowerCase(); + changed = true; + } } } // populate the files array - if(data.files) { - for(var i=0, row; row=data.files[i]; ++i) { + if (data.files) { + for (var i=0, row; row=data.files[i]; ++i) { this._files[i] = { 'index': i, 'torrent': this, 'length': row.length, 'name': row.name - } + }; } } + + return changed; }, refreshMetaData: function(data) { - this.initMetaData(data) - this.fireDataChanged() + var changed = this.initMetaData(data); + if (changed) + this.fireDataChanged(); + return changed; }, refresh: function(data) { + var changed = false; + // FIXME: unnecessary coupling... this should be handled by transmission.js - if(this.needsMetaData() && (data.metadataPercentComplete >= 1)) - transmission.refreshMetaData([ this.getId() ]) + if (this.needsMetaData() && (data.metadataPercentComplete >= 1)) + changed |= transmission.refreshMetaData([ this.getId() ]); - var f = this.fields + var f = this.fields; // refresh the dynamic fields - for(var i=0, key; key=Torrent._DynamicFields[i]; ++i) - if(key in data) - f[key] = data[key] + for (var i=0, key; key=Torrent._DynamicFields[i]; ++i) { + if (key in data) { + if (f[key] !== data[key]) { + f[key] = data[key]; + changed = true; + } + } + } - this._trackerStats = this.buildTrackerStats(data.trackerStats) + this._trackerStats = this.buildTrackerStats(data.trackerStats); if (data.fileStats) - this.refreshFiles(data) + changed |= this.refreshFiles(data); - this.fireDataChanged() + if (changed) + this.fireDataChanged(); }, refreshFiles: function(data) { - for(var i=0; i 0 + return this.getPeersGettingFromUs() > 0 || this.getPeersSendingToUs() > 0 || this.getWebseedsSendingToUs() > 0 - || this.isChecking() - break + || this.isChecking(); case Prefs._FilterSeeding: - pass = (s === Torrent._StatusSeed) || (s === Torrent._StatusSeedWait) - break + return (s === Torrent._StatusSeed) + || (s === Torrent._StatusSeedWait); case Prefs._FilterDownloading: - pass = (s === Torrent._StatusDownload) || (s === Torrent._StatusDownloadWait) - break + return (s === Torrent._StatusDownload) + || (s === Torrent._StatusDownloadWait); case Prefs._FilterPaused: - pass = this.isStopped() - break + return this.isStopped(); case Prefs._FilterFinished: - pass = this.isFinished() - break + return this.isFinished(); default: - pass = true - break + return true; } + }, - if(!pass) - return false + /** + * @param filter one of Prefs._Filter* + * @param search substring to look for, or null + * @return true if it passes the test, false if it fails + */ + test: function(state, search, tracker) + { + // flter by state... + var pass = this.testState(state); - if(!search || !search.length) - return pass + // maybe filter by text... + if (pass && search && search.length) + pass = this.getCollatedName().indexOf(search.toLowerCase()) !== -1; - return this.getCollatedName().indexOf(search.toLowerCase()) !== -1 + // maybe filter by tracker... + if (pass && tracker && tracker.length) + pass = this.getCollatedTrackers().indexOf(tracker) !== -1; + + return pass; } -} +}; /*** @@ -321,47 +359,47 @@ Torrent.prototype = Torrent.compareById = function(ta, tb) { - return ta.getId() - tb.getId() -} + return ta.getId() - tb.getId(); +}; Torrent.compareByName = function(ta, tb) { return ta.getCollatedName().compareTo(tb.getCollatedName()) - || Torrent.compareById(ta, tb) -} + || Torrent.compareById(ta, tb); +}; Torrent.compareByQueue = function(ta, tb) { - return ta.getQueuePosition() - tb.getQueuePosition() -} + return ta.getQueuePosition() - tb.getQueuePosition(); +}; Torrent.compareByAge = function(ta, tb) { - var a = ta.getDateAdded() - var b = tb.getDateAdded() - return (b - a) || Torrent.compareByQueue(ta, tb) -} + var a = ta.getDateAdded(); + var b = tb.getDateAdded(); + return (b - a) || Torrent.compareByQueue(ta, tb); +}; Torrent.compareByState = function(ta, tb) { - var a = ta.getStatus() - var b = tb.getStatus() - return (b - a) || Torrent.compareByQueue(ta, tb) -} + var a = ta.getStatus(); + var b = tb.getStatus(); + return (b - a) || Torrent.compareByQueue(ta, tb); +}; Torrent.compareByActivity = function(ta, tb) { - var a = ta.getActivity() - var b = tb.getActivity() - return (a - b) || Torrent.compareByState(ta, tb) -} -Torrent.compareByRatio = function(a, b) + var a = ta.getActivity(); + var b = tb.getActivity(); + return (b - a) || Torrent.compareByState(ta, tb); +}; +Torrent.compareByRatio = function(ta, tb) { - var a = Math.ratio(ta.getUploadedEver(), ta.getDownloadedEver()) - var b = Math.ratio(tb.getUploadedEver(), tb.getDownloadedEver()) - return (a - b) || Torrent.compareByState(ta, tb) -} + var a = Math.ratio(ta.getUploadedEver(), ta.getDownloadedEver()); + var b = Math.ratio(tb.getUploadedEver(), tb.getDownloadedEver()); + return (a - b) || Torrent.compareByState(ta, tb); +}; Torrent.compareByProgress = function(ta, tb) { - var a = ta.getPercentDone() - var b = tb.getPercentDone() - return (a - b) || Torrent.compareByRatio(ta, tb) -} + var a = ta.getPercentDone(); + var b = tb.getPercentDone(); + return (a - b) || Torrent.compareByRatio(ta, tb); +}; /** * @param torrents an array of Torrent objects @@ -373,33 +411,30 @@ Torrent.sortTorrents = function(torrents, sortMethod, sortDirection) switch(sortMethod) { case Prefs._SortByActivity: - torrents.sort(this.compareByActivity) - break + torrents.sort(this.compareByActivity); + break; case Prefs._SortByAge: - torrents.sort(this.compareByAge) - break + torrents.sort(this.compareByAge); + break; case Prefs._SortByQueue: - torrents.sort(this.compareByQueue) - break + torrents.sort(this.compareByQueue); + break; case Prefs._SortByProgress: - torrents.sort(this.compareByProgress) - break + torrents.sort(this.compareByProgress); + break; case Prefs._SortByState: - torrents.sort(this.compareByState) - break - case Prefs._SortByName: - torrents.sort(this.compareByName) - break + torrents.sort(this.compareByState); + break; case Prefs._SortByRatio: - torrents.sort(this.compareByRatio) - break + torrents.sort(this.compareByRatio); + break; default: - console.warn("unknown sort method: " + sortMethod) - break + torrents.sort(this.compareByName); + break; } - if(sortDirection === Prefs._SortDescending) - torrents.reverse() + if (sortDirection === Prefs._SortDescending) + torrents.reverse(); - return torrents -} + return torrents; +}; diff --git a/web/javascript/transmission.js b/web/javascript/transmission.js index 77415c86e..edf2df9ce 100644 --- a/web/javascript/transmission.js +++ b/web/javascript/transmission.js @@ -6,17 +6,18 @@ * Class Transmission */ -function Transmission(){ +function Transmission() +{ this.initialize(); } Transmission.prototype = { - /*-------------------------------------------- - * - * C O N S T R U C T O R - * - *--------------------------------------------*/ + /**** + ***** + ***** STARTUP + ***** + ****/ initialize: function() { @@ -29,56 +30,50 @@ Transmission.prototype = this._rows = [ ]; // Initialize the clutch preferences - Prefs.getClutchPrefs( this ); + Prefs.getClutchPrefs(this); this.preloadImages(); // Set up user events var tr = this; $(".numberinput").forceNumeric(); - $('#pause_all_link').bind('click', function(e){ tr.stopAllClicked(e); }); - $('#resume_all_link').bind('click', function(e){ tr.startAllClicked(e); }); - $('#pause_selected_link').bind('click', function(e){ tr.stopSelectedClicked(e); } ); - $('#resume_selected_link').bind('click', function(e){ tr.startSelectedClicked(e); }); - $('#remove_link').bind('click', function(e){ tr.removeClicked(e); }); - $('#filter_all_link').parent().bind('click', function(e){ tr.showAllClicked(e); }); - $('#filter_active_link').parent().bind('click', function(e){ tr.showActiveClicked(e); }); - $('#filter_downloading_link').parent().bind('click', function(e){ tr.showDownloadingClicked(e); }); - $('#filter_seeding_link').parent().bind('click', function(e){ tr.showSeedingClicked(e); }); - $('#filter_paused_link').parent().bind('click', function(e){ tr.showPausedClicked(e); }); - $('#filter_finished_link').parent().bind('click', function(e){ tr.showFinishedClicked(e); }); - $('#prefs_save_button').bind('click', function(e) { tr.savePrefsClicked(e); return false;}); - $('#prefs_cancel_button').bind('click', function(e){ tr.cancelPrefsClicked(e); return false; }); - $('#block_update_button').bind('click', function(e){ tr.blocklistUpdateClicked(e); return false; }); - $('#stats_close_button').bind('click', function(e){ tr.closeStatsClicked(e); return false; }); - $('.inspector_tab').bind('click', function(e){ tr.inspectorTabClicked(e, this); }); - $('#files_select_all').live('click', function(e){ tr.filesSelectAllClicked(e, this); }); - $('#files_deselect_all').live('click', function(e){ tr.filesDeselectAllClicked(e, this); }); - $('#open_link').bind('click', function(e){ tr.openTorrentClicked(e); }); - $('#upload_confirm_button').bind('click', function(e){ tr.confirmUploadClicked(e); return false;}); - $('#upload_cancel_button').bind('click', function(e){ tr.cancelUploadClicked(e); return false; }); - $('#turtle_button').bind('click', function(e){ tr.toggleTurtleClicked(e); return false; }); - $('#prefs_tab_general_tab').click(function(e){ changeTab(this, 'prefs_tab_general') }); - $('#prefs_tab_speed_tab').click(function(e){ changeTab(this, 'prefs_tab_speed') }); - $('#prefs_tab_peers_tab').click(function(e){ changeTab(this, 'prefs_tab_peers') }); - $('#prefs_tab_network_tab').click(function(e){ changeTab(this, 'prefs_tab_network');}); - $('#torrent_upload_form').submit(function(){ $('#upload_confirm_button').click(); return false; }); - $('#torrent_container').bind('dragover', function(e){ return tr.dragenter(e); }); - $('#torrent_container').bind('dragenter', function(e){ return tr.dragenter(e); }); - $('#torrent_container').bind('drop', function(e){ return tr.drop(e); }); + $('#pause_all_link').click(function(e) { tr.stopAllClicked(e); }); + $('#resume_all_link').click(function(e) { tr.startAllClicked(e); }); + $('#pause_selected_link').click(function(e) { tr.stopSelectedClicked(e); }); + $('#resume_selected_link').click(function(e) { tr.startSelectedClicked(e); }); + $('#remove_link').click(function(e) { tr.removeClicked(e); }); + $('#prefs_save_button').click(function(e) { tr.savePrefsClicked(e); return false;}); + $('#prefs_cancel_button').click(function(e) { tr.cancelPrefsClicked(e); return false; }); + $('#block_update_button').click(function(e) { tr.blocklistUpdateClicked(e); return false; }); + $('#stats_close_button').click(function(e) { tr.closeStatsClicked(e); return false; }); + $('.inspector_tab').click(function(e) { tr.inspectorTabClicked(e, this); }); + $('#files_select_all').live('click', function(e) { tr.filesSelectAllClicked(e, this); }); + $('#files_deselect_all').live('click', function(e) { tr.filesDeselectAllClicked(e, this); }); + $('#open_link').click(function(e) { tr.openTorrentClicked(e); }); + $('#upload_confirm_button').click(function(e) { tr.confirmUploadClicked(e); return false;}); + $('#upload_cancel_button').click(function(e) { tr.cancelUploadClicked(e); return false; }); + $('#turtle_button').click(function() { tr.toggleTurtleClicked(); return false; }); + $('#compact-button').click(function() { tr.toggleCompactClicked(); return false; }); + $('#prefs_tab_general_tab').click(function() { changeTab(this, 'prefs_tab_general'); }); + $('#prefs_tab_speed_tab').click(function() { changeTab(this, 'prefs_tab_speed'); }); + $('#prefs_tab_peers_tab').click(function() { changeTab(this, 'prefs_tab_peers'); }); + $('#prefs_tab_network_tab').click(function() { changeTab(this, 'prefs_tab_network');}); + $('#torrent_upload_form').submit(function() { $('#upload_confirm_button').click(); return false; }); + $('#torrent_container').bind('dragover', function(e) { return tr.dragenter(e); }); + $('#torrent_container').bind('dragenter', function(e) { return tr.dragenter(e); }); + $('#torrent_container').bind('drop', function(e) { return tr.drop(e); }); // tell jQuery to copy the dataTransfer property from events over if it exists jQuery.event.props.push("dataTransfer"); - $('#torrent_upload_form').submit(function(){ $('#upload_confirm_button').click(); return false; }); + $('#torrent_upload_form').submit(function() { $('#upload_confirm_button').click(); return false; }); if (iPhone) { - $('#inspector_close').bind('click', function(e){ tr.hideInspector(); }); - $('#preferences_link').bind('click', function(e){ tr.releaseClutchPreferencesButton(e); }); + $('#inspector_close').bind('click', function() { tr.hideInspector(); }); + $('#preferences_link').bind('click', function(e) { tr.releaseClutchPreferencesButton(e); }); } else { - $(document).bind('keydown', function(e){ tr.keyDown(e); }); - $('#torrent_container').bind('click', function(e){ tr.deselectAll( true ); }); - $('#filter_toggle_link').bind('click', function(e){ tr.toggleFilterClicked(e); }); - $('#inspector_link').bind('click', function(e){ tr.toggleInspectorClicked(e); }); + $(document).bind('keydown', function(e) { tr.keyDown(e); }); + $('#torrent_container').click(function() { tr.deselectAll(true); }); + $('#inspector_link').click(function(e) { tr.toggleInspectorClicked(e); }); this.setupSearchBox(); this.createContextMenu(); @@ -91,12 +86,12 @@ Transmission.prototype = this._inspector_peers_list = $('#inspector_peers_list')[0]; this._inspector_trackers_list = $('#inspector_trackers_list')[0]; this._inspector_tab_files = $('#inspector_tab_files')[0]; - this._toolbar_buttons = $('#torrent_global_menu ul li'); - this._toolbar_pause_button = $('li#pause_selected')[0]; - this._toolbar_pause_all_button = $('li#pause_all')[0]; - this._toolbar_start_button = $('li#resume_selected')[0]; - this._toolbar_start_all_button = $('li#resume_all')[0]; - this._toolbar_remove_button = $('li#remove')[0]; + this._toolbar_buttons = $('#toolbar ul li'); + this._toolbar_pause_button = $('#toolbar #pause_selected')[0]; + this._toolbar_pause_all_button = $('#toolbar #pause_all')[0]; + this._toolbar_start_button = $('#toolbar #resume_selected')[0]; + this._toolbar_start_all_button = $('#toolbar #resume_all')[0]; + this._toolbar_remove_button = $('#toolbar #remove')[0]; this._context_pause_button = $('li#context_pause_selected')[0]; this._context_start_button = $('li#context_resume_selected')[0]; this._context_start_now_button = $('li#context_resume_now_selected')[0]; @@ -131,42 +126,43 @@ Transmission.prototype = this._inspector._info_tab.upload_to = $(ti+'upload_to')[0]; // Setup the prefs gui - this.initializeSettings( ); + this.initializeSettings(); // Get preferences & torrents from the daemon - var tr = this; var async = false; - this.loadDaemonPrefs( async ); - this.loadDaemonStats( async ); + this.loadDaemonPrefs(async); + this.loadDaemonStats(async); this.initializeAllTorrents(); - this.togglePeriodicRefresh( true ); - this.togglePeriodicSessionRefresh( true ); + this.togglePeriodicRefresh(true); + this.togglePeriodicSessionRefresh(true); + + this.filterSetup(); }, - loadDaemonPrefs: function( async ){ + loadDaemonPrefs: function(async) { var tr = this; - this.remote.loadDaemonPrefs( function(data){ + this.remote.loadDaemonPrefs(function(data) { var o = data.arguments; - Prefs.getClutchPrefs( o ); - tr.updatePrefs( o ); - }, async ); + Prefs.getClutchPrefs(o); + tr.updatePrefs(o); + }, async); }, - loadDaemonStats: function( async ){ + loadDaemonStats: function(async) { var tr = this; - this.remote.loadDaemonStats( function(data){ + this.remote.loadDaemonStats(function(data) { var o = data.arguments; - tr.updateStats( o ); - }, async ); + tr.updateStats(o); + }, async); }, - checkPort: function( async ){ - $('#port_test').text('checking ...') + checkPort: function(async) { + $('#port_test').text('checking ...'); var tr = this; - this.remote.checkPort( function(data){ + this.remote.checkPort(function(data) { var o = data.arguments; - tr.updatePortStatus( o ); - }, async ); + tr.updatePortStatus(o); + }, async); }, preloadImages: function() { @@ -199,48 +195,31 @@ Transmission.prototype = } }, loadImages: function() { - for( var i=0, row; row=arguments[i]; ++i ) + for (var i=0, row; row=arguments[i]; ++i) jQuery("").attr("src", row); }, - setCompactMode: function( is_compact ) - { - this.torrentRenderer = is_compact ? new TorrentRendererCompact( ) - : new TorrentRendererFull( ); - $('ul.torrent_list li').remove(); - this._rows = []; - this.refilter(); - }, - /* * Load the clutch prefs and init the GUI according to those prefs */ - initializeSettings: function( ) + initializeSettings: function() { - Prefs.getClutchPrefs( this ); + Prefs.getClutchPrefs(this); // iPhone conditions in the section allow us to not // include transmenu js to save some bandwidth; if we // start using prefs on iPhone we need to weed // transmenu refs out of that too. - $('#filter_' + this[Prefs._FilterMode] + '_link').parent().addClass('selected'); + if (!iPhone) $('#sort_by_' + this[Prefs._SortMethod]).selectMenuItem(); - if (!iPhone) $('#sort_by_' + this[Prefs._SortMethod] ).selectMenuItem(); - - if (!iPhone && ( this[Prefs._SortDirection] == Prefs._SortDescending ) ) + if (!iPhone && (this[Prefs._SortDirection] == Prefs._SortDescending)) $('#reverse_sort_order').selectMenuItem(); - if( this[Prefs._ShowFilter] ) - this.showFilter( ); - - if( !iPhone && this[Prefs._ShowInspector] ) - this.showInspector( ); + if (!iPhone && this[Prefs._ShowInspector]) + this.showInspector(); - if( !iPhone && this[Prefs._CompactDisplayState] ) - $('#compact_view').selectMenuItem(); - - this.setCompactMode( this[Prefs._CompactDisplayState] ); + this.initCompactMode(); }, /* @@ -250,20 +229,18 @@ Transmission.prototype = { var tr = this; var search_box = $('#torrent_search'); - search_box.bind('keyup click', function(event) { - tr.setSearch(this.value); - }); + search_box.bind('keyup click', function() {tr.setSearch(this.value);}); if (!$.browser.safari) { search_box.addClass('blur'); search_box[0].value = 'Filter'; - search_box.bind('blur', function(event) { + search_box.bind('blur', function() { if (this.value == '') { $(this).addClass('blur'); this.value = 'Filter'; tr.setSearch(null); } - }).bind('focus', function(event) { + }).bind('focus', function() { if ($(this).is('.blur')) { this.value = ''; $(this).removeClass('blur'); @@ -272,72 +249,26 @@ Transmission.prototype = } }, - contextStopSelected: function( ) { - this.stopSelectedTorrents( ); - }, - contextStartSelected: function( ) { - this.startSelectedTorrents( false ); - }, - contextStartNowSelected: function( ) { - this.startSelectedTorrents( true ); - }, - contextRemoveSelected: function( ) { - this.removeSelectedTorrents( ); - }, - contextRemoveDataSelected: function( ) { - this.removeSelectedTorrentsAndData( ); - }, - contextVerifySelected: function( ) { - this.verifySelectedTorrents( ); - }, - contextReannounceSelected: function( ) { - this.reannounceSelectedTorrents( ); - }, - contextToggleInspector: function( ) { - this.toggleInspector( ); - }, - contextSelectAll: function( ) { - this.selectAll( true ); - }, - contextDeselectAll: function( ) { - this.deselectAll( true ); - }, - - // Queue - - contextMoveUp: function( ) { - this.moveUp( ); - }, - contextMoveDown: function( ) { - this.moveDown( ); - }, - contextMoveTop: function( ) { - this.moveTop( ); - }, - contextMoveBottom: function( ) { - this.moveBottom( ); - }, - /* * Create the torrent right-click menu */ createContextMenu: function() { var tr = this; var bindings = { - context_pause_selected: function(e){ tr.contextStopSelected(e); }, - context_resume_selected: function(e){ tr.contextStartSelected(e); }, - context_resume_now_selected: function(e){ tr.contextStartNowSelected(e); }, - context_remove: function(e){ tr.contextRemoveSelected(e); }, - context_removedata: function(e){ tr.contextRemoveDataSelected(e); }, - context_verify: function(e){ tr.contextVerifySelected(e); }, - context_reannounce: function(e){ tr.contextReannounceSelected(e); }, - context_toggle_inspector: function(e){ tr.contextToggleInspector(e); }, - context_select_all: function(e){ tr.contextSelectAll(e); }, - context_deselect_all: function(e){ tr.contextDeselectAll(e); }, - context_move_top: function(e){ tr.contextMoveTop(e); }, - context_move_up: function(e){ tr.contextMoveUp(e); }, - context_move_down: function(e){ tr.contextMoveDown(e); }, - context_move_bottom: function(e){ tr.contextMoveBottom(e); } + context_pause_selected: function() { tr.stopSelectedTorrents(); }, + context_resume_selected: function() { tr.startSelectedTorrents(false); }, + context_resume_now_selected: function() { tr.startSelectedTorrents(true); }, + context_remove: function() { tr.removeSelectedTorrents(); }, + context_removedata: function() { tr.removeSelectedTorrentsAndData(); }, + context_verify: function() { tr.verifySelectedTorrents(); }, + context_reannounce: function() { tr.reannounceSelectedTorrents(); }, + context_toggle_inspector: function() { tr.toggleInspector(); }, + context_select_all: function() { tr.selectAll(); }, + context_deselect_all: function() { tr.deselectAll(); }, + context_move_top: function() { tr.moveTop(); }, + context_move_up: function() { tr.moveUp(); }, + context_move_down: function() { tr.moveDown(); }, + context_move_bottom: function() { tr.moveBottom(); } }; // Setup the context menu @@ -353,9 +284,9 @@ Transmission.prototype = boundingBottomPad: 5, onContextMenu: function(e) { var closest_row = $(e.target).closest('.torrent')[0]; - for( var i=0, row; row = tr._rows[i]; ++i ) { - if( row.getElement() === closest_row ) { - tr.setSelectedRow( row ); + for (var i=0, row; row = tr._rows[i]; ++i) { + if (row.getElement() === closest_row) { + tr.setSelectedRow(row); break; } } @@ -372,7 +303,7 @@ Transmission.prototype = $('#settings_menu').transMenu({ selected_char: '✔', direction: 'up', - onClick: function(e){ return tr.processSettingsMenuEvent(e); } + onClick: function(e) { return tr.processSettingsMenuEvent(e); } }); $('#unlimited_download_rate').selectMenuItem(); @@ -381,13 +312,12 @@ Transmission.prototype = initTurtleDropDowns: function() { - var i, out, hour, mins, start, end, value, content; + var i, hour, mins, start, end, value, content; // Build the list of times - out = ""; start = $('#turtle_start_time')[0]; end = $('#turtle_end_time')[0]; for (i = 0; i < 24 * 4; i++) { - hour = parseInt(i / 4); + hour = parseInt(i / 4, 10); mins = ((i % 4) * 15); value = (i * 15); @@ -397,156 +327,143 @@ Transmission.prototype = } }, - /*-------------------------------------------- - * - * U T I L I T I E S - * - *--------------------------------------------*/ + /**** + ***** + ***** UTILITIES + ***** + ****/ getAllTorrents: function() { var torrents = []; - for(var key in this._torrents) + for (var key in this._torrents) torrents.push(this._torrents[key]); return torrents; }, getVisibleTorrents: function() { - var torrents = [ ]; - for( var i=0, row; row=this._rows[i]; ++i ) - if( row.isVisible( ) ) - torrents.push( row.getTorrent( ) ); + var torrents = []; + for (var i=0, row; row=this._rows[i]; ++i) + torrents.push(row.getTorrent()); return torrents; }, - getSelectedRows: function() + scrollToRow: function(row) { - var s = [ ]; - - for( var i=0, row; row=this._rows[i]; ++i ) - if( row.isSelected( ) ) - s.push( row ); - - return s; - }, + if (iPhone) // FIXME: why? + return; - getSelectedTorrents: function() - { - var s = this.getSelectedRows( ); + var list = $('#torrent_container'); + var scrollTop = list.scrollTop(); + var innerHeight = list.innerHeight(); - for( var i=0, row; row=s[i]; ++i ) - s[i] = s[i].getTorrent(); + var e = $(row.getElement()); + var offsetTop = e[0].offsetTop; + var offsetHeight = e.outerHeight(); - return s; - }, - - getVisibleRows: function() - { - var rows = [ ]; - for( var i=0, row; row=this._rows[i]; ++i ) - if( row.isVisible( ) ) - rows.push( row ); - return rows; + if (offsetTop < scrollTop) + list.scrollTop(offsetTop); + else if (innerHeight + scrollTop < offsetTop + offsetHeight) + list.scrollTop(offsetTop + offsetHeight - innerHeight); }, - getRowIndex: function( rows, row ) - { - for( var i=0, r; r=rows[i]; ++i ) - if( r === row ) - return i; - return null; + seedRatioLimit: function() { + if (this._prefs && this._prefs['seedRatioLimited']) + return this._prefs['seedRatioLimit']; + else + return -1; }, - setPref: function( key, val ) + setPref: function(key, val) { this[key] = val; - Prefs.setValue( key, val ); + Prefs.setValue(key, val); }, - scrollToRow: function(row) - { - if( iPhone ) // FIXME: why? - return - - var list = $('#torrent_container') - var scrollTop = list.scrollTop() - var innerHeight = list.innerHeight() + /**** + ***** + ***** SELECTION + ***** + ****/ - var e = $(row.getElement()) - var offsetTop = e[0].offsetTop - var offsetHeight = e.outerHeight() - - if( offsetTop < scrollTop ) - list.scrollTop( offsetTop ); - else if( innerHeight + scrollTop < offsetTop + offsetHeight ) - list.scrollTop( offsetTop + offsetHeight - innerHeight ); + getSelectedRows: function() { + var s = []; + for (var i=0, row; row=this._rows[i]; ++i) + if (row.isSelected()) + s.push(row); + return s; }, - seedRatioLimit: function(){ - if(this._prefs && this._prefs['seedRatioLimited']) - return this._prefs['seedRatioLimit']; - else - return -1; + getSelectedTorrents: function() { + var s = this.getSelectedRows(); + for (var i=0, row; row=s[i]; ++i) + s[i] = s[i].getTorrent(); + return s; }, - /*-------------------------------------------- - * - * S E L E C T I O N - * - *--------------------------------------------*/ + getSelectedTorrentIds: function() { + var s = []; + for (var i=0, row; row=this._rows[i]; ++i) + if (row.isSelected()) + s.push(row.getTorrent().getId()); + return s; + }, - setSelectedRow: function( row ) { - var rows = this.getSelectedRows( ); - for( var i=0, r; r=rows[i]; ++i ) - this.deselectRow( r ); - this.selectRow( row ); + setSelectedRow: function(row) { + var rows = this.getSelectedRows(); + for (var i=0, r; r=rows[i]; ++i) + this.deselectRow(r); + this.selectRow(row); }, - selectRow: function( row ) { - row.setSelected( true ); + selectRow: function(row) { + row.setSelected(true); this.callSelectionChangedSoon(); }, - deselectRow: function( row ) { - row.setSelected( false ); + deselectRow: function(row) { + row.setSelected(false); this.callSelectionChangedSoon(); }, - selectAll: function( ) { - var tr = this; - for( var i=0, row; row=tr._rows[i]; ++i ) - tr.selectRow( row ); + selectAll: function() { + for (var i=0, row; row=this._rows[i]; ++i) + this.selectRow(row); this.callSelectionChangedSoon(); }, - deselectAll: function( ) { - for( var i=0, row; row=this._rows[i]; ++i ) - this.deselectRow( row ); + deselectAll: function() { + for (var i=0, row; row=this._rows[i]; ++i) + this.deselectRow(row); this.callSelectionChangedSoon(); - this._last_row_clicked = null; + delete this._last_torrent_clicked; }, - /* - * Select a range from this torrent to the last clicked torrent - */ - selectRange: function( row ) + /* Select a range from this torrent to the last clicked torrent */ + selectRange: function(row) { - if( this._last_row_clicked === null ) - { - this.selectRow( row ); - } - else // select the range between the prevous & current - { - var rows = this.getVisibleRows( ); - var i = this.getRowIndex( rows, this._last_row_clicked ); - var end = this.getRowIndex( rows, row ); - var step = i < end ? 1 : -1; - for( ; i!=end; i+=step ) - this.selectRow( this._rows[i] ); - this.selectRow( this._rows[i] ); + if (!this._last_torrent_clicked) { + this.selectRow(row); + } else { // select the range between the prevous & current + + var prev = null; + var next = null; + for (var i=0, r; r=this._rows[i]; ++i) { + if (r.getTorrent().getId() === this._last_torrent_clicked) + prev = i; + if (r === row) + next = i; + } + if ((prev!==null) && (next!==null)) { + var min = Math.min(prev, next); + var max = Math.max(prev, next); + for (i=min; i<=max; ++i) + this.selectRow(this._rows[i]); + } } - this.callSelectionChangedSoon( ); + //this._last_row_clicked = row + this.callSelectionChangedSoon(); }, selectionChanged: function() @@ -554,13 +471,18 @@ Transmission.prototype = this.updateButtonStates(); this.updateInspector(); this.updateSelectedData(); - this.selectionChangedTimer = null; + + clearTimeout(this.selectionChangedTimer); + delete this.selectionChangedTimer; }, callSelectionChangedSoon: function() { - if( this.selectionChangedTimer === null ) - this.selectionChangedTimer = setTimeout(function(o) { o.selectionChanged(); }, 200, this); + if (!this.selectionChangedTimer) + { + var tr = this; + this.selectionChangedTimer = setTimeout(function() {tr.selectionChanged();},200); + } }, /*-------------------------------------------- @@ -574,27 +496,27 @@ Transmission.prototype = */ keyDown: function(ev) { - var up = ev.keyCode === 38 // up key pressed - var dn = ev.keyCode === 40 // down key pressed + var up = ev.keyCode === 38; // up key pressed + var dn = ev.keyCode === 40; // down key pressed - if(up || dn) + if (up || dn) { - var rows = this.getVisibleRows() + var rows = this._rows; // find the first selected row - for(var i=0, row; row=rows[i]; ++i) - if(row.isSelected()) - break - - if(i == rows.length) // no selection yet - i = 0 - else if(dn) - i = (i+1) % rows.length - else if(up) - i = (i || rows.length) - 1 - - this.setSelectedRow(rows[i]) - this.scrollToRow(rows[i]) + for (var i=0, row; row=rows[i]; ++i) + if (row.isSelected()) + break; + + if (i == rows.length) // no selection yet + i = 0; + else if (dn) + i = (i+1) % rows.length; + else if (up) + i = (i || rows.length) - 1; + + this.setSelectedRow(rows[i]); + this.scrollToRow(rows[i]); } }, @@ -603,52 +525,47 @@ Transmission.prototype = return p.className!='disabled' && p.parentNode.className!='disabled'; }, - stopAllClicked: function( event ) { - var tr = this; - if( tr.isButtonEnabled( event ) ) { - tr.stopAllTorrents( ); - tr.hideiPhoneAddressbar( ); + stopAllClicked: function(event) { + if (this.isButtonEnabled(event)) { + this.stopAllTorrents(); + this.hideiPhoneAddressbar(); } }, - stopSelectedClicked: function( event ) { - var tr = this; - if( tr.isButtonEnabled( event ) ) { - tr.stopSelectedTorrents( ); - tr.hideiPhoneAddressbar( ); + stopSelectedClicked: function(event) { + if (this.isButtonEnabled(event)) { + this.stopSelectedTorrents(); + this.hideiPhoneAddressbar(); } }, - startAllClicked: function( event ) { - var tr = this; - if( tr.isButtonEnabled( event ) ) { - tr.startAllTorrents( ); - tr.hideiPhoneAddressbar( ); + startAllClicked: function(event) { + if (this.isButtonEnabled(event)) { + this.startAllTorrents(); + this.hideiPhoneAddressbar(); } }, - startSelectedClicked: function( event ) { - var tr = this; - if( tr.isButtonEnabled( event ) ) { - tr.startSelectedTorrents( false ); - tr.hideiPhoneAddressbar( ); + startSelectedClicked: function(event) { + if (this.isButtonEnabled(event)) { + this.startSelectedTorrents(false); + this.hideiPhoneAddressbar(); } }, - openTorrentClicked: function( event ) { - var tr = this; - if( tr.isButtonEnabled( event ) ) { + openTorrentClicked: function(event) { + if (this.isButtonEnabled(event)) { $('body').addClass('open_showing'); - tr.uploadTorrentFile( ); + this.uploadTorrentFile(); + this.updateButtonStates(); } - tr.updateButtonStates(); }, - dragenter: function( event ) { - if( event.dataTransfer && event.dataTransfer.types ) { + dragenter: function(event) { + if (event.dataTransfer && event.dataTransfer.types) { var types = ["text/uri-list", "text/plain"]; - for( var i = 0; i < types.length; ++i ) { - if( event.dataTransfer.types.contains(types[i]) ) { + for (var i = 0; i < types.length; ++i) { + if (event.dataTransfer.types.contains(types[i])) { // it would be better to actually look at the links here; // sadly, (at least with Firefox,) trying would throw. event.stopPropagation(); @@ -664,35 +581,35 @@ Transmission.prototype = return true; }, - drop: function( event ) { - if( !event.dataTransfer || !event.dataTransfer.types ) { + drop: function(ev) { + if (!ev.dataTransfer || !ev.dataTransfer.types) { return true; } - event.preventDefault(); + ev.preventDefault(); var uris = null; var types = ["text/uri-list", "text/plain"]; - for( var i = 0; i < types.length; ++i ) { - if( event.dataTransfer.types.contains(types[i]) ) { - uris = event.dataTransfer.getData( types[i] ).split("\n"); + for (var i = 0; i < types.length; ++i) { + if (ev.dataTransfer.types.contains(types[i])) { + uris = ev.dataTransfer.getData(types[i]).split("\n"); break; } } var paused = $('#prefs_form #auto_start')[0].checked; - for( i = 0; i < uris.length; ++i ) { + for (i = 0; i < uris.length; ++i) { var uri = uris[i]; - if( /^#/.test(uri) ) { + if (/^#/.test(uri)) { // lines which start with "#" are comments continue; } - if( /^[a-z-]+:/i.test(uri) ) { + if (/^[a-z-]+:/i.test(uri)) { // close enough to a url - this.remote.addTorrentByUrl( uri, paused ); + this.remote.addTorrentByUrl(uri, paused); } } return false; }, - hideUploadDialog: function( ) { + hideUploadDialog: function() { $('body.open_showing').removeClass('open_showing'); if (!iPhone && Safari3) { $('div#upload_container div.dialog_window').css('top', '-205px'); @@ -703,44 +620,43 @@ Transmission.prototype = this.updateButtonStates(); }, - cancelUploadClicked: function(event) { - this.hideUploadDialog( ); + cancelUploadClicked: function() { + this.hideUploadDialog(); }, - confirmUploadClicked: function(event) { - this.uploadTorrentFile( true ); - this.hideUploadDialog( ); + confirmUploadClicked: function() { + this.uploadTorrentFile(true); + this.hideUploadDialog(); }, - cancelPrefsClicked: function(event) { - this.hidePrefsDialog( ); + cancelPrefsClicked: function() { + this.hidePrefsDialog(); }, - savePrefsClicked: function(event) + savePrefsClicked: function() { // handle the clutch prefs locally var tr = this; - var rate = parseInt( $('#prefs_form #refresh_rate')[0].value ); - if( rate != tr[Prefs._RefreshRate] ) { - tr.setPref( Prefs._RefreshRate, rate ); - tr.togglePeriodicRefresh( false ); - tr.togglePeriodicRefresh( true ); + var rate = parseInt ($('#prefs_form #refresh_rate')[0].value, 10); + if (rate != tr[Prefs._RefreshRate]) { + tr.setPref (Prefs._RefreshRate, rate); + tr.togglePeriodicRefresh (true); } - var up_bytes = parseInt( $('#prefs_form #upload_rate' )[0].value ); - var dn_bytes = parseInt( $('#prefs_form #download_rate')[0].value ); - var turtle_up_bytes = parseInt( $('#prefs_form #turtle_upload_rate' )[0].value ); - var turtle_dn_bytes = parseInt( $('#prefs_form #turtle_download_rate')[0].value ); + var up_bytes = parseInt($('#prefs_form #upload_rate' )[0].value, 10); + var dn_bytes = parseInt($('#prefs_form #download_rate' )[0].value, 10); + var turtle_up_bytes = parseInt($('#prefs_form #turtle_upload_rate')[0].value, 10); + var turtle_dn_bytes = parseInt($('#prefs_form #turtle_download_rate')[0].value, 10); // pass the new prefs upstream to the RPC server var o = { }; o[RPC._StartAddedTorrent] = $('#prefs_form #auto_start')[0].checked; - o[RPC._PeerPort] = parseInt( $('#prefs_form #port')[0].value ); + o[RPC._PeerPort] = parseInt($('#prefs_form #port')[0].value, 10); o[RPC._UpSpeedLimit] = up_bytes; o[RPC._DownSpeedLimit] = dn_bytes; o[RPC._DownloadDir] = $('#prefs_form #download_location')[0].value; - o[RPC._UpSpeedLimited] = $('#prefs_form #limit_upload' )[0].checked; + o[RPC._UpSpeedLimited] = $('#prefs_form #limit_upload')[0].checked; o[RPC._DownSpeedLimited] = $('#prefs_form #limit_download')[0].checked; o[RPC._Encryption] = $('#prefs_form #encryption')[0].checked ? RPC._EncryptionRequired @@ -748,256 +664,174 @@ Transmission.prototype = o[RPC._TurtleDownSpeedLimit] = turtle_dn_bytes; o[RPC._TurtleUpSpeedLimit] = turtle_up_bytes; o[RPC._TurtleTimeEnabled] = $('#prefs_form #turtle_schedule')[0].checked; - o[RPC._TurtleTimeBegin] = parseInt( $('#prefs_form #turtle_start_time').val() ); - o[RPC._TurtleTimeEnd] = parseInt( $('#prefs_form #turtle_end_time').val() ); - o[RPC._TurtleTimeDay] = parseInt( $('#prefs_form #turtle_days').val() ); + o[RPC._TurtleTimeBegin] = parseInt($('#prefs_form #turtle_start_time').val(), 10); + o[RPC._TurtleTimeEnd] = parseInt($('#prefs_form #turtle_end_time').val(), 10); + o[RPC._TurtleTimeDay] = parseInt($('#prefs_form #turtle_days').val(), 10); - o[RPC._PeerLimitGlobal] = parseInt( $('#prefs_form #conn_global').val() ); - o[RPC._PeerLimitPerTorrent] = parseInt( $('#prefs_form #conn_torrent').val() ); + o[RPC._PeerLimitGlobal] = parseInt($('#prefs_form #conn_global').val(), 10); + o[RPC._PeerLimitPerTorrent] = parseInt($('#prefs_form #conn_torrent').val(), 10); o[RPC._PexEnabled] = $('#prefs_form #conn_pex')[0].checked; o[RPC._DhtEnabled] = $('#prefs_form #conn_dht')[0].checked; o[RPC._LpdEnabled] = $('#prefs_form #conn_lpd')[0].checked; o[RPC._BlocklistEnabled] = $('#prefs_form #block_enable')[0].checked; o[RPC._BlocklistURL] = $('#prefs_form #block_url').val(); - o[RPC._UtpEnabled] = $('#prefs_form #network_utp')[0].checked; - o[RPC._PeerPortRandom] = $('#prefs_form #port_rand')[0].checked; + o[RPC._UtpEnabled] = $('#prefs_form #network_utp')[0].checked; + o[RPC._PeerPortRandom] = $('#prefs_form #port_rand')[0].checked; o[RPC._PortForwardingEnabled]= $('#prefs_form #port_forward')[0].checked; - - - tr.remote.savePrefs( o ); + tr.remote.savePrefs(o); - tr.hidePrefsDialog( ); + tr.hidePrefsDialog(); }, - blocklistUpdateClicked: function(event){ + blocklistUpdateClicked: function() { var tr = this; tr.remote.updateBlocklist(); }, - closeStatsClicked: function(event) { - this.hideStatsDialog( ); + closeStatsClicked: function() { + this.hideStatsDialog(); }, - removeClicked: function( event ) { + removeClicked: function(ev) { var tr = this; - if( tr.isButtonEnabled( event ) ) { - tr.removeSelectedTorrents( ); - tr.hideiPhoneAddressbar( ); + if (tr.isButtonEnabled(ev)) { + tr.removeSelectedTorrents(); + tr.hideiPhoneAddressbar(); } }, - toggleInspectorClicked: function( event ) { + toggleInspectorClicked: function(ev) { var tr = this; - if( tr.isButtonEnabled( event ) ) - tr.toggleInspector( ); - }, - - inspectorTabClicked: function(event, tab) { - if (iPhone) event.stopPropagation(); - - // Select the clicked tab, unselect the others, - // and display the appropriate info - var tab_ids = $(tab).parent('#inspector_tabs').find('.inspector_tab').map( - function() { return $(this).attr('id'); } - ); - for( var i=0, row; row=tab_ids[i]; ++i ) { - if (tab.id == row) { - $('#'+row).addClass('selected'); - $('#'+row+'_container').show(); - } else { - $('#'+row).removeClass('selected'); - $('#'+row+'_container').hide(); - } - } - this.hideiPhoneAddressbar(); + if (tr.isButtonEnabled(ev)) + tr.toggleInspector(); + }, + + inspectorTabClicked: function(ev, tab) { + if (iPhone) ev.stopPropagation(); + // select this tab and deselect the others + $(tab).addClass('selected').siblings().removeClass('selected'); + + // show this tab and hide the others + $('#'+tab.id+'_container').show().siblings('.inspector_container').hide(); + + this.hideiPhoneAddressbar(); this.updatePeersLists(); this.updateTrackersLists(); this.updateFileList(); }, - filesSelectAllClicked: function(event) { + filesSelectAllClicked: function() { var t = this._files_torrent; - if (t != null) + if (t) this.toggleFilesWantedDisplay(t, true); }, - filesDeselectAllClicked: function(event) { + filesDeselectAllClicked: function() { var t = this._files_torrent; - if (t != null) + if (t) this.toggleFilesWantedDisplay(t, false); }, toggleFilesWantedDisplay: function(torrent, wanted) { var rows = [ ]; - for( var i=0, row; row=this._files[i]; ++i ) - if( row.isEditable() && (torrent._files[i].wanted !== wanted) ) - rows.push( row ); - if( rows.length > 1 ) { + for (var i=0, row; row=this._files[i]; ++i) + if (row.isEditable() && (torrent._files[i].wanted !== wanted)) + rows.push(row); + if (rows.length > 1) { var command = wanted ? 'files-wanted' : 'files-unwanted'; - this.changeFileCommand( command, rows ); + this.changeFileCommand(command, rows); } }, - toggleFilterClicked: function(event) { - if (this.isButtonEnabled(event)) - this.toggleFilter(); - }, - setFilter: function( mode ) - { - // update the radiobuttons - var c; - switch( mode ) { - case Prefs._FilterAll: c = '#filter_all_link'; break; - case Prefs._FilterActive: c = '#filter_active_link'; break; - case Prefs._FilterSeeding: c = '#filter_seeding_link'; break; - case Prefs._FilterDownloading: c = '#filter_downloading_link'; break; - case Prefs._FilterPaused: c = '#filter_paused_link'; break; - case Prefs._FilterFinished: c = '#filter_finished_link'; break; - } - $(c).parent().siblings().removeClass('selected'); - $(c).parent().addClass('selected'); - - // do the filtering - this.setPref( Prefs._FilterMode, mode ); - this.refilter( ); - }, - showAllClicked: function( event ) { - this.setFilter( Prefs._FilterAll ); - }, - showActiveClicked: function( event ) { - this.setFilter( Prefs._FilterActive ); - }, - showDownloadingClicked: function( event ) { - this.setFilter( Prefs._FilterDownloading ); - }, - showSeedingClicked: function(event) { - this.setFilter( Prefs._FilterSeeding ); - }, - showPausedClicked: function(event) { - this.setFilter( Prefs._FilterPaused ); - }, - showFinishedClicked: function(event) { - this.setFilter( Prefs._FilterFinished ); - }, - /* * 'Clutch Preferences' was clicked (iPhone only) */ - releaseClutchPreferencesButton: function(event) { + releaseClutchPreferencesButton: function() { $('div#prefs_container div#pref_error').hide(); $('div#prefs_container h2.dialog_heading').show(); - this.showPrefsDialog( ); + this.showPrefsDialog(); }, - /* - * Turn the periodic ajax torrents refresh on & off - */ - togglePeriodicRefresh: function(state) { - var tr = this; - if (state && this._periodic_refresh == null) { - // sanity check - if( !this[Prefs._RefreshRate] ) - this[Prefs._RefreshRate] = 5; - remote = this.remote; - this._periodic_refresh = setInterval(function(){ tr.refreshTorrents(); }, this[Prefs._RefreshRate] * 1000 ); - } else { - clearInterval(this._periodic_refresh); - this._periodic_refresh = null; + getIntervalMsec: function(key, min) + { + var interval = this[key]; + if (!interval || (interval < min)) + interval = min; + return interval * 1000; + }, + + /* Turn the periodic ajax torrents refresh on & off */ + togglePeriodicRefresh: function (enabled) { + clearInterval (this._periodic_refresh); + delete this._periodic_refresh; + if (enabled) { + var tr = this; + var msec = this.getIntervalMsec(Prefs._RefreshRate, 3); + this._periodic_refresh = setInterval(function() {tr.refreshTorrents();}, msec); } }, - /* - * Turn the periodic ajax torrents refresh on & off for the selected torrents - */ - periodicTorrentUpdate: function( ids ) { - var tr = this; - if( ids ) { - var curIds = this._extra_data_ids; - if( curIds == null ) - curIds = [ ]; - if( ids.length == curIds.length ) { - var duplicate = true; - for(var i = 0; i < ids.length; i++ ) { - if( ids[i] != curIds[i] ) { - duplicate = false; - break; - } - } - if( duplicate ) return; - } - tr.refreshTorrents(ids); - clearInterval(this._metadata_refresh); - // sanity check - if( !this[Prefs._RefreshRate] ) this[Prefs._RefreshRate] = 5; - this._metadata_refresh = setInterval(function(){ tr.refreshTorrents(ids); }, this[Prefs._RefreshRate] * 1000 ); + /* Turn the periodic ajax torrents refresh on & off for the selected torrents */ + periodicTorrentUpdate: function(ids) { + clearInterval (this._metadata_refresh); + delete this._metadata_refresh; + delete this._extra_data_ids; + if (ids && ids.length) { + this.refreshTorrents(ids); this._extra_data_ids = ids; - } else { - clearInterval(this._metadata_refresh); - this._metadata_refresh = null; - this._extra_data_ids = null; + var tr = this; + var msec = this.getIntervalMsec(Prefs._RefreshRate, 3); + this._metadata_refresh = setInterval(function() { tr.refreshTorrents(ids);}, msec); } }, - /* - * Turn the periodic ajax session refresh on & off - */ - togglePeriodicSessionRefresh: function(state) { - var tr = this; - if (state && this._periodic_session_refresh == null) { - // sanity check - if( !this[Prefs._SessionRefreshRate] ) - this[Prefs._SessionRefreshRate] = 5; - remote = this.remote; - this._periodic_session_refresh = setInterval( - function(){ tr.loadDaemonPrefs(); }, this[Prefs._SessionRefreshRate] * 1000 - ); - } else { - clearInterval(this._periodic_session_refresh); - this._periodic_session_refresh = null; + /* Turn the periodic ajax session refresh on & off */ + togglePeriodicSessionRefresh: function(enabled) { + clearInterval(this._periodic_session_refresh); + delete this._periodic_session_refresh; + if (enabled) { + var tr = this; + var msec = this.getIntervalMsec(Prefs._SessionRefreshRate, 5); + this._periodic_session_refresh = setInterval(function() {tr.loadDaemonPrefs();}, msec); } }, - /* - * Turn the periodic ajax stats refresh on & off - */ - togglePeriodicStatsRefresh: function(state) { - var tr = this; - if (state && this._periodic_stats_refresh == null) { - // sanity check - if( !this[Prefs._SessionRefreshRate] ) - this[Prefs._SessionRefreshRate] = 5; - remote = this.remote; - this._periodic_stats_refresh = setInterval( - function(){ tr.loadDaemonStats(); }, this[Prefs._SessionRefreshRate] * 1000 - ); - } else { - clearInterval(this._periodic_stats_refresh); - this._periodic_stats_refresh = null; + /* Turn the periodic ajax stats refresh on & off */ + togglePeriodicStatsRefresh: function(enabled) { + clearInterval(this._periodic_stats_refresh); + delete this._periodic_stats_refresh; + if (enabled) { + var tr = this; + var msec = this.getIntervalMsec(Prefs._SessionRefreshRate, 5); + this._periodic_stats_refresh = setInterval(function() {tr.loadDaemonStats();}, msec); } }, - toggleTurtleClicked: function() { - // Toggle the value - this[Prefs._TurtleState] = !this[Prefs._TurtleState]; - // Store the result + toggleTurtleClicked: function() + { + // toggle it + var p = Prefs._TurtleState; + this[p] = !this[p]; + + // send it to the session var args = { }; - args[RPC._TurtleState] = this[Prefs._TurtleState]; - this.remote.savePrefs( args ); + args[RPC._TurtleState] = this[p]; + this.remote.savePrefs(args); }, updateSelectedData: function() { - var ids = jQuery.map(this.getSelectedTorrents( ), function(t) { return t.getId(); } ); - if( ids.length > 0 ) - this.periodicTorrentUpdate( ids ); + var ids = this.getSelectedTorrentIds(); + if (ids.length > 0) + this.periodicTorrentUpdate(ids); else - this.periodicTorrentUpdate( false ); + this.periodicTorrentUpdate(false); }, updateTurtleButton: function() { var t; var w = $('#turtle_button'); - if ( this[Prefs._TurtleState] ) { + if (this[Prefs._TurtleState]) { w.addClass('turtleEnabled'); w.removeClass('turtleDisabled'); t = [ 'Click to disable Temporary Speed Limits' ]; @@ -1006,9 +840,9 @@ Transmission.prototype = w.addClass('turtleDisabled'); t = [ 'Click to enable Temporary Speed Limits' ]; } - t.push( '(', Transmission.fmt.speed(this._prefs[RPC._TurtleUpSpeedLimit]), 'up,', - Transmission.fmt.speed(this._prefs[RPC._TurtleDownSpeedLimit]), 'down)' ); - w.attr( 'title', t.join(' ') ); + t.push('(', Transmission.fmt.speed(this._prefs[RPC._TurtleUpSpeedLimit]), 'up,', + Transmission.fmt.speed(this._prefs[RPC._TurtleDownSpeedLimit]), 'down)'); + w.attr('title', t.join(' ')); }, /*-------------------------------------------- @@ -1017,18 +851,18 @@ Transmission.prototype = * *--------------------------------------------*/ - showPrefsDialog: function( ) { + showPrefsDialog: function() { this.checkPort(true); $('body').addClass('prefs_showing'); $('#prefs_container').show(); this.hideiPhoneAddressbar(); - if( Safari3 ) + if (Safari3) setTimeout("$('div#prefs_container div.dialog_window').css('top', '0px');",10); - this.updateButtonStates( ); + this.updateButtonStates(); this.togglePeriodicSessionRefresh(false); }, - hidePrefsDialog: function( ) + hidePrefsDialog: function() { $('body.prefs_showing').removeClass('prefs_showing'); if (iPhone) { @@ -1040,14 +874,14 @@ Transmission.prototype = } else { $('#prefs_container').hide(); } - this.updateButtonStates( ); + this.updateButtonStates(); this.togglePeriodicSessionRefresh(true); }, /* * Process got some new session data from the server */ - updatePrefs: function( prefs ) + updatePrefs: function(prefs) { // remember them for later this._prefs = prefs; @@ -1059,8 +893,8 @@ Transmission.prototype = var turtle_up_limit_k = prefs[RPC._TurtleUpSpeedLimit]; var turtle_dn_limit_k = prefs[RPC._TurtleDownSpeedLimit]; - if( prefs.units ) - Transmission.fmt.updateUnits( prefs.units ); + if (prefs.units) + Transmission.fmt.updateUnits(prefs.units); $('div.download_location input')[0].value = prefs[RPC._DownloadDir]; $('div.port input')[0].value = prefs[RPC._PeerPort]; @@ -1074,32 +908,31 @@ Transmission.prototype = $('input#turtle_download_rate')[0].value = turtle_dn_limit_k; $('input#turtle_upload_rate')[0].value = turtle_up_limit_k; $('input#turtle_schedule')[0].checked = prefs[RPC._TurtleTimeEnabled]; - $('select#turtle_start_time').val( prefs[RPC._TurtleTimeBegin] ); - $('select#turtle_end_time').val( prefs[RPC._TurtleTimeEnd] ); - $('select#turtle_days').val( prefs[RPC._TurtleTimeDay] ); - $('#transmission_version').text( prefs[RPC._DaemonVersion] ); - - $('#conn_global').val( prefs[RPC._PeerLimitGlobal] ); - $('#conn_torrent').val( prefs[RPC._PeerLimitPerTorrent] ); - $('#conn_pex')[0].checked = prefs[RPC._PexEnabled]; - $('#conn_dht')[0].checked = prefs[RPC._DhtEnabled]; - $('#conn_lpd')[0].checked = prefs[RPC._LpdEnabled]; - $('#block_enable')[0].checked = prefs[RPC._BlocklistEnabled]; - $('#block_url').val( prefs[RPC._BlocklistURL]); - $('#block_size').text( prefs[RPC._BlocklistSize] + ' IP rules in the list' ); - $('#network_utp')[0].checked = prefs[RPC._UtpEnabled]; - $('#port_rand')[0].checked = prefs[RPC._PeerPortRandom]; - $('#port_forward')[0].checked = prefs[RPC._PortForwardingEnabled]; + $('select#turtle_start_time').val( prefs[RPC._TurtleTimeBegin]); + $('select#turtle_end_time').val( prefs[RPC._TurtleTimeEnd]); + $('select#turtle_days').val( prefs[RPC._TurtleTimeDay]); + $('#transmission_version').text( prefs[RPC._DaemonVersion]); + $('#conn_global').val( prefs[RPC._PeerLimitGlobal]); + $('#conn_torrent').val( prefs[RPC._PeerLimitPerTorrent]); + $('#conn_pex')[0].checked = prefs[RPC._PexEnabled]; + $('#conn_dht')[0].checked = prefs[RPC._DhtEnabled]; + $('#conn_lpd')[0].checked = prefs[RPC._LpdEnabled]; + $('#block_enable')[0].checked = prefs[RPC._BlocklistEnabled]; + $('#block_url').val( prefs[RPC._BlocklistURL]); + $('#block_size').text( prefs[RPC._BlocklistSize] + ' IP rules in the list'); + $('#network_utp')[0].checked = prefs[RPC._UtpEnabled]; + $('#port_rand')[0].checked = prefs[RPC._PeerPortRandom]; + $('#port_forward')[0].checked = prefs[RPC._PortForwardingEnabled]; if (!iPhone) { - setInnerHTML( $('#limited_download_rate')[0], [ 'Limit (', Transmission.fmt.speed(dn_limit_k), ')' ].join('') ); + setInnerHTML($('#limited_download_rate')[0], [ 'Limit (', Transmission.fmt.speed(dn_limit_k), ')' ].join('')); var key = dn_limited ? '#limited_download_rate' : '#unlimited_download_rate'; $(key).deselectMenuSiblings().selectMenuItem(); - setInnerHTML( $('#limited_upload_rate')[0], [ 'Limit (', Transmission.fmt.speed(up_limit_k), ')' ].join('') ); + setInnerHTML($('#limited_upload_rate')[0], [ 'Limit (', Transmission.fmt.speed(up_limit_k), ')' ].join('')); key = up_limited ? '#limited_upload_rate' : '#unlimited_upload_rate'; $(key).deselectMenuSiblings().selectMenuItem(); @@ -1107,27 +940,28 @@ Transmission.prototype = this[Prefs._TurtleState] = prefs[RPC._TurtleState]; this.updateTurtleButton(); + this.setCompactMode(prefs[Prefs._CompactDisplayState]); }, - updatePortStatus: function( status ){ - if(status['port-is-open']) + updatePortStatus: function(status) { + if (status['port-is-open']) $('#port_test').text('Port is open'); else $('#port_test').text('Port is closed'); }, - showStatsDialog: function( ) { + showStatsDialog: function() { this.loadDaemonStats(); $('body').addClass('stats_showing'); $('#stats_container').show(); this.hideiPhoneAddressbar(); - if( Safari3 ) + if (Safari3) setTimeout("$('div#stats_container div.dialog_window').css('top', '0px');",10); - this.updateButtonStates( ); + this.updateButtonStates(); this.togglePeriodicStatsRefresh(true); }, - hideStatsDialog: function( ){ + hideStatsDialog: function() { $('body.stats_showing').removeClass('stats_showing'); if (iPhone) { this.hideiPhoneAddressbar(); @@ -1138,14 +972,14 @@ Transmission.prototype = } else { $('#stats_container').hide(); } - this.updateButtonStates( ); + this.updateButtonStates(); this.togglePeriodicStatsRefresh(false); }, /* * Process got some new session stats from the server */ - updateStats: function( stats ) + updateStats: function(stats) { // can't think of a reason to remember this //this._stats = stats; @@ -1154,38 +988,38 @@ Transmission.prototype = var session = stats["current-stats"]; var total = stats["cumulative-stats"]; - setInnerHTML( $('#stats_session_uploaded')[0], fmt.size(session["uploadedBytes"]) ); - setInnerHTML( $('#stats_session_downloaded')[0], fmt.size(session["downloadedBytes"]) ); - setInnerHTML( $('#stats_session_ratio')[0], fmt.ratioString(Math.ratio(session["uploadedBytes"],session["downloadedBytes"]))); - setInnerHTML( $('#stats_session_duration')[0], fmt.timeInterval(session["secondsActive"]) ); - setInnerHTML( $('#stats_total_count')[0], total["sessionCount"] + " times" ); - setInnerHTML( $('#stats_total_uploaded')[0], fmt.size(total["uploadedBytes"]) ); - setInnerHTML( $('#stats_total_downloaded')[0], fmt.size(total["downloadedBytes"]) ); - setInnerHTML( $('#stats_total_ratio')[0], fmt.ratioString(Math.ratio(total["uploadedBytes"],total["downloadedBytes"]))); - setInnerHTML( $('#stats_total_duration')[0], fmt.timeInterval(total["secondsActive"]) ); + setInnerHTML($('#stats_session_uploaded')[0], fmt.size(session["uploadedBytes"])); + setInnerHTML($('#stats_session_downloaded')[0], fmt.size(session["downloadedBytes"])); + setInnerHTML($('#stats_session_ratio')[0], fmt.ratioString(Math.ratio(session["uploadedBytes"],session["downloadedBytes"]))); + setInnerHTML($('#stats_session_duration')[0], fmt.timeInterval(session["secondsActive"])); + setInnerHTML($('#stats_total_count')[0], total["sessionCount"] + " times"); + setInnerHTML($('#stats_total_uploaded')[0], fmt.size(total["uploadedBytes"])); + setInnerHTML($('#stats_total_downloaded')[0], fmt.size(total["downloadedBytes"])); + setInnerHTML($('#stats_total_ratio')[0], fmt.ratioString(Math.ratio(total["uploadedBytes"],total["downloadedBytes"]))); + setInnerHTML($('#stats_total_duration')[0], fmt.timeInterval(total["secondsActive"])); }, - setSearch: function( search ) { + setSearch: function(search) { this._current_search = search ? search.trim() : null; - this.refilter( ); + this.refilter(); }, - setSortMethod: function( sort_method ) { - this.setPref( Prefs._SortMethod, sort_method ); - this.refilter( ); + setSortMethod: function(sort_method) { + this.setPref(Prefs._SortMethod, sort_method); + this.refilter(); }, - setSortDirection: function( direction ) { - this.setPref( Prefs._SortDirection, direction ); - this.refilter( ); + setSortDirection: function(direction) { + this.setPref(Prefs._SortDirection, direction); + this.refilter(); }, /* * Process an event in the footer-menu */ - processSettingsMenuEvent: function(event) { + processSettingsMenuEvent: function(ev) { var tr = this; - var $element = $(event.target); + var $element = $(ev.target); // Figure out which menu has been clicked switch ($element.parent()[0].id) { @@ -1195,20 +1029,15 @@ Transmission.prototype = if ($element[0].id == 'preferences') { $('div#prefs_container div#pref_error').hide(); $('div#prefs_container h2.dialog_heading').show(); - tr.showPrefsDialog( ); + tr.showPrefsDialog(); } else if ($element[0].id == 'statistics') { $('div#stats_container div#stats_error').hide(); $('div#stats_container h2.dialog_heading').show(); - tr.showStatsDialog( ); + tr.showStatsDialog(); } else if ($element[0].id == 'compact_view') { - this.setPref( Prefs._CompactDisplayState, !this[Prefs._CompactDisplayState]) - if(this[Prefs._CompactDisplayState]) - $element.selectMenuItem(); - else - $element.deselectMenuItem(); - this.setCompactMode( this[Prefs._CompactDisplayState] ); + this.toggleCompactClicked(); } else if ($element[0].id == 'homepage') { window.open('http://www.transmissionbt.com/'); @@ -1225,16 +1054,16 @@ Transmission.prototype = $element.deselectMenuSiblings().selectMenuItem(); args[RPC._DownSpeedLimited] = false; } else { - var rate_str = $element[0].innerHTML - var rate_val = parseInt( rate_str ); - setInnerHTML( $('#limited_download_rate')[0], [ 'Limit (', Transmission.fmt.speed(rate_val), ')' ].join('') ); + var rate_str = $element[0].innerHTML; + var rate_val = parseInt(rate_str, 10); + setInnerHTML($('#limited_download_rate')[0], [ 'Limit (', Transmission.fmt.speed(rate_val), ')' ].join('')); $('#limited_download_rate').deselectMenuSiblings().selectMenuItem(); $('div.preference input#download_rate')[0].value = rate_str; args[RPC._DownSpeedLimit] = rate_val; args[RPC._DownSpeedLimited] = true; } $('div.preference input#limit_download')[0].checked = args[RPC._DownSpeedLimited]; - tr.remote.savePrefs( args ); + tr.remote.savePrefs(args); break; // Limit the upload rate @@ -1244,16 +1073,16 @@ Transmission.prototype = $element.deselectMenuSiblings().selectMenuItem(); args[RPC._UpSpeedLimited] = false; } else { - var rate_str = $element[0].innerHTML - var rate_val = parseInt( rate_str ); - setInnerHTML( $('#limited_upload_rate')[0], [ 'Limit (', Transmission.fmt.speed(rate_val), ')' ].join('') ); + var rate_str = $element[0].innerHTML; + var rate_val = parseInt(rate_str, 10); + setInnerHTML($('#limited_upload_rate')[0], [ 'Limit (', Transmission.fmt.speed(rate_val), ')' ].join('')); $('#limited_upload_rate').deselectMenuSiblings().selectMenuItem(); $('div.preference input#upload_rate')[0].value = rate_str; args[RPC._UpSpeedLimit] = rate_val; args[RPC._UpSpeedLimited] = true; } $('div.preference input#limit_upload')[0].checked = args[RPC._UpSpeedLimited]; - tr.remote.savePrefs( args ); + tr.remote.savePrefs(args); break; // Sort the torrent list @@ -1261,7 +1090,7 @@ Transmission.prototype = // The 'reverse sort' option state can be toggled independently of the other options if ($element.is('#reverse_sort_order')) { - if(!$element.is('#reverse_sort_order.active')) break; + if (!$element.is('#reverse_sort_order.active')) break; var dir; if ($element.menuItemIsSelected()) { $element.deselectMenuItem(); @@ -1270,18 +1099,18 @@ Transmission.prototype = $element.selectMenuItem(); dir = Prefs._SortDescending; } - tr.setSortDirection( dir ); + tr.setSortDirection(dir); // Otherwise, deselect all other options (except reverse-sort) and select this one } else { - $element.parent().find('span.selected').each( function() { + $element.parent().find('span.selected').each(function() { if (! $element.parent().is('#reverse_sort_order')) { $element.parent().deselectMenuItem(); } }); $element.selectMenuItem(); var method = $element[0].id.replace(/sort_by_/, ''); - tr.setSortMethod( method ); + tr.setSortMethod(method); } break; } @@ -1294,11 +1123,11 @@ Transmission.prototype = */ updateInspector: function() { - if( !this[Prefs._ShowInspector] ) + if (!this[Prefs._ShowInspector]) return; - var torrents = this.getSelectedTorrents( ); - if( !torrents.length && iPhone ) { + var torrents = this.getSelectedTorrents(); + if (!torrents.length && iPhone) { this.hideInspector(); return; } @@ -1319,7 +1148,6 @@ Transmission.prototype = var total_download_peers = 0; var total_download_speed = 0; var total_availability = 0; - var total_have = 0; var total_size = 0; var total_state = [ ]; var pieces = 'N/A'; @@ -1332,29 +1160,29 @@ Transmission.prototype = $("#torrent_inspector_size, .inspector_row div").css('color', '#222'); - if( torrents.length == 0 ) + if (torrents.length == 0) { - setInnerHTML( tab.name, 'No Selection' ); - setInnerHTML( tab.size, na ); - setInnerHTML( tab.pieces, na ); - setInnerHTML( tab.hash, na ); - setInnerHTML( tab.state, na ); - setInnerHTML( tab.download_speed, na ); - setInnerHTML( tab.upload_speed, na ); - setInnerHTML( tab.uploaded, na ); - setInnerHTML( tab.downloaded, na ); - setInnerHTML( tab.availability, na ); - setInnerHTML( tab.ratio, na ); - setInnerHTML( tab.have, na ); - setInnerHTML( tab.upload_to, na ); - setInnerHTML( tab.download_from, na ); - setInnerHTML( tab.secure, na ); - setInnerHTML( tab.creator_date, na ); - setInnerHTML( tab.progress, na ); - setInnerHTML( tab.comment, na ); - setInnerHTML( tab.creator, na ); - setInnerHTML( tab.download_dir, na ); - setInnerHTML( tab.error, na ); + setInnerHTML(tab.name, 'No Selection'); + setInnerHTML(tab.size, na); + setInnerHTML(tab.pieces, na); + setInnerHTML(tab.hash, na); + setInnerHTML(tab.state, na); + setInnerHTML(tab.download_speed, na); + setInnerHTML(tab.upload_speed, na); + setInnerHTML(tab.uploaded, na); + setInnerHTML(tab.downloaded, na); + setInnerHTML(tab.availability, na); + setInnerHTML(tab.ratio, na); + setInnerHTML(tab.have, na); + setInnerHTML(tab.upload_to, na); + setInnerHTML(tab.download_from, na); + setInnerHTML(tab.secure, na); + setInnerHTML(tab.creator_date, na); + setInnerHTML(tab.progress, na); + setInnerHTML(tab.comment, na); + setInnerHTML(tab.creator, na); + setInnerHTML(tab.download_dir, na); + setInnerHTML(tab.error, na); this.updateFileList(); this.updatePeersLists(); this.updateTrackersLists(); @@ -1366,30 +1194,30 @@ Transmission.prototype = ? torrents[0].getName() : torrents.length+' Transfers Selected'; - if( torrents.length == 1 ) + if (torrents.length == 1) { - var text + var text; var t = torrents[0]; - var err = t.getErrorMessage( ); - if( err ) + var err = t.getErrorMessage(); + if (err) error = err; - if(( text = t.getComment())) - comment = text - if(( text = t.getCreator())) - creator = text - if(( text = t.getDownloadDir())) - download_dir = text + if ((text = t.getComment())) + comment = text; + if ((text = t.getCreator())) + creator = text; + if ((text = t.getDownloadDir())) + download_dir = text; hash = t.getHashString(); pieces = [ t.getPieceCount(), 'pieces @', Transmission.fmt.mem(t.getPieceSize()) ].join(' '); - date_created = Transmission.fmt.timestamp( t.getDateCreated() ); + date_created = Transmission.fmt.timestamp(t.getDateCreated()); } - for( var i=0, t; t=torrents[i]; ++i ) { - var sizeWhenDone = t.getSizeWhenDone() - var left = t.getLeftUntilDone() - sizeWhenDone += sizeWhenDone - sizeDone += sizeWhenDone - left; + for (var i=0, t; t=torrents[i]; ++i) { + var l = t.getLeftUntilDone(); + var d = t.getSizeWhenDone(); + sizeWhenDone += d; + sizeDone += d - l; total_completed += t.getHave(); total_verified += t.getHaveValid(); total_size += t.getTotalSize(); @@ -1399,13 +1227,13 @@ Transmission.prototype = total_download_speed += t.getDownloadSpeed(); total_upload_peers += t.getPeersGettingFromUs(); total_download_peers += t.getPeersSendingToUs(); - total_availability += sizeWhenDone - left + t.getDesiredAvailable(); + total_availability += sizeWhenDone - l + t.getDesiredAvailable(); var s = t.getStateString(); - if( total_state.indexOf( s ) == -1 ) - total_state.push( s ); + if (total_state.indexOf(s) == -1) + total_state.push(s); - if( t.getPrivateFlag( ) ) + if (t.getPrivateFlag()) have_private = true; else have_public = true; @@ -1413,31 +1241,31 @@ Transmission.prototype = var private_string = ''; var fmt = Transmission.fmt; - if( have_private && have_public ) private_string = 'Mixed'; - else if( have_private ) private_string = 'Private Torrent'; - else if( have_public ) private_string = 'Public Torrent'; - - setInnerHTML( tab.name, name ); - setInnerHTML( tab.size, torrents.length ? fmt.size( total_size ) : na ); - setInnerHTML( tab.pieces, pieces ); - setInnerHTML( tab.hash, hash ); - setInnerHTML( tab.state, total_state.join('/') ); - setInnerHTML( tab.download_speed, torrents.length ? fmt.speedBps( total_download_speed ) : na ); - setInnerHTML( tab.upload_speed, torrents.length ? fmt.speedBps( total_upload_speed ) : na ); - setInnerHTML( tab.uploaded, torrents.length ? fmt.size( total_upload ) : na ); - setInnerHTML( tab.downloaded, torrents.length ? fmt.size( total_download ) : na ); - setInnerHTML( tab.availability, torrents.length ? fmt.percentString(Math.ratio( total_availability*100, sizeWhenDone )) + '%' : na ); - setInnerHTML( tab.ratio, torrents.length ? fmt.ratioString(Math.ratio( total_upload, total_download )) : na ); - setInnerHTML( tab.have, torrents.length ? fmt.size(total_completed) + ' (' + fmt.size(total_verified) + ' verified)' : na ); - setInnerHTML( tab.upload_to, torrents.length ? total_upload_peers : na ); - setInnerHTML( tab.download_from, torrents.length ? total_download_peers : na ); - setInnerHTML( tab.secure, private_string ); - setInnerHTML( tab.creator_date, date_created ); - setInnerHTML( tab.progress, torrents.length ? fmt.percentString(Math.ratio( sizeDone*100, sizeWhenDone )) + '%' : na ); - setInnerHTML( tab.comment, comment ); - setInnerHTML( tab.creator, creator ); - setInnerHTML( tab.download_dir, download_dir ); - setInnerHTML( tab.error, error ); + if (have_private && have_public) private_string = 'Mixed'; + else if (have_private) private_string = 'Private Torrent'; + else if (have_public) private_string = 'Public Torrent'; + + setInnerHTML(tab.name, name); + setInnerHTML(tab.size, torrents.length ? fmt.size(total_size) : na); + setInnerHTML(tab.pieces, pieces); + setInnerHTML(tab.hash, hash); + setInnerHTML(tab.state, total_state.join('/')); + setInnerHTML(tab.download_speed, torrents.length ? fmt.speedBps(total_download_speed) : na); + setInnerHTML(tab.upload_speed, torrents.length ? fmt.speedBps(total_upload_speed) : na); + setInnerHTML(tab.uploaded, torrents.length ? fmt.size(total_upload) : na); + setInnerHTML(tab.downloaded, torrents.length ? fmt.size(total_download) : na); + setInnerHTML(tab.availability, torrents.length ? fmt.percentString(Math.ratio(total_availability*100, sizeWhenDone)) + '%' : na); + setInnerHTML(tab.ratio, torrents.length ? fmt.ratioString(Math.ratio(total_upload, total_download)) : na); + setInnerHTML(tab.have, torrents.length ? fmt.size(total_completed) + ' (' + fmt.size(total_verified) + ' verified)' : na); + setInnerHTML(tab.upload_to, torrents.length ? total_upload_peers : na); + setInnerHTML(tab.download_from, torrents.length ? total_download_peers : na); + setInnerHTML(tab.secure, private_string); + setInnerHTML(tab.creator_date, date_created); + setInnerHTML(tab.progress, torrents.length ? fmt.percentString(Math.ratio(sizeDone*100, sizeWhenDone)) + '%' : na); + setInnerHTML(tab.comment, comment); + setInnerHTML(tab.creator, creator); + setInnerHTML(tab.download_dir, download_dir); + setInnerHTML(tab.error, error); this.updatePeersLists(); this.updateTrackersLists(); @@ -1445,18 +1273,18 @@ Transmission.prototype = this.updateFileList(); }, - onFileWantedToggled: function( row, want ) { + onFileWantedToggled: function(row, want) { var command = want ? 'files-wanted' : 'files-unwanted'; - this.changeFileCommand( command, [ row ] ); + this.changeFileCommand(command, [ row ]); }, - onFilePriorityToggled: function( row, priority ) { + onFilePriorityToggled: function(row, priority) { var command; - switch( priority ) { + switch(priority) { case -1: command = 'priority-low'; break; case 1: command = 'priority-high'; break; default: command = 'priority-normal'; break; } - this.changeFileCommand( command, [ row ] ); + this.changeFileCommand(command, [ row ]); }, clearFileList: function() { $(this._inspector_file_list).empty(); @@ -1466,62 +1294,61 @@ Transmission.prototype = updateFileList: function() { // if the file list is hidden, clear the list - if( this._inspector_tab_files.className.indexOf('selected') == -1 ) { - this.clearFileList( ); + if (this._inspector_tab_files.className.indexOf('selected') == -1) { + this.clearFileList(); return; } // if not torrent is selected, clear the list - var selected_torrents = this.getSelectedTorrents( ); - if( selected_torrents.length != 1 ) { - this.clearFileList( ); + var selected_torrents = this.getSelectedTorrents(); + if (selected_torrents.length != 1) { + this.clearFileList(); return; } // if the active torrent hasn't changed, noop var torrent = selected_torrents[0]; - if( this._files_torrent === torrent ) + if (this._files_torrent === torrent) return; // build the file list - this.clearFileList( ); + this.clearFileList(); this._files_torrent = torrent; var n = torrent._files.length; - this._files = new Array( n ); - var fragment = document.createDocumentFragment( ); + this._files = new Array(n); + var fragment = document.createDocumentFragment(); var tr = this; - for( var i=0; i' ); - if( torrents.length > 1 ) { - html.push( '
', torrent.getName(), '
' ); + var torrents = this.getSelectedTorrents(); + if ($(this._inspector_peers_list).is(':visible')) { + for (var k=0, torrent; torrent=torrents[k]; ++k) { + var peers = torrent.getPeers(); + html.push('
'); + if (torrents.length > 1) { + html.push('
', torrent.getName(), '
'); } - if( peers.length == 0 ) { - html.push( '
' ); // firefox won't paint the top border if the div is empty + if (peers.length == 0) { + html.push('
'); // firefox won't paint the top border if the div is empty continue; } - html.push( '', + html.push('
', '', '', '', @@ -1530,23 +1357,23 @@ Transmission.prototype = '', '', '', - '' ); - for( var i=0, peer; peer=peers[i]; ++i ) { + ''); + for (var i=0, peer; peer=peers[i]; ++i) { var parity = ((i+1) % 2 == 0 ? 'even' : 'odd'); - html.push( '', + html.push('', '', - '', - '', + '', + '', '', '', '', '', - '' ); + ''); } - html.push( '
UpStatusAddressClient
', (peer.isEncrypted ? 'Encrypted' : ''), '', ( peer.rateToPeer ? fmt.speedBps(peer.rateToPeer) : '' ), '', ( peer.rateToClient ? fmt.speedBps(peer.rateToClient) : '' ), '', (peer.rateToPeer ? fmt.speedBps(peer.rateToPeer) : ''), '', (peer.rateToClient ? fmt.speedBps(peer.rateToClient) : ''), '', Math.floor(peer.progress*100), '%', '', peer.flagStr, '', peer.address, '', peer.clientName, '
' ); + html.push('
'); } } - setInnerHTML(this._inspector_peers_list, html.join('') ); + setInnerHTML(this._inspector_peers_list, html.join('')); }, updateTrackersLists: function() { @@ -1555,45 +1382,45 @@ Transmission.prototype = var tr = this; var html = [ ]; var na = 'N/A'; - var torrents = this.getSelectedTorrents( ); - if( $(this._inspector_trackers_list).is(':visible') ) { - for( var k=0, torrent; torrent = torrents[k]; ++k ) { - html.push( '
' ); - if( torrents.length > 1 ) { - html.push( '
', torrent.getName(), '
' ); + var torrents = this.getSelectedTorrents(); + if ($(this._inspector_trackers_list).is(':visible')) { + for (var k=0, torrent; torrent = torrents[k]; ++k) { + html.push ('
'); + if (torrents.length > 1) { + html.push('
', torrent.getName(), '
'); } - for( var i=0, tier; tier=torrent._trackerStats[i]; ++i ) { - html.push( '
', - 'Tier ', (i + 1), '
', - '
    ' ); - for( var j=0, tracker; tracker=tier[j]; ++j ) { + for (var i=0, tier; tier=torrent._trackerStats[i]; ++i) { + html.push('
    ', + 'Tier ', (i + 1), '
    ', + '
      '); + for (var j=0, tracker; tracker=tier[j]; ++j) { var lastAnnounceStatusHash = tr.lastAnnounceStatus(tracker); var announceState = tr.announceState(tracker); var lastScrapeStatusHash = tr.lastScrapeStatus(tracker); // Display construction var parity = ((j+1) % 2 == 0 ? 'even' : 'odd'); - html.push( '
    • ', - tracker.host, '
      ', - '
      ', - '
      ', lastAnnounceStatusHash['label'], ': ', lastAnnounceStatusHash['value'], '
      ', - '
      ', announceState, '
      ', - '
      ', lastScrapeStatusHash['label'], ': ', lastScrapeStatusHash['value'], '
      ', - '
      ', - '', - '', - '', - '
      Seeders:', (tracker.seederCount > -1 ? tracker.seederCount : na), '
      Leechers:', (tracker.leecherCount > -1 ? tracker.leecherCount : na), '
      Downloads:', (tracker.downloadCount > -1 ? tracker.downloadCount : na), '
    • ' ); + html.push('
    • ', + tracker.host, '
      ', + '
      ', + '
      ', lastAnnounceStatusHash['label'], ': ', lastAnnounceStatusHash['value'], '
      ', + '
      ', announceState, '
      ', + '
      ', lastScrapeStatusHash['label'], ': ', lastScrapeStatusHash['value'], '
      ', + '
      ', + '', + '', + '', + '
      Seeders:', (tracker.seederCount > -1 ? tracker.seederCount : na), '
      Leechers:', (tracker.leecherCount > -1 ? tracker.leecherCount : na), '
      Downloads:', (tracker.downloadCount > -1 ? tracker.downloadCount : na), '
    • '); } - html.push( '
    ' ); + html.push('
'); } - html.push( '
' ); + html.push('
'); } } setInnerHTML(this._inspector_trackers_list, html.join('')); }, - lastAnnounceStatus: function(tracker){ + lastAnnounceStatus: function(tracker) { var lastAnnounceLabel = 'Last Announce'; var lastAnnounce = [ 'N/A' ]; if (tracker.hasAnnounced) { @@ -1608,7 +1435,7 @@ Transmission.prototype = return { 'label':lastAnnounceLabel, 'value':lastAnnounce.join('') }; }, - announceState: function(tracker){ + announceState: function(tracker) { var announceState = ''; switch (tracker.announceState) { case Torrent._TrackerActive: @@ -1616,7 +1443,7 @@ Transmission.prototype = break; case Torrent._TrackerWaiting: var timeUntilAnnounce = tracker.nextAnnounceTime - ((new Date()).getTime() / 1000); - if(timeUntilAnnounce < 0){ + if (timeUntilAnnounce < 0) { timeUntilAnnounce = 0; } announceState = 'Next announce in ' + Transmission.fmt.timeInterval(timeUntilAnnounce); @@ -1635,7 +1462,7 @@ Transmission.prototype = return announceState; }, - lastScrapeStatus: function(tracker){ + lastScrapeStatus: function(tracker) { var lastScrapeLabel = 'Last Scrape'; var lastScrape = 'N/A'; if (tracker.hasScraped) { @@ -1647,17 +1474,17 @@ Transmission.prototype = lastScrape = (tracker.lastScrapeResult ? tracker.lastScrapeResult + ' - ' : '') + lastScrapeTime; } } - return {'label':lastScrapeLabel, 'value':lastScrape} + return {'label':lastScrapeLabel, 'value':lastScrape}; }, /* * Toggle the visibility of the inspector (used by the context menu) */ toggleInspector: function() { - if( this[Prefs._ShowInspector] ) - this.hideInspector( ); + if (this[Prefs._ShowInspector]) + this.hideInspector(); else - this.showInspector( ); + this.showInspector(); }, showInspector: function() { @@ -1668,15 +1495,14 @@ Transmission.prototype = this.hideiPhoneAddressbar(); } else { var w = $('#torrent_inspector').width() + 1 + 'px'; - $('#torrent_filter_bar')[0].style.right = w; $('#torrent_container')[0].style.right = w; } - setInnerHTML( $('ul li#context_toggle_inspector')[0], 'Hide Inspector' ); + setInnerHTML($('ul li#context_toggle_inspector')[0], 'Hide Inspector'); - this.setPref( Prefs._ShowInspector, true ); - this.updateInspector( ); - this.refreshDisplay( ); + this.setPref(Prefs._ShowInspector, true); + this.updateInspector(); + this.refreshDisplay(); }, /* @@ -1687,66 +1513,39 @@ Transmission.prototype = $('#torrent_inspector').hide(); if (iPhone) { - this.deselectAll( ); + this.deselectAll(); $('body.inspector_showing').removeClass('inspector_showing'); $('#inspector_close').hide(); this.hideiPhoneAddressbar(); } else { - $('#torrent_filter_bar')[0].style.right = '0px'; $('#torrent_container')[0].style.right = '0px'; - setInnerHTML( $('ul li#context_toggle_inspector')[0], 'Show Inspector' ); + setInnerHTML($('ul li#context_toggle_inspector')[0], 'Show Inspector'); } - this.setPref( Prefs._ShowInspector, false ); - this.refreshDisplay( ); - }, - - /* - * Toggle the visibility of the filter bar - */ - toggleFilter: function() { - if( this[Prefs._ShowFilter] ) - this.hideFilter(); - else - this.showFilter(); - }, - - showFilter: function( ) { - var container_top = parseInt($('#torrent_container').position().top) + $('#torrent_filter_bar').height() + 1; - $('#torrent_container').css('top', container_top + 'px'); - $('#torrent_filter_bar').show(); - this.setPref( Prefs._ShowFilter, true ); - }, - - hideFilter: function() - { - var container_top = parseInt($('#torrent_container').css('top')) - $('#torrent_filter_bar').height() - 1; - $('#torrent_container').css('top', container_top + 'px'); - $('#torrent_filter_bar').hide(); - this.setPref( Prefs._ShowFilter, false ); - this.setFilter( Prefs._FilterAll ); + this.setPref(Prefs._ShowInspector, false); + this.refreshDisplay(); }, refreshMetaData: function(ids) { var tr = this; - this.remote.getMetaDataFor(ids, function(active, removed){ tr.updateMetaData(active); }); + this.remote.getMetaDataFor(ids, function(active) { tr.updateMetaData(active); }); }, - updateMetaData: function( torrents ) + updateMetaData: function(torrents) { var tr = this; var refresh_files_for = [ ]; var selected_torrents = this.getSelectedTorrents(); - jQuery.each( torrents, function( ) { + jQuery.each(torrents, function() { var t = tr._torrents[ this.id ]; - if( t ) { - t.refreshMetaData( this ); - if( selected_torrents.indexOf(t) != -1 ) - refresh_files_for.push( t.getId( ) ); + if (t) { + t.refreshMetaData(this); + if (selected_torrents.indexOf(t) != -1) + refresh_files_for.push(t.getId()); } - } ); - if( refresh_files_for.length > 0 ) - tr.remote.loadTorrentFiles( refresh_files_for ); + }); + if (refresh_files_for.length > 0) + tr.remote.loadTorrentFiles(refresh_files_for); }, refreshTorrents: function(ids) { @@ -1754,59 +1553,57 @@ Transmission.prototype = if (!ids) ids = 'recently-active'; - this.remote.getUpdatedDataFor(ids, function(active, removed){ tr.updateTorrentsData(active, removed); }); + this.remote.getUpdatedDataFor(ids, function(active, removed) { tr.updateTorrentsData(active, removed); }); }, - updateTorrentsData: function( updated, removed_ids ) { + updateTorrentsData: function(updated, removed_ids) { var tr = this; var new_torrent_ids = []; var refresh_files_for = []; var selected_torrents = this.getSelectedTorrents(); - for( var i=0, o; o=updated[i]; ++i ) { + for (var i=0, o; o=updated[i]; ++i) { var t = tr._torrents[o.id]; if (t == null) new_torrent_ids.push(o.id); else { t.refresh(o); - if( selected_torrents.indexOf(t) != -1 ) + if (selected_torrents.indexOf(t) != -1) refresh_files_for.push(t.getId()); } } - if(refresh_files_for.length > 0) - tr.remote.loadTorrentFiles( refresh_files_for ); + if (refresh_files_for.length > 0) + tr.remote.loadTorrentFiles(refresh_files_for); - if(new_torrent_ids.length > 0) - tr.remote.getInitialDataFor(new_torrent_ids, function(torrents){ tr.addTorrents(torrents) } ); + if (new_torrent_ids.length > 0) + tr.remote.getInitialDataFor(new_torrent_ids, function(torrents) {tr.addTorrents(torrents);}); - var removedAny = tr.deleteTorrents(removed_ids); + tr.deleteTorrents(removed_ids); - if( ( new_torrent_ids.length != 0 ) || removedAny ) { + if (new_torrent_ids.length != 0) { tr.hideiPhoneAddressbar(); - tr.deselectAll( true ); + tr.deselectAll(true); } - - this.refilter(); }, - updateTorrentsFileData: function( torrents ){ - for( var i=0, o; o=torrents[i]; ++i ) { + updateTorrentsFileData: function(torrents) { + for (var i=0, o; o=torrents[i]; ++i) { var t = this._torrents[o.id]; - if( t !== null ) { - t.refreshFiles( o ); - if( t === this._files_torrent ) + if (t) { + t.refreshFiles(o); + if (t === this._files_torrent) this.refreshFileView(); } } }, - initializeAllTorrents: function(){ + initializeAllTorrents: function() { var tr = this; - this.remote.getInitialDataFor( null ,function(torrents) { tr.addTorrents(torrents); } ); + this.remote.getInitialDataFor(null ,function(torrents) { tr.addTorrents(torrents); }); }, - onRowClicked: function( ev, row ) + onRowClicked: function(ev, row) { // Prevents click carrying to parent element // which deselects all on click @@ -1817,129 +1614,92 @@ Transmission.prototype = // 'Apple' button emulation on PC : // Need settable meta-key and ctrl-key variables for mac emulation var meta_key = ev.metaKey; - var ctrl_key = ev.ctrlKey; - if (ev.ctrlKey && navigator.appVersion.toLowerCase().indexOf("mac") == -1) { + if (ev.ctrlKey && navigator.appVersion.toLowerCase().indexOf("mac") == -1) meta_key = true; - ctrl_key = false; - } // Shift-Click - selects a range from the last-clicked row to this one if (iPhone) { - if ( row.isSelected() ) + if (row.isSelected()) this.showInspector(); - this.setSelectedRow( row, true ); + this.setSelectedRow(row, true); } else if (ev.shiftKey) { - this.selectRange( row, true ); + this.selectRange(row, true); // Need to deselect any selected text window.focus(); // Apple-Click, not selected } else if (!row.isSelected() && meta_key) { - this.selectRow( row, true ); + this.selectRow(row, true); // Regular Click, not selected } else if (!row.isSelected()) { - this.setSelectedRow( row, true ); + this.setSelectedRow(row, true); // Apple-Click, selected } else if (row.isSelected() && meta_key) { - this.deselectRow( row ); + this.deselectRow(row); // Regular Click, selected } else if (row.isSelected()) { - this.setSelectedRow( row, true ); + this.setSelectedRow(row, true); } - this._last_row_clicked = row; + this._last_torrent_clicked = row.getTorrent().getId(); }, - addTorrents: function( new_torrents ) + addTorrents: function(new_torrents) { var tr = this; + var key = 'dataChanged'; - for( var i=0, row; row=new_torrents[i]; ++i ) { - var t = new Torrent( this, row ); + for (var i=0, row; row=new_torrents[i]; ++i) { + var t = new Torrent(row); + $(t).bind(key,function() {tr.refilterSoon();}); this._torrents[t.getId()] = t; } - this.refilter( ); + this.refilterSoon(); }, - deleteTorrents: function(torrent_ids){ - - if(typeof torrent_ids == 'undefined') - return false - - var keep = [ ] - var elements = [ ] - var removedAny = false - - for(var i=0, row; row=this._rows[i]; ++i) { - var tor = row.getTorrent() - var tid = tor ? tor.getId() : -1 - if( torrent_ids.indexOf( tid ) == -1 ) - keep.push( row ) - else { - removedAny = true - delete this._torrents[ tid ] - $(row.getElement()).remove() - } + deleteTorrents: function(torrent_ids) + { + if (torrent_ids && torrent_ids.length) + { + for (var i=0, id; i=torrent_ids[i]; ++i) + delete this._torrents[id]; + this.refilter(); } - - this._rows = keep - - return removedAny }, - refreshDisplay: function( ) + refreshDisplay: function() { - var rows = this.getVisibleRows( ); - for( var i=0, row; row=rows[i]; ++i ) - row.render( this ); + for (var i=0, row; row=this._rows[i]; ++i) + row.render(this); }, /* * Set the alternating background colors for torrents */ - setTorrentBgColors: function( ) + setTorrentBgColors: function() { - var rows = this.getVisibleRows( ); - for( var i=0, row; row=rows[i]; ++i ) + for (var i=0, row; row=this._rows[i]; ++i) row.setEven((i+1) % 2 == 0); }, updateStatusbar: function() { - var torrents = this.getAllTorrents(); - var torrentCount = torrents.length; - var visibleCount = this.getVisibleTorrents().length; + this.refreshFilterButton(); - // calculate the overall speed - var upSpeed = 0; - var downSpeed = 0; - for( var i=0, row; row=torrents[i]; ++i ) { - upSpeed += row.getUploadSpeed( ); - downSpeed += row.getDownloadSpeed( ); + // up/down speed + var u=0, d=0; + var torrents = this.getAllTorrents(); + for (var i=0, row; row=torrents[i]; ++i) { + u += row.getUploadSpeed(); + d += row.getDownloadSpeed(); } - - // update torrent count label - var s; - if( torrentCount == visibleCount ) - s = torrentCount + ' Transfers'; - else - s = visibleCount + ' of ' + torrentCount + ' Transfers'; - setInnerHTML( $('#torrent_global_transfer')[0], s ); - - // update the speeds - s = Transmission.fmt.speedBps( upSpeed ); - if( iPhone ) s = 'UL: ' + s; - setInnerHTML( $('#torrent_global_upload')[0], s ); - - // download speeds - s = Transmission.fmt.speedBps( downSpeed ); - if( iPhone ) s = 'DL: ' + s; - setInnerHTML( $('#torrent_global_download')[0], s ); + setInnerHTML($('#statusbar #speed-up-label')[0], '↑ ' + Transmission.fmt.speedBps(u)); + setInnerHTML($('#statusbar #speed-dn-label')[0], '↓ ' + Transmission.fmt.speedBps(d)); }, /* @@ -1972,137 +1732,137 @@ Transmission.prototype = args.data = { 'X-Transmission-Session-Id' : tr.remote._token }; args.dataType = 'xml'; args.iframe = true; - args.success = function( data ) { + args.success = function() { tr.refreshTorrents(); - tr.togglePeriodicRefresh( true ); + tr.togglePeriodicRefresh(true); }; - tr.togglePeriodicRefresh( false ); - $('#torrent_upload_form').ajaxSubmit( args ); + tr.togglePeriodicRefresh(false); + $('#torrent_upload_form').ajaxSubmit(args); } } }, removeSelectedTorrents: function() { - var torrents = this.getSelectedTorrents( ); - if( torrents.length ) - this.promptToRemoveTorrents( torrents ); + var torrents = this.getSelectedTorrents(); + if (torrents.length) + this.promptToRemoveTorrents(torrents); }, removeSelectedTorrentsAndData: function() { - var torrents = this.getSelectedTorrents( ); - if( torrents.length ) - this.promptToRemoveTorrentsAndData( torrents ); + var torrents = this.getSelectedTorrents(); + if (torrents.length) + this.promptToRemoveTorrentsAndData(torrents); }, - promptToRemoveTorrents:function( torrents ) + promptToRemoveTorrents:function(torrents) { - if( torrents.length == 1 ) + if (torrents.length == 1) { var torrent = torrents[0]; var header = 'Remove ' + torrent.getName() + '?'; var message = 'Once removed, continuing the transfer will require the torrent file. Are you sure you want to remove it?'; - dialog.confirm( header, message, 'Remove', 'transmission.removeTorrents', torrents ); + dialog.confirm(header, message, 'Remove', 'transmission.removeTorrents', torrents); } else { var header = 'Remove ' + torrents.length + ' transfers?'; var message = 'Once removed, continuing the transfers will require the torrent files. Are you sure you want to remove them?'; - dialog.confirm( header, message, 'Remove', 'transmission.removeTorrents', torrents ); + dialog.confirm(header, message, 'Remove', 'transmission.removeTorrents', torrents); } }, - promptToRemoveTorrentsAndData:function( torrents ) + promptToRemoveTorrentsAndData:function(torrents) { - if( torrents.length == 1 ) + if (torrents.length == 1) { var torrent = torrents[0], header = 'Remove ' + torrent.getName() + ' and delete data?', message = 'All data downloaded for this torrent will be deleted. Are you sure you want to remove it?'; - dialog.confirm( header, message, 'Remove', 'transmission.removeTorrentsAndData', torrents ); + dialog.confirm(header, message, 'Remove', 'transmission.removeTorrentsAndData', torrents); } else { var header = 'Remove ' + torrents.length + ' transfers and delete data?', message = 'All data downloaded for these torrents will be deleted. Are you sure you want to remove them?'; - dialog.confirm( header, message, 'Remove', 'transmission.removeTorrentsAndData', torrents ); + dialog.confirm(header, message, 'Remove', 'transmission.removeTorrentsAndData', torrents); } }, - removeTorrents: function( torrents ) { - var torrent_ids = jQuery.map(torrents, function(t) { return t.getId(); } ); + removeTorrents: function(torrents) { + var torrent_ids = jQuery.map(torrents, function(t) { return t.getId(); }); var tr = this; - this.remote.removeTorrents( torrent_ids, function(){ tr.refreshTorrents() } ); + this.remote.removeTorrents(torrent_ids, function() { tr.refreshTorrents();}); }, - removeTorrentsAndData: function( torrents ) { - this.remote.removeTorrentsAndData( torrents ); + removeTorrentsAndData: function(torrents) { + this.remote.removeTorrentsAndData(torrents); }, verifySelectedTorrents: function() { - this.verifyTorrents( this.getSelectedTorrents( ) ); + this.verifyTorrents(this.getSelectedTorrents()); }, reannounceSelectedTorrents: function() { - this.reannounceTorrents( this.getSelectedTorrents( ) ); + this.reannounceTorrents(this.getSelectedTorrents()); }, - startSelectedTorrents: function( force ) { - this.startTorrents( this.getSelectedTorrents( ), force ); + startSelectedTorrents: function(force) { + this.startTorrents(this.getSelectedTorrents(), force); }, - startAllTorrents: function( ) { - this.startTorrents( this.getAllTorrents( ), false ); + startAllTorrents: function() { + this.startTorrents(this.getAllTorrents(), false); }, - startTorrent: function( torrent ) { - this.startTorrents( [ torrent ], false ); + startTorrent: function(torrent) { + this.startTorrents([ torrent ], false); }, - startTorrents: function( torrents, force ) { - var torrent_ids = jQuery.map(torrents, function(t) { return t.getId(); } ); + startTorrents: function(torrents, force) { + var torrent_ids = jQuery.map(torrents, function(t) { return t.getId(); }); var tr = this; - this.remote.startTorrents( torrent_ids, force, function(){ tr.refreshTorrents(torrent_ids) } ); + this.remote.startTorrents(torrent_ids, force, function() { tr.refreshTorrents(torrent_ids); }); }, - verifyTorrent: function( torrent ) { - this.verifyTorrents( [ torrent ] ); + verifyTorrent: function(torrent) { + this.verifyTorrents([ torrent ]); }, - verifyTorrents: function( torrents ) { - var torrent_ids = jQuery.map(torrents, function(t) { return t.getId(); } ); + verifyTorrents: function(torrents) { var tr = this; - this.remote.verifyTorrents( torrent_ids, function(){ tr.refreshTorrents(torrent_ids) } ); + var torrent_ids = jQuery.map(torrents, function(t) { return t.getId(); }); + this.remote.verifyTorrents(torrent_ids, function() { tr.refreshTorrents(torrent_ids); }); }, - reannounceTorrent: function( torrent ) { - this.reannounceTorrents( [ torrent ] ); + reannounceTorrent: function(torrent) { + this.reannounceTorrents([ torrent ]); }, - reannounceTorrents: function( torrents ) { - var torrent_ids = jQuery.map(torrents, function(t) { return t.getId(); } ); + reannounceTorrents: function(torrents) { var tr = this; - this.remote.reannounceTorrents( torrent_ids, function(){ tr.refreshTorrents(torrent_ids) } ); + var torrent_ids = jQuery.map(torrents, function(t) { return t.getId(); }); + this.remote.reannounceTorrents(torrent_ids, function() { tr.refreshTorrents(torrent_ids); }); }, - stopSelectedTorrents: function( ) { - this.stopTorrents( this.getSelectedTorrents( ) ); + stopSelectedTorrents: function() { + this.stopTorrents(this.getSelectedTorrents()); }, - stopAllTorrents: function( ) { - this.stopTorrents( this.getAllTorrents( ) ); + stopAllTorrents: function() { + this.stopTorrents(this.getAllTorrents()); }, - stopTorrent: function( torrent ) { - this.stopTorrents( [ torrent ] ); + stopTorrent: function(torrent) { + this.stopTorrents([ torrent ]); }, - stopTorrents: function( torrents ) { - var torrent_ids = jQuery.map(torrents, function(t) { return t.getId(); } ); + stopTorrents: function(torrents) { + var torrent_ids = jQuery.map(torrents, function(t) { return t.getId(); }); var tr = this; - this.remote.stopTorrents( torrent_ids, function(){ tr.refreshTorrents(torrent_ids )} ); + this.remote.stopTorrents(torrent_ids, function() { tr.refreshTorrents(torrent_ids);}); }, changeFileCommand: function(command, rows) { this.remote.changeFileCommand(command, rows); }, hideiPhoneAddressbar: function(timeInSeconds) { - var tr = this; - if( iPhone ) { + if (iPhone) { var delayLength = timeInSeconds ? timeInSeconds*1000 : 150; // not currently supported on iPhone - if(/*document.body.scrollTop!=1 && */scroll_timeout==null) { - scroll_timeout = setTimeout(function(){ tr.doToolbarHide(); }, delayLength); + if (/*document.body.scrollTop!=1 && */scroll_timeout==null) { + var tr = this; + scroll_timeout = setTimeout(function() {tr.doToolbarHide();}, delayLength); } } }, @@ -2112,25 +1872,25 @@ Transmission.prototype = }, // Queue - moveTop: function( ) { - var torrent_ids = jQuery.map(this.getSelectedTorrents( ), function(t) { return t.getId(); } ); + moveTop: function() { var tr = this; - this.remote.moveTorrentsToTop( torrent_ids, function(){ tr.refreshTorrents(torrent_ids )} ); + var ids = this.getSelectedTorrentIds(); + this.remote.moveTorrentsToTop(torrent_ids, function() { tr.refreshTorrents(ids);}); }, - moveUp: function( ) { - var torrent_ids = jQuery.map(this.getSelectedTorrents( ), function(t) { return t.getId(); } ); + moveUp: function() { var tr = this; - this.remote.moveTorrentsUp( torrent_ids, function(){ tr.refreshTorrents(torrent_ids )} ); + var ids = this.getSelectedTorrentIds(); + this.remote.moveTorrentsUp(torrent_ids, function() { tr.refreshTorrents(ids);}); }, - moveDown: function( ) { - var torrent_ids = jQuery.map(this.getSelectedTorrents( ), function(t) { return t.getId(); } ); + moveDown: function() { var tr = this; - this.remote.moveTorrentsDown( torrent_ids, function(){ tr.refreshTorrents(torrent_ids )} ); + var ids = this.getSelectedTorrentIds(); + this.remote.moveTorrentsDown(torrent_ids, function() { tr.refreshTorrents(ids);}); }, - moveBottom: function( ) { - var torrent_ids = jQuery.map(this.getSelectedTorrents( ), function(t) { return t.getId(); } ); + moveBottom: function() { var tr = this; - this.remote.moveTorrentsToBottom( torrent_ids, function(){ tr.refreshTorrents(torrent_ids )} ); + var ids = this.getSelectedTorrentIds(); + this.remote.moveTorrentsToBottom(torrent_ids, function() { tr.refreshTorrents(ids);}); }, @@ -2138,115 +1898,372 @@ Transmission.prototype = **** ***/ - onToggleRunningClicked: function( ev ) + onToggleRunningClicked: function(ev) { - var torrent = ev.data.r.getTorrent( ); + var torrent = ev.data.r.getTorrent(); - if( torrent.isStopped( ) ) - this.startTorrent( torrent ); + if (torrent.isStopped()) + this.startTorrent(torrent); else - this.stopTorrent( torrent ); + this.stopTorrent(torrent); }, - refilter: function() + setEnabled: function(key, flag) { - // decide which torrents to keep showing - var allTorrents = this.getAllTorrents( ); - var keep = [ ]; - for( var i=0, t; t=allTorrents[i]; ++i ) - if( t.test( this[Prefs._FilterMode], this._current_search ) ) - keep.push( t ); - - // sort the keepers - Torrent.sortTorrents( keep, this[Prefs._SortMethod], - this[Prefs._SortDirection] ); - - // make a backup of the selection - var sel = this.getSelectedTorrents( ); - - // add rows it there aren't enough - if( this._rows.length < keep.length ) { - var tr = this; - var fragment = document.createDocumentFragment( ); - while( this._rows.length < keep.length ) { - var row = new TorrentRow( this.torrentRenderer ); - if( !iPhone ) { - var b = row.getToggleRunningButton( ); - if( b !== null ) { - $(b).bind('click', {r:row}, function(e) { tr.onToggleRunningClicked(e); }); - } - } - $(row.getElement()).bind('click',{r: row}, function(ev){ tr.onRowClicked(ev,ev.data.r);}); - $(row.getElement()).bind('dblclick', function(e) { tr.toggleInspector(); }); - fragment.appendChild( row.getElement() ); - this._rows.push( row ); + $(key).toggleClass('disabled', !flag); + }, + + updateButtonStates: function() + { + var showing_dialog = new RegExp("(prefs_showing|dialog_showing|open_showing)").test(document.body.className); + this._toolbar_buttons.toggleClass('disabled', showing_dialog); + + if (!showing_dialog) + { + var haveSelection = false; + var haveActive = false; + var haveActiveSelection = false; + var havePaused = false; + var havePausedSelection = false; + + for (var i=0, row; row=this._rows[i]; ++i) { + var isStopped = row.getTorrent().isStopped(); + var isSelected = row.isSelected(); + if (!isStopped) haveActive = true; + if (isStopped) havePaused = true; + if (isSelected) haveSelection = true; + if (isSelected && !isStopped) haveActiveSelection = true; + if (isSelected && isStopped) havePausedSelection = true; } - this._torrent_list.appendChild(fragment); + + this.setEnabled(this._toolbar_pause_button, haveActiveSelection); + this.setEnabled(this._context_pause_button, haveActiveSelection); + this.setEnabled(this._toolbar_start_button, havePausedSelection); + this.setEnabled(this._context_start_button, havePausedSelection); + this.setEnabled(this._context_move_top_button, haveSelection); + this.setEnabled(this._context_move_up_button, haveSelection); + this.setEnabled(this._context_move_down_button, haveSelection); + this.setEnabled(this._context_move_bottom_button, haveSelection); + this.setEnabled(this._context_start_now_button, havePausedSelection); + this.setEnabled(this._toolbar_remove_button, haveSelection); + this.setEnabled(this._toolbar_pause_all_button, haveActive); + this.setEnabled(this._toolbar_start_all_button, havePaused); } + }, - // hide rows if there are too many - for( var i=keep.length, e; e=this._rows[i]; ++i ) { - delete e._torrent; - e.setVisible(false); + /**** + ***** + ***** FILTER + ***** + ****/ + + filterSetup: function() + { + var popup = $('#filter-popup'); + popup.dialog({ + autoOpen: false, + position: iPhone ? [0,0] : [40,80], + show: 'blind', + hide: 'blind', + title: 'Show', + width: 315 + }); + var tr = this; + $('#filter-button').click(function() { + if (popup.is(":visible")) + popup.dialog('close'); + else { + tr.refreshFilterPopup(); + popup.dialog('open'); + } + }); + this.refreshFilterButton(); + }, + + refreshFilterButton: function() + { + var state = this[Prefs._FilterMode]; + var state_all = state == Prefs._FilterAll; + var state_string = this.getStateString(state); + var tracker = this.filterTracker; + var tracker_all = !tracker; + var tracker_string = tracker ? this.getReadableDomain(tracker) : ''; + + var text; + if (state_all && tracker_all) + text = 'Show All'; + else if (state_all) + text = 'Show ' + tracker_string + ''; + else if (tracker_all) + text = 'Show ' + state_string + ''; + else + text = 'Show ' + state_string + ' at ' + tracker_string + ''; + + var torrent_count = this.getAllTorrents().length; + var visible_count = this.getVisibleTorrents().length; + if (torrent_count === visible_count) + text += ' — ' + torrent_count + ' Transfers'; + else + text += ' — ' + visible_count + ' of ' + torrent_count; + $('#filter-button')[0].innerHTML = text; + }, + + refilterSoon: function() + { + if (!this.refilterTimer) + { + var tr = this; + this.refilterTimer = setTimeout(function() {tr.refilter();}, 200); } + }, - // show the ones we're keeping - for( var i=0, len=keep.length; i' + tr.getStateString(s) + '' + + '' + counts[s] + ''; + $(div).click({'state':s}, function(ev) { tr.setFilter(ev.data.state); $('#filter-popup').dialog('close');}); + fragment.appendChild(div); + } + $('#filter-by-state .row').remove(); + $('#filter-by-state')[0].appendChild(fragment); + + /*** + **** Trackers + ***/ + + var trackers = this.getTrackers(); + var names = []; + for (var name in trackers) + names.push(name); + names.sort(); + + var fragment = document.createDocumentFragment(); + var div = document.createElement('div'); + div.id = 'show-tracker-all'; + div.className = 'row' + (tr.filterTracker ? '' : ' selected'); + div.innerHTML = '' + + 'All' + + '' + torrents.length + ''; + $(div).click(function() {tr.setFilterTracker(null); $('#filter-popup').dialog('close');}) + fragment.appendChild(div); + for (var i=0, name; name=names[i]; ++i) { + var div = document.createElement('div'); + var o = trackers[name]; + div.id = 'show-tracker-' + name; + div.className = 'row' + (o.domain === tr.filterTracker ? ' selected':''); + div.innerHTML = '' + + ''+ name + '' + + ''+ o.count + ''; + $(div).click({domain:o.domain}, function(ev) { tr.setFilterTracker(ev.data.domain); $('#filter-popup').dialog('close');}); + fragment.appendChild(div); + } + $('#filter-by-tracker .row').remove(); + $('#filter-by-tracker')[0].appendChild(fragment); + }, - for(var i=0, row; row=rows[i]; ++i) { - var isStopped = row.getTorrent().isStopped( ); - var isSelected = row.isSelected(); - if( !isStopped ) haveActive = true; - if( isStopped ) havePaused = true; - if( isSelected ) haveSelection = true; - if( isSelected && !isStopped ) haveActiveSelection = true; - if( isSelected && isStopped ) havePausedSelection = true; + getStateString: function(mode) + { + switch (mode) + { + case Prefs._FilterActive: return 'Active'; + case Prefs._FilterSeeding: return 'Seeding'; + case Prefs._FilterDownloading: return 'Downloading'; + case Prefs._FilterPaused: return 'Paused'; + case Prefs._FilterFinished: return 'Finished'; + default: return 'All'; + } + }, + + setFilterTracker: function(domain) + { + this.filterTracker = domain; + + // update which tracker is selected in the popup + var key = domain ? this.getReadableDomain(domain) : 'all'; + var id = '#show-tracker-' + key; + $(id).addClass('selected').siblings().removeClass('selected'); + + this.refilterSoon(); + }, + + /* example: "tracker.ubuntu.com" returns "ubuntu.com" */ + getDomainName: function(host) + { + var dot = host.indexOf('.'); + if (dot !== host.lastIndexOf('.')) + host = host.slice(dot+1); + return host; + }, + + /* example: "ubuntu.com" returns "Ubuntu" */ + getReadableDomain: function(name) + { + if (name.length) + name = name.charAt(0).toUpperCase() + name.slice(1); + var dot = name.indexOf('.'); + if (dot !== -1) + name = name.slice(0, dot); + return name; + }, + + getTrackers: function() + { + var trackers = {}; + + var torrents = this.getAllTorrents(); + for (var i=0, torrent; torrent=torrents[i]; ++i) { + var names = []; + for (var j=0, tier; tier=torrent._trackerStats[j]; ++j) { + for (var k=0, tracker; tracker=tier[k]; ++k) { + var uri = parseUri(tracker.announce); + var domain = this.getDomainName(uri.host); + var name = this.getReadableDomain(domain); + if (!(name in trackers)); + trackers[name] = { 'uri': uri, 'domain': domain, 'count': 0 }; + if (names.indexOf(name) === -1) + names.push(name); + } } + for (var j=0, name; name=names[j]; ++j) + trackers[name].count++; + } - this.setEnabled( this._toolbar_pause_button, haveActiveSelection ); - this.setEnabled( this._context_pause_button, haveActiveSelection ); - this.setEnabled( this._toolbar_start_button, havePausedSelection ); - this.setEnabled( this._context_start_button, havePausedSelection ); - this.setEnabled( this._context_move_top_button, haveSelection ); - this.setEnabled( this._context_move_up_button, haveSelection ); - this.setEnabled( this._context_move_down_button, haveSelection ); - this.setEnabled( this._context_move_bottom_button, haveSelection ); - this.setEnabled( this._context_start_now_button, havePausedSelection ); - this.setEnabled( this._toolbar_remove_button, haveSelection ); - this.setEnabled( this._toolbar_pause_all_button, haveActive ); - this.setEnabled( this._toolbar_start_all_button, havePaused ); + return trackers; + }, + + /*** + **** + **** Compact Mode + **** + ***/ + + toggleCompactClicked: function() + { + this.setCompactMode(!this[Prefs._CompactDisplayState]); + }, + setCompactMode: function(is_compact) + { + var key = Prefs._CompactDisplayState; + var was_compact = this[key]; + if (was_compact !== is_compact) { + this.setPref(key, is_compact); + this.onCompactModeChanged(); } + }, + initCompactMode: function() + { + this.onCompactModeChanged(); + }, + onCompactModeChanged: function() + { + var compact = this[Prefs._CompactDisplayState]; + + // update the ui: context menu + // (disabled in iphone mode...) + if (!iPhone) { + var e = $('#settings_menu #compact_view'); + if (compact) + e.selectMenuItem(); + else + e.deselectMenuItem(); + } + + // update the ui: footer button + $("#compact-button").toggleClass('enabled',compact); + + // update the ui: torrent list + this.torrentRenderer = compact ? new TorrentRendererCompact() + : new TorrentRendererFull(); + this.refilter(); } }; diff --git a/web/javascript/transmission.remote.js b/web/javascript/transmission.remote.js index 45f85735d..8558b922d 100644 --- a/web/javascript/transmission.remote.js +++ b/web/javascript/transmission.remote.js @@ -45,9 +45,9 @@ RPC._QueueMoveBottom = 'queue-move-bottom'; RPC._QueueMoveUp = 'queue-move-up'; RPC._QueueMoveDown = 'queue-move-down'; -function TransmissionRemote( controller ) +function TransmissionRemote(controller) { - this.initialize( controller ); + this.initialize(controller); return this; } @@ -71,7 +71,7 @@ TransmissionRemote.prototype = remote = this; // set the Transmission-Session-Id on a 409 - if(request.status == 409 && (token = request.getResponseHeader('X-Transmission-Session-Id'))){ + if (request.status == 409 && (token = request.getResponseHeader('X-Transmission-Session-Id'))){ remote._token = token; $.ajax(ajaxObject); return; @@ -80,7 +80,7 @@ TransmissionRemote.prototype = remote._error = request.responseText ? request.responseText.trim().replace(/(<([^>]+)>)/ig,"") : ""; - if( !remote._error.length ) + if (!remote._error.length) remote._error = 'Server not responding'; dialog.confirm('Connection Failed', @@ -97,9 +97,9 @@ TransmissionRemote.prototype = XHR.setRequestHeader('X-Transmission-Session-Id', this._token); }, - sendRequest: function( data, success, async ) { + sendRequest: function(data, success, async) { remote = this; - if( typeof async != 'boolean' ) + if (typeof async != 'boolean') async = true; var ajaxSettings = { @@ -109,62 +109,59 @@ TransmissionRemote.prototype = dataType: 'json', cache: false, data: $.toJSON(data), - beforeSend: function(XHR){ remote.appendSessionId(XHR) }, - error: function(request, error_string, exception){ remote.ajaxError(request, error_string, exception, ajaxSettings) }, + beforeSend: function(XHR){ remote.appendSessionId(XHR); }, + error: function(request, error_string, exception){ remote.ajaxError(request, error_string, exception, ajaxSettings); }, success: success, async: async }; - $.ajax( ajaxSettings ); + $.ajax(ajaxSettings); }, - loadDaemonPrefs: function( callback, async ) { - var tr = this._controller; + loadDaemonPrefs: function(callback, async) { var o = { method: 'session-get' }; - this.sendRequest( o, callback, async ); + this.sendRequest(o, callback, async); }, - checkPort: function( callback, async ) { - var tr = this._controller; + checkPort: function(callback, async) { var o = { method: 'port-test' }; - this.sendRequest( o, callback, async ); + this.sendRequest(o, callback, async); }, - loadDaemonStats: function( callback, async ) { - var tr = this._controller; + loadDaemonStats: function(callback, async) { var o = { method: 'session-stats' }; - this.sendRequest( o, callback, async ); + this.sendRequest(o, callback, async); }, getInitialDataFor: function(torrent_ids, callback) { var o = { method: 'torrent-get', arguments: { - fields: Torrent._StaticFields.concat( Torrent._MetaDataFields, - Torrent._DynamicFields, - [ 'files', 'fileStats' ] ) + fields: Torrent._StaticFields.concat(Torrent._MetaDataFields, + Torrent._DynamicFields, + [ 'files', 'fileStats' ]) } }; - if(torrent_ids) + if (torrent_ids) o.arguments.ids = torrent_ids; - this.sendRequest( o, function(data){ callback(data.arguments.torrents)} ); + this.sendRequest(o, function(data){ callback(data.arguments.torrents);}); }, getMetaDataFor: function(torrent_ids, callback) { var o = { method: 'torrent-get', arguments: { - fields: Torrent._StaticFields.concat( Torrent._MetaDataFields, - [ 'files', 'fileStats' ] ) + fields: Torrent._StaticFields.concat(Torrent._MetaDataFields, + ['files', 'fileStats']) } }; - if(torrent_ids) + if (torrent_ids) o.arguments.ids = torrent_ids; - this.sendRequest( o, function(data){ callback(data.arguments.torrents)} ); + this.sendRequest(o, function(data) {callback(data.arguments.torrents)}); }, getUpdatedDataFor: function(torrent_ids, callback) { @@ -176,36 +173,36 @@ TransmissionRemote.prototype = } }; - this.sendRequest( o, function(data){ callback(data.arguments.torrents, data.arguments.removed)} ); + this.sendRequest(o, function(data) {callback(data.arguments.torrents, data.arguments.removed);}); }, - loadTorrentFiles: function( torrent_ids ) { + loadTorrentFiles: function(torrent_ids) { var tr = this._controller; - this.sendRequest( { + this.sendRequest({ method: 'torrent-get', arguments: { fields: [ 'id', 'fileStats'], ids: torrent_ids } }, function(data) { - tr.updateTorrentsFileData( data.arguments.torrents ); - } ); + tr.updateTorrentsFileData(data.arguments.torrents); + }); }, - changeFileCommand: function( command, rows ) { + changeFileCommand: function(command, rows) { var remote = this; var torrent_ids = [ rows[0].getTorrent().getId() ]; - var files = [ ]; - for( var i=0, row; row=rows[i]; ++i ) - files.push( row.getIndex( ) ); + var files = []; + for (var i=0, row; row=rows[i]; ++i) + files.push(row.getIndex()); var o = { method: 'torrent-set', arguments: { ids: torrent_ids } }; o.arguments[command] = files; - this.sendRequest( o, function( ) { - remote._controller.refreshTorrents( torrent_ids ); + this.sendRequest(o, function() { + remote._controller.refreshTorrents(torrent_ids); }); }, - sendTorrentSetRequests: function( method, torrent_ids, args, callback ) { + sendTorrentSetRequests: function(method, torrent_ids, args, callback) { if (!args) args = { }; args['ids'] = torrent_ids; var o = { @@ -213,26 +210,26 @@ TransmissionRemote.prototype = arguments: args }; - this.sendRequest( o, function( data ) { + this.sendRequest(o, function(data) { callback(); }); }, - sendTorrentActionRequests: function( method, torrent_ids, callback ) { - this.sendTorrentSetRequests( method, torrent_ids, null, callback ); + sendTorrentActionRequests: function(method, torrent_ids, callback) { + this.sendTorrentSetRequests(method, torrent_ids, null, callback); }, - startTorrents: function( torrent_ids, noqueue, callback ) { + startTorrents: function(torrent_ids, noqueue, callback) { var name = noqueue ? 'torrent-start-now' : 'torrent-start'; - this.sendTorrentActionRequests( name, torrent_ids, callback ); + this.sendTorrentActionRequests(name, torrent_ids, callback); }, - stopTorrents: function( torrent_ids, callback ) { - this.sendTorrentActionRequests( 'torrent-stop', torrent_ids, callback ); + stopTorrents: function(torrent_ids, callback) { + this.sendTorrentActionRequests('torrent-stop', torrent_ids, callback); }, - removeTorrents: function( torrent_ids, callback ) { - this.sendTorrentActionRequests( 'torrent-remove', torrent_ids, callback ); + removeTorrents: function(torrent_ids, callback) { + this.sendTorrentActionRequests('torrent-remove', torrent_ids, callback); }, - removeTorrentsAndData: function( torrents ) { + removeTorrentsAndData: function(torrents) { var remote = this; var o = { method: 'torrent-remove', @@ -242,22 +239,24 @@ TransmissionRemote.prototype = } }; - if( torrents != null ) - for( var i=0, len=torrents.length; i div { +#toolbar ul li > div { color: #000; font-size: 1.1em; text-decoration: none; @@ -94,84 +87,38 @@ div.torrent_global_menu ul li > div { cursor: pointer; } -div.torrent_global_menu ul li div.toolbar_image { +#toolbar ul li div.toolbar_image { width: 32px; height: 32px; margin: 0 auto 5px; background-image: url('../images/buttons/toolbar_buttons.png'); } -li#open div div.toolbar_image, li#open.disabled div:active div.toolbar_image { - background-position: left 0; -} - -li#open div:active div.toolbar_image { - background-position: right 0; -} - -li#remove div div.toolbar_image, li#remove.disabled div:active div.toolbar_image { - background-position: left -32px; -} - -li#remove div:active div.toolbar_image { - background-position: right -32px; -} - -li#resume_selected div div.toolbar_image, li#resume_selected.disabled div:active div.toolbar_image { - background-position: left -96px; -} - -li#resume_selected div:active div.toolbar_image { - background-position: right -96px; -} - -li#pause_selected div div.toolbar_image, li#pause_selected.disabled div:active div.toolbar_image { - background-position: left -64px; -} - -li#pause_selected div:active div.toolbar_image { - background-position: right -64px; -} - -li#pause_all div div.toolbar_image, li#pause_all.disabled div:active div.toolbar_image { - background-position: left -128px; -} - -li#pause_all div:active div.toolbar_image { - background-position: right -128px; -} - -li#resume_all div div.toolbar_image, li#resume_all.disabled div:active div.toolbar_image { - background-position: left -160px; -} - -li#resume_all div:active div.toolbar_image { - background-position: right -160px; -} - -li#filter div div.toolbar_image, li#filter.disabled div:active div.toolbar_image { - background-position: left -192px; -} - -li#filter div:active div.toolbar_image { - background-position: right -192px; -} - -li#inspector div div.toolbar_image, li#inspector.disabled div:active div.toolbar_image { - background-position: left -224px; -} - -li#inspector div:active div.toolbar_image { - background-position: right -224px; -} - -div.torrent_global_menu ul li.disabled > div { +/* toolbar images */ +li#open div div.toolbar_image { background-position: left 0px; } +li#open div:active div.toolbar_image { background-position: right 0px; } +li#remove div div.toolbar_image { background-position: left -32px; } +li#remove div:active div.toolbar_image { background-position: right -32px; } +li#resume_selected div div.toolbar_image { background-position: left -96px; } +li#resume_selected div:active div.toolbar_image { background-position: right -96px; } +li#pause_selected div div.toolbar_image { background-position: left -64px; } +li#pause_selected div:active div.toolbar_image { background-position: right -64px; } +li#pause_all div div.toolbar_image { background-position: left -128px; } +li#pause_all div:active div.toolbar_image { background-position: right -128px; } +li#resume_all div div.toolbar_image { background-position: left -160px; } +li#resume_all div:active div.toolbar_image { background-position: right -160px; } +li#filter div div.toolbar_image { background-position: left -192px; } +li#filter div:active div.toolbar_image { background-position: right -192px; } +li#inspector div div.toolbar_image { background-position: left -224px; } +li#inspector div:active div.toolbar_image { background-position: right -224px; } + +#toolbar ul li.disabled > div { text-shadow: 0 1px 0 #fff; opacity: 0.25; cursor: default; } -div.torrent_global_menu ul li.divider { +#toolbar ul li.divider { width: 0; border-right: 1px dotted black; opacity: 0.2; @@ -179,149 +126,58 @@ div.torrent_global_menu ul li.divider { height: 49px; } -/*-------------------------------------- - * - * G L O B A L D E T A I L S - * - *--------------------------------------*/ - -div.torrent_global_details { - width: 100%; - height: 20px; - margin: 0; - background: #ddd url('../images/graphics/filter_bar.png') repeat-x left -51px; - font-size: 1.1em; - font-weight: normal; - border-bottom: 1px solid #888; - position: fixed; - left: 0; - right: 0; - top: 76px; - z-index: 2; - color: #000; - text-shadow: 0 1px 0 #f4f4f4; -} - -div.torrent_global_details div { - padding: 0 10px 1px 10px; - margin: 3px 0 0 0; -} +/*** +**** +**** STATUSBAR +**** +***/ -div.torrent_global_details div#torrent_global_transfer { - clear: left; - float: left; -} - -div.torrent_global_details div#torrent_global_upload, -div.torrent_global_details div#torrent_global_download { - float: right; - padding-left: 13px; -} - -div.torrent_global_details div#torrent_global_upload { - background: url('../images/graphics/transfer_arrows.png') left -12px no-repeat; -} - -div.torrent_global_details div#torrent_global_download { - background: url('../images/graphics/transfer_arrows.png') left 2px no-repeat; -} - -/*-------------------------------------- - * - * T O R R E N T F I L T E R B A R - * - *--------------------------------------*/ - -div#torrent_filter_bar { - margin: 0; +#statusbar { + background: #ACACAC; + border: 1px outset #AEBBCB; height: 24px; - background: #ddd url('../images/graphics/filter_bar.png') repeat-x bottom left; - border-bottom: 1px solid #888; - position: fixed; - left: 0; - right: 0px; - top: 97px; - z-index: 2; - display: none; + width: 100%; overflow: hidden; + position: relative; } -div#torrent_filter_bar ul { - height: 17px; - margin: 0; - padding: 0; +#statusbar #speed-info { + margin-top: 5px; + margin-left: 45%; text-align: left; - display: inline; } -div#torrent_filter_bar ul li { - list-style-type: none; - list-style-image: none; +#statusbar #filter-button { float: left; - padding: 0; - margin: 4px 0 0 5px; - vertical-align: middle; - height: 17px; -} - -div#torrent_filter_bar ul li a { + border: none; + padding: 1px 5px; + text-shadow: 0 1px 0 #ccc; + border-radius: 2px;*/ font-size: 1.2em; - color: #222; - text-shadow: 0 1px 0 #fff; - text-decoration: none; - font-weight: bold; - padding: 0 7px 0 0; - margin: 0 0 0 7px; - height: 17px; - display: block; - cursor: default; -} - -div#torrent_filter_bar ul li.selected, div#torrent_filter_bar ul li.selected a, div#torrent_filter_bar ul li:hover, div#torrent_filter_bar ul li:hover a, div#torrent_filter_bar ul li:active, div#torrent_filter_bar ul li:active a { - background-image: url('../images/graphics/filter_bar.png'); - background-repeat: no-repeat; - text-shadow: 0 1px 0 #444; - color: #fff !important; -} - -div#torrent_filter_bar ul li:hover { - background-position: left -17px; + margin: 5px 4px 0px 4px; + -moz-user-select: none; + -webkit-user-select: none; } - -div#torrent_filter_bar ul li:hover a { - background-position: right -17px; +#statusbar #filter-button:hover { + cursor: pointer; } - -div#torrent_filter_bar ul li:active { - background-position: left -34px; +#statusbar #filter-button .filter-selection { + text-decoration: underline; } -div#torrent_filter_bar ul li:active a { - background-position: right -34px; -} -div#torrent_filter_bar ul li.selected { - background-position: left top; -} - -div#torrent_filter_bar ul li.selected a { - background-position: right top; -} - -div#torrent_filter_bar input#torrent_search { +#statusbar input#torrent_search { + float: right; height: 15px; width: 100px; border: solid 0 #fff; - padding: 0 2px; + padding: 2px; margin: 4px 5px 0 0; - position:absolute; - right: 0px; - top: 0px; border-radius: 10px; } /* Safari-look filter input for Firefox */ @-moz-document url-prefix() { - div#torrent_filter_bar input#torrent_search { + div#statusbar input#torrent_search { background: #FFF url('../images/graphics/filter_icon.png') top left no-repeat; border: 1px solid #5D80A1; margin-top: 3px; @@ -334,19 +190,85 @@ div#torrent_filter_bar input#torrent_search { } } -div#torrent_filter_bar input#torrent_search.blur { +#statusbar input#torrent_search.blur { color: #999; } -/*-------------------------------------- - * - * T O R R E N T C O N T A I N E R - * - *--------------------------------------*/ +/*** +**** +**** FILTER POPUP +**** +***/ + +#filter-popup .count { + padding-left: 3px; +} +#filter-popup { + color: #222;/* !important; */ + background: #FFF; + z-index: 100; +} + +#filter-popup #filter-by-state .row .filter-img { + display: none; +} +div#filter-popup #filter-by-state .row .filter-name { + left: 0px; +} +#filter-popup .row { + font-size: 1.2em; + text-align: left; + cursor: pointer; + margin: 8px 2px; + position: relative; + height: 18px; + -moz-user-select: none; + -webkit-user-select: none; +} +div#filter-popup .row .filter-img { + border: none; + width: 16px; + height: 16px; + position: absolute; + left: 0px; +} +#filter-popup .row .filter-name { + position: absolute; + left: 20px; +} +#filter-popup .row .count { + float: right; + color: #aaa; +} +#filter-popup li { + text-align: left +} +#filter-popup .row:hover, +#filter-popup .row.selected { + font-weight: bold; +} +#filter-popup #filter-by-state { + float: left; + width: 120px; + overflow: hidden; + text-overflow: ellipsis; +} +#filter-popup #filter-by-tracker { + float: right; + width: 130px; + overflow: hidden; + text-overflow: ellipsis; +} + +/*** +**** +**** TORRENT CONTAINER +**** +***/ div#torrent_container { position: fixed; - top: 97px; + top: 102px; bottom: 22px; right: 0px; left: 0px; @@ -405,9 +327,14 @@ ul.torrent_list li.torrent div.torrent_name { text-overflow: ellipsis; white-space: nowrap; color: #222; + margin-top: 2px; margin-bottom: 2px; } +ul.torrent_list li.torrent div.torrent_name.compact { + font-weight: normal; +} + ul.torrent_list li.torrent div.torrent_name.paused { font-size: 1.3em; font-weight: normal; @@ -461,9 +388,6 @@ ul.torrent_list div.torrent_progress_bar_container { position: relative; margin-top: 2px; } -ul.torrent_list div.torrent_status_and_progress_bar { -/* float: right;*/ -} ul.torrent_list div.torrent_progress_bar_container.compact { width: 50px; position: absolute; @@ -571,13 +495,13 @@ li.torrent a:active div.torrent_resume { div#torrent_inspector { position: fixed; - top: 97px; + top: 102px; bottom: 22px; right: 0px; width: 570px; background-color: #ddd; border-left: 1px solid #888; - z-index: 2; + z-index: 5; text-align: left; overflow: auto; } @@ -587,7 +511,7 @@ div#torrent_inspector #torrent_inspector_name { } div#torrent_inspector #torrent_inspector_size { font-size: 1.2em; - margin: 3; + margin: 3px; display: block; padding-top: 2px; } @@ -957,7 +881,7 @@ div.torrent_footer { margin: 0; padding: 0; border-top: 1px solid #555; - background: #aaa url('../images/graphics/chrome.png') left bottom repeat-x; + background: #aaa url('../images/graphics/chrome.png') left -142px repeat-x; position: fixed; left: 0px; right: 0px; @@ -980,11 +904,11 @@ div.torrent_footer ul#settings_menu li#button { } div.torrent_footer ul#settings_menu li#button:active { - /background: transparent url('../images/graphics/chrome.png') -32px -75px no-repeat; + background: transparent url('../images/graphics/chrome.png') -32px -75px no-repeat; } div.torrent_footer ul#settings_menu li#button:hover { - /background: transparent url('../images/graphics/chrome.png') -32px -75px no-repeat; + background: transparent url('../images/graphics/chrome.png') -32px -75px no-repeat; } div.torrent_footer div#disk_space_container { @@ -1018,6 +942,31 @@ div.torrent_footer div#turtle_button { background: transparent url('../images/graphics/chrome.png') -32px -97px no-repeat; } +div.torrent_footer #compact-button { + height: 22px; + width: 32px !important; + visibility: visible; + padding: 0; + float: left; + margin-left: 38px; + position: relative; + -moz-user-select: none; + -webkit-user-select: none; +} +div.torrent_footer #compact-button { + background: transparent url('../images/graphics/chrome.png') left -185px no-repeat; +} +div.torrent_footer #compact-button:active { + background: transparent url('../images/graphics/chrome.png') -32px -185px no-repeat; +} +div.torrent_footer #compact-button.enabled { + background: transparent url('../images/graphics/chrome.png') left -163px no-repeat; +} +div.torrent_footer #compact-button.enabled:active { + background: transparent url('../images/graphics/chrome.png') -32px -163px no-repeat; +} + + /*-------------------------------------- * @@ -1040,8 +989,6 @@ div.dialog_container { div.dialog_container div.dialog_window { background-color: #eee; margin: 0 auto; - filter: alpha(opacity=95); - -moz-opacity: .95; opacity: .95; border-top: none; text-align: left; @@ -1371,8 +1318,6 @@ div#prefs_container div#pref_error { .trans_menu ul { min-width: 210px; background-color: #fff; - filter: alpha(opacity=98); - -moz-opacity: .98; opacity: .98; padding: 5px 0; text-align: left; diff --git a/web/stylesheets/ie6.css b/web/stylesheets/ie6.css deleted file mode 100644 index e3bc390e6..000000000 --- a/web/stylesheets/ie6.css +++ /dev/null @@ -1,89 +0,0 @@ -div.torrent_global_menu ul li { - width: 60px; -} -div#torrent_filter_bar ul li { - width: 100px; -} -div.torrent_footer { - position: static; -} -div#torrent_container { - position: static; - top: 97px; -} -div#torrent_inspector { - position: absolute; -} -ul.torrent_list { - width: 98%; -} -ul.torrent_list li.even { - background-color: #EDF3FE !important; - zoom: 1.0; -} - -ul.torrent_list li.selected { - background-color: #3879D7 !important; - color: #FFF; - zoom: 1.0; -} -div.torrent_footer ul#settings_menu li#button:active, -div.torrent_footer ul#settings_menu li#button:hover { - background-position: -32px -75px; -} -.trans_menu li.main li { - width: 100%; -} -.trans_menu li.active { - background-image: none !important; -} -.trans_menu li.hover { - z-index: 1 !important; /* the hover z-index has to be below the normal one the hovering items may be drawn over a submenu */ - background-color: #24e; - color: #fff; - text-shadow: none; - margin-bottom: 0px; - margin-top: 0px; -} - -div.torrent_footer ul#settings_menu li#button:active, -div.torrent_footer ul#settings_menu li#button:hover { - background-position: -32px -75px; -} -.trans_menu li.main li { - width: auto; -} -.trans_menu li.active { - background-image: none !important; -} -.trans_menu .innerBox li.hover { - z-index: 1 !important; /* the hover z-index has to be below the normal one the hovering items may be drawn over a submenu */ - background-color: #24e !important; - color: #fff !important; - text-shadow: none; -} -.trans_menu ul { - width: 210px; -} -.trans_menu li.separator { - line-height: 0px; - height: 1px !important; - font-size: 0px; - width: auto; -} -.trans_menu li, .trans_menu li.active { - position: relative; - width: auto; - zoom: 1.0; -} -.trans_menu li span.arrow { - position: absolute; - right: 3px; top: 0px; -} -.trans_menu ul ul { - margin-left: 0px !important; -} -.trans_menu li .innerBox .outerbox { - top: auto !important; - bottom: 0px !important; -} \ No newline at end of file diff --git a/web/stylesheets/iphone.css b/web/stylesheets/iphone.css index ff97a5c4f..a4a142ae0 100644 --- a/web/stylesheets/iphone.css +++ b/web/stylesheets/iphone.css @@ -23,15 +23,15 @@ body { } body div#torrent_container { - min-height: 295px; + min-height: 328px; } body div.dialog_container { - min-height: 291px; + min-height: 326px; } body div#torrent_inspector { - min-height: 323px; + min-height: 329px; } body.landscape div#torrent_container { @@ -53,30 +53,29 @@ body.open_showing #torrent_filter_bar, body.open_showing #torrent_container { display: none; } -/*-------------------------------------- - * - * T O P M E N U - * - *--------------------------------------*/ +/*** +**** +**** TOOLBAR +**** +***/ -div.torrent_global_menu { +#toolbar { width: 100%; height: 55px; margin: 0; background: #6685a1 url('../images/graphics/iphone_chrome.png') top left repeat-x; - border-top: 1px solid #2d3642; - border-bottom: 1px solid #2d3642; + border: 1px outset #AEBBCB; position: relative; text-shadow: 0 -1px 0 #446; } -div.torrent_global_menu ul { +#toolbar ul { margin: 0; padding: 0 3px; text-align: left; } -div.torrent_global_menu ul li { +#toolbar ul li { list-style-type: none; list-style-image: none; padding: 0; @@ -84,15 +83,14 @@ div.torrent_global_menu ul li { display: inline-block; } -li#remove, li#open { +#toolbar li#remove, li#open { float: left; } - -li#resume_all, li#pause_all { +#toolbar li#resume_all, li#pause_all { float: right; } -div.torrent_global_menu ul li > div { +#toolbar ul li > div { color: #fff; font-size: 9px; text-decoration: none; @@ -105,172 +103,157 @@ div.torrent_global_menu ul li > div { font-weight: bold; } -div.torrent_global_menu ul li.disabled { +#toolbar ul li.disabled { opacity: 0.25; } -div.torrent_global_menu ul li div div.toolbar_image { +#toolbar ul li div div.toolbar_image { width: 32px; height: 32px; margin: 0 auto 2px; background-image: url('../images/buttons/toolbar_buttons.png'); } -div.torrent_global_menu ul li#remove div div.toolbar_image { - background-position: left -32px; +/* toolbar images */ +li#open div div.toolbar_image { background-position: left 0px; } +li#open div:active div.toolbar_image { background-position: right 0px; } +li#remove div div.toolbar_image { background-position: left -32px; } +li#remove div:active div.toolbar_image { background-position: right -32px; } +li#resume_selected div div.toolbar_image { background-position: left -96px; } +li#resume_selected div:active div.toolbar_image { background-position: right -96px; } +li#pause_selected div div.toolbar_image { background-position: left -64px; } +li#pause_selected div:active div.toolbar_image { background-position: right -64px; } +li#pause_all div div.toolbar_image { background-position: left -128px; } +li#pause_all div:active div.toolbar_image { background-position: right -128px; } +li#resume_all div div.toolbar_image { background-position: left -160px; } +li#resume_all div:active div.toolbar_image { background-position: right -160px; } +li#filter div div.toolbar_image { background-position: left -192px; } +li#filter div:active div.toolbar_image { background-position: right -192px; } +li#inspector div div.toolbar_image { background-position: left -224px; } +li#inspector div:active div.toolbar_image { background-position: right -224px; } + +#toolbar ul li#filter, +#toolbar ul li#inspector, +#toolbar ul li.divider { + display: none; } -div.torrent_global_menu ul li#resume_selected div div.toolbar_image { - background-position: left -96px; -} +/*** +**** +**** STATUSBAR +**** +***/ -div.torrent_global_menu ul li#pause_selected div div.toolbar_image { - background-position: left -64px; +#statusbar { + margin: 0; + color: #fff; + background: #6B83A1; + border: 1px outset #AEBBCB; + width: 100%; + overflow: hidden; + position: relative; + text-align: left; } -div.torrent_global_menu ul li#pause_all div div.toolbar_image { - background-position: left -128px; +#statusbar #speed-info { + margin-top: 3px; + float: right; + margin-right: 6px; } -div.torrent_global_menu ul li#resume_all div div.toolbar_image { - background-position: left -160px; +#statusbar #filter-button { + float: left; + border: none; + font-size: 1.2em; + padding: 1px 6px; + margin-top: 1px; + overflow: hidden; + text-overflow: ellipsis; + -moz-user-select: none; + -webkit-user-select: none; } - -div.torrent_global_menu ul li#filter, div.torrent_global_menu ul li#inspector { - display: none; +#statusbar #filter-button:hover { + cursor: pointer; +} +#statusbar #filter-button .filter-selection { + text-decoration: underline; } -div.torrent_global_menu ul li.divider { + + +#statusbar #torrent_search { display: none; } -/*-------------------------------------- - * - * G L O B A L D E T A I L S - * - *--------------------------------------*/ +/*** +**** +**** FILTER POPUP +**** +***/ -div.torrent_global_details { - width: 100%; - height: 18px; - margin: 0; - background: #6685a1 url('../images/graphics/iphone_chrome.png') bottom left repeat-x; - font-size: 12px; - border-bottom: 1px solid #2d3642; - position: relative; - left: 0; - right: 0; - top: 0; - z-index: 2; - color: #fff; - text-shadow: 0 -1px 0 #446; - overflow: hidden; +#filter-popup .count { + padding-left: 3px; } - -div.torrent_global_details div { - padding: 2px 5px; - margin: 1px 0 0 0; +#filter-popup { + color: #222;/* !important; */ + background: #FFF; + z-index: 100; } -div.torrent_global_details div#torrent_global_transfer { - clear: left; - float: left; +#filter-popup #filter-by-state .row .filter-img { + display: none; } - -div.torrent_global_details div#torrent_global_upload, -div.torrent_global_details div#torrent_global_download { - float: right; +div#filter-popup #filter-by-state .row .filter-name { + left: 0px; } - -/*-------------------------------------- - * - * T O R R E N T F I L T E R B A R - * - *--------------------------------------*/ - -div#torrent_filter_bar { - margin: 0; - height: 25px; - background: #ddd url('../images/graphics/filter_bar.png') repeat-x bottom left; - border-bottom: 1px solid #777; +#filter-popup .row { + font-size: 1.2em; + text-align: left; + cursor: pointer; + margin: 15px 2px; position: relative; - width: 100%; - z-index: 2; - text-align: center; - overflow: hidden; -} - -div#torrent_filter_bar ul { - margin: 0 !important; - padding: 5px 0 0; - text-align: center !important; - display: block; - width: 100%; - height: 15px; - list-style-type: none; + height: 18px; } - -div#torrent_filter_bar ul li { - list-style-type: none; - list-style-image: none; - padding: 2px 0; - vertical-align: middle; - height: 17px; - display: inline; +div#filter-popup .row .filter-img { + border: none; + width: 16px; + height: 16px; + position: absolute; + left: 0px; } - -div#torrent_filter_bar ul li a { - font-size: 12px !important; - color: #222; - text-shadow: 0 1px 1px #fff; - text-decoration: none; - font-weight: bold; - padding: 1px 7px 2px 0; - margin: 0 0 0 7px; +#filter-popup .row .filter-name { + position: absolute; + left: 20px; } - -div#torrent_filter_bar ul li.selected, div#torrent_filter_bar ul li.selected a { - background-image: url('../images/graphics/filter_bar.png'); - background-repeat: no-repeat; - text-shadow: 0 1px 1px #444; - color: #fff !important; +#filter-popup .row .count { + float: right; + color: #aaa; } - -div#torrent_filter_bar ul li.selected { - background-position: left top; +#filter-popup li { + text-align: left } - -div#torrent_filter_bar ul li.selected a { - background-position: right top; +#filter-popup .row:hover, +#filter-popup .row.selected { + font-weight: bold; } - -div#torrent_filter_bar ul li a.finished { - display: none; +#filter-popup #filter-by-state { + float: left; + width: 120px; + overflow: hidden; + text-overflow: ellipsis; } - -div#torrent_filter_bar input#torrent_search { - position: absolute; - height: 20px; - left: 5px; - right: 5px; - bottom: 6px; - display: none; +#filter-popup #filter-by-tracker { + float: right; + width: 130px; + overflow: hidden; + text-overflow: ellipsis; } -/*-------------------------------------- - * - * T O R R E N T C O N T A I N E R - * - *--------------------------------------*/ - -div#torrent_container { - position: relative; - top: 0 !important; - right: 0px; - left: 0px; - padding: 0px; - margin: 0px; -} +/*** +**** +**** TORRENT CONTAINER +**** +***/ ul.torrent_list { width: 100%; @@ -298,6 +281,10 @@ ul.torrent_list li.torrent { background: white; } +ul.torrent_list li.torrent.compact { + padding: 4px; +} + .torrent div.torrent_progress_details, .torrent div.torrent_peer_details { clear: both; white-space: nowrap; @@ -316,11 +303,22 @@ ul.torrent_list li.torrent.selected { ul.torrent_list li.torrent div.torrent_name { font-size: 13px; - margin-bottom: 2px; font-weight: bold; - word-wrap: break-word; - width: 100%; + overflow: hidden; + text-overflow: ellipsis; + white-space: nowrap; color: #222; + margin-bottom: 2px; +} + +ul.torrent_list li.torrent div.torrent_name.compact { + font-weight: normal; +} + +ul.torrent_list li.torrent div.torrent_name.paused { + font-size: 1.3em; + font-weight: normal; + color: #777; } ul.torrent_list li.torrent.selected div.torrent_name { @@ -331,33 +329,58 @@ div.torrent_peer_details { font-size: 10px; } -/*** -**** Progressbar -***/ +/** + * Progressbar + * + * Each progressbar has three elemens: a parent container and two children, + * complete and incomplete. + * + * The only thing needed to set the progressbar percentage is to set + * the complete child's width as a percentage. This is because incomplete + * is pinned to the full width and height of the parent, and complete + * is pinned to the left side of the parent and has a higher z-index. + * + * The progressbar has different colors depending on its state, so there + * are four 'decorator' classNames: magnet, seeding, leeching, and paused. + */ ul.torrent_list div.torrent_progress_bar_container { - height: 10px; - position: relative; - margin-top: 2px; + height: 10px; + position: relative; + margin-top: 2px; +} +ul.torrent_list div.torrent_progress_bar_container.compact { + width: 50px; + position: absolute; + right: 10px; + margin-top: 2px; + /*float: right;*/ +} +ul.torrent_list div.torrent_peer_details.compact { + font-size: 12px; /* matching the progressbar height (10px) + progressbar border (1px top, 1px bottom) */ + margin-top: 2px; + margin-left: 10px; + margin-right: 65px; /* leave room on the right for the progressbar */ + float: right; /* pins it next to progressbar & forces torrent_name to ellipsize when it bumps up against this div */ } ul.torrent_list div.torrent_progress_bar_container.full { - margin-bottom: 5px; + margin-bottom: 5px; } ul.torrent_list div.torrent_progress_bar { - height: 100%; - position: absolute; - top: 0px; - left: 0px; - background-image: url('../images/progress/progress.png'); - background-repeat: repeat-x; - border: 1px solid #888; + height: 100%; + position: absolute; + top: 0px; + left: 0px; + background-image: url('../images/progress/progress.png'); + background-repeat: repeat-x; + border: 1px solid #888; } ul.torrent_list div.torrent_progress_bar.complete { - z-index: 2; + z-index: 2; } ul.torrent_list div.torrent_progress_bar.incomplete { - z-index: 1; - width: 100%; + z-index: 1; + width: 100%; } ul.torrent_list div.torrent_progress_bar.complete.paused { background-position: left -30px; @@ -382,7 +405,7 @@ ul.torrent_list div.torrent_progress_bar.complete.leeching { ul.torrent_list div.torrent_progress_bar.incomplete.leeching { background-position: left -20px; border-color: #CFCFCF; -} +} ul.torrent_list div.torrent_progress_bar.complete.seeding { background-position: left -10px; border-color: #35CA53; @@ -870,11 +893,34 @@ iframe#torrent_upload_frame { margin: 0; } +div.torrent_footer #compact-button { + position: absolute; + top: 0px; + right: 0px; + margin: 2px; + height: 18px; + width: 32px !important; +} +div.torrent_footer #compact-button { + background: transparent url('../images/graphics/chrome.png') left -31px no-repeat; +} +div.torrent_footer #compact-button.active { + background: transparent url('../images/graphics/chrome.png') -32px -31px no-repeat; +} +div.torrent_footer #compact-button.enabled { + background: transparent url('../images/graphics/chrome.png') left -53px no-repeat; +} +div.torrent_footer #compact-button.enabled.active { + background: transparent url('../images/graphics/chrome.png') -32px -53px no-repeat; +} + div.torrent_footer div#turtle_button { + position: absolute; + top: 0px; + left: 0px; + margin: 2px; height: 18px; width: 32px !important; - margin: 1px 0 0 3px; - padding: 0; } .turtleEnabled { @@ -890,6 +936,28 @@ div.torrent_footer div#turtle_button { background: transparent url('../images/graphics/chrome.png') -32px -99px no-repeat; } +div.torrent_footer #compact-button { + position: absolute; + top: 0px; + right: 0px; + margin: 2px; + height: 18px; + width: 32px !important; + visibility: visible; +} +div.torrent_footer #compact-button { + background: transparent url('../images/graphics/chrome.png') left -187px no-repeat; +} +div.torrent_footer #compact-button:active { + background: transparent url('../images/graphics/chrome.png') -32px -187px no-repeat; +} +div.torrent_footer #compact-button.enabled { + background: transparent url('../images/graphics/chrome.png') left -165px no-repeat; +} +div.torrent_footer #compact-button.enabled:active { + background: transparent url('../images/graphics/chrome.png') -32px -165px no-repeat; +} + /*-------------------------------------- * * Hide remnants of stuff we don't need, like -- 2.40.0