diff --git a/src/webui/www/private/addtrackers.html b/src/webui/www/private/addtrackers.html index 150804078..52787e22e 100644 --- a/src/webui/www/private/addtrackers.html +++ b/src/webui/www/private/addtrackers.html @@ -1,5 +1,6 @@ + QBT_TR(Trackers addition dialog)QBT_TR[CONTEXT=TrackersAdditionDlg] @@ -7,9 +8,9 @@ + -
-
+
+

QBT_TR(List of trackers to add (one per line):)QBT_TR[CONTEXT=TrackersAdditionDlg]

- -
- -
+ +
+ +
+ diff --git a/src/webui/www/private/confirmdeletion.html b/src/webui/www/private/confirmdeletion.html index 07747a316..e03eb4652 100644 --- a/src/webui/www/private/confirmdeletion.html +++ b/src/webui/www/private/confirmdeletion.html @@ -1,5 +1,6 @@ + QBT_TR(Deletion confirmation - qBittorrent)QBT_TR[CONTEXT=confirmDeletionDlg] @@ -8,13 +9,13 @@ - -
-

  QBT_TR(Are you sure you want to delete the selected torrents from the transfer list?)QBT_TR[CONTEXT=HttpServer]

-     

-
-      -
+ +
+ +

  QBT_TR(Are you sure you want to delete the selected torrents from the transfer list?)QBT_TR[CONTEXT=HttpServer]

+     

+
+      +
+ diff --git a/src/webui/www/private/css/Core.css b/src/webui/www/private/css/Core.css index ad380838e..8ce1c8a41 100644 --- a/src/webui/www/private/css/Core.css +++ b/src/webui/www/private/css/Core.css @@ -6,17 +6,17 @@ Theme: Default Copyright: Copyright (c) 2007-2009 Greg Houston, . - + License: MIT-style license. Notes: CSS rules in this file: - + 1. Rules required by all MochaUI components or are shared by more than one. 2. Theme specific adjustments to plugin styles. 3. Miscellaneous rules that have no better place to go. - + */ /* Required By All @@ -25,22 +25,22 @@ Notes: /* Clears */ .clear { - clear: both; - height: 0; + clear: both; + height: 0; } * html .clear { - font-size: 1px; - line-height: 1px; - overflow: hidden; - visibility: hidden; + font-size: 1px; + line-height: 1px; + overflow: hidden; + visibility: hidden; } /* Miscellaneous ---------------------------------------------------------------- */ #themeControl { - margin-top: 2px; + margin-top: 2px; } @@ -50,5 +50,5 @@ Notes: /* Folder Tree */ .tree li a { - color: #3f3f3f !important; + color: #3f3f3f !important; } diff --git a/src/webui/www/private/css/Layout.css b/src/webui/www/private/css/Layout.css index 45fa6fda3..7008b69e0 100644 --- a/src/webui/www/private/css/Layout.css +++ b/src/webui/www/private/css/Layout.css @@ -19,184 +19,185 @@ Required by: ---------------------------------------------------------------- */ html, body { - background: #fff; + background: #fff; } body { - margin: 0; /* Required */ + margin: 0; /* Required */ } #desktop { - position: relative; - min-width: 400px; /* Helps keep header content from wrapping */ - height: 100%; - min-height: 100%; - overflow: hidden; - cursor: default; /* Fix for issue in IE7. IE7 wants to use the I-bar text cursor */ + position: relative; + min-width: 400px; /* Helps keep header content from wrapping */ + height: 100%; + min-height: 100%; + overflow: hidden; + cursor: default; /* Fix for issue in IE7. IE7 wants to use the I-bar text cursor */ } #desktopHeader { - background: #f2f2f2; + background: #f2f2f2; } #desktopTitlebarWrapper { - position: relative; - height: 45px; - overflow: hidden; - background: #718BA6 url(../images/skin/bg-header.gif) repeat-x; + position: relative; + height: 45px; + overflow: hidden; + background: #718BA6 url(../images/skin/bg-header.gif) repeat-x; } #desktopTitlebar { - padding: 7px 8px 6px 8px; - height: 32px; - background: url(../images/skin/logo.gif) no-repeat; - background-position: left 0; + padding: 7px 8px 6px 8px; + height: 32px; + background: url(../images/skin/logo.gif) no-repeat; + background-position: left 0; } #desktopTitlebar h1.applicationTitle { - display: none; - margin: 0; - padding: 0 5px 0 0; - font-size: 20px; - line-height: 25px; - font-weight: bold; - color: #fff; + display: none; + margin: 0; + padding: 0 5px 0 0; + font-size: 20px; + line-height: 25px; + font-weight: bold; + color: #fff; } #desktopTitlebar h2.tagline { - padding: 7px 0 0 0; - font-family: Verdana, Arial, Helvetica, sans-serif; - font-size: 10px; - color: #d4dce4; - font-weight: bold; - text-align: center; - text-transform: uppercase; + padding: 7px 0 0 0; + font-family: Verdana, Arial, Helvetica, sans-serif; + font-size: 10px; + color: #d4dce4; + font-weight: bold; + text-align: center; + text-transform: uppercase; } #desktopTitlebar h2.tagline .taglineEm { - color: #fff; - font-weight: bold; + color: #fff; + font-weight: bold; } #topNav { - font-family: Verdana, Arial, Helvetica, sans-serif; - font-size: 10px; - position: absolute; - right: 0; - top: 0; - color: #d4dce4; - text-align: right; - padding: 13px 10px 0 0; + font-family: Verdana, Arial, Helvetica, sans-serif; + font-size: 10px; + position: absolute; + right: 0; + top: 0; + color: #d4dce4; + text-align: right; + padding: 13px 10px 0 0; } #topNav a { - color: #fff; - font-weight: normal; + color: #fff; + font-weight: normal; } #topNav a:hover { - text-decoration: none; + text-decoration: none; } /* Navbar */ #desktopNavbar { - background: #f2f2f2; - /*height: 30px;*/ - margin: 0 0px; - overflow: hidden; /* Remove this line if you want the menu to be backward compatible with Firefox 2 */ - /* Fixes by Chris */ - /*background-color: #ccc;*/ - height: 20px; - border-bottom: 1px solid #3f3f3f; + background: #f2f2f2; + /*height: 30px;*/ + margin: 0 0px; + overflow: hidden; /* Remove this line if you want the menu to be backward compatible with Firefox 2 */ + /* Fixes by Chris */ + /*background-color: #ccc;*/ + height: 20px; + border-bottom: 1px solid #3f3f3f; } #desktopNavbar ul { - padding: 0; - margin: 0; - list-style: none; - font-size: 12px; + padding: 0; + margin: 0; + list-style: none; + font-size: 12px; } #desktopNavbar>ul>li { - float: left; + float: left; } #desktopNavbar a { - display: block; + display: block; } #desktopNavbar ul li a { - /*padding: 6px 10px 6px 10px;*/ - color: #333; - font-weight: normal; - /* Fix by Chris */ - padding: 2px 10px 6px 10px; + /*padding: 6px 10px 6px 10px;*/ + color: #333; + font-weight: normal; + /* Fix by Chris */ + padding: 2px 10px 6px 10px; } #desktopNavbar ul li a:hover { - color: #333; - /* Fix By Chris */ - background-color: #fff; + color: #333; + /* Fix By Chris */ + background-color: #fff; } #desktopNavbar ul li a.arrow-right, #desktopNavbar ul li a:hover.arrow-right { - background-image: url(../images/skin/arrow-right.gif); - background-repeat: no-repeat; - background-position: right 7px; + background-image: url(../images/skin/arrow-right.gif); + background-repeat: no-repeat; + background-position: right 7px; } #desktopNavbar li ul { - border: 1px solid #3f3f3f; - background: #fff url(../images/skin/bg-dropdown.gif) repeat-y; - position: absolute; - left: -999em; - z-index: 8000; - /* Fix by Chris */ - margin-top: -6px; + border: 1px solid #3f3f3f; + background: #fff url(../images/skin/bg-dropdown.gif) repeat-y; + position: absolute; + left: -999em; + z-index: 8000; + /* Fix by Chris */ + margin-top: -6px; } #desktopNavbar li:hover ul ul, #desktopNavbar li.ieHover ul ul, #desktopNavbar li:hover ul ul ul, #desktopNavbar li.ieHover ul ul ul { - left: -999em; + left: -999em; } -#desktopNavbar li ul ul { /* third-and-above-level lists */ - margin: -22px 0 0 163px; +#desktopNavbar li ul ul { /* third-and-above-level lists */ + margin: -22px 0 0 163px; } #desktopNavbar li ul li .check { - position: absolute; - top: 8px; - left: 6px; - width: 5px; - height: 5px; - background: #555; - overflow: hidden; - line-height: 1px; - font-size: 1px; + position: absolute; + top: 8px; + left: 6px; + width: 5px; + height: 5px; + background: #555; + overflow: hidden; + line-height: 1px; + font-size: 1px; } #desktopNavbar li ul li a { - position: relative; - /*padding: 1px 9px 1px 25px;*/ - min-width: 120px; - color: #3f3f3f; - font-weight: normal; - /* Fix By Chris */ - padding: 1px 10px 1px 20px; /* Reduce left padding */ + position: relative; + /*padding: 1px 9px 1px 25px;*/ + min-width: 120px; + color: #3f3f3f; + font-weight: normal; + /* Fix By Chris */ + padding: 1px 10px 1px 20px; + /* Reduce left padding */ } #desktopNavbar li ul li a:hover { - background: #6C98D9; - color: #fff; - -moz-border-radius: 2px; + background: #6C98D9; + color: #fff; + -moz-border-radius: 2px; } #desktopNavbar li ul li a:hover .check { - background: #fff; + background: #fff; } #desktopNavbar li:hover ul, @@ -204,45 +205,45 @@ body { #desktopNavbar li li.ieHover ul, #desktopNavbar li li li.ieHover ul, #desktopNavbar li li:hover ul, -#desktopNavbar li li li:hover ul { /* lists nested under hovered list items */ - left: auto; +#desktopNavbar li li li:hover ul { /* lists nested under hovered list items */ + left: auto; } -#desktopNavbar li:hover { /* For IE7 */ +#desktopNavbar li:hover { /* For IE7 */ position: static; } li.divider { - margin-top: 2px; - padding-top: 3px; - border-top: 1px solid #ebebeb; + margin-top: 2px; + padding-top: 3px; + border-top: 1px solid #ebebeb; } #pageWrapper { - position: relative; - overflow: hidden; /* This can be set to hidden or auto */ - border-top: 1px solid #909090; - border-bottom: 1px solid #909090; - /*height: 100%;*/ + position: relative; + overflow: hidden; /* This can be set to hidden or auto */ + border-top: 1px solid #909090; + border-bottom: 1px solid #909090; + /*height: 100%;*/ } /* Footer */ #desktopFooterWrapper { - position: absolute; - left: 0; - bottom: 0; - width: 100%; - height: 30px; - overflow: hidden; + position: absolute; + left: 0; + bottom: 0; + width: 100%; + height: 30px; + overflow: hidden; } #desktopFooter { - font-family: Verdana, Arial, Helvetica, sans-serif; - font-size: 11px; - height: 24px; - padding: 6px 8px 0 8px; - background: #f2f2f2; + font-family: Verdana, Arial, Helvetica, sans-serif; + font-size: 11px; + height: 24px; + padding: 6px 8px 0 8px; + background: #f2f2f2; } @@ -253,159 +254,159 @@ li.divider { /* Columns */ .column { - position: relative; - float: left; - overflow: hidden; /* Required by IE6 */ + position: relative; + float: left; + overflow: hidden; /* Required by IE6 */ } /* Panels */ .panel { - position: relative; - overflow: auto; - background: #f8f8f8; - border-bottom: 1px solid #b9b9b9; + position: relative; + overflow: auto; + background: #f8f8f8; + border-bottom: 1px solid #b9b9b9; } .panelWrapper.collapsed .panel-header { - border-bottom: 0; + border-bottom: 0; } .panelAlt { - background: #f2f2f2; + background: #f2f2f2; } .bottomPanel { - border-bottom: 0; + border-bottom: 0; } .pad { - padding: 8px; + padding: 8px; } #mainPanel { - background: #fff; + background: #fff; } .panel-header { - position: relative; - background: #f1f1f1 url(../images/skin/bg-panel-header.gif) repeat-x; - height: 30px; - overflow: hidden; - border-bottom: 1px solid #d3d3d3; + position: relative; + background: #f1f1f1 url(../images/skin/bg-panel-header.gif) repeat-x; + height: 30px; + overflow: hidden; + border-bottom: 1px solid #d3d3d3; } .panel-headerContent { - padding-top: 2px; + padding-top: 2px; } .panel-headerContent.tabs { - background: url(../images/skin/tabs.gif) repeat-x; - background-position: left -68px; + background: url(../images/skin/tabs.gif) repeat-x; + background-position: left -68px; } .panel-header h2 { - display: inline-block; - font-size: 12px; - margin: 0; - padding: 3px 8px 0 8px; - height: 22px; - overflow: hidden; - color: #333; + display: inline-block; + font-size: 12px; + margin: 0; + padding: 3px 8px 0 8px; + height: 22px; + overflow: hidden; + color: #333; } .panel-collapse { - background: url(../images/skin/collapse-expand.gif) left top no-repeat; + background: url(../images/skin/collapse-expand.gif) left top no-repeat; } .panel-expand { - background: url(../images/skin/collapse-expand.gif) left -16px no-repeat; + background: url(../images/skin/collapse-expand.gif) left -16px no-repeat; } .icon16 { - margin: 4px 0 0 2px; - cursor: pointer; + margin: 4px 0 0 2px; + cursor: pointer; } /* Column and Panel Handles */ .horizontalHandle { - height: 4px; - line-height: 1px; - font-size: 1px; - overflow: hidden; - background: #eee url(../images/skin/bg-handle-horizontal.gif) repeat-x; + height: 4px; + line-height: 1px; + font-size: 1px; + overflow: hidden; + background: #eee url(../images/skin/bg-handle-horizontal.gif) repeat-x; } .horizontalHandle.detached .handleIcon { - background: transparent; + background: transparent; } .horizontalHandle .handleIcon { - margin: 0 auto; - height: 4px; - line-height: 1px; - font-size: 1px; - overflow: hidden; - background: url(../images/skin/handle-icon-horizontal.gif) center center no-repeat; + margin: 0 auto; + height: 4px; + line-height: 1px; + font-size: 1px; + overflow: hidden; + background: url(../images/skin/handle-icon-horizontal.gif) center center no-repeat; } .columnHandle { - min-height: 10px; - float: left; - width: 4px; - overflow: hidden; - background: #c3c3c3 url(../images/skin/handle-icon.gif) center center no-repeat; - border: 1px solid #909090; - border-top: 0; - border-bottom: 0; + min-height: 10px; + float: left; + width: 4px; + overflow: hidden; + background: #c3c3c3 url(../images/skin/handle-icon.gif) center center no-repeat; + border: 1px solid #909090; + border-top: 0; + border-bottom: 0; } /* Toolboxes */ .toolbox { - float: right; - margin-top: 3px; - padding: 0 5px; - height: 24px; - overflow: hidden; - text-align: right; + float: right; + margin-top: 3px; + padding: 0 5px; + height: 24px; + overflow: hidden; + text-align: right; } .panel-header-toolbox { } -div.toolbox.divider { /* Have to specify div here for IE6's sake */ - background: url(../images/skin/toolbox-divider.gif) repeat-y; - padding-left: 8px; +div.toolbox.divider { /* Have to specify div here for IE6's sake */ + background: url(../images/skin/toolbox-divider.gif) repeat-y; + padding-left: 8px; } .toolbox img.disabled { - cursor: default; + cursor: default; } .iconWrapper { - display: inline-block; - height: 22px; - min-width: 22px; - overflow: hidden; - border: 1px solid transparent; + display: inline-block; + height: 22px; + min-width: 22px; + overflow: hidden; + border: 1px solid transparent; } * html .iconWrapper { - padding: 1px; - border: 0; + padding: 1px; + border: 0; } .iconWrapper img { - cursor: pointer; - margin: 0; - padding: 3px; + cursor: pointer; + margin: 0; + padding: 3px; } .iconWrapper:hover { - border: 1px solid #a0a0a0; - -moz-border-radius: 3px; + border: 1px solid #a0a0a0; + -moz-border-radius: 3px; } #spinnerWrapper { @@ -416,15 +417,15 @@ div.toolbox.divider { /* Have to specify div here for IE6's sake */ } #spinner { - display: none; - background: url(../images/skin/spinner.gif) no-repeat; - width: 16px; - height: 16px; + display: none; + background: url(../images/skin/spinner.gif) no-repeat; + width: 16px; + height: 16px; } #desktopFooter td { - vertical-align: top; - text-align: left; + vertical-align: top; + text-align: left; } td.speedLabel { diff --git a/src/webui/www/private/css/Tabs.css b/src/webui/www/private/css/Tabs.css index 0672c4716..fb438eb64 100644 --- a/src/webui/www/private/css/Tabs.css +++ b/src/webui/www/private/css/Tabs.css @@ -6,61 +6,61 @@ Theme: Default Copyright: Copyright (c) 2007-2009 Greg Houston, . - + License: MIT-style license. Required by: Tabs.js - + */ /* Toolbar Tabs */ -.toolbarTabs { - padding: 0 5px 2px 2px; - background: url(../images/skin/tabs.gif) repeat-x; - background-position: left -70px; - overflow: visible; +.toolbarTabs { + padding: 0 5px 2px 2px; + background: url(../images/skin/tabs.gif) repeat-x; + background-position: left -70px; + overflow: visible; } -.tab-menu { - padding-top: 1px; - list-style: none; - margin: 0; - padding: 0; - line-height: 16px; - font-size: 11px; +.tab-menu { + padding-top: 1px; + list-style: none; + margin: 0; + padding: 0; + line-height: 16px; + font-size: 11px; } .tab-menu li { - display: block; - float: left; - margin: 0 0 5px 0; - cursor: pointer; - background: url(../images/skin/tabs.gif) repeat-x; - background-position: left -35px; + display: block; + float: left; + margin: 0 0 5px 0; + cursor: pointer; + background: url(../images/skin/tabs.gif) repeat-x; + background-position: left -35px; } .tab-menu li.selected { - background: url(../images/skin/tabs.gif) repeat-x; - background-position: left 0; + background: url(../images/skin/tabs.gif) repeat-x; + background-position: left 0; } .tab-menu li a { - display: block; - margin-left: 8px; - padding: 6px 15px 5px 9px; - text-align: center; - font-weight: normal; - color: #181818; - background: url(../images/skin/tabs.gif) repeat-x; - background-position: right -35px; + display: block; + margin-left: 8px; + padding: 6px 15px 5px 9px; + text-align: center; + font-weight: normal; + color: #181818; + background: url(../images/skin/tabs.gif) repeat-x; + background-position: right -35px; } .tab-menu li.selected a { - color: #181818; - font-weight: bold; - background: url(../images/skin/tabs.gif) repeat-x; - background-position: right 0; + color: #181818; + font-weight: bold; + background: url(../images/skin/tabs.gif) repeat-x; + background-position: right 0; } diff --git a/src/webui/www/private/css/Window.css b/src/webui/www/private/css/Window.css index 1f491fdcf..30a64ca39 100644 --- a/src/webui/www/private/css/Window.css +++ b/src/webui/www/private/css/Window.css @@ -6,12 +6,12 @@ Theme: Default Copyright: Copyright (c) 2007-2009 Greg Houston, . - + License: MIT-style license. - + Required by: - Window.js and Modal.css + Window.js and Modal.css */ @@ -19,160 +19,159 @@ Required by: ---------------------------------------------------------------- */ .mocha { - display: none; - overflow: hidden; - background-color: #e5e5e5; + display: none; + overflow: hidden; + background-color: #e5e5e5; } -.mocha.isFocused { -} +.mocha.isFocused {} .mochaOverlay { - position: absolute; /* This is also set in theme.js in order to make theme transitions smoother */ - top: 0; - left: 0; + position: absolute; /* This is also set in theme.js in order to make theme transitions smoother */ + top: 0; + left: 0; } /* We get a little creative here in order to define a gradient in the CSS using a query string appended to a background image. - + "from" is the top color of the gradient. "to" is the bottom color of the gradient. - + Both must be hex values without the leading # sign. - -*/ + +*/ .mochaTitlebar { - width: 100%; - overflow: hidden; - background: url(../images/skin/spacer.gif?from=fafafa&to=e5e5e5); + width: 100%; + overflow: hidden; + background: url(../images/skin/spacer.gif?from=fafafa&to=e5e5e5); } .mochaTitlebar h3 { - font-size: 12px; - line-height: 15px; - font-weight: bold; - margin: 0; - padding: 5px 10px 4px 12px; - color: #888; + font-size: 12px; + line-height: 15px; + font-weight: bold; + margin: 0; + padding: 5px 10px 4px 12px; + color: #888; } .mocha.isFocused .mochaTitlebar h3 { - color: #181818; + color: #181818; } .mochaToolbarWrapper { - width: 100%; /* For IE */ - position: relative; - height: 29px; - background: #f1f1f1; - overflow: hidden; - border-top: 1px solid #d9d9d9; + width: 100%; /* For IE */ + position: relative; + height: 29px; + background: #f1f1f1; + overflow: hidden; + border-top: 1px solid #d9d9d9; } div.mochaToolbarWrapper.bottom { - border: 0; - border-bottom: 1px solid #d9d9d9; + border: 0; + border-bottom: 1px solid #d9d9d9; } .mochaToolbar { - width: 100%; /* For IE */ - border-top: 1px solid #fff; + width: 100%; /* For IE */ + border-top: 1px solid #fff; } .mochaContentBorder { - border-top: 1px solid #dadada; - border-bottom: 1px solid #dadada; + border-top: 1px solid #dadada; + border-bottom: 1px solid #dadada; } -.mochaContentWrapper { /* Has a fixed height and scrollbars if required. */ - font-size: 12px; - overflow: auto; - background: #fff; +.mochaContentWrapper { /* Has a fixed height and scrollbars if required. */ + font-size: 12px; + overflow: auto; + background: #fff; } - + .mochaContent { - padding: 10px 12px; + padding: 10px 12px; } .mocha .handle { - position: absolute; - background: #0f0; - width: 3px; - height: 3px; - z-index: 2; - -ms-filter: "progid:DXImageTransform.Microsoft.Alpha(Opacity=0)"; /* IE8 */ - filter: progid:DXImageTransform.Microsoft.Alpha(Opacity=0); /* IE6 and 7*/ - opacity: .0; - -moz-opacity: .0; - overflow: hidden; - font-size: 1px; /* For IE6 */ + position: absolute; + background: #0f0; + width: 3px; + height: 3px; + z-index: 2; + -ms-filter: "progid:DXImageTransform.Microsoft.Alpha(Opacity=0)"; /* IE8 */ + filter: progid:DXImageTransform.Microsoft.Alpha(Opacity=0); /* IE6 and 7*/ + opacity: .0; + -moz-opacity: .0; + overflow: hidden; + font-size: 1px; /* For IE6 */ } -.mocha .corner { /* Corner resize handles */ - width: 10px; - height: 10px; - background: #f00; +.mocha .corner { /* Corner resize handles */ + width: 10px; + height: 10px; + background: #f00; } -.mocha .cornerSE { /* Bottom right resize handle */ - width: 20px; - height: 20px; - background: #fefefe; /* This is the color of the visible resize handle */ +.mocha .cornerSE { /* Bottom right resize handle */ + width: 20px; + height: 20px; + background: #fefefe; /* This is the color of the visible resize handle */ } .mochaCanvasHeader { - position: absolute; - top: 0; - left: 0; - background: transparent; - z-index: -1; - visibility: hidden; - overflow: hidden; + position: absolute; + top: 0; + left: 0; + background: transparent; + z-index: -1; + visibility: hidden; + overflow: hidden; } .mochaControls { - position: absolute; - width: 52px; - top: 8px; - right: 8px; - height: 14px; - z-index: 4; - background: transparent; + position: absolute; + width: 52px; + top: 8px; + right: 8px; + height: 14px; + z-index: 4; + background: transparent; } .mochaCanvasControls { - position: absolute; - top: 8px; - right: 8px; - z-index: 3; - background: transparent; + position: absolute; + top: 8px; + right: 8px; + z-index: 3; + background: transparent; } /* To use images for these buttons: 1. Set the useCanvasControls window option to false. 2. If you use a different button size you may need to reposition the controls. - Modify the controlsOffset window option. + Modify the controlsOffset window option. 2. Replcac the background-color with a background-image for each button. */ .mochaMinimizeButton, .mochaMaximizeButton, .mochaCloseButton { - float: right; - width: 14px; - height: 14px; - font-size: 1px; - cursor: pointer; - z-index: 4; - color: #666; - background-color: #fff; - margin-left: 5px; + float: right; + width: 14px; + height: 14px; + font-size: 1px; + cursor: pointer; + z-index: 4; + color: #666; + background-color: #fff; + margin-left: 5px; } .mochaMinimizeButton { - margin-left: 0; + margin-left: 0; } .mochaMaximizeButton { @@ -181,200 +180,203 @@ div.mochaToolbarWrapper.bottom { .mochaCloseButton { } -.mochaSpinner{ - display: none; - position: absolute; - bottom: 7px; - left: 6px; - width: 16px; - height: 16px; - background: url(../images/skin/spinner.gif) no-repeat; +.mochaSpinner { + display: none; + position: absolute; + bottom: 7px; + left: 6px; + width: 16px; + height: 16px; + background: url(../images/skin/spinner.gif) no-repeat; } .mochaIframe { - width: 100%; -} - + width: 100%; +} + /* Fix for IE6 select z-index issue */ .zIndexFix { - display: block; - position: absolute; - top: 0; - left: 0; - z-index: -1; - filter: mask(); - width: 100px; - height: 100px; - border: 1px solid transparent; + display: block; + position: absolute; + top: 0; + left: 0; + z-index: -1; + filter: mask(); + width: 100px; + height: 100px; + border: 1px solid transparent; } /* Viewport overlays ---------------------------------------------------------------- */ #modalOverlay { - display: none; - position: fixed; - top: 0; - left: 0; - width: 100%; - background: #000; - -ms-filter: "progid:DXImageTransform.Microsoft.Alpha(Opacity=0)"; /* IE8 */ - filter: progid:DXImageTransform.Microsoft.Alpha(Opacity=0); /* IE6 and 7*/ - opacity: 0; - -moz-opacity: 0; - z-index: 10000; + display: none; + position: fixed; + top: 0; + left: 0; + width: 100%; + background: #000; + -ms-filter: "progid:DXImageTransform.Microsoft.Alpha(Opacity=0)"; /* IE8 */ + filter: progid:DXImageTransform.Microsoft.Alpha(Opacity=0); /* IE6 and 7*/ + opacity: 0; + -moz-opacity: 0; + z-index: 10000; } /* Fix for IE6 select z-index issue */ #modalFix { - display: none; - position: absolute; - top: 0; - left: 0; - width: 100%; - -ms-filter: "progid:DXImageTransform.Microsoft.Alpha(Opacity=0)"; /* IE8 */ - filter: progid:DXImageTransform.Microsoft.Alpha(Opacity=0); /* IE6 and 7*/ - opacity: 0; - -moz-opacity: 0; - z-index: 9999; + display: none; + position: absolute; + top: 0; + left: 0; + width: 100%; + -ms-filter: "progid:DXImageTransform.Microsoft.Alpha(Opacity=0)"; /* IE8 */ + filter: progid:DXImageTransform.Microsoft.Alpha(Opacity=0); /* IE6 and 7*/ + opacity: 0; + -moz-opacity: 0; + z-index: 9999; } /* Underlay */ -#windowUnderlay { - position: fixed; - top: 0; - left: 0; - width: 100%; - background: #fff; +#windowUnderlay { + position: fixed; + top: 0; + left: 0; + width: 100%; + background: #fff; } -* html #windowUnderlay { - position: absolute; +* html #windowUnderlay { + position: absolute; } /* The replaced class is used internally when converting CSS values to Canvas. These classes should not be removed. */ -.mocha.replaced, .mochaTitlebar.replaced, .mochaMinimizeButton.replaced, .mochaMaximizeButton.replaced, .mochaCloseButton.replaced { - background-color: transparent !important; +.mocha.replaced, .mochaTitlebar.replaced, .mochaMinimizeButton.replaced, +.mochaMaximizeButton.replaced, .mochaCloseButton.replaced { + background-color: transparent !important; } .windowClosed { - visibility: hidden; - display: none; - position: absolute; - top: -20000px; - left: -20000px; - z-index: -1; - overflow: hidden; + visibility: hidden; + display: none; + position: absolute; + top: -20000px; + left: -20000px; + z-index: -1; + overflow: hidden; } -.windowClosed .mochaContentBorder, .windowClosed .mochaToolbarWrapper, .windowClosed .mochaTitlebar, .windowClosed .mochaControls, +.windowClosed .mochaContentBorder, .windowClosed .mochaToolbarWrapper, +.windowClosed .mochaTitlebar, .windowClosed .mochaControls, .windowClosed .mochaCanvasControls { - position: absolute; - top: 0; - left: 0; - visibility: hidden; - display: none; - z-index: -1; -} + position: absolute; + top: 0; + left: 0; + visibility: hidden; + display: none; + z-index: -1; +} /* Modals */ .modal2 { - border: 8px solid #fff; + border: 8px solid #fff; } .modal2 .mochaContentBorder { - border-width: 0px; + border-width: 0px; } - + /* Window Themes */ .mocha.no-canvas { - background: #e5e5e5; - border: 1px solid #555; + background: #e5e5e5; + border: 1px solid #555; } .mocha.no-canvas .mochaTitlebar { - background: #e5e5e5; + background: #e5e5e5; } .mocha.transparent .mochaTitlebar h3 { - color: #fff; - display: none; + color: #fff; + display: none; } .mocha.transparent .mochaContentWrapper { - background: transparent; + background: transparent; } .mocha.notification { - background: #cedff2; + background: #cedff2; } .mocha.notification .mochaTitlebar { - -ms-filter: "progid:DXImageTransform.Microsoft.Alpha(Opacity=0)"; /* IE8 */ - filter: progid:DXImageTransform.Microsoft.Alpha(Opacity=0); /* IE6 and 7*/ - opacity: .0; - -moz-opacity: 0; + -ms-filter: "progid:DXImageTransform.Microsoft.Alpha(Opacity=0)"; /* IE8 */ + filter: progid:DXImageTransform.Microsoft.Alpha(Opacity=0); /* IE6 and 7*/ + opacity: .0; + -moz-opacity: 0; } .mocha.notification .mochaContentBorder { - border-width: 0px; + border-width: 0px; } .mocha.notification .mochaContentWrapper { - text-align: center; - font-size: 12px; - font-weight: bold; - background: transparent; + text-align: center; + font-size: 12px; + font-weight: bold; + background: transparent; } /* Example Window Themes */ #about_contentWrapper { - background: #e5e5e5 url(../images/skin/logo2.gif) 3px 3px no-repeat; + background: #e5e5e5 url(../images/skin/logo2.gif) 3px 3px no-repeat; } #builder_contentWrapper { - background: #f5f5f7; + background: #f5f5f7; } #json01 .mochaTitlebar { - background: #6dd2db; + background: #6dd2db; } #json02 .mochaTitlebar { - background: #6db6db; + background: #6db6db; } #json03 .mochaTitlebar { - background: #6d92db; + background: #6d92db; } .jsonExample .mochaTitlebar h3 { - color: #ddd; -} + color: #ddd; +} /* This does not work in IE6. */ .isFocused.jsonExample .mochaTitlebar h3 { - color: #fff; + color: #fff; } #fxmorpherExample .mochaContentWrapper { - background: #577a9e; + background: #577a9e; } #clock { - background: #fff; + background: #fff; } /* Workaround to make invisible buttons clickable */ + .mochaMinimizeButton.replaced, .mochaMaximizeButton.replaced, .mochaCloseButton.replaced { - background-image: url(data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7) !important; + background-image: url(data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7) !important; } /* iOS iframe scrolling */ diff --git a/src/webui/www/private/css/dynamicTable.css b/src/webui/www/private/css/dynamicTable.css index 8f20d81c4..58f6f09e5 100644 --- a/src/webui/www/private/css/dynamicTable.css +++ b/src/webui/www/private/css/dynamicTable.css @@ -1,11 +1,10 @@ - - /************************************************************** Dynamic Table v 0.4 **************************************************************/ + .dynamicTable tbody tr { background-color: #fff; } @@ -34,8 +33,8 @@ } #transferList img.stateIcon { - height: 1.3em; - vertical-align: middle; + height: 1.3em; + vertical-align: middle; margin-bottom: -1px; } @@ -45,7 +44,7 @@ tr.dynamicTableHeader { .dynamicTable { table-layout: fixed; - width :1%; + width: 1%; padding: 0; border-spacing: 0; } @@ -63,7 +62,7 @@ tr.dynamicTableHeader { } .dynamicTable td { - padding:0px 4px; + padding: 0px 4px; white-space: nowrap; } diff --git a/src/webui/www/private/css/style.css b/src/webui/www/private/css/style.css index f87fed980..82dde7e84 100644 --- a/src/webui/www/private/css/style.css +++ b/src/webui/www/private/css/style.css @@ -1,9 +1,16 @@ /* Reset */ /*ul,ol,dl,li,dt,dd,h1,h2,h3,h4,h5,h6,pre,form,body,html,p,blockquote,fieldset,input,object,iframe { margin: 0; padding: 0; }*/ -a img,:link img,:visited img { border: none; } + +a img, :link img, :visited img { + border: none; +} + /*table { border-collapse: collapse; border-spacing: 0; }*/ -:focus { outline: none; } + +:focus { + outline: none; +} /* Structure */ @@ -100,7 +107,7 @@ pre { margin: 0 0 10px 0; padding: 10px; border: 1px solid #d1d7dc; - } +} /* Dividers */ @@ -116,13 +123,13 @@ hr { } #urls { - width:90%; - height:100%; + width: 90%; + height: 100%; } #trackersUrls { - width:90%; - height:100%; + width: 90%; + height: 100%; } #Filters ul { @@ -172,45 +179,75 @@ a.propButton img { /* context menu specific */ -.contextMenu { border:1px solid #999; padding:0; background:#eee; list-style-type:none; display:none;} -.contextMenu .separator { border-top:1px solid #999; } -.contextMenu li { margin:0; padding:0;} +.contextMenu { + border: 1px solid #999; + padding: 0; + background: #eee; + list-style-type: none; + display: none; +} + +.contextMenu .separator { + border-top: 1px solid #999; +} + +.contextMenu li { + margin: 0; + padding: 0; +} + .contextMenu li a { display: block; padding: 5px 20px 5px 5px; font-size: 12px; text-decoration: none; - font-family: tahoma,arial,sans-serif; + font-family: tahoma, arial, sans-serif; color: #000; white-space: nowrap; } -.contextMenu li a:hover { background-color:#ddd; } -.contextMenu li a.disabled { color:#ccc; font-style:italic; } -.contextMenu li a.disabled:hover { background-color:#eee; } + +.contextMenu li a:hover { + background-color: #ddd; +} + +.contextMenu li a.disabled { + color: #ccc; + font-style: italic; +} + +.contextMenu li a.disabled:hover { + background-color: #eee; +} + .contextMenu li ul { padding: 0; - border:1px solid #999; padding:0; background:#eee; - list-style-type:none; + border: 1px solid #999; + padding: 0; + background: #eee; + list-style-type: none; position: absolute; left: -999em; z-index: 8000; margin: -29px 0 0 100%; width: 164px; } + .contextMenu li ul li a { position: relative; } + .contextMenu li a.arrow-right, .contextMenu li a:hover.arrow-right { background-image: url(../images/skin/arrow-right.gif); background-repeat: no-repeat; background-position: right center; } + .contextMenu li:hover ul, .contextMenu li.ieHover ul, .contextMenu li li.ieHover ul, .contextMenu li li li.ieHover ul, .contextMenu li li:hover ul, -.contextMenu li li li:hover ul { /* lists nested under hovered list items */ +.contextMenu li li li:hover ul { /* lists nested under hovered list items */ left: auto; } @@ -218,7 +255,7 @@ a.propButton img { width: 16px; height: 16px; margin-bottom: -4px; - -ms-interpolation-mode : bicubic; + -ms-interpolation-mode: bicubic; } /* Sliders */ @@ -280,6 +317,7 @@ a.propButton img { } /* Mocha Customization */ + #mochaToolbar { margin-top: 5px; } @@ -392,7 +430,8 @@ td.generalLabel { line-height: 20px; } -#trackersTable, #webseedsTable { +#trackersTable, +#webseedsTable { line-height: 25px; } @@ -425,7 +464,7 @@ td.generalLabel { } .select-watched-folder-editable { - position:relative; + position: relative; background-color: white; border: solid grey 1px; width: 160px; diff --git a/src/webui/www/private/download.html b/src/webui/www/private/download.html index 3de510b1d..6073cce8d 100644 --- a/src/webui/www/private/download.html +++ b/src/webui/www/private/download.html @@ -1,5 +1,6 @@ + QBT_TR(Add Torrent Links)QBT_TR[CONTEXT=downloadFromURL] @@ -8,84 +9,85 @@ + - -
-
-
-

