| OLD | NEW |
| 1 <!DOCTYPE HTML> | 1 <!DOCTYPE HTML> |
| 2 <html id="t"> | 2 <html id="t" jsvalues="dir:textdirection;"> |
| 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 <script type="text/javascript"> | 6 <script type="text/javascript"> |
| 7 /////////////////////////////////////////////////////////////////////////////// | 7 /////////////////////////////////////////////////////////////////////////////// |
| 8 // Globals: | 8 // Globals: |
| 9 var RESULTS_PER_PAGE = 150; | 9 var RESULTS_PER_PAGE = 150; |
| 10 var MAX_SEARCH_DEPTH_MONTHS = 18; | 10 var MAX_SEARCH_DEPTH_MONTHS = 18; |
| 11 | 11 |
| 12 // Amount of time between pageviews that we consider a 'break' in browsing, | 12 // Amount of time between pageviews that we consider a 'break' in browsing, |
| (...skipping 239 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 252 } | 252 } |
| 253 | 253 |
| 254 /** | 254 /** |
| 255 * Tell the model that the view will want to see the current page. When | 255 * Tell the model that the view will want to see the current page. When |
| 256 * the data becomes available, the model will call the view back. | 256 * the data becomes available, the model will call the view back. |
| 257 * @page {Number} page The page we want to view. | 257 * @page {Number} page The page we want to view. |
| 258 */ | 258 */ |
| 259 HistoryModel.prototype.requestPage = function(page) { | 259 HistoryModel.prototype.requestPage = function(page) { |
| 260 this.requestedPage_ = page; | 260 this.requestedPage_ = page; |
| 261 this.changed = true; | 261 this.changed = true; |
| 262 this.updateSearch_(); | 262 this.updateSearch_(false); |
| 263 } | 263 } |
| 264 | 264 |
| 265 /** | 265 /** |
| 266 * Receiver for history query. | 266 * Receiver for history query. |
| 267 * @param {String} term The search term that the results are for. | 267 * @param {String} term The search term that the results are for. |
| 268 * @param {Array} results A list of results | 268 * @param {Array} results A list of results |
| 269 */ | 269 */ |
| 270 HistoryModel.prototype.addResults = function(term, results) { | 270 HistoryModel.prototype.addResults = function(info, results) { |
| 271 this.inFlight_ = false; | 271 this.inFlight_ = false; |
| 272 if (term != this.searchText_) { | 272 if (info.term != this.searchText_) { |
| 273 // If our results aren't for our current search term, they're rubbish. | 273 // If our results aren't for our current search term, they're rubbish. |
| 274 return; | 274 return; |
| 275 } | 275 } |
| 276 | 276 |
| 277 // Currently we assume we're getting things in date order. This needs to | 277 // Currently we assume we're getting things in date order. This needs to |
| 278 // be updated if that ever changes. | 278 // be updated if that ever changes. |
| 279 if (results) { | 279 if (results) { |
| 280 var lastURL, lastDay; | 280 var lastURL, lastDay; |
| 281 var oldLength = this.pages_.length; | 281 var oldLength = this.pages_.length; |
| 282 if (oldLength) { | 282 if (oldLength) { |
| (...skipping 12 matching lines...) Expand all Loading... |
| 295 // this is used to determine how day headers should be drawn. | 295 // this is used to determine how day headers should be drawn. |
| 296 this.pages_.push(new Page(thisResult, thisDay == lastDay, this)); | 296 this.pages_.push(new Page(thisResult, thisDay == lastDay, this)); |
| 297 lastDay = thisDay; | 297 lastDay = thisDay; |
| 298 lastURL = thisURL; | 298 lastURL = thisURL; |
| 299 } | 299 } |
| 300 } | 300 } |
| 301 } | 301 } |
| 302 if (results.length) | 302 if (results.length) |
| 303 this.changed = true; | 303 this.changed = true; |
| 304 | 304 |
| 305 this.updateSearch_(); | 305 this.updateSearch_(info.finished); |
| 306 } | 306 } |
| 307 | 307 |
| 308 /** | 308 /** |
| 309 * @return {Number} The number of pages in the model. | 309 * @return {Number} The number of pages in the model. |
| 310 */ | 310 */ |
| 311 HistoryModel.prototype.getSize = function() { | 311 HistoryModel.prototype.getSize = function() { |
| 312 return this.pages_.length; | 312 return this.pages_.length; |
| 313 } | 313 } |
| 314 | 314 |
| 315 /** | 315 /** |
| (...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 347 this.requestedPage_ = 0; | 347 this.requestedPage_ = 0; |
| 348 | 348 |
| 349 this.complete_ = false; | 349 this.complete_ = false; |
| 350 } | 350 } |
| 351 | 351 |
| 352 /** | 352 /** |
| 353 * Figure out if we need to do more searches to fill the currently requested | 353 * Figure out if we need to do more searches to fill the currently requested |
| 354 * page. If we think we can fill the page, call the view and let it know | 354 * page. If we think we can fill the page, call the view and let it know |
| 355 * we're ready to show something. | 355 * we're ready to show something. |
| 356 */ | 356 */ |
| 357 HistoryModel.prototype.updateSearch_ = function() { | 357 HistoryModel.prototype.updateSearch_ = function(finished) { |
| 358 if (this.searchText_ && this.searchDepth_ >= MAX_SEARCH_DEPTH_MONTHS) { | 358 if ((this.searchText_ && this.searchDepth_ >= MAX_SEARCH_DEPTH_MONTHS) || |
| 359 finished) { |
| 359 // We have maxed out. There will be no more data. | 360 // We have maxed out. There will be no more data. |
| 360 this.complete_ = true; | 361 this.complete_ = true; |
| 361 this.view_.onModelReady(); | 362 this.view_.onModelReady(); |
| 362 this.changed = false; | 363 this.changed = false; |
| 363 } else { | 364 } else { |
| 364 // If we can't fill the requested page, ask for more data unless a request | 365 // If we can't fill the requested page, ask for more data unless a request |
| 365 // is still in-flight. | 366 // is still in-flight. |
| 366 if (!this.canFillPage_(this.requestedPage_) && !this.inFlight_) { | 367 if (!this.canFillPage_(this.requestedPage_) && !this.inFlight_) { |
| 367 this.getSearchResults_(this.searchDepth_ + 1); | 368 this.getSearchResults_(this.searchDepth_ + 1); |
| 368 } | 369 } |
| (...skipping 385 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 754 deleteInFlight = true; | 755 deleteInFlight = true; |
| 755 chrome.send("deleteDay", [deleteQueue[0]]); | 756 chrome.send("deleteDay", [deleteQueue[0]]); |
| 756 } | 757 } |
| 757 } | 758 } |
| 758 | 759 |
| 759 /////////////////////////////////////////////////////////////////////////////// | 760 /////////////////////////////////////////////////////////////////////////////// |
| 760 // Chrome callbacks: | 761 // Chrome callbacks: |
| 761 /** | 762 /** |
| 762 * Our history system calls this function with results from searches. | 763 * Our history system calls this function with results from searches. |
| 763 */ | 764 */ |
| 764 function historyResult(term, results) { | 765 function historyResult(info, results) { |
| 765 historyModel.addResults(term, results); | 766 historyModel.addResults(info, results); |
| 766 } | 767 } |
| 767 | 768 |
| 768 /** | 769 /** |
| 769 * Our history system calls this function when a deletion has finished. | 770 * Our history system calls this function when a deletion has finished. |
| 770 */ | 771 */ |
| 771 function deleteComplete() { | 772 function deleteComplete() { |
| 772 historyView.reload(); | 773 window.console.log("Delete complete"); |
| 773 deleteInFlight = false; | 774 deleteInFlight = false; |
| 774 if (deleteQueue.length > 1) { | 775 if (deleteQueue.length > 1) { |
| 775 deleteQueue = deleteQueue.slice(1, deleteQueue.length); | 776 deleteQueue = deleteQueue.slice(1, deleteQueue.length); |
| 776 deleteNextInQueue(); | 777 deleteNextInQueue(); |
| 777 } | 778 } |
| 778 } | 779 } |
| 779 | 780 |
| 780 /** | 781 /** |
| 781 * Our history system calls this function if a delete is not ready (e.g. | 782 * Our history system calls this function if a delete is not ready (e.g. |
| 782 * another delete is in-progress). | 783 * another delete is in-progress). |
| 783 */ | 784 */ |
| 784 function deleteFailed() { | 785 function deleteFailed() { |
| 786 window.console.log("Delete failed"); |
| 785 // The deletion failed - try again later. | 787 // The deletion failed - try again later. |
| 786 deleteInFlight = false; | 788 deleteInFlight = false; |
| 787 setTimeout(deleteNextInQueue, 500); | 789 setTimeout(deleteNextInQueue, 500); |
| 788 } | 790 } |
| 791 |
| 792 /** |
| 793 * We're called when something is deleted (either by us or by someone |
| 794 * else). |
| 795 */ |
| 796 function historyDeleted() { |
| 797 window.console.log("History deleted"); |
| 798 historyView.reload(); |
| 799 } |
| 789 </script> | 800 </script> |
| 790 <style type="text/css"> | 801 <style type="text/css"> |
| 791 body { | 802 body { |
| 792 font-family:arial; | 803 font-family:arial; |
| 793 background-color:white; | 804 background-color:white; |
| 794 color:black; | 805 color:black; |
| 795 font-size:84%; | 806 font-size:84%; |
| 796 margin:10px; | 807 margin:10px; |
| 797 } | 808 } |
| 798 .header { | 809 .header { |
| (...skipping 118 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 917 <span id="searchresultsfor" jscontent="searchresultsfor">Search results for '%
s'</span> | 928 <span id="searchresultsfor" jscontent="searchresultsfor">Search results for '%
s'</span> |
| 918 <span id="history" jscontent="history">History</span> | 929 <span id="history" jscontent="history">History</span> |
| 919 <span id="cont" jscontent="cont">(cont.)</span> | 930 <span id="cont" jscontent="cont">(cont.)</span> |
| 920 <span id="noresults" jscontent="noresults">No results</span> | 931 <span id="noresults" jscontent="noresults">No results</span> |
| 921 <span id="noitems" jscontent="noitems">No items</span> | 932 <span id="noitems" jscontent="noitems">No items</span> |
| 922 <span id="deleteday" jscontent="deleteday">Delete history for this day</span> | 933 <span id="deleteday" jscontent="deleteday">Delete history for this day</span> |
| 923 <span id="deletedaywarning" jscontent="deletedaywarning">Are you sure you want
to delete this day?</span> | 934 <span id="deletedaywarning" jscontent="deletedaywarning">Are you sure you want
to delete this day?</span> |
| 924 </div> | 935 </div> |
| 925 </body> | 936 </body> |
| 926 </html> | 937 </html> |
| OLD | NEW |