Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(395)

Side by Side Diff: chrome/browser/resources/downloads.html

Issue 40047: Make the download page focus the input field onload.... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 11 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 <!DOCTYPE HTML> 1 <!DOCTYPE HTML>
2 <html id="t"> 2 <html id="t">
3 <head> 3 <head>
4 <meta charset="utf-8"> 4 <meta charset="utf-8">
5 <title jscontent="title"></title> 5 <title jscontent="title"></title>
6 <style type="text/css"> 6 <style type="text/css">
7 body { 7 body {
8 font-family:arial; 8 font-family:arial;
9 background-color:white; 9 background-color:white;
10 color:black; 10 color:black;
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after
58 } 58 }
59 .download .url { 59 .download .url {
60 color:#080; 60 color:#080;
61 width:500px; 61 width:500px;
62 white-space:nowrap; 62 white-space:nowrap;
63 overflow:hidden; 63 overflow:hidden;
64 text-overflow:ellipsis; 64 text-overflow:ellipsis;
65 } 65 }
66 .controls a { 66 .controls a {
67 color:#777; 67 color:#777;
68 margin-right:16px;
68 } 69 }
69 #downloads-pagination { 70 #downloads-pagination {
70 padding-top:24px; 71 padding-top:24px;
71 margin-left:18px; 72 margin-left:18px;
72 } 73 }
73 .page-navigation { 74 .page-navigation {
74 padding:8px; 75 padding:8px;
75 background-color:#ebeff9; 76 background-color:#ebeff9;
76 margin-right:4px; 77 margin-right:4px;
77 } 78 }
(...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after
180 /////////////////////////////////////////////////////////////////////////////// 181 ///////////////////////////////////////////////////////////////////////////////
181 // Downloads 182 // Downloads
182 /** 183 /**
183 * Class to hold all the information about the visible downloads. 184 * Class to hold all the information about the visible downloads.
184 */ 185 */
185 function Downloads() { 186 function Downloads() {
186 this.downloads_ = {}; 187 this.downloads_ = {};
187 this.node_ = $('downloads-display'); 188 this.node_ = $('downloads-display');
188 this.summary_ = $('downloads-summary'); 189 this.summary_ = $('downloads-summary');
189 this.searchText_ = ""; 190 this.searchText_ = "";
191
192 // Keep track of the dates of the newest and oldest downloads so that we
193 // know where to insert them.
194 this.newestTime_ = -1;
190 } 195 }
191 196
192 /** 197 /**
193 * Called when a download has been updated or added. 198 * Called when a download has been updated or added.
194 * @param {Object} download A backend download object (see downloads_ui.cc) 199 * @param {Object} download A backend download object (see downloads_ui.cc)
195 */ 200 */
196 Downloads.prototype.updated = function(download) { 201 Downloads.prototype.updated = function(download) {
197 var id = download.id; 202 var id = download.id;
198 if (!!this.downloads_[id]) { 203 if (!!this.downloads_[id]) {
199 this.downloads_[id].update(download); 204 this.downloads_[id].update(download);
200 } else { 205 } else {
201 this.downloads_[id] = new Download(download); 206 this.downloads_[id] = new Download(download);
202 // We get downloads in display order, so we don't have to worry about 207 // We get downloads in display order, so we don't have to worry about
203 // maintaining correct order for now. 208 // maintaining correct order - we can assume that any downloads not in
204 this.node_.insertBefore(this.downloads_[id].node, 209 // display order are new ones and so we can add them to the top of the
205 this.node_.firstChild); 210 // list.
211 if (download.started > this.newestTime_) {
212 this.node_.insertBefore(this.downloads_[id].node, this.node_.firstChild);
213 this.newestTime_ = download.started;
214 } else {
215 this.node_.appendChild(this.downloads_[id].node);
216 }
206 } 217 }
207 } 218 }
208 219
209 /** 220 /**
210 * Set our display search text. 221 * Set our display search text.
211 * @param {String} searchText The string we're searching for. 222 * @param {String} searchText The string we're searching for.
212 */ 223 */
213 Downloads.prototype.setSearchText = function(searchText) { 224 Downloads.prototype.setSearchText = function(searchText) {
214 this.searchText_ = searchText; 225 this.searchText_ = searchText;
215 } 226 }
(...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after
293 this.safe_.appendChild(this.nodeURL_); 304 this.safe_.appendChild(this.nodeURL_);
294 305
295 // Controls. 306 // Controls.
296 this.nodeControls_ = createElementWithClassName('div', 'controls'); 307 this.nodeControls_ = createElementWithClassName('div', 'controls');
297 this.safe_.appendChild(this.nodeControls_); 308 this.safe_.appendChild(this.nodeControls_);
298 309
299 this.controlShow_ = createLink(bind(this.show_, this), 310 this.controlShow_ = createLink(bind(this.show_, this),
300 localStrings.getString('control_showinfolder')); 311 localStrings.getString('control_showinfolder'));
301 this.nodeControls_.appendChild(this.controlShow_); 312 this.nodeControls_.appendChild(this.controlShow_);
302 313
303 this.controlPause_ = createLink(bind(this.pause_, this), 314 // Pause/Resume are a toggle.
315 this.controlPause_ = createLink(bind(this.togglePause_, this),
304 localStrings.getString('control_pause')); 316 localStrings.getString('control_pause'));
305 this.nodeControls_.appendChild(this.controlPause_); 317 this.nodeControls_.appendChild(this.controlPause_);
306 318
319 this.controlResume_ = createLink(bind(this.togglePause_, this),
320 localStrings.getString('control_resume'));
321 this.nodeControls_.appendChild(this.controlResume_);
322
307 this.controlCancel_ = createLink(bind(this.cancel_, this), 323 this.controlCancel_ = createLink(bind(this.cancel_, this),
308 localStrings.getString('control_cancel')); 324 localStrings.getString('control_cancel'));
309 this.nodeControls_.appendChild(this.controlCancel_); 325 this.nodeControls_.appendChild(this.controlCancel_);
310 326
311 // Container for 'unsafe download' UI. 327 // Container for 'unsafe download' UI.
312 this.danger_ = createElementWithClassName('div', 'show-dangerous'); 328 this.danger_ = createElementWithClassName('div', 'show-dangerous');
313 this.node.appendChild(this.danger_); 329 this.node.appendChild(this.danger_);
314 330
315 this.dangerDesc_ = document.createElement("div"); 331 this.dangerDesc_ = document.createElement("div");
316 this.danger_.appendChild(this.dangerDesc_); 332 this.danger_.appendChild(this.dangerDesc_);
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after
366 this.nodeFileLink_.href = this.filePath_; 382 this.nodeFileLink_.href = this.filePath_;
367 } else { 383 } else {
368 this.nodeFileName_.innerHTML = this.fileName_; 384 this.nodeFileName_.innerHTML = this.fileName_;
369 } 385 }
370 386
371 showInline(this.nodeFileLink_, this.state_ == Download.States.COMPLETE); 387 showInline(this.nodeFileLink_, this.state_ == Download.States.COMPLETE);
372 showInline(this.nodeFileName_, this.state_ != Download.States.COMPLETE); 388 showInline(this.nodeFileName_, this.state_ != Download.States.COMPLETE);
373 389
374 showInline(this.controlShow_, this.state_ == Download.States.COMPLETE); 390 showInline(this.controlShow_, this.state_ == Download.States.COMPLETE);
375 showInline(this.controlPause_, this.state_ == Download.States.IN_PROGRESS); 391 showInline(this.controlPause_, this.state_ == Download.States.IN_PROGRESS);
392 showInline(this.controlResume_, this.state_ == Download.States.PAUSED);
376 showInline(this.controlCancel_, this.state_ == Download.States.IN_PROGRESS); 393 showInline(this.controlCancel_, this.state_ == Download.States.IN_PROGRESS);
377 394
378 this.nodeURL_.innerHTML = this.url_; 395 this.nodeURL_.innerHTML = this.url_;
379 this.nodeStatus_.innerHTML = this.getStatusText_(); 396 this.nodeStatus_.innerHTML = this.getStatusText_();
380 397
381 this.danger_.style.display = 'none'; 398 this.danger_.style.display = 'none';
382 this.safe_.style.display = 'block'; 399 this.safe_.style.display = 'block';
383 } 400 }
384 } 401 }
385 402
386 /** 403 /**
387 * Removes applicable bits from the DOM in preparation for deletion. 404 * Removes applicable bits from the DOM in preparation for deletion.
388 */ 405 */
389 Download.prototype.clear = function() { 406 Download.prototype.clear = function() {
390 this.safe_.ondragstart = null; 407 this.safe_.ondragstart = null;
391 this.nodeFileLink_.onclick = null; 408 this.nodeFileLink_.onclick = null;
392 this.controlShow_.onclick = null; 409 this.controlShow_.onclick = null;
393 this.controlCancel_.onclick = null; 410 this.controlCancel_.onclick = null;
394 this.controlPause_.onclick = null; 411 this.controlPause_.onclick = null;
412 this.controlResume_.onclick = null;
395 this.dangerDiscard_.onclick = null; 413 this.dangerDiscard_.onclick = null;
396 414
397 this.node.innerHTML = ''; 415 this.node.innerHTML = '';
398 } 416 }
399 417
400 /** 418 /**
401 * @return {String} User-visible status update text. 419 * @return {String} User-visible status update text.
402 */ 420 */
403 Download.prototype.getStatusText_ = function() { 421 Download.prototype.getStatusText_ = function() {
404 switch (this.state_) { 422 switch (this.state_) {
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after
455 * Tells the backend to show the file in explorer. 473 * Tells the backend to show the file in explorer.
456 */ 474 */
457 Download.prototype.show_ = function() { 475 Download.prototype.show_ = function() {
458 chrome.send("show", [this.id_.toString()]); 476 chrome.send("show", [this.id_.toString()]);
459 return false; 477 return false;
460 } 478 }
461 479
462 /** 480 /**
463 * Tells the backend to pause this download. 481 * Tells the backend to pause this download.
464 */ 482 */
465 Download.prototype.pause_ = function() { 483 Download.prototype.togglePause_ = function() {
466 chrome.send("pause", [this.id_.toString()]); 484 chrome.send("togglepause", [this.id_.toString()]);
467 return false; 485 return false;
468 } 486 }
469 487
470 /** 488 /**
471 * Tells the backend to cancel this download. 489 * Tells the backend to cancel this download.
472 */ 490 */
473 Download.prototype.cancel_ = function() { 491 Download.prototype.cancel_ = function() {
474 chrome.send("cancel", [this.id_.toString()]); 492 chrome.send("cancel", [this.id_.toString()]);
475 return false; 493 return false;
476 } 494 }
477 495
478 /////////////////////////////////////////////////////////////////////////////// 496 ///////////////////////////////////////////////////////////////////////////////
479 // Page: 497 // Page:
480 var downloads, localStrings; 498 var downloads, localStrings, resultsTimeout;
481 499
482 function load() { 500 function load() {
483 localStrings = new LocalStrings($('l10n')); 501 localStrings = new LocalStrings($('l10n'));
484 downloads = new Downloads(); 502 downloads = new Downloads();
503 $('term').focus();
485 setSearch(""); 504 setSearch("");
486 } 505 }
487 506
488 function setSearch(searchText) { 507 function setSearch(searchText) {
489 downloads.clear(); 508 downloads.clear();
490 downloads.setSearchText(searchText); 509 downloads.setSearchText(searchText);
491 chrome.send("getDownloads", [searchText.toString()]); 510 chrome.send("getDownloads", [searchText.toString()]);
492 } 511 }
493 512
494 /////////////////////////////////////////////////////////////////////////////// 513 ///////////////////////////////////////////////////////////////////////////////
495 // Chrome callbacks: 514 // Chrome callbacks:
496 /** 515 /**
497 * Our history system calls this function with results from searches or when 516 * Our history system calls this function with results from searches or when
498 * downloads are added or removed. 517 * downloads are added or removed.
499 */ 518 */
500 function downloadsList(results) { 519 function downloadsList(results) {
520 if (resultsTimeout)
521 clearTimeout(resultsTimeout);
501 downloadUpdated(results); 522 downloadUpdated(results);
502 downloads.updateSummary();
503 } 523 }
504 524
505 /** 525 /**
506 * When a download is updated (progress, state change), this is called. 526 * When a download is updated (progress, state change), this is called.
507 */ 527 */
508 function downloadUpdated(results) { 528 function downloadUpdated(results) {
509 for (var i = 0, thisResult; thisResult = results[i]; i++) { 529 if (results.length) {
510 downloads.updated(thisResult); 530 downloads.updated(results[0]);
531 if (results.length > 1)
532 resultsTimeout = setTimeout(downloadUpdated, 5, results.slice(1));
533 else
534 downloads.updateSummary();
511 } 535 }
512 } 536 }
513 </script> 537 </script>
514 </head> 538 </head>
515 <body onload="load();"> 539 <body onload="load();">
516 <div class="header"> 540 <div class="header">
517 <a href="" onclick="setSearch(''); return false;"> 541 <a href="" onclick="setSearch(''); return false;">
518 <img src="../../app/theme/downloads_section.png" 542 <img src="../../app/theme/downloads_section.png"
519 width="67" height="67" class="logo" border="0" /></a> 543 width="67" height="67" class="logo" border="0" /></a>
520 <form method="post" action="" 544 <form method="post" action=""
(...skipping 21 matching lines...) Expand all
542 <span id="danger_save" jscontent="danger_save">Save</span> 566 <span id="danger_save" jscontent="danger_save">Save</span>
543 <span id="danger_discard" jscontent="danger_discard">Discard</span> 567 <span id="danger_discard" jscontent="danger_discard">Discard</span>
544 568
545 <span id="control_pause" jscontent="control_pause">Pause</span> 569 <span id="control_pause" jscontent="control_pause">Pause</span>
546 <span id="control_showinfolder" jscontent="control_showinfolder">Show in folde r</span> 570 <span id="control_showinfolder" jscontent="control_showinfolder">Show in folde r</span>
547 <span id="control_cancel" jscontent="control_cancel">Cancel</span> 571 <span id="control_cancel" jscontent="control_cancel">Cancel</span>
548 <span id="control_resume" jscontent="control_resume">Resume</span> 572 <span id="control_resume" jscontent="control_resume">Resume</span>
549 </div> 573 </div>
550 </body> 574 </body>
551 </html> 575 </html>
OLDNEW
« chrome/browser/dom_ui/downloads_ui.cc ('K') | « chrome/browser/dom_ui/downloads_ui.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698