Merge pull request #1396 from gigaherz/title-mods

Assign the filename to the page title instead of the full URL
This commit is contained in:
notmasteryet 2012-03-30 16:28:55 -07:00
commit 9998af0af8

View File

@ -15,6 +15,15 @@ var kMaxScale = 4.0;
var kImageDirectory = './images/';
var kSettingsMemory = 20;
function getFileName(url) {
var anchor = url.indexOf('#');
var query = url.indexOf('?');
var end = Math.min(
anchor > 0 ? anchor : url.length,
query > 0 ? query : url.length);
return url.substring(url.lastIndexOf('/', end) + 1, end);
}
var Cache = function cacheCache(size) {
var data = [];
this.push = function cachePush(view) {
@ -300,7 +309,9 @@ var PDFView = {
},
open: function pdfViewOpen(url, scale) {
document.title = this.url = url;
this.url = url;
document.title = decodeURIComponent(getFileName(url)) || url;
if (!PDFView.loadingBar) {
PDFView.loadingBar = new ProgressBar('#loadingBar', {});