QBT_TR(Download Torrents from their URLs or Magnet links)QBT_TR[CONTEXT=HttpServer]

- -

QBT_TR(Only one link per line)QBT_TR[CONTEXT=HttpServer]

-
-
- - -
-
- - -
-
- - -
-
- - -
-
- - - -
-
- - -
-
- - -
-
- - -
-
- - -
-
- - -
-
- - -
-
- -
-
-
-
- -
+ $('start_torrent').addEventListener('change', function() { + $('add_paused').disabled = $('start_torrent').checked; + }); + +
+ diff --git a/src/webui/www/private/downloadlimit.html b/src/webui/www/private/downloadlimit.html index 4894702a0..e02902976 100644 --- a/src/webui/www/private/downloadlimit.html +++ b/src/webui/www/private/downloadlimit.html @@ -1,5 +1,6 @@ + QBT_TR(Torrent Download Speed Limiting)QBT_TR[CONTEXT=TransferListWidget] @@ -9,54 +10,56 @@ - -
-
-
QBT_TR(Download limit:)QBT_TR[CONTEXT=PropertiesWidget] QBT_TR(KiB/s)QBT_TR[CONTEXT=SpeedLimitDialog]
-
-
-
-
-
-
- - -
- + +
+
+
QBT_TR(Download limit:)QBT_TR[CONTEXT=PropertiesWidget] QBT_TR(KiB/s)QBT_TR[CONTEXT=SpeedLimitDialog]
+
+
+
+
+
+
+ + +
+ + + diff --git a/src/webui/www/private/filters.html b/src/webui/www/private/filters.html index 3a9729277..150e89ece 100644 --- a/src/webui/www/private/filters.html +++ b/src/webui/www/private/filters.html @@ -17,33 +17,33 @@ + + diff --git a/src/webui/www/private/newcategory.html b/src/webui/www/private/newcategory.html index 9bc4ed957..eaa62752c 100644 --- a/src/webui/www/private/newcategory.html +++ b/src/webui/www/private/newcategory.html @@ -1,5 +1,6 @@ + QBT_TR(New Category)QBT_TR[CONTEXT=TransferListWidget] @@ -10,7 +11,7 @@ var newCategoryKeyboardEvents = new Keyboard({ defaultEventType: 'keydown', events: { - 'enter': function (event) { + 'enter': function(event) { $('newCategoryButton').click(); event.preventDefault(); } @@ -38,13 +39,12 @@ data: { category: categoryName }, - onComplete: function () { + onComplete: function() { window.parent.closeWindows(); } }).send(); } - else - { + else { new Request({ url: 'api/v2/torrents/setCategory', method: 'post', @@ -52,7 +52,7 @@ hashes: hashesList, category: categoryName }, - onComplete: function () { + onComplete: function() { window.parent.closeWindows(); } }).send(); @@ -61,13 +61,15 @@ }); +

QBT_TR(Category)QBT_TR[CONTEXT=TransferListWidget]:

- +
- +
+ diff --git a/src/webui/www/private/preferences.html b/src/webui/www/private/preferences.html index 1db6db176..957afbe9e 100644 --- a/src/webui/www/private/preferences.html +++ b/src/webui/www/private/preferences.html @@ -1,5 +1,6 @@ + QBT_TR(Download from URLs)QBT_TR[CONTEXT=downloadFromURL] @@ -9,43 +10,45 @@ + - - + + - + $('PrefDownloadsLink').addEvent('click', function(e) { + $$('.PrefTab').addClass('invisible'); + $('DownloadsTab').removeClass('invisible'); + }); + $('PrefConnectionLink').addEvent('click', function(e) { + $$('.PrefTab').addClass('invisible'); + $('ConnectionTab').removeClass('invisible'); + }); + $('PrefSpeedLink').addEvent('click', function(e) { + $$('.PrefTab').addClass('invisible'); + $('SpeedTab').removeClass('invisible'); + }); + $('PrefBittorrentLink').addEvent('click', function(e) { + $$('.PrefTab').addClass('invisible'); + $('BittorrentTab').removeClass('invisible'); + }); + $('PrefWebUILink').addEvent('click', function(e) { + $$('.PrefTab').addClass('invisible'); + $('WebUITab').removeClass('invisible'); + }); + + diff --git a/src/webui/www/private/preferences_content.html b/src/webui/www/private/preferences_content.html index 872c8e1be..aae68c59f 100644 --- a/src/webui/www/private/preferences_content.html +++ b/src/webui/www/private/preferences_content.html @@ -1,766 +1,774 @@
-
- QBT_TR(Hard Disk)QBT_TR[CONTEXT=HttpServer] -
- - -
-
- - - -
- -
- - - -

- QBT_TR(Automatically add torrents from:)QBT_TR[CONTEXT=OptionsDialog]
- - - - - - - -
QBT_TR(Monitored Folder)QBT_TR[CONTEXT=ScanFoldersModel]QBT_TR(Override Save Location)QBT_TR[CONTEXT=ScanFoldersModel]
-
- - - Add -
-

- -    -
- -    -
-
+
+ QBT_TR(Hard Disk)QBT_TR[CONTEXT=HttpServer] +
+ + +
+
+ + + +
+ +
+ + + +

QBT_TR(Automatically add torrents from:)QBT_TR[CONTEXT=OptionsDialog]
+ + + + + + + + + + + + + + +
QBT_TR(Monitored Folder)QBT_TR[CONTEXT=ScanFoldersModel]QBT_TR(Override Save Location)QBT_TR[CONTEXT=ScanFoldersModel]
+
+ + + Add +
+

+ +    +
+ +    +
+
-
- - -
- -
-
- -
-
- -
-
- -
- -
-
- -
-
-
+
+ + +
+ +
+
+ +
+
+ +
+
+ +
+ +
+
+ +
+
+
-
- - -
-
QBT_TR(Supported parameters (case sensitive):)QBT_TR[CONTEXT=OptionsDialog] -
    -
  • QBT_TR(%N: Torrent name)QBT_TR[CONTEXT=OptionsDialog]
  • -
  • QBT_TR(%L: Category)QBT_TR[CONTEXT=OptionsDialog]
  • -
  • QBT_TR(%G: Tags (seperated by comma))QBT_TR[CONTEXT=OptionsDialog]
  • -
  • QBT_TR(%F: Content path (same as root path for multifile torrent))QBT_TR[CONTEXT=OptionsDialog]
  • -
  • QBT_TR(%R: Root path (first torrent subdirectory path))QBT_TR[CONTEXT=OptionsDialog]
  • -
  • QBT_TR(%D: Save path)QBT_TR[CONTEXT=OptionsDialog]
  • -
  • QBT_TR(%C: Number of files)QBT_TR[CONTEXT=OptionsDialog]
  • -
  • QBT_TR(%Z: Torrent size (bytes))QBT_TR[CONTEXT=OptionsDialog]
  • -
  • QBT_TR(%T: Current tracker)QBT_TR[CONTEXT=OptionsDialog]
  • -
  • QBT_TR(%I: Info hash)QBT_TR[CONTEXT=OptionsDialog]
  • -
- QBT_TR(Tip: Encapsulate parameter with quotation marks to avoid text being cut off at whitespace (e.g., "%N"))QBT_TR[CONTEXT=OptionsDialog] -
-
+
+ + +
+
QBT_TR(Supported parameters (case sensitive):)QBT_TR[CONTEXT=OptionsDialog] +
    +
  • QBT_TR(%N: Torrent name)QBT_TR[CONTEXT=OptionsDialog]
  • +
  • QBT_TR(%L: Category)QBT_TR[CONTEXT=OptionsDialog]
  • +
  • QBT_TR(%G: Tags (seperated by comma))QBT_TR[CONTEXT=OptionsDialog]
  • +
  • QBT_TR(%F: Content path (same as root path for multifile torrent))QBT_TR[CONTEXT=OptionsDialog]
  • +
  • QBT_TR(%R: Root path (first torrent subdirectory path))QBT_TR[CONTEXT=OptionsDialog]
  • +
  • QBT_TR(%D: Save path)QBT_TR[CONTEXT=OptionsDialog]
  • +
  • QBT_TR(%C: Number of files)QBT_TR[CONTEXT=OptionsDialog]
  • +
  • QBT_TR(%Z: Torrent size (bytes))QBT_TR[CONTEXT=OptionsDialog]
  • +
  • QBT_TR(%T: Current tracker)QBT_TR[CONTEXT=OptionsDialog]
  • +
  • QBT_TR(%I: Info hash)QBT_TR[CONTEXT=OptionsDialog]
  • +
+ QBT_TR(Tip: Encapsulate parameter with quotation marks to avoid text being cut off at whitespace (e.g., "%N"))QBT_TR[CONTEXT=OptionsDialog] +
+

-
+
diff --git a/src/webui/www/private/properties.html b/src/webui/www/private/properties.html index 72c849496..66486e917 100644 --- a/src/webui/www/private/properties.html +++ b/src/webui/www/private/properties.html @@ -1,10 +1,10 @@ diff --git a/src/webui/www/private/properties_content.html b/src/webui/www/private/properties_content.html index 9362d3f91..ac17525d5 100644 --- a/src/webui/www/private/properties_content.html +++ b/src/webui/www/private/properties_content.html @@ -1,49 +1,81 @@
- QBT_TR(Transfer)QBT_TR[CONTEXT=PropertiesWidget] - - - - - - - - - - - - - - - - - - - - - - -
QBT_TR(Time Active:)QBT_TR[CONTEXT=PropertiesWidget]QBT_TR(ETA:)QBT_TR[CONTEXT=PropertiesWidget]QBT_TR(Connections:)QBT_TR[CONTEXT=PropertiesWidget]
QBT_TR(Downloaded:)QBT_TR[CONTEXT=PropertiesWidget]QBT_TR(Uploaded:)QBT_TR[CONTEXT=PropertiesWidget]QBT_TR(Seeds:)QBT_TR[CONTEXT=PropertiesWidget]
QBT_TR(Download Speed:)QBT_TR[CONTEXT=PropertiesWidget]QBT_TR(Upload Speed:)QBT_TR[CONTEXT=PropertiesWidget]QBT_TR(Peers:)QBT_TR[CONTEXT=PropertiesWidget]
QBT_TR(Download Limit:)QBT_TR[CONTEXT=PropertiesWidget]QBT_TR(Upload Limit:)QBT_TR[CONTEXT=PropertiesWidget]QBT_TR(Wasted:)QBT_TR[CONTEXT=PropertiesWidget]
QBT_TR(Share Ratio:)QBT_TR[CONTEXT=PropertiesWidget]QBT_TR(Reannounce In:)QBT_TR[CONTEXT=PropertiesWidget]QBT_TR(Last Seen Complete:)QBT_TR[CONTEXT=PropertiesWidget]
+ QBT_TR(Transfer)QBT_TR[CONTEXT=PropertiesWidget] + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
QBT_TR(Time Active:)QBT_TR[CONTEXT=PropertiesWidget]QBT_TR(ETA:)QBT_TR[CONTEXT=PropertiesWidget]QBT_TR(Connections:)QBT_TR[CONTEXT=PropertiesWidget]
QBT_TR(Downloaded:)QBT_TR[CONTEXT=PropertiesWidget]QBT_TR(Uploaded:)QBT_TR[CONTEXT=PropertiesWidget]QBT_TR(Seeds:)QBT_TR[CONTEXT=PropertiesWidget]
QBT_TR(Download Speed:)QBT_TR[CONTEXT=PropertiesWidget]QBT_TR(Upload Speed:)QBT_TR[CONTEXT=PropertiesWidget]QBT_TR(Peers:)QBT_TR[CONTEXT=PropertiesWidget]
QBT_TR(Download Limit:)QBT_TR[CONTEXT=PropertiesWidget]QBT_TR(Upload Limit:)QBT_TR[CONTEXT=PropertiesWidget]QBT_TR(Wasted:)QBT_TR[CONTEXT=PropertiesWidget]
QBT_TR(Share Ratio:)QBT_TR[CONTEXT=PropertiesWidget]QBT_TR(Reannounce In:)QBT_TR[CONTEXT=PropertiesWidget]QBT_TR(Last Seen Complete:)QBT_TR[CONTEXT=PropertiesWidget]
- QBT_TR(Information)QBT_TR[CONTEXT=PropertiesWidget] - - - - - - - - - - - - - - - - -
QBT_TR(Total Size:)QBT_TR[CONTEXT=PropertiesWidget]QBT_TR(Pieces:)QBT_TR[CONTEXT=PropertiesWidget]QBT_TR(Created By:)QBT_TR[CONTEXT=PropertiesWidget]
QBT_TR(Added On:)QBT_TR[CONTEXT=PropertiesWidget]QBT_TR(Completed On:)QBT_TR[CONTEXT=PropertiesWidget]QBT_TR(Created On:)QBT_TR[CONTEXT=PropertiesWidget]
QBT_TR(Torrent Hash:)QBT_TR[CONTEXT=PropertiesWidget]
QBT_TR(Save Path:)QBT_TR[CONTEXT=PropertiesWidget]
QBT_TR(Comment:)QBT_TR[CONTEXT=PropertiesWidget]
+ QBT_TR(Information)QBT_TR[CONTEXT=PropertiesWidget] + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
QBT_TR(Total Size:)QBT_TR[CONTEXT=PropertiesWidget]QBT_TR(Pieces:)QBT_TR[CONTEXT=PropertiesWidget]QBT_TR(Created By:)QBT_TR[CONTEXT=PropertiesWidget]
QBT_TR(Added On:)QBT_TR[CONTEXT=PropertiesWidget]QBT_TR(Completed On:)QBT_TR[CONTEXT=PropertiesWidget]QBT_TR(Created On:)QBT_TR[CONTEXT=PropertiesWidget]
QBT_TR(Torrent Hash:)QBT_TR[CONTEXT=PropertiesWidget]
QBT_TR(Save Path:)QBT_TR[CONTEXT=PropertiesWidget]
QBT_TR(Comment:)QBT_TR[CONTEXT=PropertiesWidget]
diff --git a/src/webui/www/private/rename.html b/src/webui/www/private/rename.html index 299e1d650..7d573f58e 100644 --- a/src/webui/www/private/rename.html +++ b/src/webui/www/private/rename.html @@ -1,5 +1,6 @@ + QBT_TR(Rename)QBT_TR[CONTEXT=TransferListWidget] @@ -11,7 +12,7 @@ var renameKeyboardEvents = new Keyboard({ defaultEventType: 'keydown', events: { - 'enter': function (event) { + 'enter': function(event) { $('renameButton').click(); event.preventDefault(); } @@ -42,7 +43,7 @@ hash: hash, name: name }, - onComplete: function () { + onComplete: function() { window.parent.closeWindows(); } }).send(); @@ -51,13 +52,15 @@ }); +

QBT_TR(New name)QBT_TR[CONTEXT=TransferListWidget]:

- +
- +
+ diff --git a/src/webui/www/private/scripts/client.js b/src/webui/www/private/scripts/client.js index c4361e3a8..3c4f67b74 100644 --- a/src/webui/www/private/scripts/client.js +++ b/src/webui/www/private/scripts/client.js @@ -25,15 +25,15 @@ torrentsTable = new TorrentsTable(); torrentPeersTable = new TorrentPeersTable(); -var updatePropertiesPanel = function () {}; +var updatePropertiesPanel = function() {}; -var updateTorrentData = function () {}; -var updateTrackersData = function () {}; -var updateTorrentPeersData = function () {}; -var updateWebSeedsData = function () {}; -var updateTorrentFilesData = function () {}; +var updateTorrentData = function() {}; +var updateTrackersData = function() {}; +var updateTorrentPeersData = function() {}; +var updateWebSeedsData = function() {}; +var updateTorrentFilesData = function() {}; -var updateMainData = function () {}; +var updateMainData = function() {}; var alternativeSpeedLimits = false; var queueing_enabled = true; var syncMainDataTimerPeriod = 1500; @@ -46,12 +46,12 @@ var CATEGORIES_UNCATEGORIZED = 2; var category_list = {}; var selected_category = CATEGORIES_ALL; -var setCategoryFilter = function(){}; +var setCategoryFilter = function() {}; var selected_filter = getLocalStorageItem('selected_filter', 'all'); -var setFilter = function(){}; +var setFilter = function() {}; -var loadSelectedCategory = function () { +var loadSelectedCategory = function() { selected_category = getLocalStorageItem('selected_category', CATEGORIES_ALL); }; loadSelectedCategory(); @@ -65,9 +65,9 @@ function genHash(string) { return hash; } -window.addEvent('load', function () { +window.addEvent('load', function() { - var saveColumnSizes = function () { + var saveColumnSizes = function() { var filters_width = $('Filters').getSize().x; var properties_height_rel = $('propertiesPanel').getSize().y / Window.getSize().y; localStorage.setItem('filters_width', filters_width); @@ -92,17 +92,17 @@ window.addEvent('load', function () { else filt_w = 120; new MochaUI.Column({ - id : 'filtersColumn', - placement : 'left', - onResize : saveColumnSizes, - width : filt_w, - resizeLimit : [100, 300] + id: 'filtersColumn', + placement: 'left', + onResize: saveColumnSizes, + width: filt_w, + resizeLimit: [100, 300] }); new MochaUI.Column({ - id : 'mainColumn', - placement : 'main', - width : null, - resizeLimit : [100, 300] + id: 'mainColumn', + placement: 'main', + width: null, + resizeLimit: [100, 300] }); setCategoryFilter = function(hash) { @@ -113,7 +113,7 @@ window.addEvent('load', function () { updateMainData(); }; - setFilter = function (f) { + setFilter = function(f) { // Visually Select the right filter $("all_filter").removeClass("selectedFilter"); $("downloading_filter").removeClass("selectedFilter"); @@ -133,22 +133,22 @@ window.addEvent('load', function () { }; new MochaUI.Panel({ - id : 'Filters', - title : 'Panel', - header : false, - padding : { - top : 0, - right : 0, - bottom : 0, - left : 0 + id: 'Filters', + title: 'Panel', + header: false, + padding: { + top: 0, + right: 0, + bottom: 0, + left: 0 }, - loadMethod : 'xhr', - contentURL : 'filters.html', - onContentLoaded : function () { + loadMethod: 'xhr', + contentURL: 'filters.html', + onContentLoaded: function() { setFilter(selected_filter); }, - column : 'filtersColumn', - height : 300 + column: 'filtersColumn', + height: 300 }); initializeWindows(); @@ -203,7 +203,10 @@ window.addEvent('load', function () { } var categoryHash = genHash(category); if (category_list[categoryHash] === null) // This should not happen - category_list[categoryHash] = {name: category, torrents: []}; + category_list[categoryHash] = { + name: category, + torrents: [] + }; if (!Object.contains(category_list[categoryHash].torrents, torrent['hash'])) { removeTorrentFromCategoryList(torrent['hash']); category_list[categoryHash].torrents = category_list[categoryHash].torrents.combine([torrent['hash']]); @@ -235,10 +238,13 @@ window.addEvent('load', function () { categoryList.empty(); var create_link = function(hash, text, count) { - var html = '' + - '' + - escapeHtml(text) + ' (' + count + ')' + ''; - var el = new Element('li', {id: hash, html: html}); + var html = '' + + '' + + escapeHtml(text) + ' (' + count + ')' + ''; + var el = new Element('li', { + id: hash, + html: html + }); categoriesFilterContextMenu.addTarget(el); return el; }; @@ -281,21 +287,21 @@ window.addEvent('load', function () { }; var syncMainDataTimer; - var syncMainData = function () { + var syncMainData = function() { var url = new URI('api/v2/sync/maindata'); url.setData('rid', syncMainDataLastResponseId); var request = new Request.JSON({ - url : url, - noCache : true, - method : 'get', - onFailure : function () { + url: url, + noCache: true, + method: 'get', + onFailure: function() { var errorDiv = $('error_div'); if (errorDiv) errorDiv.set('html', 'QBT_TR(qBittorrent client is not reachable)QBT_TR[CONTEXT=HttpServer]'); clearTimeout(syncMainDataTimer); syncMainDataTimer = syncMainData.delay(2000); }, - onSuccess : function (response) { + onSuccess: function(response) { $('error_div').set('html', ''); if (response) { var torrentsTableSelectedRows; @@ -312,7 +318,10 @@ window.addEvent('load', function () { if (response['categories']) { response['categories'].each(function(category) { var categoryHash = genHash(category); - category_list[categoryHash] = {name: category, torrents: []}; + category_list[categoryHash] = { + name: category, + torrents: [] + }; }); update_categories = true; } @@ -341,7 +350,7 @@ window.addEvent('load', function () { setupCopyEventHandler(); } if (response['torrents_removed']) - response['torrents_removed'].each(function (hash) { + response['torrents_removed'].each(function(hash) { torrentsTable.removeRow(hash); removeTorrentFromCategoryList(hash); update_categories = true; // Always to update All category @@ -350,7 +359,7 @@ window.addEvent('load', function () { torrentsTable.altRow(); if (response['server_state']) { var tmp = response['server_state']; - for(var k in tmp) + for (var k in tmp) serverState[k] = tmp[k]; processServerState(); } @@ -376,7 +385,7 @@ window.addEvent('load', function () { syncMainDataTimer = syncMainData.delay(100); }; - var processServerState = function () { + var processServerState = function() { var transfer_info = friendlyUnit(serverState.dl_info_speed, true); if (serverState.dl_rate_limit > 0) transfer_info += " [" + friendlyUnit(serverState.dl_rate_limit, true) + "]"; @@ -390,7 +399,8 @@ window.addEvent('load', function () { if (speedInTitle) { document.title = "QBT_TR([D: %1, U: %2] qBittorrent %3)QBT_TR[CONTEXT=MainWindow]".replace("%1", friendlyUnit(serverState.dl_info_speed, true)).replace("%2", friendlyUnit(serverState.up_info_speed, true)).replace("%3", "${VERSION}"); document.title += " QBT_TR(Web UI)QBT_TR[CONTEXT=OptionsDialog]"; - }else + } + else document.title = "qBittorrent ${VERSION} QBT_TR(Web UI)QBT_TR[CONTEXT=OptionsDialog]"; $('DHTNodes').set('html', 'QBT_TR(DHT: %1 nodes)QBT_TR[CONTEXT=StatusBar]'.replace("%1", serverState.dht_nodes)); @@ -460,16 +470,17 @@ window.addEvent('load', function () { // Change icon immediately to give some feedback updateAltSpeedIcon(!alternativeSpeedLimits); - new Request({url: 'api/v2/transfer/toggleSpeedLimitsMode', - method: 'post', - onComplete: function() { - alternativeSpeedLimits = !alternativeSpeedLimits; - updateMainData(); - }, - onFailure: function() { - // Restore icon in case of failure - updateAltSpeedIcon(alternativeSpeedLimits); - } + new Request({ + url: 'api/v2/transfer/toggleSpeedLimitsMode', + method: 'post', + onComplete: function() { + alternativeSpeedLimits = !alternativeSpeedLimits; + updateMainData(); + }, + onFailure: function() { + // Restore icon in case of failure + updateAltSpeedIcon(alternativeSpeedLimits); + } }).send(); }); @@ -517,23 +528,23 @@ window.addEvent('load', function () { $('StatisticsLink').addEvent('click', StatisticsLinkFN); new MochaUI.Panel({ - id : 'transferList', - title : 'Panel', - header : false, - padding : { - top : 0, - right : 0, - bottom : 0, - left : 0 + id: 'transferList', + title: 'Panel', + header: false, + padding: { + top: 0, + right: 0, + bottom: 0, + left: 0 }, - loadMethod : 'xhr', - contentURL : 'transferlist.html', - onContentLoaded : function () { + loadMethod: 'xhr', + contentURL: 'transferlist.html', + onContentLoaded: function() { updateMainData(); }, - column : 'mainColumn', - onResize : saveColumnSizes, - height : null + column: 'mainColumn', + onResize: saveColumnSizes, + height: null }); var prop_h = localStorage.getItem('properties_height_rel'); if ($defined(prop_h)) @@ -541,22 +552,22 @@ window.addEvent('load', function () { else prop_h = Window.getSize().y / 2.0; new MochaUI.Panel({ - id : 'propertiesPanel', - title : 'Panel', - header : true, - padding : { - top : 0, - right : 0, - bottom : 0, - left : 0 + id: 'propertiesPanel', + title: 'Panel', + header: true, + padding: { + top: 0, + right: 0, + bottom: 0, + left: 0 }, - contentURL : 'properties_content.html', - require : { - css : ['css/Tabs.css', 'css/dynamicTable.css'], - js : ['scripts/prop-general.js', 'scripts/prop-trackers.js', 'scripts/prop-webseeds.js', 'scripts/prop-files.js'], + contentURL: 'properties_content.html', + require: { + css: ['css/Tabs.css', 'css/dynamicTable.css'], + js: ['scripts/prop-general.js', 'scripts/prop-trackers.js', 'scripts/prop-webseeds.js', 'scripts/prop-files.js'], }, - tabsURL : 'properties.html', - tabsOnload : function() { + tabsURL: 'properties.html', + tabsOnload: function() { MochaUI.initializeTabs('propertiesTabs'); updatePropertiesPanel = function() { @@ -572,7 +583,7 @@ window.addEvent('load', function () { updateTorrentFilesData(); }; - $('PropGeneralLink').addEvent('click', function(e){ + $('PropGeneralLink').addEvent('click', function(e) { $('prop_general').removeClass("invisible"); $('prop_trackers').addClass("invisible"); $('prop_webseeds').addClass("invisible"); @@ -582,7 +593,7 @@ window.addEvent('load', function () { localStorage.setItem('selected_tab', this.id); }); - $('PropTrackersLink').addEvent('click', function(e){ + $('PropTrackersLink').addEvent('click', function(e) { $('prop_trackers').removeClass("invisible"); $('prop_general').addClass("invisible"); $('prop_webseeds').addClass("invisible"); @@ -592,7 +603,7 @@ window.addEvent('load', function () { localStorage.setItem('selected_tab', this.id); }); - $('PropPeersLink').addEvent('click', function(e){ + $('PropPeersLink').addEvent('click', function(e) { $('prop_peers').removeClass("invisible"); $('prop_trackers').addClass("invisible"); $('prop_general').addClass("invisible"); @@ -602,7 +613,7 @@ window.addEvent('load', function () { localStorage.setItem('selected_tab', this.id); }); - $('PropWebSeedsLink').addEvent('click', function(e){ + $('PropWebSeedsLink').addEvent('click', function(e) { $('prop_webseeds').removeClass("invisible"); $('prop_general').addClass("invisible"); $('prop_trackers').addClass("invisible"); @@ -612,7 +623,7 @@ window.addEvent('load', function () { localStorage.setItem('selected_tab', this.id); }); - $('PropFilesLink').addEvent('click', function(e){ + $('PropFilesLink').addEvent('click', function(e) { $('prop_files').removeClass("invisible"); $('prop_general').addClass("invisible"); $('prop_trackers').addClass("invisible"); @@ -622,12 +633,12 @@ window.addEvent('load', function () { localStorage.setItem('selected_tab', this.id); }); - $('propertiesPanel_collapseToggle').addEvent('click', function(e){ + $('propertiesPanel_collapseToggle').addEvent('click', function(e) { updatePropertiesPanel(); }); }, - column : 'mainColumn', - height : prop_h + column: 'mainColumn', + height: prop_h }); }); @@ -679,9 +690,9 @@ keyboardEvents.activate(); var loadTorrentPeersTimer; var syncTorrentPeersLastResponseId = 0; var show_flags = true; -var loadTorrentPeersData = function(){ - if ($('prop_peers').hasClass('invisible') || - $('propertiesPanel_collapseToggle').hasClass('panel-expand')) { +var loadTorrentPeersData = function() { + if ($('prop_peers').hasClass('invisible') + || $('propertiesPanel_collapseToggle').hasClass('panel-expand')) { syncTorrentPeersLastResponseId = 0; torrentPeersTable.clear(); return; @@ -727,7 +738,7 @@ var loadTorrentPeersData = function(){ } } if (response['peers_removed']) - response['peers_removed'].each(function (hash) { + response['peers_removed'].each(function(hash) { torrentPeersTable.removeRow(hash); }); torrentPeersTable.updateTable(full_update); @@ -750,7 +761,7 @@ var loadTorrentPeersData = function(){ }).send(); }; -updateTorrentPeersData = function(){ +updateTorrentPeersData = function() { clearTimeout(loadTorrentPeersTimer); loadTorrentPeersData(); }; diff --git a/src/webui/www/private/scripts/contextmenu.js b/src/webui/www/private/scripts/contextmenu.js index 153675354..e21b0c87e 100644 --- a/src/webui/www/private/scripts/contextmenu.js +++ b/src/webui/www/private/scripts/contextmenu.js @@ -174,10 +174,10 @@ var ContextMenu = new Class({ }.bind(this)); }, - updateMenuItems: function () {}, + updateMenuItems: function() {}, //show menu - show: function (trigger) { + show: function(trigger) { if (lastShownContexMenu && lastShownContexMenu != this) lastShownContexMenu.hide(); this.fx.start(1); @@ -188,7 +188,7 @@ var ContextMenu = new Class({ }, //hide the menu - hide: function (trigger) { + hide: function(trigger) { if (this.shown) { this.fx.start(0); //this.menu.fade('out'); @@ -198,42 +198,42 @@ var ContextMenu = new Class({ return this; }, - setItemChecked: function (item, checked) { + setItemChecked: function(item, checked) { this.menu.getElement('a[href$=' + item + ']').firstChild.style.opacity = - checked ? '1' : '0'; + checked ? '1' : '0'; return this; }, - getItemChecked: function (item) { + getItemChecked: function(item) { return '0' != this.menu.getElement('a[href$=' + item + ']').firstChild.style.opacity; }, //hide an item - hideItem: function (item) { + hideItem: function(item) { this.menu.getElement('a[href$=' + item + ']').parentNode.addClass('invisible'); return this; }, //show an item - showItem: function (item) { + showItem: function(item) { this.menu.getElement('a[href$=' + item + ']').parentNode.removeClass('invisible'); return this; }, //disable the entire menu - disable: function () { + disable: function() { this.options.disabled = true; return this; }, //enable the entire menu - enable: function () { + enable: function() { this.options.disabled = false; return this; }, //execute an action - execute: function (action, element) { + execute: function(action, element) { if (this.options.actions[action]) { this.options.actions[action](element, this, action); } @@ -244,7 +244,7 @@ var ContextMenu = new Class({ var TorrentsTableContextMenu = new Class({ Extends: ContextMenu, - updateMenuItems: function () { + updateMenuItems: function() { all_are_seq_dl = true; there_are_seq_dl = false; all_are_f_l_piece_prio = true; @@ -259,7 +259,7 @@ var TorrentsTableContextMenu = new Class({ there_are_auto_tmm = false; var h = torrentsTable.selectedRowsIds(); - h.each(function(item, index){ + h.each(function(item, index) { var data = torrentsTable.rows.get(item).full_data; if (data['seq_dl'] !== true) @@ -310,7 +310,8 @@ var TorrentsTableContextMenu = new Class({ this.hideItem('FirstLastPiecePrio'); this.showItem('SuperSeeding'); this.setItemChecked('SuperSeeding', all_are_super_seeding); - } else { + } + else { if (!show_seq_dl && show_f_l_piece_prio) this.menu.getElement('a[href$=FirstLastPiecePrio]').parentNode.addClass('separator'); else @@ -351,22 +352,28 @@ var TorrentsTableContextMenu = new Class({ }, - updateCategoriesSubMenu : function (category_list) { + updateCategoriesSubMenu: function(category_list) { var categoryList = $('contextCategoryList'); categoryList.empty(); - categoryList.appendChild(new Element('li', {html: 'QBT_TR(New...)QBT_TR[CONTEXT=TransferListWidget] QBT_TR(New...)QBT_TR[CONTEXT=TransferListWidget]'})); - categoryList.appendChild(new Element('li', {html: 'QBT_TR(Reset)QBT_TR[CONTEXT=TransferListWidget] QBT_TR(Reset)QBT_TR[CONTEXT=TransferListWidget]'})); + categoryList.appendChild(new Element('li', { + html: 'QBT_TR(New...)QBT_TR[CONTEXT=TransferListWidget] QBT_TR(New...)QBT_TR[CONTEXT=TransferListWidget]' + })); + categoryList.appendChild(new Element('li', { + html: 'QBT_TR(Reset)QBT_TR[CONTEXT=TransferListWidget] QBT_TR(Reset)QBT_TR[CONTEXT=TransferListWidget]' + })); var sortedCategories = []; - Object.each(category_list, function (category) { + Object.each(category_list, function(category) { sortedCategories.push(category.name); }); sortedCategories.sort(); var first = true; - Object.each(sortedCategories, function (categoryName) { + Object.each(sortedCategories, function(categoryName) { var categoryHash = genHash(categoryName); - var el = new Element('li', {html: ' ' + escapeHtml(categoryName) + ''}); + var el = new Element('li', { + html: ' ' + escapeHtml(categoryName) + '' + }); if (first) { el.addClass('separator'); first = false; @@ -378,7 +385,7 @@ var TorrentsTableContextMenu = new Class({ var CategoriesFilterContextMenu = new Class({ Extends: ContextMenu, - updateMenuItems: function () { + updateMenuItems: function() { var id = this.options.element.id; if (id != CATEGORIES_ALL && id != CATEGORIES_UNCATEGORIZED) this.showItem('DeleteCategory'); diff --git a/src/webui/www/private/scripts/download.js b/src/webui/www/private/scripts/download.js index 92e9ef742..94c3208ae 100644 --- a/src/webui/www/private/scripts/download.js +++ b/src/webui/www/private/scripts/download.js @@ -38,5 +38,5 @@ getSavePath = function() { }; $(window).addEventListener("load", function() { - getSavePath(); + getSavePath(); }); diff --git a/src/webui/www/private/scripts/dynamicTable.js b/src/webui/www/private/scripts/dynamicTable.js index 2da1be28d..ebae00c21 100644 --- a/src/webui/www/private/scripts/dynamicTable.js +++ b/src/webui/www/private/scripts/dynamicTable.js @@ -36,1299 +36,1307 @@ var ProgressColumnWidth = -1; var DynamicTable = new Class({ - initialize : function () {}, + initialize: function() {}, - setup : function (dynamicTableDivId, dynamicTableFixedHeaderDivId, contextMenu) { - this.dynamicTableDivId = dynamicTableDivId; - this.dynamicTableFixedHeaderDivId = dynamicTableFixedHeaderDivId; - this.fixedTableHeader = $(dynamicTableFixedHeaderDivId).getElements('tr')[0]; - this.hiddenTableHeader = $(dynamicTableDivId).getElements('tr')[0]; - this.tableBody = $(dynamicTableDivId).getElements('tbody')[0]; - this.rows = new Hash(); - this.selectedRows = []; - this.columns = []; - this.contextMenu = contextMenu; - this.sortedColumn = getLocalStorageItem('sorted_column_' + this.dynamicTableDivId, 0); - this.reverseSort = getLocalStorageItem('reverse_sort_' + this.dynamicTableDivId, '0'); - this.initColumns(); - this.loadColumnsOrder(); - this.updateTableHeaders(); - this.setupCommonEvents(); - this.setupHeaderEvents(); - this.setupHeaderMenu(); - }, + setup: function(dynamicTableDivId, dynamicTableFixedHeaderDivId, contextMenu) { + this.dynamicTableDivId = dynamicTableDivId; + this.dynamicTableFixedHeaderDivId = dynamicTableFixedHeaderDivId; + this.fixedTableHeader = $(dynamicTableFixedHeaderDivId).getElements('tr')[0]; + this.hiddenTableHeader = $(dynamicTableDivId).getElements('tr')[0]; + this.tableBody = $(dynamicTableDivId).getElements('tbody')[0]; + this.rows = new Hash(); + this.selectedRows = []; + this.columns = []; + this.contextMenu = contextMenu; + this.sortedColumn = getLocalStorageItem('sorted_column_' + this.dynamicTableDivId, 0); + this.reverseSort = getLocalStorageItem('reverse_sort_' + this.dynamicTableDivId, '0'); + this.initColumns(); + this.loadColumnsOrder(); + this.updateTableHeaders(); + this.setupCommonEvents(); + this.setupHeaderEvents(); + this.setupHeaderMenu(); + }, - setupCommonEvents : function () { - var scrollFn = function() { - $(this.dynamicTableFixedHeaderDivId).getElements('table')[0].style.left = - -$(this.dynamicTableDivId).scrollLeft + 'px'; - }.bind(this); + setupCommonEvents: function() { + var scrollFn = function() { + $(this.dynamicTableFixedHeaderDivId).getElements('table')[0].style.left = -$(this.dynamicTableDivId).scrollLeft + 'px'; + }.bind(this); - $(this.dynamicTableDivId).addEvent('scroll', scrollFn); + $(this.dynamicTableDivId).addEvent('scroll', scrollFn); - var resizeFn = function() { - var panel = $(this.dynamicTableDivId).getParent('.panel'); - var h = panel.getBoundingClientRect().height - $(this.dynamicTableFixedHeaderDivId).getBoundingClientRect().height; + var resizeFn = function() { + var panel = $(this.dynamicTableDivId).getParent('.panel'); + var h = panel.getBoundingClientRect().height - $(this.dynamicTableFixedHeaderDivId).getBoundingClientRect().height; + $(this.dynamicTableDivId).style.height = h + 'px'; + + // Workaround due to inaccurate calculation of elements heights by browser + + var n = 2; + + while (panel.clientWidth != panel.offsetWidth && n > 0) { // is panel vertical scrollbar visible ? + n--; + h -= 0.5; $(this.dynamicTableDivId).style.height = h + 'px'; + } - // Workaround due to inaccurate calculation of elements heights by browser + this.lastPanelHeight = panel.getBoundingClientRect().height; + }.bind(this); - var n = 2; + $(this.dynamicTableDivId).getParent('.panel').addEvent('resize', resizeFn); - while (panel.clientWidth != panel.offsetWidth && n > 0) { // is panel vertical scrollbar visible ? - n--; - h -= 0.5; - $(this.dynamicTableDivId).style.height = h + 'px'; - } + this.lastPanelHeight = 0; + // Workaround. Resize event is called not always (for example it isn't called when browser window changes it's size) + + var checkResizeFn = function() { + var panel = $(this.dynamicTableDivId).getParent('.panel'); + if (this.lastPanelHeight != panel.getBoundingClientRect().height) { this.lastPanelHeight = panel.getBoundingClientRect().height; - }.bind(this); + panel.fireEvent('resize'); + } + }.bind(this); - $(this.dynamicTableDivId).getParent('.panel').addEvent('resize', resizeFn); + setInterval(checkResizeFn, 500); + }, - this.lastPanelHeight = 0; + setupHeaderEvents: function() { + this.currentHeaderAction = ''; + this.canResize = false; - // Workaround. Resize event is called not always (for example it isn't called when browser window changes it's size) + var resetElementBorderStyle = function(el, side) { + if (side === 'left' || side !== 'right') { + el.setStyle('border-left-style', ''); + el.setStyle('border-left-color', ''); + el.setStyle('border-left-width', ''); + } + if (side === 'right' || side !== 'left') { + el.setStyle('border-right-style', ''); + el.setStyle('border-right-color', ''); + el.setStyle('border-right-width', ''); + } + }; - var checkResizeFn = function() { - var panel = $(this.dynamicTableDivId).getParent('.panel'); - if (this.lastPanelHeight != panel.getBoundingClientRect().height) { - this.lastPanelHeight = panel.getBoundingClientRect().height; - panel.fireEvent('resize'); + var mouseMoveFn = function(e) { + var brect = e.target.getBoundingClientRect(); + var mouseXRelative = e.event.clientX - brect.left; + if (this.currentHeaderAction === '') { + if (brect.width - mouseXRelative < 5) { + this.resizeTh = e.target; + this.canResize = true; + e.target.getParent("tr").style.cursor = 'col-resize'; } - }.bind(this); - - setInterval(checkResizeFn, 500); - }, - - setupHeaderEvents : function () { - this.currentHeaderAction = ''; - this.canResize = false; - - var resetElementBorderStyle = function (el, side) { - if (side === 'left' || side !== 'right') { - el.setStyle('border-left-style', ''); - el.setStyle('border-left-color', ''); - el.setStyle('border-left-width', ''); - } - if (side === 'right' || side !== 'left') { - el.setStyle('border-right-style', ''); - el.setStyle('border-right-color', ''); - el.setStyle('border-right-width', ''); - } - }; - - var mouseMoveFn = function (e) { - var brect = e.target.getBoundingClientRect(); - var mouseXRelative = e.event.clientX - brect.left; - if (this.currentHeaderAction === '') { - if (brect.width - mouseXRelative < 5) { - this.resizeTh = e.target; - this.canResize = true; - e.target.getParent("tr").style.cursor = 'col-resize'; - } - else if ((mouseXRelative < 5) && e.target.getPrevious('[class=""]')) { - this.resizeTh = e.target.getPrevious('[class=""]'); - this.canResize = true; - e.target.getParent("tr").style.cursor = 'col-resize'; - } else { - this.canResize = false; - e.target.getParent("tr").style.cursor = ''; - } - } - if (this.currentHeaderAction === 'drag') { - var previousVisibleSibling = e.target.getPrevious('[class=""]'); - var borderChangeElement = previousVisibleSibling; - var changeBorderSide = 'right'; - - if (mouseXRelative > brect.width / 2) { - borderChangeElement = e.target; - this.dropSide = 'right'; - } - else { - this.dropSide = 'left'; - } - - e.target.getParent("tr").style.cursor = 'move'; - - if (!previousVisibleSibling) { // right most column - borderChangeElement = e.target; - - if (mouseXRelative <= brect.width / 2) - changeBorderSide = 'left'; - } - - borderChangeElement.setStyle('border-' + changeBorderSide + '-style', 'solid'); - borderChangeElement.setStyle('border-' + changeBorderSide + '-color', '#e60'); - borderChangeElement.setStyle('border-' + changeBorderSide + '-width', 'initial'); - - resetElementBorderStyle(borderChangeElement, changeBorderSide === 'right' ? 'left' : 'right'); - - borderChangeElement.getSiblings('[class=""]').each(function(el){ - resetElementBorderStyle(el); - }); - } - this.lastHoverTh = e.target; - this.lastClientX = e.event.clientX; - }.bind(this); - - var mouseOutFn = function (e) { - resetElementBorderStyle(e.target); - }.bind(this); - - var onBeforeStart = function (el) { - this.clickedTh = el; - this.currentHeaderAction = 'start'; - this.dragMovement = false; - this.dragStartX = this.lastClientX; - }.bind(this); - - var onStart = function (el, event) { - if (this.canResize) { - this.currentHeaderAction = 'resize'; - this.startWidth = this.resizeTh.getStyle('width').toFloat(); + else if ((mouseXRelative < 5) && e.target.getPrevious('[class=""]')) { + this.resizeTh = e.target.getPrevious('[class=""]'); + this.canResize = true; + e.target.getParent("tr").style.cursor = 'col-resize'; } else { - this.currentHeaderAction = 'drag'; - el.setStyle('background-color', '#C1D5E7'); + this.canResize = false; + e.target.getParent("tr").style.cursor = ''; } - }.bind(this); + } + if (this.currentHeaderAction === 'drag') { + var previousVisibleSibling = e.target.getPrevious('[class=""]'); + var borderChangeElement = previousVisibleSibling; + var changeBorderSide = 'right'; - var onDrag = function (el, event) { - if (this.currentHeaderAction === 'resize') { - var width = this.startWidth + (event.page.x - this.dragStartX); - if (width < 16) - width = 16; - this.columns[this.resizeTh.columnName].width = width; - this.updateColumn(this.resizeTh.columnName); + if (mouseXRelative > brect.width / 2) { + borderChangeElement = e.target; + this.dropSide = 'right'; + } + else { + this.dropSide = 'left'; } - }.bind(this); - var onComplete = function (el, event) { - resetElementBorderStyle(this.lastHoverTh); - el.setStyle('background-color', ''); - if (this.currentHeaderAction === 'resize') - localStorage.setItem('column_' + this.resizeTh.columnName + '_width_' + this.dynamicTableDivId, this.columns[this.resizeTh.columnName].width); - if ((this.currentHeaderAction === 'drag') && (el !== this.lastHoverTh)) { - this.saveColumnsOrder(); - var val = localStorage.getItem('columns_order_' + this.dynamicTableDivId).split(','); - val.erase(el.columnName); - var pos = val.indexOf(this.lastHoverTh.columnName); - if (this.dropSide === 'right') pos++; - val.splice(pos, 0, el.columnName); - localStorage.setItem('columns_order_' + this.dynamicTableDivId, val.join(',')); - this.loadColumnsOrder(); - this.updateTableHeaders(); - while (this.tableBody.firstChild) - this.tableBody.removeChild(this.tableBody.firstChild); - this.updateTable(true); + e.target.getParent("tr").style.cursor = 'move'; + + if (!previousVisibleSibling) { // right most column + borderChangeElement = e.target; + + if (mouseXRelative <= brect.width / 2) + changeBorderSide = 'left'; } - if (this.currentHeaderAction === 'drag') { + + borderChangeElement.setStyle('border-' + changeBorderSide + '-style', 'solid'); + borderChangeElement.setStyle('border-' + changeBorderSide + '-color', '#e60'); + borderChangeElement.setStyle('border-' + changeBorderSide + '-width', 'initial'); + + resetElementBorderStyle(borderChangeElement, changeBorderSide === 'right' ? 'left' : 'right'); + + borderChangeElement.getSiblings('[class=""]').each(function(el) { resetElementBorderStyle(el); - el.getSiblings('[class=""]').each(function(el){ - resetElementBorderStyle(el); - }); - } - this.currentHeaderAction = ''; - }.bind(this); - - var onCancel = function (el) { - this.currentHeaderAction = ''; - this.setSortedColumn(el.columnName); - }.bind(this); - - var ths = this.fixedTableHeader.getElements('th'); - - for (var i = 0; i < ths.length; i++) { - var th = ths[i]; - th.addEvent('mousemove', mouseMoveFn); - th.addEvent('mouseout', mouseOutFn); - th.makeResizable({ - modifiers : {x: '', y: ''}, - onBeforeStart : onBeforeStart, - onStart : onStart, - onDrag : onDrag, - onComplete : onComplete, - onCancel : onCancel }); } - }, + this.lastHoverTh = e.target; + this.lastClientX = e.event.clientX; + }.bind(this); - setupDynamicTableHeaderContextMenuClass : function () { - if (!DynamicTableHeaderContextMenuClass) { - DynamicTableHeaderContextMenuClass = new Class({ - Extends: ContextMenu, - updateMenuItems: function () { - for (var i = 0; i < this.dynamicTable.columns.length; i++) { - if (this.dynamicTable.columns[i].caption === '') - continue; - if (this.dynamicTable.columns[i].visible !== '0') - this.setItemChecked(this.dynamicTable.columns[i].name, true); - else - this.setItemChecked(this.dynamicTable.columns[i].name, false); + var mouseOutFn = function(e) { + resetElementBorderStyle(e.target); + }.bind(this); + + var onBeforeStart = function(el) { + this.clickedTh = el; + this.currentHeaderAction = 'start'; + this.dragMovement = false; + this.dragStartX = this.lastClientX; + }.bind(this); + + var onStart = function(el, event) { + if (this.canResize) { + this.currentHeaderAction = 'resize'; + this.startWidth = this.resizeTh.getStyle('width').toFloat(); + } + else { + this.currentHeaderAction = 'drag'; + el.setStyle('background-color', '#C1D5E7'); + } + }.bind(this); + + var onDrag = function(el, event) { + if (this.currentHeaderAction === 'resize') { + var width = this.startWidth + (event.page.x - this.dragStartX); + if (width < 16) + width = 16; + this.columns[this.resizeTh.columnName].width = width; + this.updateColumn(this.resizeTh.columnName); + } + }.bind(this); + + var onComplete = function(el, event) { + resetElementBorderStyle(this.lastHoverTh); + el.setStyle('background-color', ''); + if (this.currentHeaderAction === 'resize') + localStorage.setItem('column_' + this.resizeTh.columnName + '_width_' + this.dynamicTableDivId, this.columns[this.resizeTh.columnName].width); + if ((this.currentHeaderAction === 'drag') && (el !== this.lastHoverTh)) { + this.saveColumnsOrder(); + var val = localStorage.getItem('columns_order_' + this.dynamicTableDivId).split(','); + val.erase(el.columnName); + var pos = val.indexOf(this.lastHoverTh.columnName); + if (this.dropSide === 'right') pos++; + val.splice(pos, 0, el.columnName); + localStorage.setItem('columns_order_' + this.dynamicTableDivId, val.join(',')); + this.loadColumnsOrder(); + this.updateTableHeaders(); + while (this.tableBody.firstChild) + this.tableBody.removeChild(this.tableBody.firstChild); + this.updateTable(true); + } + if (this.currentHeaderAction === 'drag') { + resetElementBorderStyle(el); + el.getSiblings('[class=""]').each(function(el) { + resetElementBorderStyle(el); + }); + } + this.currentHeaderAction = ''; + }.bind(this); + + var onCancel = function(el) { + this.currentHeaderAction = ''; + this.setSortedColumn(el.columnName); + }.bind(this); + + var ths = this.fixedTableHeader.getElements('th'); + + for (var i = 0; i < ths.length; i++) { + var th = ths[i]; + th.addEvent('mousemove', mouseMoveFn); + th.addEvent('mouseout', mouseOutFn); + th.makeResizable({ + modifiers: { + x: '', + y: '' + }, + onBeforeStart: onBeforeStart, + onStart: onStart, + onDrag: onDrag, + onComplete: onComplete, + onCancel: onCancel + }); + } + }, + + setupDynamicTableHeaderContextMenuClass: function() { + if (!DynamicTableHeaderContextMenuClass) { + DynamicTableHeaderContextMenuClass = new Class({ + Extends: ContextMenu, + updateMenuItems: function() { + for (var i = 0; i < this.dynamicTable.columns.length; i++) { + if (this.dynamicTable.columns[i].caption === '') + continue; + if (this.dynamicTable.columns[i].visible !== '0') + this.setItemChecked(this.dynamicTable.columns[i].name, true); + else + this.setItemChecked(this.dynamicTable.columns[i].name, false); + } + } + }); + } + }, + + showColumn: function(columnName, show) { + this.columns[columnName].visible = show ? '1' : '0'; + localStorage.setItem('column_' + columnName + '_visible_' + this.dynamicTableDivId, show ? '1' : '0'); + this.updateColumn(columnName); + }, + + setupHeaderMenu: function() { + this.setupDynamicTableHeaderContextMenuClass(); + + var menuId = this.dynamicTableDivId + '_headerMenu'; + + var ul = new Element('ul', { + id: menuId, + class: 'contextMenu scrollableMenu' + }); + + var createLi = function(columnName, text) { + var html = '' + escapeHtml(text) + ''; + return new Element('li', { + html: html + }); + }; + + var actions = {}; + + var onMenuItemClicked = function(element, ref, action) { + this.showColumn(action, this.columns[action].visible === '0'); + }.bind(this); + + for (var i = 0; i < this.columns.length; i++) { + var text = this.columns[i].caption; + if (text === '') + continue; + ul.appendChild(createLi(this.columns[i].name, text)); + actions[this.columns[i].name] = onMenuItemClicked; + } + + ul.inject(document.body); + + this.headerContextMenu = new DynamicTableHeaderContextMenuClass({ + targets: '#' + this.dynamicTableFixedHeaderDivId + ' tr', + actions: actions, + menu: menuId, + offsets: { + x: -15, + y: 2 + } + }); + + this.headerContextMenu.dynamicTable = this; + }, + + initColumns: function() {}, + + newColumn: function(name, style, caption, defaultWidth, defaultVisible) { + var column = {}; + column['name'] = name; + column['visible'] = getLocalStorageItem('column_' + name + '_visible_' + this.dynamicTableDivId, defaultVisible ? '1' : '0'); + column['force_hide'] = false; + column['caption'] = caption; + column['style'] = style; + column['width'] = getLocalStorageItem('column_' + name + '_width_' + this.dynamicTableDivId, defaultWidth); + column['dataProperties'] = [name]; + column['getRowValue'] = function(row, pos) { + if (pos === undefined) + pos = 0; + return row['full_data'][this.dataProperties[pos]]; + }; + column['compareRows'] = function(row1, row2) { + if (this.getRowValue(row1) < this.getRowValue(row2)) + return -1; + else if (this.getRowValue(row1) > this.getRowValue(row2)) + return 1; + else return 0; + }; + column['updateTd'] = function(td, row) { + td.innerHTML = this.getRowValue(row); + }; + column['onResize'] = null; + this.columns.push(column); + this.columns[name] = column; + + this.hiddenTableHeader.appendChild(new Element('th')); + this.fixedTableHeader.appendChild(new Element('th')); + }, + + loadColumnsOrder: function() { + var columnsOrder = []; + var val = localStorage.getItem('columns_order_' + this.dynamicTableDivId); + if (val === null || val === undefined) return; + val.split(',').forEach(function(v) { + if ((v in this.columns) && (!columnsOrder.contains(v))) + columnsOrder.push(v); + }.bind(this)); + + for (i = 0; i < this.columns.length; i++) + if (!columnsOrder.contains(this.columns[i].name)) + columnsOrder.push(this.columns[i].name); + + for (i = 0; i < this.columns.length; i++) + this.columns[i] = this.columns[columnsOrder[i]]; + }, + + saveColumnsOrder: function() { + val = ''; + for (i = 0; i < this.columns.length; i++) { + if (i > 0) + val += ','; + val += this.columns[i].name; + } + localStorage.setItem('columns_order_' + this.dynamicTableDivId, val); + }, + + updateTableHeaders: function() { + this.updateHeader(this.hiddenTableHeader); + this.updateHeader(this.fixedTableHeader); + }, + + updateHeader: function(header) { + var ths = header.getElements('th'); + + for (var i = 0; i < ths.length; i++) { + th = ths[i]; + th._this = this; + th.setAttribute('title', this.columns[i].caption); + th.innerHTML = this.columns[i].caption; + th.setAttribute('style', 'width: ' + this.columns[i].width + 'px;' + this.columns[i].style); + th.columnName = this.columns[i].name; + if ((this.columns[i].visible == '0') || this.columns[i].force_hide) + th.addClass('invisible'); + else + th.removeClass('invisible'); + } + }, + + getColumnPos: function(columnName) { + for (var i = 0; i < this.columns.length; i++) + if (this.columns[i].name == columnName) + return i; + return -1; + }, + + updateColumn: function(columnName) { + var pos = this.getColumnPos(columnName); + var visible = ((this.columns[pos].visible != '0') && !this.columns[pos].force_hide); + var ths = this.hiddenTableHeader.getElements('th'); + var fths = this.fixedTableHeader.getElements('th'); + var trs = this.tableBody.getElements('tr'); + var style = 'width: ' + this.columns[pos].width + 'px;' + this.columns[pos].style; + + ths[pos].setAttribute('style', style); + fths[pos].setAttribute('style', style); + + if (visible) { + ths[pos].removeClass('invisible'); + fths[pos].removeClass('invisible'); + for (var i = 0; i < trs.length; i++) + trs[i].getElements('td')[pos].removeClass('invisible'); + } + else { + ths[pos].addClass('invisible'); + fths[pos].addClass('invisible'); + for (var j = 0; j < trs.length; j++) + trs[j].getElements('td')[pos].addClass('invisible'); + } + if (this.columns[pos].onResize !== null) { + this.columns[pos].onResize(columnName); + } + }, + + setSortedColumn: function(column) { + if (column != this.sortedColumn) { + this.sortedColumn = column; + this.reverseSort = '0'; + } + else { + // Toggle sort order + this.reverseSort = this.reverseSort == '0' ? '1' : '0'; + } + localStorage.setItem('sorted_column_' + this.dynamicTableDivId, column); + localStorage.setItem('reverse_sort_' + this.dynamicTableDivId, this.reverseSort); + this.updateTable(false); + }, + + getSelectedRowId: function() { + if (this.selectedRows.length > 0) + return this.selectedRows[0]; + return ''; + }, + + altRow: function() { + if (!MUI.ieLegacySupport) + return; + + var trs = this.tableBody.getElements('tr'); + trs.each(function(el, i) { + if (i % 2) { + el.addClass('alt'); + } + else { + el.removeClass('alt'); + } + }.bind(this)); + }, + + selectAll: function() { + this.selectedRows.empty(); + + var trs = this.tableBody.getElements('tr'); + for (var i = 0; i < trs.length; i++) { + var tr = trs[i]; + this.selectedRows.push(tr.rowId); + if (!tr.hasClass('selected')) + tr.addClass('selected'); + } + }, + + deselectAll: function() { + this.selectedRows.empty(); + }, + + selectRow: function(rowId) { + this.deselectAll(); + this.selectedRows.push(rowId); + this.tableBody.getElements('tr').each(function(tr) { + if (tr.rowId == rowId) + tr.addClass('selected'); + else + tr.removeClass('selected'); + }); + this.onSelectedRowChanged(); + }, + + reselectRows: function(rowIds) { + this.deselectAll(); + this.selectedRows = rowIds.slice(); + this.tableBody.getElements('tr').each(function(tr) { + if (rowIds.indexOf(tr.rowId) > -1) + tr.addClass('selected'); + }); + }, + + onSelectedRowChanged: function() {}, + + updateRowData: function(data) { + var rowId = data['rowId']; + var row; + + if (!this.rows.has(rowId)) { + row = {}; + this.rows.set(rowId, row); + row['full_data'] = {}; + row['rowId'] = rowId; + } + else + row = this.rows.get(rowId); + + row['data'] = data; + + for (var x in data) + row['full_data'][x] = data[x]; + }, + + getFilteredAndSortedRows: function() { + var filteredRows = []; + + var rows = this.rows.getValues(); + + for (i = 0; i < rows.length; i++) { + filteredRows.push(rows[i]); + filteredRows[rows[i].rowId] = rows[i]; + } + + filteredRows.sort(function(row1, row2) { + var column = this.columns[this.sortedColumn]; + res = column.compareRows(row1, row2); + if (this.reverseSort == '0') + return res; + else + return -res; + }.bind(this)); + return filteredRows; + }, + + getTrByRowId: function(rowId) { + trs = this.tableBody.getElements('tr'); + for (var i = 0; i < trs.length; i++) + if (trs[i].rowId == rowId) + return trs[i]; + return null; + }, + + updateTable: function(fullUpdate) { + if (fullUpdate === undefined) + fullUpdate = false; + + var rows = this.getFilteredAndSortedRows(); + + for (var i = 0; i < this.selectedRows.length; i++) + if (!(this.selectedRows[i] in rows)) { + this.selectedRows.splice(i, 1); + i--; + } + + var trs = this.tableBody.getElements('tr'); + + for (var rowPos = 0; rowPos < rows.length; rowPos++) { + var rowId = rows[rowPos]['rowId']; + tr_found = false; + for (var j = rowPos; j < trs.length; j++) + if (trs[j]['rowId'] == rowId) { + tr_found = true; + if (rowPos == j) + break; + trs[j].inject(trs[rowPos], 'before'); + var tmpTr = trs[j]; + trs.splice(j, 1); + trs.splice(rowPos, 0, tmpTr); + break; + } + if (tr_found) // row already exists in the table + this.updateRow(trs[rowPos], fullUpdate); + else { // else create a new row in the table + var tr = new Element('tr'); + + tr['rowId'] = rows[rowPos]['rowId']; + + tr._this = this; + tr.addEvent('contextmenu', function(e) { + if (!this._this.selectedRows.contains(this.rowId)) + this._this.selectRow(this.rowId); + return true; + }); + tr.addEvent('click', function(e) { + e.stop(); + if (e.control) { + // CTRL key was pressed + if (this._this.selectedRows.contains(this.rowId)) { + // remove it + this._this.selectedRows.erase(this.rowId); + // Remove selected style + this.removeClass('selected'); + } + else { + this._this.selectedRows.push(this.rowId); + // Add selected style + this.addClass('selected'); } } + else { + if (e.shift && this._this.selectedRows.length == 1) { + // Shift key was pressed + var first_row_id = this._this.selectedRows[0]; + var last_row_id = this.rowId; + this._this.selectedRows.empty(); + var trs = this._this.tableBody.getElements('tr'); + var select = false; + for (var i = 0; i < trs.length; i++) { + var tr = trs[i]; + + if ((tr.rowId == first_row_id) || (tr.rowId == last_row_id)) { + this._this.selectedRows.push(tr.rowId); + tr.addClass('selected'); + select = !select; + } + else { + if (select) { + this._this.selectedRows.push(tr.rowId); + tr.addClass('selected'); + } + else + tr.removeClass('selected'); + } + } + } + else { + // Simple selection + this._this.selectRow(this.rowId); + } + } + return false; }); - } - }, - showColumn : function (columnName, show) { - this.columns[columnName].visible = show ? '1' : '0'; - localStorage.setItem('column_' + columnName + '_visible_' + this.dynamicTableDivId, show ? '1' : '0'); - this.updateColumn(columnName); - }, + this.setupTr(tr); - setupHeaderMenu : function () { - this.setupDynamicTableHeaderContextMenuClass(); - - var menuId = this.dynamicTableDivId + '_headerMenu'; - - var ul = new Element('ul', {id: menuId, class: 'contextMenu scrollableMenu'}); - - var createLi = function(columnName, text) { - var html = '' + escapeHtml(text) + ''; - return new Element('li', {html: html}); - }; - - var actions = {}; - - var onMenuItemClicked = function (element, ref, action) { - this.showColumn(action, this.columns[action].visible === '0'); - }.bind(this); - - for (var i = 0; i < this.columns.length; i++) { - var text = this.columns[i].caption; - if (text === '') - continue; - ul.appendChild(createLi(this.columns[i].name, text)); - actions[this.columns[i].name] = onMenuItemClicked; - } - - ul.inject(document.body); - - this.headerContextMenu = new DynamicTableHeaderContextMenuClass({ - targets: '#' + this.dynamicTableFixedHeaderDivId + ' tr', - actions: actions, - menu : menuId, - offsets : { - x : -15, - y : 2 + for (var k = 0; k < this.columns.length; k++) { + var td = new Element('td'); + if ((this.columns[k].visible == '0') || this.columns[k].force_hide) + td.addClass('invisible'); + td.injectInside(tr); } - }); - this.headerContextMenu.dynamicTable = this; - }, - - initColumns : function () {}, - - newColumn : function (name, style, caption, defaultWidth, defaultVisible) { - var column = {}; - column['name'] = name; - column['visible'] = getLocalStorageItem('column_' + name + '_visible_' + this.dynamicTableDivId, defaultVisible ? '1' : '0'); - column['force_hide'] = false; - column['caption'] = caption; - column['style'] = style; - column['width'] = getLocalStorageItem('column_' + name + '_width_' + this.dynamicTableDivId, defaultWidth); - column['dataProperties'] = [name]; - column['getRowValue'] = function (row, pos) { - if (pos === undefined) - pos = 0; - return row['full_data'][this.dataProperties[pos]]; - }; - column['compareRows'] = function (row1, row2) { - if (this.getRowValue(row1) < this.getRowValue(row2)) - return -1; - else if (this.getRowValue(row1) > this.getRowValue(row2)) - return 1; - else return 0; - }; - column['updateTd'] = function (td, row) { - td.innerHTML = this.getRowValue(row); - }; - column['onResize'] = null; - this.columns.push(column); - this.columns[name] = column; - - this.hiddenTableHeader.appendChild(new Element('th')); - this.fixedTableHeader.appendChild(new Element('th')); - }, - - loadColumnsOrder : function () { - var columnsOrder = []; - var val = localStorage.getItem('columns_order_' + this.dynamicTableDivId); - if (val === null || val === undefined) return; - val.split(',').forEach(function(v) { - if ((v in this.columns) && (!columnsOrder.contains(v))) - columnsOrder.push(v); - }.bind(this)); - - for (i = 0; i < this.columns.length; i++) - if (!columnsOrder.contains(this.columns[i].name)) - columnsOrder.push(this.columns[i].name); - - for (i = 0; i < this.columns.length; i++) - this.columns[i] = this.columns[columnsOrder[i]]; - }, - - saveColumnsOrder : function () { - val = ''; - for (i = 0; i < this.columns.length; i++) { - if (i > 0) - val += ','; - val += this.columns[i].name; - } - localStorage.setItem('columns_order_' + this.dynamicTableDivId, val); - }, - - updateTableHeaders : function () { - this.updateHeader(this.hiddenTableHeader); - this.updateHeader(this.fixedTableHeader); - }, - - updateHeader : function (header) { - var ths = header.getElements('th'); - - for (var i = 0; i < ths.length; i++) { - th = ths[i]; - th._this = this; - th.setAttribute('title', this.columns[i].caption); - th.innerHTML = this.columns[i].caption; - th.setAttribute('style', 'width: ' + this.columns[i].width + 'px;' + this.columns[i].style); - th.columnName = this.columns[i].name; - if ((this.columns[i].visible == '0') || this.columns[i].force_hide) - th.addClass('invisible'); - else - th.removeClass('invisible'); - } - }, - - getColumnPos : function (columnName) { - for (var i = 0; i < this.columns.length; i++) - if (this.columns[i].name == columnName) - return i; - return -1; - }, - - updateColumn : function (columnName) { - var pos = this.getColumnPos(columnName); - var visible = ((this.columns[pos].visible != '0') && !this.columns[pos].force_hide); - var ths = this.hiddenTableHeader.getElements('th'); - var fths = this.fixedTableHeader.getElements('th'); - var trs = this.tableBody.getElements('tr'); - var style = 'width: ' + this.columns[pos].width + 'px;' + this.columns[pos].style; - - ths[pos].setAttribute('style', style); - fths[pos].setAttribute('style', style); - - if (visible) { - ths[pos].removeClass('invisible'); - fths[pos].removeClass('invisible'); - for (var i = 0; i < trs.length; i++) - trs[i].getElements('td')[pos].removeClass('invisible'); - } - else { - ths[pos].addClass('invisible'); - fths[pos].addClass('invisible'); - for (var j = 0; j < trs.length; j++) - trs[j].getElements('td')[pos].addClass('invisible'); - } - if (this.columns[pos].onResize !== null) - { - this.columns[pos].onResize(columnName); - } - }, - - setSortedColumn : function (column) { - if (column != this.sortedColumn) { - this.sortedColumn = column; - this.reverseSort = '0'; - } - else { - // Toggle sort order - this.reverseSort = this.reverseSort == '0' ? '1' : '0'; - } - localStorage.setItem('sorted_column_' + this.dynamicTableDivId, column); - localStorage.setItem('reverse_sort_' + this.dynamicTableDivId, this.reverseSort); - this.updateTable(false); - }, - - getSelectedRowId : function () { - if (this.selectedRows.length > 0) - return this.selectedRows[0]; - return ''; - }, - - altRow : function () { - if (!MUI.ieLegacySupport) - return; - - var trs = this.tableBody.getElements('tr'); - trs.each(function (el, i) { - if (i % 2) { - el.addClass('alt'); - } else { - el.removeClass('alt'); + // Insert + if (rowPos >= trs.length) { + tr.inject(this.tableBody); + trs.push(tr); + } + else { + tr.inject(trs[rowPos], 'before'); + trs.splice(rowPos, 0, tr); } - }.bind(this)); - }, - selectAll : function () { - this.selectedRows.empty(); + // Update context menu + if (this.contextMenu) + this.contextMenu.addTarget(tr); - var trs = this.tableBody.getElements('tr'); - for (var i = 0; i < trs.length; i++) { - var tr = trs[i]; - this.selectedRows.push(tr.rowId); - if (!tr.hasClass('selected')) - tr.addClass('selected'); + this.updateRow(tr, true); } - }, + } - deselectAll : function () { - this.selectedRows.empty(); - }, + rowPos = rows.length; - selectRow : function (rowId) { - this.deselectAll(); - this.selectedRows.push(rowId); - this.tableBody.getElements('tr').each(function(tr) { - if (tr.rowId == rowId) - tr.addClass('selected'); - else - tr.removeClass('selected'); - }); - this.onSelectedRowChanged(); - }, + while ((rowPos < trs.length) && (trs.length > 0)) { + trs[trs.length - 1].dispose(); + trs.pop(); + } + }, - reselectRows : function(rowIds) { - this.deselectAll(); - this.selectedRows = rowIds.slice(); - this.tableBody.getElements('tr').each(function(tr) { - if (rowIds.indexOf(tr.rowId) > -1) - tr.addClass('selected'); - }); - }, + setupTr: function(tr) {}, - onSelectedRowChanged : function () {}, + updateRow: function(tr, fullUpdate) { + var row = this.rows.get(tr.rowId); + data = row[fullUpdate ? 'full_data' : 'data']; - updateRowData : function (data) { - var rowId = data['rowId']; - var row; + tds = tr.getElements('td'); + for (var i = 0; i < this.columns.length; i++) { + if (data.hasOwnProperty(this.columns[i].dataProperties[0])) + this.columns[i].updateTd(tds[i], row); + } + row['data'] = {}; + }, - if (!this.rows.has(rowId)) { - row = {}; - this.rows.set(rowId, row); - row['full_data'] = {}; - row['rowId'] = rowId; + removeRow: function(rowId) { + this.selectedRows.erase(rowId); + var tr = this.getTrByRowId(rowId); + if (tr !== null) { + tr.dispose(); + this.rows.erase(rowId); + return true; + } + return false; + }, + + clear: function() { + this.selectedRows.empty(); + this.rows.empty(); + var trs = this.tableBody.getElements('tr'); + while (trs.length > 0) { + trs[trs.length - 1].dispose(); + trs.pop(); + } + }, + + selectedRowsIds: function() { + return this.selectedRows.slice(); + }, + + getRowIds: function() { + return this.rows.getKeys(); + }, +}); + +var TorrentsTable = new Class({ + Extends: DynamicTable, + + initColumns: function() { + this.newColumn('priority', '', '#', 30, true); + this.newColumn('state_icon', 'cursor: default', '', 22, true); + this.newColumn('name', '', 'QBT_TR(Name)QBT_TR[CONTEXT=TorrentModel]', 200, true); + this.newColumn('size', '', 'QBT_TR(Size)QBT_TR[CONTEXT=TorrentModel]', 100, true); + this.newColumn('total_size', '', 'QBT_TR(Total Size)QBT_TR[CONTEXT=TorrentModel]', 100, false); + this.newColumn('progress', '', 'QBT_TR(Done)QBT_TR[CONTEXT=TorrentModel]', 85, true); + this.newColumn('status', '', 'QBT_TR(Status)QBT_TR[CONTEXT=TorrentModel]', 100, true); + this.newColumn('num_seeds', '', 'QBT_TR(Seeds)QBT_TR[CONTEXT=TorrentModel]', 100, true); + this.newColumn('num_leechs', '', 'QBT_TR(Peers)QBT_TR[CONTEXT=TorrentModel]', 100, true); + this.newColumn('dlspeed', '', 'QBT_TR(Down Speed)QBT_TR[CONTEXT=TorrentModel]', 100, true); + this.newColumn('upspeed', '', 'QBT_TR(Up Speed)QBT_TR[CONTEXT=TorrentModel]', 100, true); + this.newColumn('eta', '', 'QBT_TR(ETA)QBT_TR[CONTEXT=TorrentModel]', 100, true); + this.newColumn('ratio', '', 'QBT_TR(Ratio)QBT_TR[CONTEXT=TorrentModel]', 100, true); + this.newColumn('category', '', 'QBT_TR(Category)QBT_TR[CONTEXT=TorrentModel]', 100, true); + this.newColumn('tags', '', 'QBT_TR(Tags)QBT_TR[CONTEXT=TorrentModel]', 100, true); + this.newColumn('added_on', '', 'QBT_TR(Added On)QBT_TR[CONTEXT=TorrentModel]', 100, true); + this.newColumn('completion_on', '', 'QBT_TR(Completed On)QBT_TR[CONTEXT=TorrentModel]', 100, false); + this.newColumn('tracker', '', 'QBT_TR(Tracker)QBT_TR[CONTEXT=TorrentModel]', 100, false); + this.newColumn('dl_limit', '', 'QBT_TR(Down Limit)QBT_TR[CONTEXT=TorrentModel]', 100, false); + this.newColumn('up_limit', '', 'QBT_TR(Up Limit)QBT_TR[CONTEXT=TorrentModel]', 100, false); + this.newColumn('downloaded', '', 'QBT_TR(Downloaded)QBT_TR[CONTEXT=TorrentModel]', 100, false); + this.newColumn('uploaded', '', 'QBT_TR(Uploaded)QBT_TR[CONTEXT=TorrentModel]', 100, false); + this.newColumn('downloaded_session', '', 'QBT_TR(Session Download)QBT_TR[CONTEXT=TorrentModel]', 100, false); + this.newColumn('uploaded_session', '', 'QBT_TR(Session Upload)QBT_TR[CONTEXT=TorrentModel]', 100, false); + this.newColumn('amount_left', '', 'QBT_TR(Remaining)QBT_TR[CONTEXT=TorrentModel]', 100, false); + this.newColumn('time_active', '', 'QBT_TR(Time Active)QBT_TR[CONTEXT=TorrentModel]', 100, false); + this.newColumn('save_path', '', 'QBT_TR(Save path)QBT_TR[CONTEXT=TorrentModel]', 100, false); + this.newColumn('completed', '', 'QBT_TR(Completed)QBT_TR[CONTEXT=TorrentModel]', 100, false); + this.newColumn('ratio_limit', '', 'QBT_TR(Ratio Limit)QBT_TR[CONTEXT=TorrentModel]', 100, false); + this.newColumn('seen_complete', '', 'QBT_TR(Last Seen Complete)QBT_TR[CONTEXT=TorrentModel]', 100, false); + this.newColumn('last_activity', '', 'QBT_TR(Last Activity)QBT_TR[CONTEXT=TorrentModel]', 100, false); + + this.columns['state_icon'].onclick = ''; + this.columns['state_icon'].dataProperties[0] = 'state'; + + this.columns['num_seeds'].dataProperties.push('num_complete'); + + this.columns['num_leechs'].dataProperties.push('num_incomplete'); + + this.initColumnsFunctions(); + }, + + initColumnsFunctions: function() { + + // state_icon + this.columns['state_icon'].updateTd = function(td, row) { + var state = this.getRowValue(row); + // normalize states + switch (state) { + case "forcedDL": + case "metaDL": + state = "downloading"; + break; + case "allocating": + state = "stalledDL"; + break; + case "forcedUP": + state = "uploading"; + break; + case "pausedDL": + state = "paused"; + break; + case "pausedUP": + state = "completed"; + break; + case "queuedDL": + case "queuedUP": + state = "queued"; + break; + case "checkingDL": + case "checkingUP": + case "queuedForChecking": + case "checkingResumeData": + state = "checking"; + break; + case "unknown": + case "missingFiles": + state = "error"; + break; + default: + break; // do nothing + } + + var img_path = 'images/skin/' + state + '.png'; + + if (td.getChildren('img').length) { + var img = td.getChildren('img')[0]; + if (img.src.indexOf(img_path) < 0) + img.set('src', img_path); } else - row = this.rows.get(rowId); + td.adopt(new Element('img', { + 'src': img_path, + 'class': 'stateIcon' + })); + }; - row['data'] = data; + // status + this.columns['status'].updateTd = function(td, row) { + var state = this.getRowValue(row); + if (!state) return; - for(var x in data) - row['full_data'][x] = data[x]; - }, + var status; + switch (state) { + case "downloading": + status = "Downloading"; + break; + case "stalledDL": + status = "Stalled"; + break; + case "metaDL": + status = "Downloading metadata"; + break; + case "forcedDL": + status = "[F] Downloading"; + break; + case "allocating": + status = "Allocating"; + break; + case "uploading": + case "stalledUP": + status = "Seeding"; + break; + case "forcedUP": + status = "[F] Seeding"; + break; + case "queuedDL": + case "queuedUP": + status = "Queued"; + break; + case "checkingDL": + case "checkingUP": + status = "Checking"; + break; + case "queuedForChecking": + status = "Queued for checking"; + break; + case "checkingResumeData": + status = "Checking resume data"; + break; + case "pausedDL": + status = "Paused"; + break; + case "pausedUP": + status = "Completed"; + break; + case "missingFiles": + status = "Missing Files"; + break; + case "error": + status = "Errored"; + break; + default: + status = "Unknown"; + } - getFilteredAndSortedRows : function () { - var filteredRows = []; + td.set('html', status); + }; - var rows = this.rows.getValues(); + // priority + this.columns['priority'].updateTd = function(td, row) { + var priority = this.getRowValue(row); + td.set('html', priority < 1 ? '*' : priority); + }; - for (i = 0; i < rows.length; i++) - { + this.columns['priority'].compareRows = function(row1, row2) { + var row1_val = this.getRowValue(row1); + var row2_val = this.getRowValue(row2); + if (row1_val < 1) + row1_val = 1000000; + if (row2_val < 1) + row2_val = 1000000; + if (row1_val < row2_val) + return -1; + else if (row1_val > row2_val) + return 1; + else return 0; + }; + + // name, category + this.columns['name'].updateTd = function(td, row) { + td.set('html', escapeHtml(this.getRowValue(row))); + }; + this.columns['category'].updateTd = this.columns['name'].updateTd; + + // size + this.columns['size'].updateTd = function(td, row) { + var size = this.getRowValue(row); + td.set('html', friendlyUnit(size, false)); + }; + + // progress + this.columns['progress'].updateTd = function(td, row) { + var progress = this.getRowValue(row); + var progressFormated = (progress * 100).round(1); + if (progressFormated == 100.0 && progress != 1.0) + progressFormated = 99.9; + + if (td.getChildren('div').length) { + var div = td.getChildren('div')[0]; + if (td.resized) { + td.resized = false; + div.setWidth(ProgressColumnWidth - 5); + } + if (div.getValue() != progressFormated) + div.setValue(progressFormated); + } + else { + if (ProgressColumnWidth < 0) + ProgressColumnWidth = td.offsetWidth; + td.adopt(new ProgressBar(progressFormated.toFloat(), { + 'width': ProgressColumnWidth - 5 + })); + td.resized = false; + } + }; + + this.columns['progress'].onResize = function(columnName) { + var pos = this.getColumnPos(columnName); + var trs = this.tableBody.getElements('tr'); + ProgressColumnWidth = -1; + for (var i = 0; i < trs.length; i++) { + var td = trs[i].getElements('td')[pos]; + if (ProgressColumnWidth < 0) + ProgressColumnWidth = td.offsetWidth; + td.resized = true; + this.columns[columnName].updateTd(td, this.rows.get(trs[i].rowId)); + } + }.bind(this); + + // num_seeds + this.columns['num_seeds'].updateTd = function(td, row) { + var num_seeds = this.getRowValue(row, 0); + var num_complete = this.getRowValue(row, 1); + var html = num_seeds; + if (num_complete != -1) + html += ' (' + num_complete + ')'; + td.set('html', html); + }; + this.columns['num_seeds'].compareRows = function(row1, row2) { + var num_seeds1 = this.getRowValue(row1, 0); + var num_complete1 = this.getRowValue(row1, 1); + + var num_seeds2 = this.getRowValue(row2, 0); + var num_complete2 = this.getRowValue(row2, 1); + + if (num_complete1 < num_complete2) + return -1; + else if (num_complete1 > num_complete2) + return 1; + else if (num_seeds1 < num_seeds2) + return -1; + else if (num_seeds1 > num_seeds2) + return 1; + else return 0; + }; + + // num_leechs + this.columns['num_leechs'].updateTd = this.columns['num_seeds'].updateTd; + this.columns['num_leechs'].compareRows = this.columns['num_seeds'].compareRows; + + // dlspeed + this.columns['dlspeed'].updateTd = function(td, row) { + var speed = this.getRowValue(row); + td.set('html', friendlyUnit(speed, true)); + }; + + // upspeed + this.columns['upspeed'].updateTd = this.columns['dlspeed'].updateTd; + + // eta + this.columns['eta'].updateTd = function(td, row) { + var eta = this.getRowValue(row); + td.set('html', friendlyDuration(eta, true)); + }; + + // ratio + this.columns['ratio'].updateTd = function(td, row) { + var ratio = this.getRowValue(row); + var html = null; + if (ratio == -1) + html = '∞'; + else + html = (Math.floor(100 * ratio) / 100).toFixed(2); //Don't round up + td.set('html', html); + }; + + // tags + this.columns['tags'].updateTd = this.columns['name'].updateTd; + + // added on + this.columns['added_on'].updateTd = function(td, row) { + var date = new Date(this.getRowValue(row) * 1000).toLocaleString(); + td.set('html', date); + }; + + // completion_on + this.columns['completion_on'].updateTd = function(td, row) { + var val = this.getRowValue(row); + if (val === 0xffffffff || val < 0) + td.set('html', ''); + else { + var date = new Date(this.getRowValue(row) * 1000).toLocaleString(); + td.set('html', date); + } + }; + + // seen_complete + this.columns['seen_complete'].updateTd = this.columns['completion_on'].updateTd; + + // dl_limit, up_limit + this.columns['dl_limit'].updateTd = function(td, row) { + var speed = this.getRowValue(row); + if (speed === 0) + td.set('html', '∞'); + else + td.set('html', friendlyUnit(speed, true)); + }; + + this.columns['up_limit'].updateTd = this.columns['dl_limit'].updateTd; + + // downloaded, uploaded, downloaded_session, uploaded_session, amount_left, completed, total_size + this.columns['downloaded'].updateTd = this.columns['size'].updateTd; + this.columns['uploaded'].updateTd = this.columns['size'].updateTd; + this.columns['downloaded_session'].updateTd = this.columns['size'].updateTd; + this.columns['uploaded_session'].updateTd = this.columns['size'].updateTd; + this.columns['amount_left'].updateTd = this.columns['size'].updateTd; + this.columns['amount_left'].updateTd = this.columns['size'].updateTd; + this.columns['completed'].updateTd = this.columns['size'].updateTd; + this.columns['total_size'].updateTd = this.columns['size'].updateTd; + + // save_path, tracker + this.columns['save_path'].updateTd = this.columns['name'].updateTd; + this.columns['tracker'].updateTd = this.columns['name'].updateTd; + + // ratio_limit + this.columns['ratio_limit'].updateTd = this.columns['ratio'].updateTd; + + // last_activity + this.columns['last_activity'].updateTd = function(td, row) { + var val = this.getRowValue(row); + if (val < 1) + td.set('html', '∞'); + else + td.set('html', 'QBT_TR(%1 ago)QBT_TR[CONTEXT=TransferListDelegate]'.replace('%1', friendlyDuration((new Date()) / 1000 - val, true))); + }; + + // time active + this.columns['time_active'].updateTd = function(td, row) { + var time = this.getRowValue(row); + td.set('html', friendlyDuration(time)); + }; + }, + + applyFilter: function(row, filterName, categoryHash) { + var state = row['full_data'].state; + var inactive = false; + var r; + + switch (filterName) { + case 'downloading': + if (state != 'downloading' && !~state.indexOf('DL')) + return false; + break; + case 'seeding': + if (state != 'uploading' && state != 'forcedUP' && state != 'stalledUP' && state != 'queuedUP' && state != 'checkingUP') + return false; + break; + case 'completed': + if (state != 'uploading' && !~state.indexOf('UP')) + return false; + break; + case 'paused': + if (!~state.indexOf('paused')) + return false; + break; + case 'resumed': + if (~state.indexOf('paused')) + return false; + break; + case 'inactive': + inactive = true; + // fallthrough + case 'active': + if (state == 'stalledDL') + r = (row['full_data'].upspeed > 0); + else + r = state == 'metaDL' || state == 'downloading' || state == 'forcedDL' || state == 'uploading' || state == 'forcedUP'; + if (r == inactive) + return false; + break; + case 'errored': + if (state != 'error' && state != "unknown" && state != "missingFiles") + return false; + break; + } + + if (categoryHash == CATEGORIES_ALL) + return true; + + if (categoryHash == CATEGORIES_UNCATEGORIZED && row['full_data'].category.length === 0) + return true; + + if (categoryHash != genHash(row['full_data'].category)) + return false; + + return true; + }, + + getFilteredTorrentsNumber: function(filterName, categoryHash) { + var cnt = 0; + var rows = this.rows.getValues(); + + for (i = 0; i < rows.length; i++) + if (this.applyFilter(rows[i], filterName, categoryHash)) cnt++; + return cnt; + }, + + getFilteredTorrentsHashes: function(filterName, categoryHash) { + var rowsHashes = []; + var rows = this.rows.getValues(); + + for (i = 0; i < rows.length; i++) + if (this.applyFilter(rows[i], filterName, categoryHash)) + rowsHashes.push(rows[i]['rowId']); + + return rowsHashes; + }, + + getFilteredAndSortedRows: function() { + var filteredRows = []; + + var rows = this.rows.getValues(); + + for (i = 0; i < rows.length; i++) + if (this.applyFilter(rows[i], selected_filter, selected_category)) { filteredRows.push(rows[i]); filteredRows[rows[i].rowId] = rows[i]; } - filteredRows.sort(function (row1, row2) { - var column = this.columns[this.sortedColumn]; - res = column.compareRows(row1, row2); - if (this.reverseSort == '0') - return res; - else - return -res; - }.bind(this)); - return filteredRows; - }, + filteredRows.sort(function(row1, row2) { + var column = this.columns[this.sortedColumn]; + res = column.compareRows(row1, row2); + if (this.reverseSort == '0') + return res; + else + return -res; + }.bind(this)); + return filteredRows; + }, - getTrByRowId : function (rowId) { - trs = this.tableBody.getElements('tr'); - for (var i = 0; i < trs.length; i++) - if (trs[i].rowId == rowId) - return trs[i]; - return null; - }, - - updateTable : function (fullUpdate) { - if (fullUpdate === undefined) - fullUpdate = false; - - var rows = this.getFilteredAndSortedRows(); - - for (var i = 0; i < this.selectedRows.length; i++) - if (!(this.selectedRows[i] in rows)) { - this.selectedRows.splice(i, 1); - i--; - } - - var trs = this.tableBody.getElements('tr'); - - for (var rowPos = 0; rowPos < rows.length; rowPos++) { - var rowId = rows[rowPos]['rowId']; - tr_found = false; - for (var j = rowPos; j < trs.length; j++) - if (trs[j]['rowId'] == rowId) { - tr_found = true; - if (rowPos == j) - break; - trs[j].inject(trs[rowPos], 'before'); - var tmpTr = trs[j]; - trs.splice(j, 1); - trs.splice(rowPos, 0, tmpTr); - break; - } - if (tr_found) // row already exists in the table - this.updateRow(trs[rowPos], fullUpdate); - else { // else create a new row in the table - var tr = new Element('tr'); - - tr['rowId'] = rows[rowPos]['rowId']; - - tr._this = this; - tr.addEvent('contextmenu', function (e) { - if (!this._this.selectedRows.contains(this.rowId)) - this._this.selectRow(this.rowId); - return true; - }); - tr.addEvent('click', function (e) { - e.stop(); - if (e.control) { - // CTRL key was pressed - if (this._this.selectedRows.contains(this.rowId)) { - // remove it - this._this.selectedRows.erase(this.rowId); - // Remove selected style - this.removeClass('selected'); - } - else { - this._this.selectedRows.push(this.rowId); - // Add selected style - this.addClass('selected'); - } - } - else { - if (e.shift && this._this.selectedRows.length == 1) { - // Shift key was pressed - var first_row_id = this._this.selectedRows[0]; - var last_row_id = this.rowId; - this._this.selectedRows.empty(); - var trs = this._this.tableBody.getElements('tr'); - var select = false; - for (var i = 0; i < trs.length; i++) { - var tr = trs[i]; - - if ((tr.rowId == first_row_id) || (tr.rowId == last_row_id)) { - this._this.selectedRows.push(tr.rowId); - tr.addClass('selected'); - select = !select; - } - else { - if (select) { - this._this.selectedRows.push(tr.rowId); - tr.addClass('selected'); - } - else - tr.removeClass('selected'); - } - } - } else { - // Simple selection - this._this.selectRow(this.rowId); - } - } - return false; - }); - - this.setupTr(tr); - - for (var k = 0 ; k < this.columns.length; k++) { - var td = new Element('td'); - if ((this.columns[k].visible == '0') || this.columns[k].force_hide) - td.addClass('invisible'); - td.injectInside(tr); - } - - // Insert - if (rowPos >= trs.length) { - tr.inject(this.tableBody); - trs.push(tr); - } - else { - tr.inject(trs[rowPos], 'before'); - trs.splice(rowPos, 0, tr); - } - - // Update context menu - if (this.contextMenu) - this.contextMenu.addTarget(tr); - - this.updateRow(tr, true); - } - } - - rowPos = rows.length; - - while ((rowPos < trs.length) && (trs.length > 0)) { - trs[trs.length - 1].dispose(); - trs.pop(); - } - }, - - setupTr : function (tr) {}, - - updateRow : function (tr, fullUpdate) { - var row = this.rows.get(tr.rowId); - data = row[fullUpdate ? 'full_data' : 'data']; - - tds = tr.getElements('td'); - for (var i = 0; i < this.columns.length; i++) { - if (data.hasOwnProperty(this.columns[i].dataProperties[0])) - this.columns[i].updateTd(tds[i], row); - } - row['data'] = {}; - }, - - removeRow : function (rowId) { - this.selectedRows.erase(rowId); - var tr = this.getTrByRowId(rowId); - if (tr !== null) { - tr.dispose(); - this.rows.erase(rowId); - return true; - } - return false; - }, - - clear : function () { - this.selectedRows.empty(); - this.rows.empty(); - var trs = this.tableBody.getElements('tr'); - while (trs.length > 0) { - trs[trs.length - 1].dispose(); - trs.pop(); - } - }, - - selectedRowsIds : function () { - return this.selectedRows.slice(); - }, - - getRowIds : function () { - return this.rows.getKeys(); - }, - }); - -var TorrentsTable = new Class({ - Extends: DynamicTable, - - initColumns : function () { - this.newColumn('priority', '', '#', 30, true); - this.newColumn('state_icon', 'cursor: default', '', 22, true); - this.newColumn('name', '', 'QBT_TR(Name)QBT_TR[CONTEXT=TorrentModel]', 200, true); - this.newColumn('size', '', 'QBT_TR(Size)QBT_TR[CONTEXT=TorrentModel]', 100, true); - this.newColumn('total_size', '', 'QBT_TR(Total Size)QBT_TR[CONTEXT=TorrentModel]', 100, false); - this.newColumn('progress', '', 'QBT_TR(Done)QBT_TR[CONTEXT=TorrentModel]', 85, true); - this.newColumn('status', '', 'QBT_TR(Status)QBT_TR[CONTEXT=TorrentModel]', 100, true); - this.newColumn('num_seeds', '', 'QBT_TR(Seeds)QBT_TR[CONTEXT=TorrentModel]', 100, true); - this.newColumn('num_leechs', '', 'QBT_TR(Peers)QBT_TR[CONTEXT=TorrentModel]', 100, true); - this.newColumn('dlspeed', '', 'QBT_TR(Down Speed)QBT_TR[CONTEXT=TorrentModel]', 100, true); - this.newColumn('upspeed', '', 'QBT_TR(Up Speed)QBT_TR[CONTEXT=TorrentModel]', 100, true); - this.newColumn('eta', '', 'QBT_TR(ETA)QBT_TR[CONTEXT=TorrentModel]', 100, true); - this.newColumn('ratio', '', 'QBT_TR(Ratio)QBT_TR[CONTEXT=TorrentModel]', 100, true); - this.newColumn('category', '', 'QBT_TR(Category)QBT_TR[CONTEXT=TorrentModel]', 100, true); - this.newColumn('tags', '', 'QBT_TR(Tags)QBT_TR[CONTEXT=TorrentModel]', 100, true); - this.newColumn('added_on', '', 'QBT_TR(Added On)QBT_TR[CONTEXT=TorrentModel]', 100, true); - this.newColumn('completion_on', '', 'QBT_TR(Completed On)QBT_TR[CONTEXT=TorrentModel]', 100, false); - this.newColumn('tracker', '', 'QBT_TR(Tracker)QBT_TR[CONTEXT=TorrentModel]', 100, false); - this.newColumn('dl_limit', '', 'QBT_TR(Down Limit)QBT_TR[CONTEXT=TorrentModel]', 100, false); - this.newColumn('up_limit', '', 'QBT_TR(Up Limit)QBT_TR[CONTEXT=TorrentModel]', 100, false); - this.newColumn('downloaded', '', 'QBT_TR(Downloaded)QBT_TR[CONTEXT=TorrentModel]', 100, false); - this.newColumn('uploaded', '', 'QBT_TR(Uploaded)QBT_TR[CONTEXT=TorrentModel]', 100, false); - this.newColumn('downloaded_session', '', 'QBT_TR(Session Download)QBT_TR[CONTEXT=TorrentModel]', 100, false); - this.newColumn('uploaded_session', '', 'QBT_TR(Session Upload)QBT_TR[CONTEXT=TorrentModel]', 100, false); - this.newColumn('amount_left', '', 'QBT_TR(Remaining)QBT_TR[CONTEXT=TorrentModel]', 100, false); - this.newColumn('time_active', '', 'QBT_TR(Time Active)QBT_TR[CONTEXT=TorrentModel]', 100, false); - this.newColumn('save_path', '', 'QBT_TR(Save path)QBT_TR[CONTEXT=TorrentModel]', 100, false); - this.newColumn('completed', '', 'QBT_TR(Completed)QBT_TR[CONTEXT=TorrentModel]', 100, false); - this.newColumn('ratio_limit', '', 'QBT_TR(Ratio Limit)QBT_TR[CONTEXT=TorrentModel]', 100, false); - this.newColumn('seen_complete', '', 'QBT_TR(Last Seen Complete)QBT_TR[CONTEXT=TorrentModel]', 100, false); - this.newColumn('last_activity', '', 'QBT_TR(Last Activity)QBT_TR[CONTEXT=TorrentModel]', 100, false); - - this.columns['state_icon'].onclick = ''; - this.columns['state_icon'].dataProperties[0] = 'state'; - - this.columns['num_seeds'].dataProperties.push('num_complete'); - - this.columns['num_leechs'].dataProperties.push('num_incomplete'); - - this.initColumnsFunctions(); - }, - - initColumnsFunctions : function () { - - // state_icon - this.columns['state_icon'].updateTd = function (td, row) { - var state = this.getRowValue(row); - // normalize states - switch (state) { - case "forcedDL": - case "metaDL": - state = "downloading"; - break; - case "allocating": - state = "stalledDL"; - break; - case "forcedUP": - state = "uploading"; - break; - case "pausedDL": - state = "paused"; - break; - case "pausedUP": - state = "completed"; - break; - case "queuedDL": - case "queuedUP": - state = "queued"; - break; - case "checkingDL": - case "checkingUP": - case "queuedForChecking": - case "checkingResumeData": - state = "checking"; - break; - case "unknown": - case "missingFiles": - state = "error"; - break; - default: - break; // do nothing - } - - var img_path = 'images/skin/' + state + '.png'; - - if (td.getChildren('img').length) { - var img = td.getChildren('img')[0]; - if (img.src.indexOf(img_path) < 0) - img.set('src', img_path); - } - else - td.adopt(new Element('img', { - 'src' : img_path, - 'class' : 'stateIcon' - })); - }; - - // status - this.columns['status'].updateTd = function (td, row) { - var state = this.getRowValue(row); - if (!state) return; - - var status; - switch (state) { - case "downloading": - status = "Downloading"; - break; - case "stalledDL": - status = "Stalled"; - break; - case "metaDL": - status = "Downloading metadata"; - break; - case "forcedDL": - status = "[F] Downloading"; - break; - case "allocating": - status = "Allocating"; - break; - case "uploading": - case "stalledUP": - status = "Seeding"; - break; - case "forcedUP": - status = "[F] Seeding"; - break; - case "queuedDL": - case "queuedUP": - status = "Queued"; - break; - case "checkingDL": - case "checkingUP": - status = "Checking"; - break; - case "queuedForChecking": - status = "Queued for checking"; - break; - case "checkingResumeData": - status = "Checking resume data"; - break; - case "pausedDL": - status = "Paused"; - break; - case "pausedUP": - status = "Completed"; - break; - case "missingFiles": - status = "Missing Files"; - break; - case "error": - status = "Errored"; - break; - default: - status = "Unknown"; - } - - td.set('html', status); - }; - - // priority - this.columns['priority'].updateTd = function (td, row) { - var priority = this.getRowValue(row); - td.set('html', priority < 1 ? '*' : priority); - }; - - this.columns['priority'].compareRows = function (row1, row2) { - var row1_val = this.getRowValue(row1); - var row2_val = this.getRowValue(row2); - if (row1_val < 1) - row1_val = 1000000; - if (row2_val < 1) - row2_val = 1000000; - if (row1_val < row2_val) - return -1; - else if (row1_val > row2_val) - return 1; - else return 0; - }; - - // name, category - this.columns['name'].updateTd = function (td, row) { - td.set('html', escapeHtml(this.getRowValue(row))); - }; - this.columns['category'].updateTd = this.columns['name'].updateTd; - - // size - this.columns['size'].updateTd = function (td, row) { - var size = this.getRowValue(row); - td.set('html', friendlyUnit(size, false)); - }; - - // progress - this.columns['progress'].updateTd = function (td, row) { - var progress = this.getRowValue(row); - var progressFormated = (progress * 100).round(1); - if (progressFormated == 100.0 && progress != 1.0) - progressFormated = 99.9; - - if (td.getChildren('div').length) { - var div = td.getChildren('div')[0]; - if (td.resized) { - td.resized = false; - div.setWidth(ProgressColumnWidth - 5); - } - if (div.getValue() != progressFormated) - div.setValue(progressFormated); - } - else { - if (ProgressColumnWidth < 0) - ProgressColumnWidth = td.offsetWidth; - td.adopt(new ProgressBar(progressFormated.toFloat(), { - 'width' : ProgressColumnWidth - 5 - })); - td.resized = false; - } - }; - - this.columns['progress'].onResize = function (columnName) { - var pos = this.getColumnPos(columnName); - var trs = this.tableBody.getElements('tr'); - ProgressColumnWidth = -1; - for (var i = 0; i < trs.length; i++) { - var td = trs[i].getElements('td')[pos]; - if (ProgressColumnWidth < 0) - ProgressColumnWidth = td.offsetWidth; - td.resized = true; - this.columns[columnName].updateTd(td, this.rows.get(trs[i].rowId)); - } - }.bind(this); - - // num_seeds - this.columns['num_seeds'].updateTd = function (td, row) { - var num_seeds = this.getRowValue(row, 0); - var num_complete = this.getRowValue(row, 1); - var html = num_seeds; - if (num_complete != -1) - html += ' (' + num_complete + ')'; - td.set('html', html); - }; - this.columns['num_seeds'].compareRows = function (row1, row2) { - var num_seeds1 = this.getRowValue(row1, 0); - var num_complete1 = this.getRowValue(row1, 1); - - var num_seeds2 = this.getRowValue(row2, 0); - var num_complete2 = this.getRowValue(row2, 1); - - if (num_complete1 < num_complete2) - return -1; - else if (num_complete1 > num_complete2) - return 1; - else if (num_seeds1 < num_seeds2) - return -1; - else if (num_seeds1 > num_seeds2) - return 1; - else return 0; - }; - - // num_leechs - this.columns['num_leechs'].updateTd = this.columns['num_seeds'].updateTd; - this.columns['num_leechs'].compareRows = this.columns['num_seeds'].compareRows; - - // dlspeed - this.columns['dlspeed'].updateTd = function (td, row) { - var speed = this.getRowValue(row); - td.set('html', friendlyUnit(speed, true)); - }; - - // upspeed - this.columns['upspeed'].updateTd = this.columns['dlspeed'].updateTd; - - // eta - this.columns['eta'].updateTd = function (td, row) { - var eta = this.getRowValue(row); - td.set('html', friendlyDuration(eta, true)); - }; - - // ratio - this.columns['ratio'].updateTd = function (td, row) { - var ratio = this.getRowValue(row); - var html = null; - if (ratio == -1) - html = '∞'; - else - html = (Math.floor(100 * ratio) / 100).toFixed(2); //Don't round up - td.set('html', html); - }; - - // tags - this.columns['tags'].updateTd = this.columns['name'].updateTd; - - // added on - this.columns['added_on'].updateTd = function (td, row) { - var date = new Date(this.getRowValue(row) * 1000).toLocaleString(); - td.set('html', date); - }; - - // completion_on - this.columns['completion_on'].updateTd = function (td, row) { - var val = this.getRowValue(row); - if (val === 0xffffffff || val < 0) - td.set('html', ''); - else { - var date = new Date(this.getRowValue(row) * 1000).toLocaleString(); - td.set('html', date); - } - }; - - // seen_complete - this.columns['seen_complete'].updateTd = this.columns['completion_on'].updateTd; - - // dl_limit, up_limit - this.columns['dl_limit'].updateTd = function (td, row) { - var speed = this.getRowValue(row); - if (speed === 0) - td.set('html', '∞'); - else - td.set('html', friendlyUnit(speed, true)); - }; - - this.columns['up_limit'].updateTd = this.columns['dl_limit'].updateTd; - - // downloaded, uploaded, downloaded_session, uploaded_session, amount_left, completed, total_size - this.columns['downloaded'].updateTd = this.columns['size'].updateTd; - this.columns['uploaded'].updateTd = this.columns['size'].updateTd; - this.columns['downloaded_session'].updateTd = this.columns['size'].updateTd; - this.columns['uploaded_session'].updateTd = this.columns['size'].updateTd; - this.columns['amount_left'].updateTd = this.columns['size'].updateTd; - this.columns['amount_left'].updateTd = this.columns['size'].updateTd; - this.columns['completed'].updateTd = this.columns['size'].updateTd; - this.columns['total_size'].updateTd = this.columns['size'].updateTd; - - // save_path, tracker - this.columns['save_path'].updateTd = this.columns['name'].updateTd; - this.columns['tracker'].updateTd = this.columns['name'].updateTd; - - // ratio_limit - this.columns['ratio_limit'].updateTd = this.columns['ratio'].updateTd; - - // last_activity - this.columns['last_activity'].updateTd = function (td, row) { - var val = this.getRowValue(row); - if (val < 1) - td.set('html', '∞'); - else - td.set('html', 'QBT_TR(%1 ago)QBT_TR[CONTEXT=TransferListDelegate]'.replace('%1', friendlyDuration((new Date()) / 1000 - val, true))); - }; - - // time active - this.columns['time_active'].updateTd = function (td, row) { - var time = this.getRowValue(row); - td.set('html', friendlyDuration(time)); - }; - }, - - applyFilter : function (row, filterName, categoryHash) { + setupTr: function(tr) { + tr.addEvent('dblclick', function(e) { + e.stop(); + this._this.selectRow(this.rowId); + var row = this._this.rows.get(this.rowId); var state = row['full_data'].state; - var inactive = false; - var r; - - switch(filterName) { - case 'downloading': - if (state != 'downloading' && !~state.indexOf('DL')) - return false; - break; - case 'seeding': - if (state != 'uploading' && state != 'forcedUP' && state != 'stalledUP' && state != 'queuedUP' && state != 'checkingUP') - return false; - break; - case 'completed': - if (state != 'uploading' && !~state.indexOf('UP')) - return false; - break; - case 'paused': - if (!~state.indexOf('paused')) - return false; - break; - case 'resumed': - if (~state.indexOf('paused')) - return false; - break; - case 'inactive': - inactive = true; - // fallthrough - case 'active': - if (state == 'stalledDL') - r = (row['full_data'].upspeed > 0); - else - r = state == 'metaDL' || state == 'downloading' || state == 'forcedDL' || state == 'uploading' || state == 'forcedUP'; - if (r == inactive) - return false; - break; - case 'errored': - if (state != 'error' && state != "unknown" && state != "missingFiles") - return false; - break; - } - - if (categoryHash == CATEGORIES_ALL) - return true; - - if (categoryHash == CATEGORIES_UNCATEGORIZED && row['full_data'].category.length === 0) - return true; - - if (categoryHash != genHash(row['full_data'].category)) - return false; - + if (~state.indexOf('paused')) + startFN(); + else + pauseFN(); return true; - }, + }); + tr.addClass("torrentsTableContextMenuTarget"); + }, - getFilteredTorrentsNumber : function (filterName, categoryHash) { - var cnt = 0; - var rows = this.rows.getValues(); + getCurrentTorrentHash: function() { + return this.getSelectedRowId(); + }, - for (i = 0; i < rows.length; i++) - if (this.applyFilter(rows[i], filterName, categoryHash)) cnt++; - return cnt; - }, - - getFilteredTorrentsHashes : function (filterName, categoryHash) { - var rowsHashes = []; - var rows = this.rows.getValues(); - - for (i = 0; i < rows.length; i++) - if (this.applyFilter(rows[i], filterName, categoryHash)) - rowsHashes.push(rows[i]['rowId']); - - return rowsHashes; - }, - - getFilteredAndSortedRows : function () { - var filteredRows = []; - - var rows = this.rows.getValues(); - - for (i = 0; i < rows.length; i++) - if (this.applyFilter(rows[i], selected_filter, selected_category)) { - filteredRows.push(rows[i]); - filteredRows[rows[i].rowId] = rows[i]; - } - - filteredRows.sort(function (row1, row2) { - var column = this.columns[this.sortedColumn]; - res = column.compareRows(row1, row2); - if (this.reverseSort == '0') - return res; - else - return -res; - }.bind(this)); - return filteredRows; - }, - - setupTr : function (tr) { - tr.addEvent('dblclick', function (e) { - e.stop(); - this._this.selectRow(this.rowId); - var row = this._this.rows.get(this.rowId); - var state = row['full_data'].state; - if (~state.indexOf('paused')) - startFN(); - else - pauseFN(); - return true; - }); - tr.addClass("torrentsTableContextMenuTarget"); - }, - - getCurrentTorrentHash : function () { - return this.getSelectedRowId(); - }, - - onSelectedRowChanged : function () { - updatePropertiesPanel(); - } - }); + onSelectedRowChanged: function() { + updatePropertiesPanel(); + } +}); var TorrentPeersTable = new Class({ - Extends: DynamicTable, + Extends: DynamicTable, - initColumns : function () { - this.newColumn('country', '', 'QBT_TR(Country)QBT_TR[CONTEXT=PeerListWidget]', 22, true); - this.newColumn('ip', '', 'QBT_TR(IP)QBT_TR[CONTEXT=PeerListWidget]', 80, true); - this.newColumn('port', '', 'QBT_TR(Port)QBT_TR[CONTEXT=PeerListWidget]', 35, true); - this.newColumn('client', '', 'QBT_TR(Client)QBT_TR[CONTEXT=PeerListWidget]', 140, true); - this.newColumn('progress', '', 'QBT_TR(Progress)QBT_TR[CONTEXT=PeerListWidget]', 50, true); - this.newColumn('dl_speed', '', 'QBT_TR(Down Speed)QBT_TR[CONTEXT=PeerListWidget]', 50, true); - this.newColumn('up_speed', '', 'QBT_TR(Up Speed)QBT_TR[CONTEXT=PeerListWidget]', 50, true); - this.newColumn('downloaded', '', 'QBT_TR(Downloaded)QBT_TR[CONTEXT=PeerListWidget]', 50, true); - this.newColumn('uploaded', '', 'QBT_TR(Uploaded)QBT_TR[CONTEXT=PeerListWidget]', 50, true); - this.newColumn('connection', '', 'QBT_TR(Connection)QBT_TR[CONTEXT=PeerListWidget]', 50, true); - this.newColumn('flags', '', 'QBT_TR(Flags)QBT_TR[CONTEXT=PeerListWidget]', 50, true); - this.newColumn('relevance', '', 'QBT_TR(Relevance)QBT_TR[CONTEXT=PeerListWidget]', 30, true); - this.newColumn('files', '', 'QBT_TR(Files)QBT_TR[CONTEXT=PeerListWidget]', 100, true); + initColumns: function() { + this.newColumn('country', '', 'QBT_TR(Country)QBT_TR[CONTEXT=PeerListWidget]', 22, true); + this.newColumn('ip', '', 'QBT_TR(IP)QBT_TR[CONTEXT=PeerListWidget]', 80, true); + this.newColumn('port', '', 'QBT_TR(Port)QBT_TR[CONTEXT=PeerListWidget]', 35, true); + this.newColumn('client', '', 'QBT_TR(Client)QBT_TR[CONTEXT=PeerListWidget]', 140, true); + this.newColumn('progress', '', 'QBT_TR(Progress)QBT_TR[CONTEXT=PeerListWidget]', 50, true); + this.newColumn('dl_speed', '', 'QBT_TR(Down Speed)QBT_TR[CONTEXT=PeerListWidget]', 50, true); + this.newColumn('up_speed', '', 'QBT_TR(Up Speed)QBT_TR[CONTEXT=PeerListWidget]', 50, true); + this.newColumn('downloaded', '', 'QBT_TR(Downloaded)QBT_TR[CONTEXT=PeerListWidget]', 50, true); + this.newColumn('uploaded', '', 'QBT_TR(Uploaded)QBT_TR[CONTEXT=PeerListWidget]', 50, true); + this.newColumn('connection', '', 'QBT_TR(Connection)QBT_TR[CONTEXT=PeerListWidget]', 50, true); + this.newColumn('flags', '', 'QBT_TR(Flags)QBT_TR[CONTEXT=PeerListWidget]', 50, true); + this.newColumn('relevance', '', 'QBT_TR(Relevance)QBT_TR[CONTEXT=PeerListWidget]', 30, true); + this.newColumn('files', '', 'QBT_TR(Files)QBT_TR[CONTEXT=PeerListWidget]', 100, true); - this.columns['country'].dataProperties.push('country_code'); - this.columns['flags'].dataProperties.push('flags_desc'); - this.initColumnsFunctions(); - }, + this.columns['country'].dataProperties.push('country_code'); + this.columns['flags'].dataProperties.push('flags_desc'); + this.initColumnsFunctions(); + }, - initColumnsFunctions : function () { + initColumnsFunctions: function() { - // country + // country - this.columns['country'].updateTd = function (td, row) { - var country = this.getRowValue(row, 0); - var country_code = this.getRowValue(row, 1); + this.columns['country'].updateTd = function(td, row) { + var country = this.getRowValue(row, 0); + var country_code = this.getRowValue(row, 1); - if (!country_code) { - if (td.getChildren('img').length) - td.getChildren('img')[0].dispose(); - return; - } + if (!country_code) { + if (td.getChildren('img').length) + td.getChildren('img')[0].dispose(); + return; + } - var img_path = 'images/flags/' + country_code + '.svg'; + var img_path = 'images/flags/' + country_code + '.svg'; - if (td.getChildren('img').length) { - var img = td.getChildren('img')[0]; - img.set('src', img_path); - img.set('class', 'flags'); - img.set('alt', country); - img.set('title', country); - } - else - td.adopt(new Element('img', { - 'src' : img_path, - 'class' : 'flags', - 'alt' : country, - 'title' : country - })); - }; + if (td.getChildren('img').length) { + var img = td.getChildren('img')[0]; + img.set('src', img_path); + img.set('class', 'flags'); + img.set('alt', country); + img.set('title', country); + } + else + td.adopt(new Element('img', { + 'src': img_path, + 'class': 'flags', + 'alt': country, + 'title': country + })); + }; - // ip + // ip - this.columns['ip'].compareRows = function (row1, row2) { - var ip1 = this.getRowValue(row1); - var ip2 = this.getRowValue(row2); + this.columns['ip'].compareRows = function(row1, row2) { + var ip1 = this.getRowValue(row1); + var ip2 = this.getRowValue(row2); - var a = ip1.split("."); - var b = ip2.split("."); + var a = ip1.split("."); + var b = ip2.split("."); - for (var i = 0; i < 4; i++){ - if (a[i] != b[i]) - return a[i] - b[i]; - } + for (var i = 0; i < 4; i++) { + if (a[i] != b[i]) + return a[i] - b[i]; + } - return 0; - }; + return 0; + }; - // progress, relevance + // progress, relevance - this.columns['progress'].updateTd = function (td, row) { - var progress = this.getRowValue(row); - var progressFormated = (progress * 100).round(1); - if (progressFormated == 100.0 && progress != 1.0) - progressFormated = 99.9; - progressFormated += "%"; - td.set('html', progressFormated); - }; + this.columns['progress'].updateTd = function(td, row) { + var progress = this.getRowValue(row); + var progressFormated = (progress * 100).round(1); + if (progressFormated == 100.0 && progress != 1.0) + progressFormated = 99.9; + progressFormated += "%"; + td.set('html', progressFormated); + }; - this.columns['relevance'].updateTd = this.columns['progress'].updateTd; + this.columns['relevance'].updateTd = this.columns['progress'].updateTd; - // dl_speed, up_speed + // dl_speed, up_speed - this.columns['dl_speed'].updateTd = function (td, row) { - var speed = this.getRowValue(row); - if (speed === 0) - td.set('html', ''); - else - td.set('html', friendlyUnit(speed, true)); - }; + this.columns['dl_speed'].updateTd = function(td, row) { + var speed = this.getRowValue(row); + if (speed === 0) + td.set('html', ''); + else + td.set('html', friendlyUnit(speed, true)); + }; - this.columns['up_speed'].updateTd = this.columns['dl_speed'].updateTd; + this.columns['up_speed'].updateTd = this.columns['dl_speed'].updateTd; - // downloaded, uploaded + // downloaded, uploaded - this.columns['downloaded'].updateTd = function (td, row) { - var downloaded = this.getRowValue(row); - td.set('html', friendlyUnit(downloaded, false)); - }; + this.columns['downloaded'].updateTd = function(td, row) { + var downloaded = this.getRowValue(row); + td.set('html', friendlyUnit(downloaded, false)); + }; - this.columns['uploaded'].updateTd = this.columns['downloaded'].updateTd; + this.columns['uploaded'].updateTd = this.columns['downloaded'].updateTd; - // flags + // flags - this.columns['flags'].updateTd = function (td, row) { - td.innerHTML = this.getRowValue(row, 0); - td.title = this.getRowValue(row, 1); - }; + this.columns['flags'].updateTd = function(td, row) { + td.innerHTML = this.getRowValue(row, 0); + td.title = this.getRowValue(row, 1); + }; - // files + // files - this.columns['files'].updateTd = function (td, row) { - td.innerHTML = escapeHtml(this.getRowValue(row, 0).replace('\n', ';')); - td.title = escapeHtml(this.getRowValue(row, 0)); - }; + this.columns['files'].updateTd = function(td, row) { + td.innerHTML = escapeHtml(this.getRowValue(row, 0).replace('\n', ';')); + td.title = escapeHtml(this.getRowValue(row, 0)); + }; - } - }); + } +}); /*************************************************************/ diff --git a/src/webui/www/private/scripts/misc.js b/src/webui/www/private/scripts/misc.js index 6d76837e1..b1d14b1b9 100644 --- a/src/webui/www/private/scripts/misc.js +++ b/src/webui/www/private/scripts/misc.js @@ -90,14 +90,14 @@ if (!Date.prototype.toISOString) { } Date.prototype.toISOString = function() { - return this.getUTCFullYear() + - '-' + pad(this.getUTCMonth() + 1) + - '-' + pad(this.getUTCDate()) + - 'T' + pad(this.getUTCHours()) + - ':' + pad(this.getUTCMinutes()) + - ':' + pad(this.getUTCSeconds()) + - '.' + (this.getUTCMilliseconds() / 1000).toFixed(3).slice(2, 5) + - 'Z'; + return this.getUTCFullYear() + + '-' + pad(this.getUTCMonth() + 1) + + '-' + pad(this.getUTCDate()) + + 'T' + pad(this.getUTCHours()) + + ':' + pad(this.getUTCMinutes()) + + ':' + pad(this.getUTCSeconds()) + + '.' + (this.getUTCMilliseconds() / 1000).toFixed(3).slice(2, 5) + + 'Z'; }; }()); @@ -108,7 +108,7 @@ if (!Date.prototype.toISOString) { */ function parseHtmlLinks(text) { var exp = /(\b(https?|ftp|file):\/\/[-A-Z0-9+&@#\/%?=~_|!:,.;]*[-A-Z0-9+&@#\/%=~_|])/ig; - return text.replace(exp,"$1"); + return text.replace(exp, "$1"); } function escapeHtml(str) { diff --git a/src/webui/www/private/scripts/mocha-init.js b/src/webui/www/private/scripts/mocha-init.js index 0b8a701cf..0ea4f16af 100644 --- a/src/webui/www/private/scripts/mocha-init.js +++ b/src/webui/www/private/scripts/mocha-init.js @@ -406,7 +406,7 @@ initializeWindows = function() { } }; - torrentNewCategoryFN = function () { + torrentNewCategoryFN = function() { var hashes = torrentsTable.selectedRowsIds(); if (hashes.length) { new MochaUI.Window({ @@ -425,7 +425,7 @@ initializeWindows = function() { } }; - torrentSetCategoryFN = function (categoryHash) { + torrentSetCategoryFN = function(categoryHash) { var categoryName = ''; if (categoryHash != 0) categoryName = category_list[categoryHash].name; @@ -442,7 +442,7 @@ initializeWindows = function() { } }; - createCategoryFN = function () { + createCategoryFN = function() { new MochaUI.Window({ id: 'newCategoryPage', title: "QBT_TR(New Category)QBT_TR[CONTEXT=CategoryFilterWidget]", @@ -459,7 +459,7 @@ initializeWindows = function() { updateMainData(); }; - removeCategoryFN = function (categoryHash) { + removeCategoryFN = function(categoryHash) { var categoryName = category_list[categoryHash].name; new Request({ url: 'api/v2/torrents/removeCategories', @@ -471,7 +471,7 @@ initializeWindows = function() { setCategoryFilter(CATEGORIES_ALL); }; - deleteUnusedCategoriesFN = function () { + deleteUnusedCategoriesFN = function() { var categories = []; for (var hash in category_list) { if (torrentsTable.getFilteredTorrentsNumber('all', hash) === 0) @@ -487,7 +487,7 @@ initializeWindows = function() { setCategoryFilter(CATEGORIES_ALL); }; - startTorrentsByCategoryFN = function (categoryHash) { + startTorrentsByCategoryFN = function(categoryHash) { var hashes = torrentsTable.getFilteredTorrentsHashes('all', categoryHash); if (hashes.length) { new Request({ @@ -501,7 +501,7 @@ initializeWindows = function() { } }; - pauseTorrentsByCategoryFN = function (categoryHash) { + pauseTorrentsByCategoryFN = function(categoryHash) { var hashes = torrentsTable.getFilteredTorrentsHashes('all', categoryHash); if (hashes.length) { new Request({ @@ -515,7 +515,7 @@ initializeWindows = function() { } }; - deleteTorrentsByCategoryFN = function (categoryHash) { + deleteTorrentsByCategoryFN = function(categoryHash) { var hashes = torrentsTable.getFilteredTorrentsHashes('all', categoryHash); if (hashes.length) { new MochaUI.Window({ diff --git a/src/webui/www/private/scripts/prop-files.js b/src/webui/www/private/scripts/prop-files.js index b09b77eb3..fff20d550 100644 --- a/src/webui/www/private/scripts/prop-files.js +++ b/src/webui/www/private/scripts/prop-files.js @@ -203,27 +203,27 @@ var filesDynTable = new Class({ var tds = tr.getElements('td'); for (var i = 0; i < row.length; i++) { switch (i) { - case 0: - if (row[i] > 0) - tds[i].getChildren('input')[0].set('checked', 'checked'); - else - tds[i].getChildren('input')[0].removeProperty('checked'); - break; - case 3: - $('pbf_' + id).setValue(row[i].toFloat()); - break; - case 4: - if (!is_seed && row[i] > 0) { - tds[i].getChildren('select').set('value', row[i]); - $('comboPrio' + id).removeClass("invisible"); - } - else { - if (!$('comboPrio' + id).hasClass("invisible")) - $('comboPrio' + id).addClass("invisible"); - } - break; - default: - tds[i].set('html', row[i]); + case 0: + if (row[i] > 0) + tds[i].getChildren('input')[0].set('checked', 'checked'); + else + tds[i].getChildren('input')[0].removeProperty('checked'); + break; + case 3: + $('pbf_' + id).setValue(row[i].toFloat()); + break; + case 4: + if (!is_seed && row[i] > 0) { + tds[i].getChildren('select').set('value', row[i]); + $('comboPrio' + id).removeClass("invisible"); + } + else { + if (!$('comboPrio' + id).hasClass("invisible")) + $('comboPrio' + id).addClass("invisible"); + } + break; + default: + tds[i].set('html', row[i]); } } return true; @@ -241,29 +241,29 @@ var filesDynTable = new Class({ for (var i = 0; i < row.length; i++) { var td = new Element('td'); switch (i) { - case 0: - var tree_img = new Element('img', { - src: 'images/L.gif', - style: 'margin-bottom: -2px' - }); - td.adopt(tree_img, createDownloadedCB(id, row[i])); - break; - case 1: - td.set('html', row[i]); - td.set('title', row[i]); - break; - case 3: - td.adopt(new ProgressBar(row[i].toFloat(), { - 'id': 'pbf_' + id, - 'width': 80 - })); - break; - case 4: - td.adopt(createPriorityCombo(id, row[i])); - break; - default: - td.set('html', row[i]); - break; + case 0: + var tree_img = new Element('img', { + src: 'images/L.gif', + style: 'margin-bottom: -2px' + }); + td.adopt(tree_img, createDownloadedCB(id, row[i])); + break; + case 1: + td.set('html', row[i]); + td.set('title', row[i]); + break; + case 3: + td.adopt(new ProgressBar(row[i].toFloat(), { + 'id': 'pbf_' + id, + 'width': 80 + })); + break; + case 4: + td.adopt(createPriorityCombo(id, row[i])); + break; + default: + td.set('html', row[i]); + break; } td.injectInside(tr); } @@ -273,8 +273,8 @@ var filesDynTable = new Class({ var loadTorrentFilesDataTimer; var loadTorrentFilesData = function() { - if ($('prop_files').hasClass('invisible') || - $('propertiesPanel_collapseToggle').hasClass('panel-expand')) { + if ($('prop_files').hasClass('invisible') + || $('propertiesPanel_collapseToggle').hasClass('panel-expand')) { // Tab changed, don't do anything return; } diff --git a/src/webui/www/private/scripts/prop-general.js b/src/webui/www/private/scripts/prop-general.js index 339371f8b..953efa533 100644 --- a/src/webui/www/private/scripts/prop-general.js +++ b/src/webui/www/private/scripts/prop-general.js @@ -27,8 +27,8 @@ var clearData = function() { var loadTorrentDataTimer; var loadTorrentData = function() { - if ($('prop_general').hasClass('invisible') || - $('propertiesPanel_collapseToggle').hasClass('panel-expand')) { + if ($('prop_general').hasClass('invisible') + || $('propertiesPanel_collapseToggle').hasClass('panel-expand')) { // Tab changed, don't do anything return; } @@ -58,8 +58,8 @@ var loadTorrentData = function() { // Update Torrent data if (data.seeding_time > 0) temp = "QBT_TR(%1 (%2 this session))QBT_TR[CONTEXT=PropertiesWidget]" - .replace("%1", friendlyDuration(data.time_elapsed)) - .replace("%2", friendlyDuration(data.seeding_time)); + .replace("%1", friendlyDuration(data.time_elapsed)) + .replace("%2", friendlyDuration(data.seeding_time)); else temp = friendlyDuration(data.time_elapsed); $('time_elapsed').set('html', temp); @@ -67,28 +67,28 @@ var loadTorrentData = function() { $('eta').set('html', friendlyDuration(data.eta)); temp = "QBT_TR(%1 (%2 max))QBT_TR[CONTEXT=PropertiesWidget]" - .replace("%1", data.nb_connections) - .replace("%2", data.nb_connections_limit < 0 ? "∞" : data.nb_connections_limit); + .replace("%1", data.nb_connections) + .replace("%2", data.nb_connections_limit < 0 ? "∞" : data.nb_connections_limit); $('nb_connections').set('html', temp); temp = "QBT_TR(%1 (%2 this session))QBT_TR[CONTEXT=PropertiesWidget]" - .replace("%1", friendlyUnit(data.total_downloaded)) - .replace("%2", friendlyUnit(data.total_downloaded_session)); + .replace("%1", friendlyUnit(data.total_downloaded)) + .replace("%2", friendlyUnit(data.total_downloaded_session)); $('total_downloaded').set('html', temp); temp = "QBT_TR(%1 (%2 this session))QBT_TR[CONTEXT=PropertiesWidget]" - .replace("%1", friendlyUnit(data.total_uploaded)) - .replace("%2", friendlyUnit(data.total_uploaded_session)); + .replace("%1", friendlyUnit(data.total_uploaded)) + .replace("%2", friendlyUnit(data.total_uploaded_session)); $('total_uploaded').set('html', temp); temp = "QBT_TR(%1 (%2 avg.))QBT_TR[CONTEXT=PropertiesWidget]" - .replace("%1", friendlyUnit(data.dl_speed, true)) - .replace("%2", friendlyUnit(data.dl_speed_avg, true)); + .replace("%1", friendlyUnit(data.dl_speed, true)) + .replace("%2", friendlyUnit(data.dl_speed_avg, true)); $('dl_speed').set('html', temp); temp = "QBT_TR(%1 (%2 avg.))QBT_TR[CONTEXT=PropertiesWidget]" - .replace("%1", friendlyUnit(data.up_speed, true)) - .replace("%2", friendlyUnit(data.up_speed_avg, true)); + .replace("%1", friendlyUnit(data.up_speed, true)) + .replace("%2", friendlyUnit(data.up_speed_avg, true)); $('up_speed').set('html', temp); temp = (data.dl_limit == -1 ? "∞" : friendlyUnit(data.dl_limit, true)); @@ -100,13 +100,13 @@ var loadTorrentData = function() { $('total_wasted').set('html', friendlyUnit(data.total_wasted)); temp = "QBT_TR(%1 (%2 total))QBT_TR[CONTEXT=PropertiesWidget]" - .replace("%1", data.seeds) - .replace("%2", data.seeds_total); + .replace("%1", data.seeds) + .replace("%2", data.seeds_total); $('seeds').set('html', temp); temp = "QBT_TR(%1 (%2 total))QBT_TR[CONTEXT=PropertiesWidget]" - .replace("%1", data.peers) - .replace("%2", data.peers_total); + .replace("%1", data.peers) + .replace("%2", data.peers_total); $('peers').set('html', temp); $('share_ratio').set('html', data.share_ratio.toFixed(2)); @@ -123,9 +123,9 @@ var loadTorrentData = function() { if (data.pieces_num != -1) temp = "QBT_TR(%1 x %2 (have %3))QBT_TR[CONTEXT=PropertiesWidget]" - .replace("%1", data.pieces_num) - .replace("%2", friendlyUnit(data.piece_size)) - .replace("%3", data.pieces_have); + .replace("%1", data.pieces_num) + .replace("%2", friendlyUnit(data.piece_size)) + .replace("%3", data.pieces_have); else temp = "QBT_TR(Unknown)QBT_TR[CONTEXT=HttpServer]"; $('pieces').set('html', temp); diff --git a/src/webui/www/private/scripts/prop-trackers.js b/src/webui/www/private/scripts/prop-trackers.js index 6770de5ad..fab9201c3 100644 --- a/src/webui/www/private/scripts/prop-trackers.js +++ b/src/webui/www/private/scripts/prop-trackers.js @@ -54,8 +54,8 @@ var current_hash = ""; var loadTrackersDataTimer; var loadTrackersData = function() { - if ($('prop_trackers').hasClass('invisible') || - $('propertiesPanel_collapseToggle').hasClass('panel-expand')) { + if ($('prop_trackers').hasClass('invisible') + || $('propertiesPanel_collapseToggle').hasClass('panel-expand')) { // Tab changed, don't do anything return; } diff --git a/src/webui/www/private/scripts/prop-webseeds.js b/src/webui/www/private/scripts/prop-webseeds.js index 5cde2b30d..494821537 100644 --- a/src/webui/www/private/scripts/prop-webseeds.js +++ b/src/webui/www/private/scripts/prop-webseeds.js @@ -54,8 +54,8 @@ var current_hash = ""; var loadWebSeedsDataTimer; var loadWebSeedsData = function() { - if ($('prop_webseeds').hasClass('invisible') || - $('propertiesPanel_collapseToggle').hasClass('panel-expand')) { + if ($('prop_webseeds').hasClass('invisible') + || $('propertiesPanel_collapseToggle').hasClass('panel-expand')) { // Tab changed, don't do anything return; } diff --git a/src/webui/www/private/setlocation.html b/src/webui/www/private/setlocation.html index ebf884021..6824099a7 100644 --- a/src/webui/www/private/setlocation.html +++ b/src/webui/www/private/setlocation.html @@ -1,5 +1,6 @@ + QBT_TR(Set location)QBT_TR[CONTEXT=HttpServer] @@ -10,7 +11,7 @@ var setLocationKeyboardEvents = new Keyboard({ defaultEventType: 'keydown', events: { - 'enter': function (event) { + 'enter': function(event) { $('setLocationButton').click(); event.preventDefault(); } @@ -35,7 +36,7 @@ hashes: hashesList, location: location }, - onComplete: function () { + onComplete: function() { window.parent.closeWindows(); } }).send(); @@ -43,13 +44,15 @@ }); +

QBT_TR(Location)QBT_TR[CONTEXT=TransferListWidget]:

- +
- +
+ diff --git a/src/webui/www/private/transferlist.html b/src/webui/www/private/transferlist.html index 6a9353d46..779e61019 100644 --- a/src/webui/www/private/transferlist.html +++ b/src/webui/www/private/transferlist.html @@ -16,74 +16,73 @@ + - -
-
- -
-
-
- - -
-
- - -
-
- - -
-
- - - -
-
- - -
-
- - -
-
- - -
-
- - -
-
- - -
-
- - -
-
- -
-
-
- -
+ $('start_torrent').addEventListener('change', function() { + $('add_paused').disabled = $('start_torrent').checked; + }); + +
+ diff --git a/src/webui/www/private/uploadlimit.html b/src/webui/www/private/uploadlimit.html index 6cdb27948..1f0a5a93b 100644 --- a/src/webui/www/private/uploadlimit.html +++ b/src/webui/www/private/uploadlimit.html @@ -1,5 +1,6 @@ + QBT_TR(Torrent Upload Speed Limiting)QBT_TR[CONTEXT=TransferListWidget] @@ -9,54 +10,56 @@ - -
-
-
QBT_TR(Upload limit:)QBT_TR[CONTEXT=PropertiesWidget] QBT_TR(KiB/s)QBT_TR[CONTEXT=SpeedLimitDialog]
-
-
-
-
-
-
- - -
- + +
+
+
QBT_TR(Upload limit:)QBT_TR[CONTEXT=PropertiesWidget] QBT_TR(KiB/s)QBT_TR[CONTEXT=SpeedLimitDialog]
+
+
+
+
+
+
+ + +
+ + + diff --git a/src/webui/www/public/css/style.css b/src/webui/www/public/css/style.css index 61a56233b..384f092c6 100644 --- a/src/webui/www/public/css/style.css +++ b/src/webui/www/public/css/style.css @@ -33,5 +33,5 @@ body { } #logo img { - height: 11em; + height: 11em; } diff --git a/src/webui/www/public/login.html b/src/webui/www/public/login.html index 080795745..9b0bbe734 100644 --- a/src/webui/www/public/login.html +++ b/src/webui/www/public/login.html @@ -1,5 +1,6 @@ + qBittorrent QBT_TR(Web UI)QBT_TR[CONTEXT=OptionsDialog] @@ -7,50 +8,53 @@ +

qBittorrent QBT_TR(Web UI)QBT_TR[CONTEXT=OptionsDialog]

@@ -61,11 +65,12 @@
- +
+