mozilla/pdf.js — pull request #974 by saebekassebil (2011-12-23 16:50:39+00:00)
Title: Settings Manager and Extended API

This PR is addressing the need for a simple "database" to save settings in (Discussed in #966)
It implements a Settings object in viewer.js, which then can be called globally. Right now I haven't implemented any thing but a "remember scroll position" feature, using window.pageYOffset, *not* Hash objects.

Furthermore I've chosen to expose some data, thereby extending the API a little
```PDFDocModel``` now has two additional members: ```fileID``` which is the ID attribute hidden in the XRef trailer, and ```getFingerprint()``` which returns the fileID if existent or a MD5 sum of the first 100 bytes in the PDF stream (after suggestion by notmasteryet).
```PDFDoc``` has gotten a ```fingerprint``` attribute, which returns the underlying ```PDFDocModel```'s ```getFingerprint()``` value.
```XRef``` has gotten a new member ```trailer``` which I use to get the ID. I could imagine that this attribute could get useful for something else, later.

And finally I've implemented the ```Settings``` object. It works by first checking if ```localStorage``` is available. If it isn't it uses FUEL if it's in the extension and Cookies if not.

This PR doesn't really do anything but the "remember scroll position" stuff. But @jviereck told me to make this PR so that we could discuss where to go from here.
He suggested I use the Hash object too, but I'm a little confused on how to choose between the scroll position or the hash position.