Changeset 12749
- Timestamp:
- Aug 26, 2011, 1:46:07 AM (12 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/web/javascript/transmission.js
r12748 r12749 722 722 }, 723 723 724 inspectorTabClicked: function(ev, tab) {725 if (iPhone) ev.stopPropagation();726 727 // select this tab and deselect the others728 $(tab).addClass('selected').siblings().removeClass('selected');729 730 // show this tab and hide the others731 $('#'+tab.id+'_container').show().siblings('.inspector_container').hide();732 733 this.hideiPhoneAddressbar();734 this.updatePeersLists();735 this.updateTrackersLists();736 this.updateFileList();737 },738 739 724 filesSelectAllClicked: function() { 740 725 var t = this._file_torrent; … … 1132 1117 }, 1133 1118 1119 1120 onTorrentChanged: function(ev) 1121 { 1122 this.refilterSoon(); 1123 1124 // if this torrent is in the inspector, refresh the inspector 1125 if (this[Prefs._ShowInspector]) 1126 if (this.getSelectedTorrentIds().indexOf(ev.target.getId()) !== -1) 1127 this.updateInspector(); 1128 }, 1129 1130 updateFromTorrentGet: function(updates, removed_ids) 1131 { 1132 var new_ids = []; 1133 1134 for (var i=0, o; o=updates[i]; ++i) { 1135 var t; 1136 var id = o.id; 1137 if ((t = this._torrents[id])) 1138 t.refresh(o); 1139 else { 1140 t = this._torrents[id] = new Torrent(o); 1141 $(t).bind('dataChanged',function(ev) {tr.onTorrentChanged(ev);}); 1142 new_ids.push(id); 1143 } 1144 } 1145 1146 if (new_ids.length) { 1147 var tr = this; 1148 this.remote.getTorrentInitial(new_ids, function(a,b){tr.updateFromTorrentGet(a,b);}); 1149 this.refilterSoon(); 1150 } 1151 1152 if (removed_ids) { 1153 this.deleteTorrents(removed_ids); 1154 this.refilterSoon(); 1155 } 1156 }, 1157 1158 refreshTorrents: function(ids) { 1159 if (!ids) 1160 ids = 'recently-active'; 1161 var tr = this; 1162 this.remote.getTorrentStats(ids, function(a,b){tr.updateFromTorrentGet(a,b);}); 1163 }, 1164 initializeAllTorrents: function() { 1165 var tr = this; 1166 this.remote.getTorrentInitial(null, function(a,b){tr.updateFromTorrentGet(a,b);}); 1167 }, 1168 refreshMetadata: function(ids) { 1169 var tr = this; 1170 this.remote.getTorrentMetadata(ids, function(a,b){tr.updateFromTorrentGet(a,b);}); 1171 }, 1172 refreshInspectorTorrents: function(full) { 1173 var tr = this; 1174 var ids = tr.getSelectedTorrentIds(); 1175 if (ids.length > 0) 1176 this.remote.getTorrentDetails(ids, full, function(a,b){tr.updateFromTorrentGet(a,b);}); 1177 }, 1178 1179 onRowClicked: function(ev, row) 1180 { 1181 // Prevents click carrying to parent element 1182 // which deselects all on click 1183 ev.stopPropagation(); 1184 // but still hide the context menu if it is showing 1185 $('#jqContextMenu').hide(); 1186 1187 // 'Apple' button emulation on PC : 1188 // Need settable meta-key and ctrl-key variables for mac emulation 1189 var meta_key = ev.metaKey; 1190 if (ev.ctrlKey && navigator.appVersion.toLowerCase().indexOf("mac") == -1) 1191 meta_key = true; 1192 1193 // Shift-Click - selects a range from the last-clicked row to this one 1194 if (iPhone) { 1195 if (row.isSelected()) 1196 this.setInspectorVisible(true); 1197 this.setSelectedRow(row); 1198 1199 } else if (ev.shiftKey) { 1200 this.selectRange(row); 1201 // Need to deselect any selected text 1202 window.focus(); 1203 1204 // Apple-Click, not selected 1205 } else if (!row.isSelected() && meta_key) { 1206 this.selectRow(row); 1207 1208 // Regular Click, not selected 1209 } else if (!row.isSelected()) { 1210 this.setSelectedRow(row); 1211 1212 // Apple-Click, selected 1213 } else if (row.isSelected() && meta_key) { 1214 this.deselectRow(row); 1215 1216 // Regular Click, selected 1217 } else if (row.isSelected()) { 1218 this.setSelectedRow(row); 1219 } 1220 1221 this._last_torrent_clicked = row.getTorrentId(); 1222 }, 1223 1224 deleteTorrents: function(torrent_ids) 1225 { 1226 if (torrent_ids && torrent_ids.length) 1227 { 1228 for (var i=0, id; id=torrent_ids[i]; ++i) 1229 delete this._torrents[id]; 1230 this.refilter(); 1231 } 1232 }, 1233 1234 updateStatusbar: function() 1235 { 1236 this.refreshFilterButton(); 1237 1238 // up/down speed 1239 var u=0, d=0; 1240 var torrents = this.getAllTorrents(); 1241 for (var i=0, row; row=torrents[i]; ++i) { 1242 u += row.getUploadSpeed(); 1243 d += row.getDownloadSpeed(); 1244 } 1245 setInnerHTML($('#statusbar #speed-up-label')[0], '↑ ' + Transmission.fmt.speedBps(u)); 1246 setInnerHTML($('#statusbar #speed-dn-label')[0], '↓ ' + Transmission.fmt.speedBps(d)); 1247 }, 1248 1249 /* 1250 * Select a torrent file to upload 1251 * FIXME 1252 */ 1253 uploadTorrentFile: function(confirmed) 1254 { 1255 // Display the upload dialog 1256 if (! confirmed) { 1257 $('input#torrent_upload_file').attr('value', ''); 1258 $('input#torrent_upload_url').attr('value', ''); 1259 $('input#torrent_auto_start').attr('checked', $('#prefs_form #auto_start')[0].checked); 1260 $('#upload_container').show(); 1261 $('#torrent_upload_url').focus(); 1262 if (!iPhone && Safari3) { 1263 setTimeout("$('div#upload_container div.dialog_window').css('top', '0px');",10); 1264 } 1265 1266 // Submit the upload form 1267 } else { 1268 var tr = this; 1269 var args = { }; 1270 var paused = !$('#torrent_auto_start').is(':checked'); 1271 if ('' != $('#torrent_upload_url').val()) { 1272 tr.remote.addTorrentByUrl($('#torrent_upload_url').val(), { paused: paused }); 1273 } else { 1274 args.url = '../upload?paused=' + paused; 1275 args.type = 'POST'; 1276 args.data = { 'X-Transmission-Session-Id' : tr.remote._token }; 1277 args.dataType = 'xml'; 1278 args.iframe = true; 1279 args.success = function() { 1280 tr.refreshTorrents(); 1281 tr.togglePeriodicRefresh(true); 1282 }; 1283 tr.togglePeriodicRefresh(false); 1284 $('#torrent_upload_form').ajaxSubmit(args); 1285 } 1286 } 1287 }, 1288 1289 removeSelectedTorrents: function() { 1290 var torrents = this.getSelectedTorrents(); 1291 if (torrents.length) 1292 this.promptToRemoveTorrents(torrents); 1293 }, 1294 1295 removeSelectedTorrentsAndData: function() { 1296 var torrents = this.getSelectedTorrents(); 1297 if (torrents.length) 1298 this.promptToRemoveTorrentsAndData(torrents); 1299 }, 1300 1301 promptToRemoveTorrents:function(torrents) 1302 { 1303 if (torrents.length == 1) 1304 { 1305 var torrent = torrents[0]; 1306 var header = 'Remove ' + torrent.getName() + '?'; 1307 var message = 'Once removed, continuing the transfer will require the torrent file. Are you sure you want to remove it?'; 1308 dialog.confirm(header, message, 'Remove', 'transmission.removeTorrents', torrents); 1309 } 1310 else 1311 { 1312 var header = 'Remove ' + torrents.length + ' transfers?'; 1313 var message = 'Once removed, continuing the transfers will require the torrent files. Are you sure you want to remove them?'; 1314 dialog.confirm(header, message, 'Remove', 'transmission.removeTorrents', torrents); 1315 } 1316 }, 1317 1318 promptToRemoveTorrentsAndData:function(torrents) 1319 { 1320 if (torrents.length == 1) 1321 { 1322 var torrent = torrents[0], 1323 header = 'Remove ' + torrent.getName() + ' and delete data?', 1324 message = 'All data downloaded for this torrent will be deleted. Are you sure you want to remove it?'; 1325 dialog.confirm(header, message, 'Remove', 'transmission.removeTorrentsAndData', torrents); 1326 } 1327 else 1328 { 1329 var header = 'Remove ' + torrents.length + ' transfers and delete data?', 1330 message = 'All data downloaded for these torrents will be deleted. Are you sure you want to remove them?'; 1331 dialog.confirm(header, message, 'Remove', 'transmission.removeTorrentsAndData', torrents); 1332 } 1333 }, 1334 1335 removeTorrents: function(torrents) { 1336 var torrent_ids = jQuery.map(torrents, function(t) { return t.getId(); }); 1337 var tr = this; 1338 this.remote.removeTorrents(torrent_ids, function() { tr.refreshTorrents();}); 1339 }, 1340 1341 removeTorrentsAndData: function(torrents) { 1342 this.remote.removeTorrentsAndData(torrents); 1343 }, 1344 1345 verifySelectedTorrents: function() { 1346 this.verifyTorrents(this.getSelectedTorrents()); 1347 }, 1348 1349 reannounceSelectedTorrents: function() { 1350 this.reannounceTorrents(this.getSelectedTorrents()); 1351 }, 1352 1353 startSelectedTorrents: function(force) { 1354 this.startTorrents(this.getSelectedTorrents(), force); 1355 }, 1356 startAllTorrents: function() { 1357 this.startTorrents(this.getAllTorrents(), false); 1358 }, 1359 startTorrent: function(torrent) { 1360 this.startTorrents([ torrent ], false); 1361 }, 1362 startTorrents: function(torrents, force) { 1363 var torrent_ids = jQuery.map(torrents, function(t) { return t.getId(); }); 1364 var tr = this; 1365 this.remote.startTorrents(torrent_ids, force, function() { tr.refreshTorrents(torrent_ids); }); 1366 }, 1367 verifyTorrent: function(torrent) { 1368 this.verifyTorrents([ torrent ]); 1369 }, 1370 verifyTorrents: function(torrents) { 1371 var tr = this; 1372 var torrent_ids = jQuery.map(torrents, function(t) { return t.getId(); }); 1373 this.remote.verifyTorrents(torrent_ids, function() { tr.refreshTorrents(torrent_ids); }); 1374 }, 1375 1376 reannounceTorrent: function(torrent) { 1377 this.reannounceTorrents([ torrent ]); 1378 }, 1379 reannounceTorrents: function(torrents) { 1380 var tr = this; 1381 var torrent_ids = jQuery.map(torrents, function(t) { return t.getId(); }); 1382 this.remote.reannounceTorrents(torrent_ids, function() { tr.refreshTorrents(torrent_ids); }); 1383 }, 1384 1385 stopSelectedTorrents: function() { 1386 this.stopTorrents(this.getSelectedTorrents()); 1387 }, 1388 stopAllTorrents: function() { 1389 this.stopTorrents(this.getAllTorrents()); 1390 }, 1391 stopTorrent: function(torrent) { 1392 this.stopTorrents([ torrent ]); 1393 }, 1394 stopTorrents: function(torrents) { 1395 var torrent_ids = jQuery.map(torrents, function(t) { return t.getId(); }); 1396 var tr = this; 1397 this.remote.stopTorrents(torrent_ids, function() { tr.refreshTorrents(torrent_ids);}); 1398 }, 1399 changeFileCommand: function(command, rows) { 1400 this.remote.changeFileCommand(command, rows); 1401 }, 1402 1403 hideiPhoneAddressbar: function(timeInSeconds) { 1404 if (iPhone) { 1405 var delayLength = timeInSeconds ? timeInSeconds*1000 : 150; 1406 // not currently supported on iPhone 1407 if (/*document.body.scrollTop!=1 && */scroll_timeout==null) { 1408 var tr = this; 1409 scroll_timeout = setTimeout(function() {tr.doToolbarHide();}, delayLength); 1410 } 1411 } 1412 }, 1413 doToolbarHide: function() { 1414 window.scrollTo(0,1); 1415 scroll_timeout=null; 1416 }, 1417 1418 // Queue 1419 moveTop: function() { 1420 var tr = this; 1421 var torrent_ids = this.getSelectedTorrentIds(); 1422 this.remote.moveTorrentsToTop(torrent_ids, function() { tr.refreshTorrents(torrent_ids);}); 1423 }, 1424 moveUp: function() { 1425 var tr = this; 1426 var torrent_ids = this.getSelectedTorrentIds(); 1427 this.remote.moveTorrentsUp(torrent_ids, function() { tr.refreshTorrents(torrent_ids);}); 1428 }, 1429 moveDown: function() { 1430 var tr = this; 1431 var torrent_ids = this.getSelectedTorrentIds(); 1432 this.remote.moveTorrentsDown(torrent_ids, function() { tr.refreshTorrents(torrent_ids);}); 1433 }, 1434 moveBottom: function() { 1435 var tr = this; 1436 var torrent_ids = this.getSelectedTorrentIds(); 1437 this.remote.moveTorrentsToBottom(torrent_ids, function() { tr.refreshTorrents(torrent_ids);}); 1438 }, 1439 1440 1441 /*** 1442 **** 1443 ***/ 1444 1445 onToggleRunningClicked: function(ev) 1446 { 1447 var torrent = ev.data.r.getTorrent(); 1448 1449 if (torrent.isStopped()) 1450 this.startTorrent(torrent); 1451 else 1452 this.stopTorrent(torrent); 1453 }, 1454 1455 setEnabled: function(key, flag) 1456 { 1457 $(key).toggleClass('disabled', !flag); 1458 }, 1459 1460 updateButtonStates: function() 1461 { 1462 var showing_dialog = new RegExp("(prefs_showing|dialog_showing|open_showing)").test(document.body.className); 1463 this._toolbar_buttons.toggleClass('disabled', showing_dialog); 1464 1465 if (!showing_dialog) 1466 { 1467 var haveSelection = false; 1468 var haveActive = false; 1469 var haveActiveSelection = false; 1470 var havePaused = false; 1471 var havePausedSelection = false; 1472 1473 for (var i=0, row; row=this._rows[i]; ++i) { 1474 var isStopped = row.getTorrent().isStopped(); 1475 var isSelected = row.isSelected(); 1476 if (!isStopped) haveActive = true; 1477 if (isStopped) havePaused = true; 1478 if (isSelected) haveSelection = true; 1479 if (isSelected && !isStopped) haveActiveSelection = true; 1480 if (isSelected && isStopped) havePausedSelection = true; 1481 } 1482 1483 this.setEnabled(this._toolbar_pause_button, haveActiveSelection); 1484 this.setEnabled(this._context_pause_button, haveActiveSelection); 1485 this.setEnabled(this._toolbar_start_button, havePausedSelection); 1486 this.setEnabled(this._context_start_button, havePausedSelection); 1487 this.setEnabled(this._context_move_top_button, haveSelection); 1488 this.setEnabled(this._context_move_up_button, haveSelection); 1489 this.setEnabled(this._context_move_down_button, haveSelection); 1490 this.setEnabled(this._context_move_bottom_button, haveSelection); 1491 this.setEnabled(this._context_start_now_button, havePausedSelection); 1492 this.setEnabled(this._toolbar_remove_button, haveSelection); 1493 this.setEnabled(this._toolbar_pause_all_button, haveActive); 1494 this.setEnabled(this._toolbar_start_all_button, havePaused); 1495 } 1496 }, 1497 1498 /**** 1499 ***** 1500 ***** INSPECTOR 1501 ***** 1502 ****/ 1503 1504 inspectorTabClicked: function(ev, tab) 1505 { 1506 if (iPhone) ev.stopPropagation(); 1507 1508 // select this tab and deselect the others 1509 $(tab).addClass('selected').siblings().removeClass('selected'); 1510 1511 // show this tab and hide the others 1512 $('#'+tab.id+'_container').show().siblings('.inspector_container').hide(); 1513 1514 this.hideiPhoneAddressbar(); 1515 this.updatePeersLists(); 1516 this.updateTrackersLists(); 1517 this.updateFileList(); 1518 }, 1134 1519 /* 1135 1520 * Update the inspector with the latest data for the selected torrents … … 1535 1920 }, 1536 1921 1537 onTorrentChanged: function(ev)1538 {1539 this.refilterSoon();1540 1541 // if this torrent is in the inspector, refresh the inspector1542 if (this[Prefs._ShowInspector])1543 if (this.getSelectedTorrentIds().indexOf(ev.target.getId()) !== -1)1544 this.updateInspector();1545 },1546 1547 updateFromTorrentGet: function(updates, removed_ids)1548 {1549 var new_ids = [];1550 1551 for (var i=0, o; o=updates[i]; ++i) {1552 var t;1553 var id = o.id;1554 if ((t = this._torrents[id]))1555 t.refresh(o);1556 else {1557 t = this._torrents[id] = new Torrent(o);1558 $(t).bind('dataChanged',function(ev) {tr.onTorrentChanged(ev);});1559 new_ids.push(id);1560 }1561 }1562 1563 if (new_ids.length) {1564 var tr = this;1565 this.remote.getTorrentInitial(new_ids, function(a,b){tr.updateFromTorrentGet(a,b);});1566 this.refilterSoon();1567 }1568 1569 if (removed_ids) {1570 this.deleteTorrents(removed_ids);1571 this.refilterSoon();1572 }1573 },1574 1575 refreshTorrents: function(ids) {1576 if (!ids)1577 ids = 'recently-active';1578 var tr = this;1579 this.remote.getTorrentStats(ids, function(a,b){tr.updateFromTorrentGet(a,b);});1580 },1581 initializeAllTorrents: function() {1582 var tr = this;1583 this.remote.getTorrentInitial(null, function(a,b){tr.updateFromTorrentGet(a,b);});1584 },1585 refreshMetadata: function(ids) {1586 var tr = this;1587 this.remote.getTorrentMetadata(ids, function(a,b){tr.updateFromTorrentGet(a,b);});1588 },1589 refreshInspectorTorrents: function(full) {1590 var tr = this;1591 var ids = tr.getSelectedTorrentIds();1592 if (ids.length > 0)1593 this.remote.getTorrentDetails(ids, full, function(a,b){tr.updateFromTorrentGet(a,b);});1594 },1595 1596 onRowClicked: function(ev, row)1597 {1598 // Prevents click carrying to parent element1599 // which deselects all on click1600 ev.stopPropagation();1601 // but still hide the context menu if it is showing1602 $('#jqContextMenu').hide();1603 1604 // 'Apple' button emulation on PC :1605 // Need settable meta-key and ctrl-key variables for mac emulation1606 var meta_key = ev.metaKey;1607 if (ev.ctrlKey && navigator.appVersion.toLowerCase().indexOf("mac") == -1)1608 meta_key = true;1609 1610 // Shift-Click - selects a range from the last-clicked row to this one1611 if (iPhone) {1612 if (row.isSelected())1613 this.setInspectorVisible(true);1614 this.setSelectedRow(row);1615 1616 } else if (ev.shiftKey) {1617 this.selectRange(row);1618 // Need to deselect any selected text1619 window.focus();1620 1621 // Apple-Click, not selected1622 } else if (!row.isSelected() && meta_key) {1623 this.selectRow(row);1624 1625 // Regular Click, not selected1626 } else if (!row.isSelected()) {1627 this.setSelectedRow(row);1628 1629 // Apple-Click, selected1630 } else if (row.isSelected() && meta_key) {1631 this.deselectRow(row);1632 1633 // Regular Click, selected1634 } else if (row.isSelected()) {1635 this.setSelectedRow(row);1636 }1637 1638 this._last_torrent_clicked = row.getTorrentId();1639 },1640 1641 deleteTorrents: function(torrent_ids)1642 {1643 if (torrent_ids && torrent_ids.length)1644 {1645 for (var i=0, id; id=torrent_ids[i]; ++i)1646 delete this._torrents[id];1647 this.refilter();1648 }1649 },1650 1651 updateStatusbar: function()1652 {1653 this.refreshFilterButton();1654 1655 // up/down speed1656 var u=0, d=0;1657 var torrents = this.getAllTorrents();1658 for (var i=0, row; row=torrents[i]; ++i) {1659 u += row.getUploadSpeed();1660 d += row.getDownloadSpeed();1661 }1662 setInnerHTML($('#statusbar #speed-up-label')[0], '↑ ' + Transmission.fmt.speedBps(u));1663 setInnerHTML($('#statusbar #speed-dn-label')[0], '↓ ' + Transmission.fmt.speedBps(d));1664 },1665 1666 /*1667 * Select a torrent file to upload1668 * FIXME1669 */1670 uploadTorrentFile: function(confirmed)1671 {1672 // Display the upload dialog1673 if (! confirmed) {1674 $('input#torrent_upload_file').attr('value', '');1675 $('input#torrent_upload_url').attr('value', '');1676 $('input#torrent_auto_start').attr('checked', $('#prefs_form #auto_start')[0].checked);1677 $('#upload_container').show();1678 $('#torrent_upload_url').focus();1679 if (!iPhone && Safari3) {1680 setTimeout("$('div#upload_container div.dialog_window').css('top', '0px');",10);1681 }1682 1683 // Submit the upload form1684 } else {1685 var tr = this;1686 var args = { };1687 var paused = !$('#torrent_auto_start').is(':checked');1688 if ('' != $('#torrent_upload_url').val()) {1689 tr.remote.addTorrentByUrl($('#torrent_upload_url').val(), { paused: paused });1690 } else {1691 args.url = '../upload?paused=' + paused;1692 args.type = 'POST';1693 args.data = { 'X-Transmission-Session-Id' : tr.remote._token };1694 args.dataType = 'xml';1695 args.iframe = true;1696 args.success = function() {1697 tr.refreshTorrents();1698 tr.togglePeriodicRefresh(true);1699 };1700 tr.togglePeriodicRefresh(false);1701 $('#torrent_upload_form').ajaxSubmit(args);1702 }1703 }1704 },1705 1706 removeSelectedTorrents: function() {1707 var torrents = this.getSelectedTorrents();1708 if (torrents.length)1709 this.promptToRemoveTorrents(torrents);1710 },1711 1712 removeSelectedTorrentsAndData: function() {1713 var torrents = this.getSelectedTorrents();1714 if (torrents.length)1715 this.promptToRemoveTorrentsAndData(torrents);1716 },1717 1718 promptToRemoveTorrents:function(torrents)1719 {1720 if (torrents.length == 1)1721 {1722 var torrent = torrents[0];1723 var header = 'Remove ' + torrent.getName() + '?';1724 var message = 'Once removed, continuing the transfer will require the torrent file. Are you sure you want to remove it?';1725 dialog.confirm(header, message, 'Remove', 'transmission.removeTorrents', torrents);1726 }1727 else1728 {1729 var header = 'Remove ' + torrents.length + ' transfers?';1730 var message = 'Once removed, continuing the transfers will require the torrent files. Are you sure you want to remove them?';1731 dialog.confirm(header, message, 'Remove', 'transmission.removeTorrents', torrents);1732 }1733 },1734 1735 promptToRemoveTorrentsAndData:function(torrents)1736 {1737 if (torrents.length == 1)1738 {1739 var torrent = torrents[0],1740 header = 'Remove ' + torrent.getName() + ' and delete data?',1741 message = 'All data downloaded for this torrent will be deleted. Are you sure you want to remove it?';1742 dialog.confirm(header, message, 'Remove', 'transmission.removeTorrentsAndData', torrents);1743 }1744 else1745 {1746 var header = 'Remove ' + torrents.length + ' transfers and delete data?',1747 message = 'All data downloaded for these torrents will be deleted. Are you sure you want to remove them?';1748 dialog.confirm(header, message, 'Remove', 'transmission.removeTorrentsAndData', torrents);1749 }1750 },1751 1752 removeTorrents: function(torrents) {1753 var torrent_ids = jQuery.map(torrents, function(t) { return t.getId(); });1754 var tr = this;1755 this.remote.removeTorrents(torrent_ids, function() { tr.refreshTorrents();});1756 },1757 1758 removeTorrentsAndData: function(torrents) {1759 this.remote.removeTorrentsAndData(torrents);1760 },1761 1762 verifySelectedTorrents: function() {1763 this.verifyTorrents(this.getSelectedTorrents());1764 },1765 1766 reannounceSelectedTorrents: function() {1767 this.reannounceTorrents(this.getSelectedTorrents());1768 },1769 1770 startSelectedTorrents: function(force) {1771 this.startTorrents(this.getSelectedTorrents(), force);1772 },1773 startAllTorrents: function() {1774 this.startTorrents(this.getAllTorrents(), false);1775 },1776 startTorrent: function(torrent) {1777 this.startTorrents([ torrent ], false);1778 },1779 startTorrents: function(torrents, force) {1780 var torrent_ids = jQuery.map(torrents, function(t) { return t.getId(); });1781 var tr = this;1782 this.remote.startTorrents(torrent_ids, force, function() { tr.refreshTorrents(torrent_ids); });1783 },1784 verifyTorrent: function(torrent) {1785 this.verifyTorrents([ torrent ]);1786 },1787 verifyTorrents: function(torrents) {1788 var tr = this;1789 var torrent_ids = jQuery.map(torrents, function(t) { return t.getId(); });1790 this.remote.verifyTorrents(torrent_ids, function() { tr.refreshTorrents(torrent_ids); });1791 },1792 1793 reannounceTorrent: function(torrent) {1794 this.reannounceTorrents([ torrent ]);1795 },1796 reannounceTorrents: function(torrents) {1797 var tr = this;1798 var torrent_ids = jQuery.map(torrents, function(t) { return t.getId(); });1799 this.remote.reannounceTorrents(torrent_ids, function() { tr.refreshTorrents(torrent_ids); });1800 },1801 1802 stopSelectedTorrents: function() {1803 this.stopTorrents(this.getSelectedTorrents());1804 },1805 stopAllTorrents: function() {1806 this.stopTorrents(this.getAllTorrents());1807 },1808 stopTorrent: function(torrent) {1809 this.stopTorrents([ torrent ]);1810 },1811 stopTorrents: function(torrents) {1812 var torrent_ids = jQuery.map(torrents, function(t) { return t.getId(); });1813 var tr = this;1814 this.remote.stopTorrents(torrent_ids, function() { tr.refreshTorrents(torrent_ids);});1815 },1816 changeFileCommand: function(command, rows) {1817 this.remote.changeFileCommand(command, rows);1818 },1819 1820 hideiPhoneAddressbar: function(timeInSeconds) {1821 if (iPhone) {1822 var delayLength = timeInSeconds ? timeInSeconds*1000 : 150;1823 // not currently supported on iPhone1824 if (/*document.body.scrollTop!=1 && */scroll_timeout==null) {1825 var tr = this;1826 scroll_timeout = setTimeout(function() {tr.doToolbarHide();}, delayLength);1827 }1828 }1829 },1830 doToolbarHide: function() {1831 window.scrollTo(0,1);1832 scroll_timeout=null;1833 },1834 1835 // Queue1836 moveTop: function() {1837 var tr = this;1838 var torrent_ids = this.getSelectedTorrentIds();1839 this.remote.moveTorrentsToTop(torrent_ids, function() { tr.refreshTorrents(torrent_ids);});1840 },1841 moveUp: function() {1842 var tr = this;1843 var torrent_ids = this.getSelectedTorrentIds();1844 this.remote.moveTorrentsUp(torrent_ids, function() { tr.refreshTorrents(torrent_ids);});1845 },1846 moveDown: function() {1847 var tr = this;1848 var torrent_ids = this.getSelectedTorrentIds();1849 this.remote.moveTorrentsDown(torrent_ids, function() { tr.refreshTorrents(torrent_ids);});1850 },1851 moveBottom: function() {1852 var tr = this;1853 var torrent_ids = this.getSelectedTorrentIds();1854 this.remote.moveTorrentsToBottom(torrent_ids, function() { tr.refreshTorrents(torrent_ids);});1855 },1856 1857 1858 /***1859 ****1860 ***/1861 1862 onToggleRunningClicked: function(ev)1863 {1864 var torrent = ev.data.r.getTorrent();1865 1866 if (torrent.isStopped())1867 this.startTorrent(torrent);1868 else1869 this.stopTorrent(torrent);1870 },1871 1872 setEnabled: function(key, flag)1873 {1874 $(key).toggleClass('disabled', !flag);1875 },1876 1877 updateButtonStates: function()1878 {1879 var showing_dialog = new RegExp("(prefs_showing|dialog_showing|open_showing)").test(document.body.className);1880 this._toolbar_buttons.toggleClass('disabled', showing_dialog);1881 1882 if (!showing_dialog)1883 {1884 var haveSelection = false;1885 var haveActive = false;1886 var haveActiveSelection = false;1887 var havePaused = false;1888 var havePausedSelection = false;1889 1890 for (var i=0, row; row=this._rows[i]; ++i) {1891 var isStopped = row.getTorrent().isStopped();1892 var isSelected = row.isSelected();1893 if (!isStopped) haveActive = true;1894 if (isStopped) havePaused = true;1895 if (isSelected) haveSelection = true;1896 if (isSelected && !isStopped) haveActiveSelection = true;1897 if (isSelected && isStopped) havePausedSelection = true;1898 }1899 1900 this.setEnabled(this._toolbar_pause_button, haveActiveSelection);1901 this.setEnabled(this._context_pause_button, haveActiveSelection);1902 this.setEnabled(this._toolbar_start_button, havePausedSelection);1903 this.setEnabled(this._context_start_button, havePausedSelection);1904 this.setEnabled(this._context_move_top_button, haveSelection);1905 this.setEnabled(this._context_move_up_button, haveSelection);1906 this.setEnabled(this._context_move_down_button, haveSelection);1907 this.setEnabled(this._context_move_bottom_button, haveSelection);1908 this.setEnabled(this._context_start_now_button, havePausedSelection);1909 this.setEnabled(this._toolbar_remove_button, haveSelection);1910 this.setEnabled(this._toolbar_pause_all_button, haveActive);1911 this.setEnabled(this._toolbar_start_all_button, havePaused);1912 }1913 },1914 1915 1922 /**** 1916 1923 *****
Note: See TracChangeset
for help on using the changeset viewer.