mirror of
https://github.com/mozilla/pdf.js.git
synced 2025-04-19 22:58:07 +02:00
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:
commit
9998af0af8
1 changed files with 12 additions and 1 deletions
|
@ -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', {});
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue